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