Exemplo n.º 1
0
        public void Play(IBattlePhase iBattlePhase, Action callback)
        {
            List <ShipModel_Defender> list = new List <ShipModel_Defender>();

            _iBattlePhase = iBattlePhase;
            _actCallback  = callback;
            _isPlaying    = true;
            BattleTaskManager.GetBattleShips().UpdateDamageAll(iBattlePhase, isFriend: false);
            if (iBattlePhase.HasGekichinEvent())
            {
                iBattlePhase.GetGekichinShips().ForEach(delegate(ShipModel_Defender x)
                {
                    _queFriedShipModel.Enqueue(x);
                });
                if (iBattlePhase.HasTaihaEvent())
                {
                    _listFriendShipModel.AddRange(iBattlePhase.GetDefenders(is_friend: true, DamagedStates.Taiha));
                }
                if (iBattlePhase.HasChuhaEvent())
                {
                    _listFriendShipModel.AddRange(iBattlePhase.GetDefenders(is_friend: true, DamagedStates.Tyuuha));
                }
                if (_listFriendShipModel.Count != 0)
                {
                    Observable.Timer(TimeSpan.FromSeconds(1.5)).Subscribe(delegate
                    {
                        ProdDamage prodDamage = this;
                        BattleShips ships     = BattleTaskManager.GetBattleShips();
                        _listFriendShipModel.ForEach(delegate(ShipModel_Defender x)
                        {
                            ships.dicFriendBattleShips[x.Index].UpdateDamage(x);
                        });
                    });
                }
                PlaySinking();
            }
            else if (iBattlePhase.HasTaihaEvent())
            {
                list.AddRange(iBattlePhase.GetDefenders(is_friend: true, DamagedStates.Taiha));
                if (iBattlePhase.HasChuhaEvent())
                {
                    list.AddRange(iBattlePhase.GetDefenders(is_friend: true, DamagedStates.Tyuuha));
                }
                _queFriedShipModel = new Queue <ShipModel_Defender>();
                int num = 0;
                foreach (ShipModel_Defender item in list)
                {
                    if (num >= 3)
                    {
                        break;
                    }
                    _queFriedShipModel.Enqueue(item);
                    num++;
                }
                PlayHeavyDamage(DamagedStates.Taiha);
            }
            else if (iBattlePhase.HasChuhaEvent())
            {
                list.AddRange(iBattlePhase.GetDefenders(is_friend: true, DamagedStates.Tyuuha).ConvertAll((ShipModel_Defender s) => s));
                int num2 = 0;
                foreach (ShipModel_Defender item2 in list)
                {
                    if (num2 >= 3)
                    {
                        break;
                    }
                    _queFriedShipModel.Enqueue(item2);
                    num2++;
                }
                PlayHeavyDamage(DamagedStates.Tyuuha);
            }
            else
            {
                OnFinished();
            }
            list.Clear();
        }
        public void Play(IBattlePhase iBattlePhase, Action callback)
        {
            List <ShipModel_Defender> list = new List <ShipModel_Defender>();

            this._iBattlePhase = iBattlePhase;
            this._actCallback  = callback;
            this._isPlaying    = true;
            BattleTaskManager.GetBattleShips().UpdateDamageAll(iBattlePhase, false);
            if (iBattlePhase.HasGekichinEvent())
            {
                iBattlePhase.GetGekichinShips().ForEach(delegate(ShipModel_Defender x)
                {
                    this._queFriedShipModel.Enqueue(x);
                });
                if (iBattlePhase.HasTaihaEvent())
                {
                    this._listFriendShipModel.AddRange(iBattlePhase.GetDefenders(true, DamagedStates.Taiha));
                }
                if (iBattlePhase.HasChuhaEvent())
                {
                    this._listFriendShipModel.AddRange(iBattlePhase.GetDefenders(true, DamagedStates.Tyuuha));
                }
                if (this._listFriendShipModel.get_Count() != 0)
                {
                    Observable.Timer(TimeSpan.FromSeconds(1.5)).Subscribe(delegate(long _)
                    {
                        BattleShips ships = BattleTaskManager.GetBattleShips();
                        this._listFriendShipModel.ForEach(delegate(ShipModel_Defender x)
                        {
                            ships.dicFriendBattleShips.get_Item(x.Index).UpdateDamage(x);
                        });
                    });
                }
                this.PlaySinking();
            }
            else if (iBattlePhase.HasTaihaEvent())
            {
                list.AddRange(iBattlePhase.GetDefenders(true, DamagedStates.Taiha));
                if (iBattlePhase.HasChuhaEvent())
                {
                    list.AddRange(iBattlePhase.GetDefenders(true, DamagedStates.Tyuuha));
                }
                this._queFriedShipModel = new Queue <ShipModel_Defender>();
                int num = 0;
                using (List <ShipModel_Defender> .Enumerator enumerator = list.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        ShipModel_Defender current = enumerator.get_Current();
                        if (num >= 3)
                        {
                            break;
                        }
                        this._queFriedShipModel.Enqueue(current);
                        num++;
                    }
                }
                this.PlayHeavyDamage(DamagedStates.Taiha);
            }
            else if (iBattlePhase.HasChuhaEvent())
            {
                list.AddRange(iBattlePhase.GetDefenders(true, DamagedStates.Tyuuha).ConvertAll <ShipModel_Defender>((ShipModel_Defender s) => s));
                int num2 = 0;
                using (List <ShipModel_Defender> .Enumerator enumerator2 = list.GetEnumerator())
                {
                    while (enumerator2.MoveNext())
                    {
                        ShipModel_Defender current2 = enumerator2.get_Current();
                        if (num2 >= 3)
                        {
                            break;
                        }
                        this._queFriedShipModel.Enqueue(current2);
                        num2++;
                    }
                }
                this.PlayHeavyDamage(DamagedStates.Tyuuha);
            }
            else
            {
                this.OnFinished();
            }
            list.Clear();
        }