//添加防御塔 public TowerInfo AddTower(int towerId) { towerIndexId += 1; int towerType = J_Tower.GetData(towerId)._towerType; //增加兵营 if (towerType == 4) { BarrackTowerInfo towerInfo = new BarrackTowerInfo(towerIndexId, towerId); this.eventDispatcher.Broadcast("AddTower", towerInfo); towers.Add(towerIndexId, towerInfo); towerInfo.ChangeState("idle"); return(towerInfo); } //增加空地 else if (towerType == 5) { OpenSpaceInfo spaceInfo = new OpenSpaceInfo(towerIndexId, towerId); this.eventDispatcher.Broadcast("AddTower", spaceInfo); towers.Add(towerIndexId, spaceInfo); spaceInfo.ChangeState("idle"); return(spaceInfo); } //增加攻击塔 else { AttackTowerInfo towerInfo = new AttackTowerInfo(towerIndexId, towerId); this.eventDispatcher.Broadcast("AddTower", towerInfo); towers.Add(towerIndexId, towerInfo); towerInfo.ChangeState("idle"); return(towerInfo); } }
//传入barrackInfo public void SetParam(StateParam _param) { if (_param == null) { return; } towerInfo = (BarrackTowerInfo)_param.targetInfo; }
public void AddTower(object[] data) { TowerInfo tempInfo = (TowerInfo)data[0]; int towerId; TowerView towerView; //若为兵营 if (tempInfo.towerType == 4) { BarrackTowerInfo towerInfo = (BarrackTowerInfo)tempInfo; towerId = towerInfo.Id; towerView = new BarrackTowerView(towerInfo); } //若为空地 else if (tempInfo.towerType == 5) { OpenSpaceInfo spaceInfo = (OpenSpaceInfo)tempInfo; towerId = spaceInfo.Id; towerView = new OpenSpaceView(spaceInfo); } //魔法塔 else if (tempInfo.towerType == 2) { AttackTowerInfo towerInfo = (AttackTowerInfo)tempInfo; towerId = towerInfo.Id; towerView = new MageTowerView(towerInfo); } //炮塔 else if (tempInfo.towerType == 3) { AttackTowerInfo towerInfo = (AttackTowerInfo)tempInfo; towerId = towerInfo.Id; towerView = new ArtilleryTowerView(towerInfo); } //箭塔 else { AttackTowerInfo towerInfo = (AttackTowerInfo)tempInfo; towerId = towerInfo.Id; towerView = new ArrowTowerView(towerInfo); } towerView.LoadModel(); if (towers.ContainsKey(towerId)) { towers[towerId] = towerView; } else { towers.Add(towerId, towerView); } }
public BarrackIdle(BarrackTowerInfo _barrackInfo) { barrackInfo = _barrackInfo; intervalTime = 10; curTime = 0; }
public BarrackTowerView(BarrackTowerInfo towerInfo) { this.towerInfo = towerInfo; this.towerInfo.eventDispatcher.Register("DoAction", DoAction); }
//关联兵营、兵营Id和停留位置 public void SetTowerInfo(BarrackTowerInfo tower, int id, Vector3 pos) { barrackTower = tower; barrackSoliderId = id; barrackSoliderPos = pos; }
public BarrackConstructing(BarrackTowerInfo _towerInfo) { towerInfo = _towerInfo; }
public BarrackStart(BarrackTowerInfo _barrackInfo) { barrackInfo = _barrackInfo; curTime = 0; }