FirstGateId; # 初始化第一关的关卡id $this->CurrentGateId = $startId; $this->UnlockedGatesMaxId = $startId; $this->GateList = new \stdClass(); $Ins_GateInfo = new Ins_GateInfo(); $Ins_GateInfo->GateId = $this->CurrentGateId; $this->GateList->$startId = $Ins_GateInfo; $this->GatesChallengeRecord = new \stdClass(); $this->xunluo_StartTs = now(); } public function __construct($arg = null) { if ($arg == null) { if ($this->CurrentGateId == 0) { $startId = 1; $this->CurrentGateId = $startId; $this->UnlockedGatesMaxId = $startId; $this->GateList = new \stdClass(); $Ins_GateInfo = new Ins_GateInfo(); $Ins_GateInfo->GateId = $this->CurrentGateId; $this->GateList->$startId = $Ins_GateInfo; } $this->GatesChallengeRecord = new \stdClass(); $this->xunluo_StartTs = now(); $this->TowerGate = new Ins_TowerGateInfo(); $this->TowerGate->skill_beidong = new \stdClass(); $this->TowerGate->skill_zhudong = new \stdClass(); $this->TowerGate->skill_zhudong_lockState = new \stdClass(); $this->TowerGate->skill_beidong_lockState = new \stdClass(); $this->TowerGate->CurLayer = 0; // 默认从1层开始 } else { parent::__construct($arg); $this->TowerGateInfo()->fixArray(); if (null != $this->GateList) { foreach ($this->GateList as $id => &$gt) { $gt = new Ins_GateInfo($gt); $gt->fixArray(); } } } } /** * 计算启灵进化的buff加成 */ public function GetEnvovleBuffs() { $addHp = $addAtk = $addDecDamage = $addEatFood = 0; # 初始化加成值 $arr = GameConfig::evolve(); foreach ($arr as $key => $value) { isEditor() and $value = new \sm_evolve(); if ($key <= $this->evolveMaxId_left) { isEditor() and $p = new \sm_predicate(); $p = GameConfig::predicate_getItem($value->predicateId); my_Assert(null != $p, ErrCode::err_const_no); switch ($p->actionType) { case 'addHp': # + 血量上限 $addHp += $p->actionParam1; break; case 'addDamge': # + 攻击力 $addAtk += $p->actionParam1; break; case 'addDecDamage': # + 减伤 $addDecDamage += $p->actionParam1; break; case 'addEatFood': # + 肉食恢复 $addEatFood += $p->actionParam1; break; } } } return array($addHp, $addAtk, $addDecDamage, $addEatFood); # 返回元组 } /** * 挑战关卡数据结构 * @return Ins_TowerGateInfo */ public function TowerGateInfo() { $this->TowerGate = new Ins_TowerGateInfo($this->TowerGate); return $this->TowerGate; } /** * 当前关卡信息 * @return Ins_GateInfo */ public function CurGateInfo() { $gateId = $this->CurrentGateId; my_Assert(StlUtil::dictHasProperty($this->GateList, $gateId), ErrCode::gate_NoUserGateInfo); $gateInfo = ctx()->gates->GateList->$gateId; return $gateInfo; } /** * @return int 解锁下一剧情关卡 */ public function UnlockNextPlotGate($gateId) { $nextId = $gateId; foreach (GameConfig::gate() as $k => $v) { isEditor() and $v = new \sm_gate(); if ($v->unlockGateId == $gateId) { $nextId = $v->gateId; } } // echoLine("解锁下一关卡 $nextId"); if (Ins_GateInfo::gateNum($this->UnlockedGatesMaxId) < Ins_GateInfo::gateNum($nextId)# 下一关尚未解锁 && !StlUtil::dictHasProperty($this->GateList, $nextId)) { // $this->CurrentGateId = $nextId; # 不再自动推到下一关, -2024.5.31 $this->UnlockedGatesMaxId = $nextId; $gate = new Ins_GateInfo(); $gate->GateId = $nextId; $this->GateList->$nextId = $gate; } return $nextId; } /** * @param int $gateId 通关的关卡id */ public function UnlockMainChallengeGate($gateId) { $dic = GameConfig::gate(); $index = 0; # 挑战关卡解锁逻辑. -gwang 2024年4月15日 foreach ($dic as $id => $item) { if (Ins_GateInfo::GateTypeFromId($id) == Enum_GateType::MainChallengeGate # && $item->challengeGateId == $gateId) { $index += 1; $gate = new Ins_GateInfo(); $gate->GateId = $id; ctx()->gates->GateList->$id = $gate; } if ($index >= 3) { # 最多3个难度 break; } } } /** * 最大通关id */ public function maxPassGateNumId() { $maxIndex = 0; //$maxGateId = 0; foreach ($this->GateList as $gateId => $Ins_GateInfo) { if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) { $maxIndex = Ins_GateInfo::gateNum($gateId); //$maxGateId = $gateId; } } return $maxIndex; } /** * 最大通关id */ public function maxPassGateId() { $maxIndex = 0; $maxGateId = 0; foreach ($this->GateList as $gateId => $Ins_GateInfo) { if ($Ins_GateInfo->pass > 0 && Ins_GateInfo::gateNum($gateId) > $maxIndex) { $maxIndex = Ins_GateInfo::gateNum($gateId); $maxGateId = $gateId; } } return $maxGateId; } }