void OnEntitySpawned(SceneEntityPosAgent agent) { m_MaxCount++; if (!EntityMonsterBeacon.IsBcnMonsterProtoId(agent.protoId)) // not encoded, unexpected agent { return; } int spType, lvl, spawnType; EntityMonsterBeacon.DecodeBcnMonsterProtoId(agent.protoId, out spType, out lvl, out spawnType); int areaType = PeGameMgr.IsStory ? PeMappingMgr.Instance.GetAiSpawnMapId(new Vector2(agent.Pos.x, agent.Pos.z)) : AiUtil.GetMapID(agent.Pos); AISpawnTDWavesData.TDMonsterSpData data = AISpawnTDWavesData.GetMonsterSpData(false, spType, lvl, spawnType, areaType); float rhp = data != null ? data._rhp : 200.0f; float dps = data != null ? data._dps : 50.0f; SiegeAgent siegeAgent = new SiegeAgent(this, agent, rhp, dps); agent.spInfo = new SiegeAgent.AgentInfo(m_Beacon, siegeAgent); m_Agents.Add(siegeAgent); }
static int GetMonsterProtoIDForBeacon(int bcnProtoId, Vector3 pos, ref float fScale) { if (!EntityMonsterBeacon.IsBcnMonsterProtoId(bcnProtoId)) // not encoded { return(bcnProtoId); } int spType, lvl, spawnType; EntityMonsterBeacon.DecodeBcnMonsterProtoId(bcnProtoId, out spType, out lvl, out spawnType); int terType = 0; int areaType = -1; AISpawnTDWavesData.TDMonsterData md = null; if (spType < EntityMonsterBeacon.TowerDefenseSpType_Beg) { PointType pt = AiUtil.GetPointType(pos); switch (pt) { default: case PointType.PT_Ground: terType = 0; break; case PointType.PT_Water: terType = 1; break; case PointType.PT_Slope: terType = 2; break; case PointType.PT_Cave: terType = 3; break; } areaType = PeGameMgr.IsStory ? PeMappingMgr.Instance.GetAiSpawnMapId(new Vector2(pos.x, pos.z)) : AiUtil.GetMapID(pos); if (PeGameMgr.IsAdventure && areaType == 5) { areaType = 2; } } int opPlayerId = -1; if (MainPlayerCmpt.gMainPlayer != null) { SkAliveEntity skPlayer = MainPlayerCmpt.gMainPlayer.Entity.aliveEntity; if (skPlayer != null) { opPlayerId = (int)skPlayer.GetAttribute(AttribType.DefaultPlayerID); } } md = AISpawnTDWavesData.GetMonsterProtoId(!PeGameMgr.IsStory, spType, lvl, spawnType, areaType, terType, opPlayerId); if (null != md) { // md.ProtoId |= EntityProto.IdAirbornePujaMask; // test airborne if (md.IsAirbornePuja) { md.ProtoId |= EntityProto.IdAirbornePujaMask; } if (md.IsAirbornePaja) { md.ProtoId |= EntityProto.IdAirbornePajaMask; } if (md.IsGrp) { md.ProtoId |= EntityProto.IdGrpMask; } return(md.ProtoId); } return(-1); }