void TryCreateMonsterSiege() { Camp camp = Camp.GetCamp(PeCreature.Instance.mainPlayer.position); if (m_Beacon == null && camp != null) { if (Time.time - m_LastRandomTime > m_RandTime * 60.0f) { m_LastRandomTime = Time.time; m_RandTime = Random.Range(minMinute, maxMinute); if (Random.value > probability) { m_FailedCout++; } else { m_Beacon = EntityMonsterBeacon.CreateMonsterBeaconByTDID(1, null, null); m_Beacon.TargetPosition = camp.Pos; m_Beacon.transform.position = camp.Pos; m_Beacon.handlerNewWave += OnNewWave; m_FailedCout = 0; } } } }
void CreateMonsterBeacon() { if (_lvl > 0 && assembly != null && assembly.m_Entity != null) { if (m_Beacon != null) { m_Beacon.Delete(); } m_UIData = new TowerInfoUIData(); m_Beacon = EntityMonsterBeacon.CreateMonsterBeaconByTDID(_lvl, transform, m_UIData); m_Beacon.gameObject.AddComponent <MonsterSiege>().SetCreator(assembly.m_Entity.m_Creator as CSMgCreator, m_UIData); } }
void SetSiegeID(int id) { if (m_CurSiegeID == 0 && m_MonsterSiege == null) { m_Town.SetMsId(id); m_CurSiegeID = id; m_IsReady = false; m_SpawnFinished = false; m_ElapsedTime = 0.0f; m_UIData = new TowerInfoUIData(); m_MonsterSiege = EntityMonsterBeacon.CreateMonsterBeaconByTDID(m_CurSiegeID, null, m_UIData); m_MonsterSiege.transform.position = m_Town.TransPos; m_MonsterSiege.TargetPosition = m_Town.TransPos; m_MonsterSiege.handlerOneDeath += OnMemberDeath; m_MonsterSiege.handerNewEntity += OnMemberCreated; m_MonsterSiege.handlerNewWave += OnNewWave; } }
public override void OnActivate() { base.OnActivate(); if (_entityBcn != null) { Debug.LogError("[MonsterBeaconItem]:MonsterBeacon has existed."); return; } //Put off aispawn tower defense int entityId = GameConfig.IsMultiMode ? id : -1; _entityBcn = EntityMonsterBeacon.CreateMonsterBeaconByTDID(m_monsterBeaconId, transform, new TowerInfoUIData(), entityId, null, -1, true); if (_entityBcn != null) { _entityBcn.handlerNewWave += OnNewWave; _agent = DragItemAgent.GetById(id); if (_agent != null) { SceneMan.RemoveSceneObj(_agent); // Not been managed by sceneMan } } }
public bool Start() { //if (playerMission.GetMissionFlagType(MissionId) == null) return false; if (SceneEntityCreator.self.PlayerTrans == null) { return(false); } //if (!MissionManager.Instance.m_bHadInitMission) //{ // Debug.LogError("[MissionManager]Mission not inited."); // return false; //} MissionCommonData data = MissionManager.GetMissionCommonData(MissionId); for (int i = 0; i < data.m_TargetIDList.Count; i++) { if (data.m_TargetIDList[i] == TargetId) { _idxTarId = i; break; } } if (_idxTarId == -1) { return(false); } _towerData = MissionManager.GetTypeTowerDefendsData(TargetId); if (_towerData == null) { return(false); } if (PeGameMgr.IsSingle) { playerMission.m_TowerUIData.MaxCount = _towerData.m_Count; } else { playerMission.m_TowerUIData.MaxCount = 0; } playerMission.m_TowerUIData.MissionID = MissionId; playerMission.m_TowerUIData.CurCount = 0; if (_towerData.m_TdInfoId != 0) { _entityBcn = EntityMonsterBeacon.CreateMonsterBeaconByTDID(_towerData.m_TdInfoId, SceneEntityCreator.self.PlayerTrans, playerMission.m_TowerUIData, _entityBcnId, _towerData, data.m_iNpc); } else if (_towerData.m_SweepId.Count > 0) { _entityBcn = EntityMonsterBeacon.CreateMonsterBeaconBySweepID(_towerData.m_SweepId, SceneEntityCreator.self.PlayerTrans, playerMission.m_TowerUIData, _towerData.m_Time, _entityBcnId, _towerData, data.m_iNpc); } else { return(false); } if (_towerData.m_tolTime != 0) { MissionManager.Instance.SetTowerMissionStartTime(TargetId); } if (_entityBcn == null) { return(false); } _entityBcnId = _entityBcn.Id; _entityBcn.handlerNewWave += OnNewWave; _entityBcn.handlerOneDeath += OnOneDeath; PeEntity npc = null; for (int m = 0; m < _towerData.m_iNpcList.Count; m++) { npc = EntityMgr.Instance.Get(_towerData.m_iNpcList[m]); if (npc == null) { continue; } npc.SetInvincible(false); } //_leftCntToFin = _towerData.m_Count; //Register all waves into playerMission to avoid complete shortly string value = "0_0_0_0_0"; // just for pass checking in IsReplyTarget: x(spType), num, cnt, created, completeTarget playerMission.ModifyQuestVariable(MissionId, PlayerMission.MissionFlagTDMonster + _idxTarId, value); //MissionManager.mTowerKillNum = "0"; //MissionManager.mTowerMonCount = towerData.m_Count.ToString(); return(true); }