private BattleProcess.TorpedoInfo[] ConvertTorpedoInfo(BattleProcess holder, dynamic data)
        {
            var r = new List <BattleProcess.TorpedoInfo>(12);

            for (int i = 1; i < 7; i++)
            {
                if (data.api_frai.IsDefined(i) && (data.api_frai[i] > 0))
                {
                    r.Add(new BattleProcess.TorpedoInfo(holder)
                    {
                        ZwFrom   = i,
                        ZwTo     = (int)data.api_frai[i] + 6,
                        ZwDamage = (int)data.api_fydam[i]
                    });
                }
                if (data.api_erai.IsDefined(i) && (data.api_erai[i] > 0))
                {
                    r.Add(new BattleProcess.TorpedoInfo(holder)
                    {
                        ZwFrom   = i + 6,
                        ZwTo     = (int)data.api_erai[i],
                        ZwDamage = (int)data.api_eydam[i]
                    });
                }
            }
            return(r.ToArray());
        }
示例#2
0
        public async Task RunAsync()
        {
            var tokenProp1 = new SampleMovingBattleTokenProperty();
            var skills     = new Skill[]
            {
                new Skill()
                {
                    Property = new SampleMoveSkillProperty()
                }
            };

            var battleContext = new BattleContext()
            {
                LocalPlayer = new Player()
                {
                    Tokens = new BattleToken[]
                    {
                        new BattleToken(0, tokenProp1, skills),
                    },
                },
                RemotePlayer = new Player()
                {
                    Tokens = new BattleToken[]
                    {
                        new BattleToken(1, tokenProp1, skills),
                    },
                },
            };
            var battleView = view.GotoBattle(battleContext);

            battleContext.View = battleView;
            var battleProcess = new BattleProcess(battleContext);
            await battleProcess.RunAsync();
        }
        private BattleProcess.BombardInfo[] ConvertBombards(BattleProcess holder, dynamic data, bool isEscort)
        {
            List <BattleProcess.BombardInfo> r = new List <BattleProcess.BombardInfo>(12);

            for (int i = 1; data.api_at_list.IsDefined(i); i++)
            {
                List <int> dmgs = new List <int>(2);
                List <int> tgts = new List <int>(2);
                List <int> sis  = new List <int>(3);
                int        attackType;

                for (int j = 0; data.api_damage[i].IsDefined(j); j++)
                {
                    if (data.api_df_list[i][j] > 0)
                    {
                        dmgs.Add((int)data.api_damage[i][j]);
                        tgts.Add((int)data.api_df_list[i][j]);
                    }
                }
                for (int j = 0; data.api_si_list[i].IsDefined(j); j++)
                {
                    if (data.api_si_list[i][j] > 0)
                    {
                        sis.Add((int)data.api_si_list[i][j]);
                    }
                }

                if (data.api_at_type())
                {
                    attackType = (int)data.api_at_type[i];
                }
                else
                {
                    attackType = (int)-data.api_sp_list[i];
                }

                var from          = (int)data.api_at_list[i];
                var ourShipOffset = isEscort ? 12 : 0;
                r.Add(new BattleProcess.BombardInfo(holder)
                {
                    ZwFrom    = from < 7 ? from + ourShipOffset : from,
                    ZwTo      = tgts.Select(x => x < 7 ? x + ourShipOffset : x).ToArray(),
                    ZwDamage  = dmgs.ToArray(),
                    ZwEquipts = sis.Select(x => new EquiptInfo(KanColleClient.Current.Master.SlotItems[x], x)).ToArray(),
                    ZwType    = (BattleProcess.BombardInfo.AttackType)attackType
                });
            }
            return(r.ToArray());
        }
        private BattleProcess.AirWarfareInfo CreateSupportAttackInfo(BattleProcess holder, dynamic data)
        {
            List <int>  enemyDamage    = new List <int>(6);
            List <bool> enemyBombed    = new List <bool>(6);
            List <bool> enemyTorpedoed = new List <bool>(6);

            for (int i = 1; i < 7; i++)
            {
                if (data.api_damage.IsDefined(i) && data.api_damage[i] >= 0)
                {
                    enemyBombed.Add(holder.SupportType == BattleProcess.SupportInfo.Type.GunFight);
                    enemyTorpedoed.Add(holder.SupportType == BattleProcess.SupportInfo.Type.Torpedo);
                    enemyDamage.Add((int)data.api_damage[i]);
                }
            }
            return(new BattleProcess.AirWarfareInfo(holder)
            {
                ZwEnemyCarrierShip = null,
                ZwEnemyStage1Engaged = 0,
                ZwEnemyStage1Lost = 0,
                ZwEnemyReconnInTouch = -1,
                ZwEnemyReconnInTouchName = "",
                ZwEnemyStage2Engaged = 0,
                ZwEnemyStage2Lost = 0,

                ZwOurCarrierShip = null,
                ZwOurReconnInTouch = -1,
                ZwOurReconnInTouchName = "",
                ZwOurStage1Engaged = 0,
                ZwOurStage1Lost = 0,
                ZwOurStage2Engaged = 0,
                ZwOurStage2Lost = 0,
                ZwOurAirspaceControl = BattleProcess.AirWarfareInfo.AirspaceControl.None,

                ZwEnemyShipBombed = enemyBombed.ToArray(),
                ZwEnemyShipDamages = enemyDamage.ToArray(),
                ZwEnemyShipTorpedoed = enemyTorpedoed.ToArray(),
                ZwOurShipBombed = null,
                ZwOurShipDamages = null,
                ZwOurShipTorpedoed = null
            });
        }
示例#5
0
    // Use this for initialization
    void Start()
    {
        Statics.Init();
        List <RoleData>           teamsData = new List <RoleData>();
        List <List <SecretData> > secrets   = new List <List <SecretData> >();

        for (int i = 0, len = TeamRoleIds.Count; i < len; i++)
        {
            teamsData.Add(JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", TeamRoleIds[i]));
            secrets.Add(DbManager.Instance.GetSecretsBelongBooks(teamsData[i].ResourceBookDataIds));
        }
        List <RoleData> enemysData = new List <RoleData>();

        for (int i = 0, len = EnemyRoleIds.Count; i < len; i++)
        {
            enemysData.Add(JsonManager.GetInstance().GetMapping <RoleData>("RoleDatas", EnemyRoleIds[i]));
        }
        BattleLogic.Instance.AutoFight = true;
        BattleLogic.Instance.Init(teamsData, secrets, enemysData);
        while (true)
        {
            BattleLogic.Instance.Action();
            BattleProcess process = BattleLogic.Instance.PopProcess();
            if (process != null)
            {
                Debug.Log(JsonManager.GetInstance().SerializeObject(process));
            }
            if (BattleLogic.Instance.GetProcessCount() == 0)
            {
                if (BattleLogic.Instance.IsFail())
                {
                    break;
                }
                if (BattleLogic.Instance.IsWin())
                {
                    break;
                }
            }
        }
    }
        private BattleProcess.AirWarfareInfo ConvertAirWarfare(BattleProcess holder, dynamic data)
        {
            List <int> planeFrom = new List <int>(12);

            if (data.api_plane_from != null)
            {
                for (int i = 0; i < 6; i++)
                {
                    if (data.api_plane_from[0].IsDefined(i) && data.api_plane_from[0][i] > 0)
                    {
                        planeFrom.Add((int)data.api_plane_from[0][i]);
                    }
                    if (data.api_plane_from.IsDefined(1) && data.api_plane_from[1].IsDefined(i) && data.api_plane_from[1][i] > 0)
                    {
                        planeFrom.Add((int)data.api_plane_from[1][i]);
                    }
                }
            }
            List <bool> ourBombed       = new List <bool>(6);
            List <bool> ourTorpedoed    = new List <bool>(6);
            List <int>  ourDamage       = new List <int>(6);
            List <bool> enemyBombed     = new List <bool>(6);
            List <bool> enemyTorpedoed  = new List <bool>(6);
            List <int>  enemyDamage     = new List <int>(6);
            List <bool> escortBombed    = new List <bool>(6);
            List <bool> escortTorpedoed = new List <bool>(6);
            List <int>  escortDamage    = new List <int>(6);

            if (data.api_stage3 != null)
            {
                for (int i = 1; i < 7; i++)
                {
                    if (data.api_stage3.api_fdam() && data.api_stage3.api_fdam.IsDefined(i) && data.api_stage3.api_fdam[i] >= 0)
                    {
                        ourBombed.Add(data.api_stage3.api_fbak_flag[i] != 0);
                        ourTorpedoed.Add(data.api_stage3.api_frai_flag[i] != 0);
                        ourDamage.Add((int)data.api_stage3.api_fdam[i]);
                    }
                    if (data.api_stage3.api_edam() && data.api_stage3.api_edam.IsDefined(i) && data.api_stage3.api_edam[i] >= 0)
                    {
                        enemyBombed.Add(data.api_stage3.api_ebak_flag[i] != 0);
                        enemyTorpedoed.Add(data.api_stage3.api_erai_flag[i] != 0);
                        enemyDamage.Add((int)data.api_stage3.api_edam[i]);
                    }
                    if (data.api_stage3_combined() && data.api_stage3_combined != null && data.api_stage3_combined.api_fdam())
                    {
                        if (data.api_stage3_combined.api_fdam.IsDefined(i) && data.api_stage3_combined.api_fdam[i] >= 0)
                        {
                            escortBombed.Add(data.api_stage3_combined.api_fbak_flag[i] != 0);
                            escortTorpedoed.Add(data.api_stage3_combined.api_frai_flag[i] != 0);
                            escortDamage.Add((int)data.api_stage3_combined.api_fdam[i]);
                        }
                    }
                }
            }
            BattleProcess.AirWarfareInfo.AirspaceControl ac = BattleProcess.AirWarfareInfo.AirspaceControl.None;
            if (data.api_stage1 != null && data.api_stage1.api_disp_seiku())
            {
                switch ((int)(data.api_stage1.api_disp_seiku))
                {
                case 0:
                    ac = BattleProcess.AirWarfareInfo.AirspaceControl.Parity;
                    break;

                case 3:
                case 4:
                    ac = (BattleProcess.AirWarfareInfo.AirspaceControl)(int)(data.api_stage1.api_disp_seiku + 1);
                    break;

                case 1:
                case 2:
                    ac = (BattleProcess.AirWarfareInfo.AirspaceControl)(int) data.api_stage1.api_disp_seiku;
                    break;

                default:
                    ac = (BattleProcess.AirWarfareInfo.AirspaceControl)(int) - Math.Abs(data.api_stage1.api_disp_seiku);
                    break;
                }
            }
            BattleProcess.AirWarfareInfo r;
            if (data.api_deck_id())   //航空支援
            {
                r = new BattleProcess.AirWarfareInfo(holder)
                {
                    ZwEnemyCarrierShip       = planeFrom.Where(x => x > 6).Select(x => x - 7).ToArray(),
                    ZwEnemyStage1Engaged     = (int)(data.api_stage1?.api_e_count ?? 0),
                    ZwEnemyStage1Lost        = (int)(data.api_stage1?.api_e_lostcount ?? 0),
                    ZwEnemyReconnInTouch     = -1,
                    ZwEnemyReconnInTouchName = "",
                    ZwEnemyStage2Engaged     = 0,
                    ZwEnemyStage2Lost        = 0,

                    ZwOurCarrierShip       = null,
                    ZwOurReconnInTouch     = -1,
                    ZwOurReconnInTouchName = "",
                    ZwOurStage1Engaged     = (int)(data.api_stage1?.api_f_count ?? 0),
                    ZwOurStage1Lost        = (int)(data.api_stage1?.api_f_lostcount ?? 0),
                    ZwOurStage2Engaged     = (int)(data.api_stage2?.api_f_count ?? 0),
                    ZwOurStage2Lost        = (int)(data.api_stage2?.api_f_lostcount ?? 0),
                    ZwOurAirspaceControl   = BattleProcess.AirWarfareInfo.AirspaceControl.None,

                    ZwEnemyShipBombed    = enemyBombed.ToArray(),
                    ZwEnemyShipDamages   = enemyDamage.ToArray(),
                    ZwEnemyShipTorpedoed = enemyTorpedoed.ToArray(),
                    ZwOurShipBombed      = null,
                    ZwOurShipDamages     = null,
                    ZwOurShipTorpedoed   = null
                };
            }
            else
            {
                r = new BattleProcess.AirWarfareInfo(holder)
                {
                    ZwEnemyCarrierShip   = planeFrom.Where(x => x > 6).Select(x => x - 7).ToArray(),
                    ZwEnemyReconnInTouch = (int)(data.api_stage1?.api_touch_plane[1] ?? -1),
                    ZwEnemyStage1Engaged = (int)(data.api_stage1?.api_e_count ?? 0),
                    ZwEnemyStage1Lost    = (int)(data.api_stage1?.api_e_lostcount ?? 0),
                    ZwEnemyStage2Engaged = (int)(data.api_stage2?.api_e_count ?? 0),
                    ZwEnemyStage2Lost    = (int)(data.api_stage2?.api_e_lostcount ?? 0),

                    ZwOurCarrierShip     = planeFrom.Where(x => x < 7).Select(x => x - 1).ToArray(),
                    ZwOurReconnInTouch   = (int)(data.api_stage1?.api_touch_plane[0] ?? -1),
                    ZwOurStage1Engaged   = (int)(data.api_stage1?.api_f_count ?? 0),
                    ZwOurStage1Lost      = (int)(data.api_stage1?.api_f_lostcount ?? 0),
                    ZwOurStage2Engaged   = (int)(data.api_stage2?.api_f_count ?? 0),
                    ZwOurStage2Lost      = (int)(data.api_stage2?.api_f_lostcount ?? 0),
                    ZwOurAirspaceControl = ac,

                    ZwEnemyShipBombed    = enemyBombed.ToArray(),
                    ZwEnemyShipDamages   = enemyDamage.ToArray(),
                    ZwEnemyShipTorpedoed = enemyTorpedoed.ToArray(),
                    ZwOurShipBombed      = ourBombed.ToArray(),
                    ZwOurShipDamages     = ourDamage.ToArray(),
                    ZwOurShipTorpedoed   = ourTorpedoed.ToArray(),

                    ZwEscortShipBombed    = escortBombed?.ToArray(),
                    ZwEscortShipTorpedoed = escortTorpedoed?.ToArray(),
                    ZwEscortShipDamages   = escortDamage?.ToArray()
                };
                if (data.api_stage2 != null && data.api_stage2.api_air_fire() && data.api_stage2.api_air_fire != null)  //对空CI
                {
                    r.ZwCutInShipNo = (int)data.api_stage2.api_air_fire.api_idx;
                    r.ZwCutInType   = (BattleProcess.AirWarfareInfo.AaCutInType)(int) data.api_stage2.api_air_fire.api_kind;
                    List <int> ciEquipts = new List <int>();
                    for (int i = 0; data.api_stage2.api_air_fire.api_use_items.IsDefined(i); i++)
                    {
                        ciEquipts.Add((int)data.api_stage2.api_air_fire.api_use_items[i]);
                    }
                    r.ZwCutInEquipts = ciEquipts.Select(x => new EquiptInfo(KanColleClient.Current.Master.SlotItems[x], x)).ToArray();
                }
                else
                {
                    r.ZwCutInEquipts = null;
                }
                if (r.ZwOurReconnInTouch < 0)
                {
                    r.ZwOurReconnInTouchName = "没有舰载机";
                }
                else
                {
                    r.ZwOurReconnInTouchName = Helpers.GetEquiptNameWithFallback(r.ZwOurReconnInTouch, "{0} 号侦察机");
                }
                if (r.ZwEnemyReconnInTouch < 0)
                {
                    r.ZwEnemyReconnInTouchName = "没有舰载机";
                }
                else
                {
                    r.ZwEnemyReconnInTouchName = Helpers.GetEquiptNameWithFallback(r.ZwEnemyReconnInTouch, "{0} 号侦察机");
                }
            }
            return(r);
        }
        public void OnNext(Session value)
        {
            if (_onBattle == null)
            {
                return;
            }

            try {
                var     response = value.Response.Body;
                string  json     = Encoding.ASCII.GetString(response, 7, response.Length - 7);
                dynamic res      = DynamicJson.Parse(json);
                if (!res.api_result() || res.api_result != 1)
                {
                    return;
                }

                var data = res.api_data;

                BattleProcess result = new BattleProcess();
                result.ZwRawData = json;

                int fleetId; // dock deck傻傻分不清楚
                if (data.api_dock_id())
                {
                    fleetId = Convert.ToInt32(data.api_dock_id);
                }
                else
                {
                    fleetId = Convert.ToInt32(data.api_deck_id);
                }
                result.ZwOurShips   = ConvertOurFleet(fleetId, data.api_nowhps, data.api_maxhps, data.api_fParam);
                result.ZwEnemyShips = ConvertEnemyFleet(data.api_ship_ke, data.api_ship_lv, data.api_nowhps, data.api_maxhps, data.api_eParam, data.api_eKyouka, data.api_eSlot);
                if (data.api_nowhps_combined())  //联合舰队
                {
                    result.ZwOurEscort = ConvertOurFleet(fleetId + 1, data.api_nowhps_combined, data.api_maxhps_combined, data.api_fParam_combined);
                }

                if (data.api_formation())
                {
                    result.ZwOurFormation   = (BattleProcess.Formation)Convert.ToInt32(data.api_formation[0]);
                    result.ZwEnemyFormation = (BattleProcess.Formation)(int) data.api_formation[1];
                    result.ZwEncounter      = (BattleProcess.EncounterForm)(int) data.api_formation[2];
                }
                if (data.api_flare_pos())   //夜战
                {
                    var r = new BattleProcess.NightWarInfo(result)
                    {
                        ZwRawData            = json,
                        ZwBombard            = ConvertBombards(result, data.api_hougeki, value.Request.PathAndQuery.Contains("api_req_combined_battle")),
                        ZwOurReconnInTouch   = (int)data.api_touch_plane[0],
                        ZwEnemyReconnInTouch = (int)data.api_touch_plane[1]
                    };
                    if (r.ZwOurReconnInTouch < 0)
                    {
                        r.ZwOurReconnInTouchName = "没有舰载机";
                    }
                    else
                    {
                        r.ZwOurReconnInTouchName = Helpers.GetEquiptNameWithFallback(r.ZwOurReconnInTouch, "{0} 号侦察机");
                    }
                    if (r.ZwEnemyReconnInTouch < 0)
                    {
                        r.ZwEnemyReconnInTouchName = "没有舰载机";
                    }
                    else
                    {
                        r.ZwEnemyReconnInTouchName = Helpers.GetEquiptNameWithFallback(r.ZwEnemyReconnInTouch, "{0} 号侦察机");
                    }
                    result.ZwHasNightWar        = true;
                    result.ZwNightWar           = r;
                    result.ZwAirWarfare         = _dummyAirwarfare.Clone();
                    result.ZwAirWarfare._parent = result;
                }
                if (data.api_stage_flag())   //昼战 航空战/炮击战 共有部分
                {
                    result.ZwAirWarfare  = ConvertAirWarfare(result, data.api_kouku);
                    result.ZwOurReconn   = (BattleProcess.ReconnResult)(int) data.api_search[0];
                    result.ZwEnemyReconn = (BattleProcess.ReconnResult)(int) data.api_search[1];
                    result.ZwHasNightWar = data.api_midnight_flag > 0;

                    if (data.api_stage_flag2())   //昼战 航空战
                    {
                        result.ZwAirWarfare2 = ConvertAirWarfare(result, data.api_kouku2);
                    }
                    else if (data.api_hourai_flag())     //昼战 炮击战
                    {
                        if (data.api_opening_atack() && data.api_opening_atack != null)
                        {
                            result.ZwOpeningTorpedoAttack = ConvertTorpedoInfo(result, data.api_opening_atack);
                        }
                        if (data.api_hougeki1() && data.api_hougeki1 != null)
                        {
                            result.ZwBombardRound1 = ConvertBombards(result, data.api_hougeki1, (value.Request.PathAndQuery.Contains("api_req_combined_battle") && !value.Request.PathAndQuery.Contains("water")));
                        }
                        if (data.api_hougeki2() && data.api_hougeki2 != null)
                        {
                            result.ZwBombardRound2 = ConvertBombards(result, data.api_hougeki2, false);
                        }
                        if (data.api_hougeki3() && data.api_hougeki3 != null)
                        {
                            result.ZwBombardRound3 = ConvertBombards(result, data.api_hougeki3, (value.Request.PathAndQuery.Contains("api_req_combined_battle") && value.Request.PathAndQuery.Contains("water")));
                        }
                        if (data.api_raigeki() && data.api_raigeki != null)
                        {
                            result.ZwClosingTorpedoAttack = ConvertTorpedoInfo(result, data.api_raigeki);
                        }
                        result.ZwSupportType = (BattleProcess.SupportInfo.Type)(int)(data.api_support_flag() ? data.api_support_flag : 0);
                        if (data.api_support_info() && (data.api_support_info != null))
                        {
                            int supportDeckId = (int)(data.api_support_info.api_support_airatack?.api_deck_id ?? data.api_support_info.api_support_hourai.api_deck_id);
                            result.ZwSupport = new BattleProcess.SupportInfo()
                            {
                                ZwSupportShips = KanColleClient.Current.Homeport.Organization.Fleets[supportDeckId].Ships.Select((x, i) => {
                                    var localShip = DataStore.Store.Current.Ships[x.Id];
                                    return(new BattleProcess.ShipInfo()
                                    {
                                        ZwShipNameType = new ShipNameType(x.Info, i),
                                        ZwId = x.Id,
                                        ZwLv = x.Level,
                                        ZwCurrentHp = x.HP.Current,
                                        ZwMaxHp = x.HP.Maximum,
                                        ZwParameter = new BattleProcess.ShipInfo.ParameterInfo()
                                        {
                                            ZwPower = x.Firepower.Current,
                                            ZwTorpedo = x.Torpedo.Current,
                                            ZwAntiAir = x.AA.Current,
                                            ZwDefense = x.Armer.Current
                                        },
                                        ZwEnhancement = new BattleProcess.ShipInfo.ParameterInfo()
                                        {
                                            ZwAntiAir = localShip.EnhancedAntiAir,
                                            ZwDefense = localShip.EnhancedDefense,
                                            ZwPower = localShip.EnhancedPower,
                                            ZwTorpedo = localShip.EnhancedTorpedo
                                        },
                                        ZwEquipts = x.EquippedSlots.Select(si => new EquiptInfo(si)).ToArray()
                                    });
                                }).ToArray()
                            };
                            if (data.api_support_info.api_support_airatack != null)
                            {
                                result.ZwSupport.ZwAttackInfo = ConvertAirWarfare(result, data.api_support_info.api_support_airatack);
                            }
                            else if (data.api_support_info.api_support_hourai != null)
                            {
                                result.ZwSupport.ZwAttackInfo = CreateSupportAttackInfo(result, data.api_support_info.api_support_hourai);
                            }
                        }
                    }
                }

                _onBattle(result);
            } catch (Exception) { }
        }
示例#8
0
 public void GameOver()
 {
     _curProcess = BattleProcess.GameOver;
     EventDispatcher.TriggerEvent(EventDefine.GameOver);
 }
示例#9
0
        void Update()
        {
            if (paused)
            {
                return;
            }
            switch (state)
            {
            case ready:
                if (Time.fixedTime - readyDate > 1)
                {
                    state = fight;
                }
                break;

            case fight:
                if (BattleLogic.Instance.CurrentEnemyRole != null && BattleLogic.Instance.CurrentEnemyRole.GetCurrentBook() != null)
                {
                    enemyCDProgress.fillAmount = BattleLogic.Instance.CurrentEnemyRole.GetCurrentBook().GetCurrentSkill().GetCDProgress(BattleLogic.Instance.Frame);
                }
                BattleLogic.Instance.Action();
                BattleProcess process = BattleLogic.Instance.PopProcess();
                if (process != null)
                {
                    dealBattleProcess(process);
                }
                if (BattleLogic.Instance.GetProcessCount() == 0)
                {
                    if (BattleLogic.Instance.IsFail())       //判负
                    {
                        state = fail;
                        break;
                    }
                    if (BattleLogic.Instance.IsWin())       //判胜
                    {
                        state = win;
                        break;
                    }
                }
                break;

            case delayDoing:
                if (Time.fixedTime - delayDate > delayTimeout)
                {
                    state = fight;
                }
                break;

            case win:
                state = waiting;
                isWin = true;
                alphaGroup.gameObject.SetActive(true);
                winSprite.gameObject.SetActive(true);
                alphaGroup.DOFade(1, 1).SetDelay(1).OnComplete(endSend);
                SoundManager.GetInstance().StopBGM();
                refreshTeamBlood();
                refreshEnemyBlood();
                break;

            case fail:
                state = waiting;
                isWin = false;
                alphaGroup.gameObject.SetActive(true);
                failSprite.gameObject.SetActive(true);
                alphaGroup.DOFade(1, 1).SetDelay(1).OnComplete(endSend);
                SoundManager.GetInstance().StopBGM();
                refreshTeamBlood();
                refreshEnemyBlood();
                break;

            case waiting:
                break;
            }
        }
示例#10
0
        void dealBattleProcess(BattleProcess process)
        {
            freeHeightGrid.PushContext(process.Result);
            switch (process.Type)
            {
            case BattleProcessType.Normal:
            default:

                break;

            case BattleProcessType.EnemyPop:
                enemyBody.DOFade(0, 0);
                refreshEnemy();
                enemyBody.DOFade(1, 0.45f);
                state             = delayDoing;
                delayDate         = Time.fixedTime;
                delayTimeout      = 0.5f;
                enemyNumText.text = string.Format("剩余敌人: {0}/{1}", BattleLogic.Instance.EnemysData.Count - BattleLogic.Instance.CurrentEnemy, BattleLogic.Instance.EnemysData.Count);
                break;

            case BattleProcessType.Attack:
                if (process.IsTeam)
                {
                    refreshEnemyBlood();
                    dealSkillEffectAndSound("Team", process.Skill);
                    //记录使用过的招式
                    if (!usedSkillIdMapping.ContainsKey(process.Skill.Id))
                    {
                        usedSkillIdMapping.Add(process.Skill.Id, 1);
                    }
                    else
                    {
                        usedSkillIdMapping[process.Skill.Id]++;
                    }
                    enemyBody.transform.DOShakePosition(0.25f, 20, 50, 90);
                }
                else
                {
                    refreshTeamBlood();
                    dealSkillEffectAndSound("Enemy", process.Skill);
                    enemyBody.transform.DOScale(1.5f, 0.15f).SetLoops(2, LoopType.Yoyo);
                }
                if (!process.IsMissed)
                {
                    Statics.CreatePopMsg(
                        process.IsTeam ? enemyPoplPos.transform.position : teamPoplPos.transform.position,
                        process.HurtedHP > 0 ? ("+" + process.HurtedHP) : process.HurtedHP.ToString(),
                        process.HurtedHP > 0 ? Color.green : Color.red, 40, 0.2f);
                }
                else
                {
                    if (!process.IsIgnoreAttack)
                    {
                        Statics.CreatePopMsg(
                            process.IsTeam ? enemyPoplPos.transform.position : teamPoplPos.transform.position,
                            "闪避",
                            Color.white, 40, 0.2f);
                    }
                    else
                    {
                        Statics.CreatePopMsg(
                            process.IsTeam ? enemyPoplPos.transform.position : teamPoplPos.transform.position,
                            "无视伤害",
                            Color.white, 40, 0.2f);
                    }
                }
                state        = delayDoing;
                delayDate    = Time.fixedTime;
                delayTimeout = 0.3f;
                break;

            case BattleProcessType.Increase:
            case BattleProcessType.Plus:
                if (process.IsTeam)
                {
                    refreshTeamBlood();
                    dealSkillEffectAndSound("Enemy", process.Skill);
                }
                else
                {
                    refreshEnemyBlood();
                }
                if (process.HurtedHP != 0)
                {
                    Statics.CreatePopMsg(
                        process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.3f : enemyPoplPos.transform.position + Vector3.up * 0.3f,
                        process.HurtedHP > 0 ? ("+" + process.HurtedHP + "(恢复)") : process.HurtedHP.ToString() + "(流血)",
                        process.HurtedHP > 0 ? Color.green : Color.red, 40, 0.2f);
                }
                break;

            case BattleProcessType.Drug:
                refreshTeamBlood();
                Statics.CreatePopMsg(
                    process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.3f : enemyPoplPos.transform.position + Vector3.up * 0.3f,
                    "+" + process.HurtedHP + "(药)",
                    Color.green, 40, 0.2f);
                break;

            case BattleProcessType.ReboundInjury:
                if (process.IsTeam)
                {
                    refreshTeamBlood();
                }
                else
                {
                    refreshEnemyBlood();
                }
                Statics.CreatePopMsg(
                    process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.4f : enemyPoplPos.transform.position + Vector3.up * 0.4f,
                    process.HurtedHP + "(反伤)",
                    Color.red, 40, 0.2f);
                break;

            case BattleProcessType.AccidentalInjury:
                if (process.IsTeam)
                {
                    refreshTeamBlood();
                }
                else
                {
                    refreshEnemyBlood();
                }
                Statics.CreatePopMsg(
                    process.IsTeam ? teamPoplPos.transform.position + Vector3.up * 0.5f : enemyPoplPos.transform.position + Vector3.up * 0.5f,
                    process.HurtedHP + "(误伤)",
                    Color.red, 40, 0.2f);
                break;
            }
        }