//添加防御塔 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); } }
public ArrowTowerView(AttackTowerInfo towerInfo) { this.towerInfo = towerInfo; this.towerInfo.towerView = this; this.towerInfo.eventDispatcher.Register("DoAction", DoAction); this.shooterNum = 1; }
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 ArtilleryTowerView(AttackTowerInfo towerInfo) { this.towerInfo = towerInfo; this.towerInfo.eventDispatcher.Register("DoAction", DoAction); }
public TowerConstructing(AttackTowerInfo _towerInfo) { towerInfo = _towerInfo; }
public TowerIdle(AttackTowerInfo _towerInfo) { towerInfo = _towerInfo; intervalTime = 1; curTime = 0; }
public MageTowerView(AttackTowerInfo towerInfo) { this.towerInfo = towerInfo; this.towerInfo.towerView = this; this.towerInfo.eventDispatcher.Register("DoAction", DoAction); }
public TowerAtk(AttackTowerInfo _towerInfo) { towerInfo = _towerInfo; attackTime = 0; curTime = 0; }