private void UpdateSelectGrid()
        {
            if (this.m_SelectGrid.x < 0 || this.m_SelectGrid.y < 0)
            {
                return;
            }
            if (this.m_SelectParty < 0)
            {
                for (int index = 0; index < this.m_Units.Count; ++index)
                {
                    TacticsUnitController unit = this.m_Units[index];
                    if (unit.Unit.x == this.m_SelectGrid.x && unit.Unit.y == this.m_SelectGrid.y)
                    {
                        this.m_SelectParty = index;
                        break;
                    }
                }
                if (this.m_SelectParty < 0)
                {
                    return;
                }
                this.UpdateUnitStatus(0, false);
            }
            else
            {
                int num = this.CheckExistUnit(this.m_SelectGrid.x, this.m_SelectGrid.y);
                if (num != -1)
                {
                    this.m_SelectParty = num;
                    this.UpdateUnitStatus(0, true);
                    MonoSingleton <MySound> .Instance.PlaySEOneShot("SE_0005", 0.0f);
                }
                else
                {
                    using (List <UnitSetting> .Enumerator enumerator = this.CurrentMap.PartyUnitSettings.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            UnitSetting current = enumerator.Current;
                            if (this.CheckExistUnit((int)current.pos.x, (int)current.pos.y) == -1 && (int)current.pos.x == this.m_SelectGrid.x && (int)current.pos.y == this.m_SelectGrid.y)
                            {
                                this.m_Units[this.m_SelectParty].Unit.x = (int)current.pos.x;
                                this.m_Units[this.m_SelectParty].Unit.y = (int)current.pos.y;
                                this.CalcPosition(this.m_Units[this.m_SelectParty]);
                                this.UpdateUnitStatus(0, true);
                                MonoSingleton <MySound> .Instance.PlaySEOneShot("SE_0002", 0.0f);

                                break;
                            }
                        }
                    }
                }
            }
        }
        private void UpdateGridColor()
        {
            if (this.CurrentMap == null)
            {
                return;
            }
            GameSettings      instance1 = GameSettings.Instance;
            GridMap <Color32> grid      = new GridMap <Color32>(this.CurrentMap.Width, this.CurrentMap.Height);
            MyPhoton          instance2 = PunMonoSingleton <MyPhoton> .Instance;

            if (this.CurrentMap.PartyUnitSettings != null)
            {
                using (List <UnitSetting> .Enumerator enumerator = this.CurrentMap.PartyUnitSettings.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        UnitSetting current = enumerator.Current;
                        grid.set((int)current.pos.x, (int)current.pos.y, Color32.op_Implicit(instance1.Colors.WalkableArea));
                    }
                }
            }
            using (List <TacticsUnitController> .Enumerator enumerator = this.m_Units.GetEnumerator())
            {
                while (enumerator.MoveNext())
                {
                    TacticsUnitController current = enumerator.Current;
                    if (current.Unit.OwnerPlayerIndex != instance2.MyPlayerIndex)
                    {
                        grid.set(current.Unit.x, current.Unit.y, Color32.op_Implicit(instance1.Colors.Helper));
                    }
                }
            }
            if (this.CurrentMap.NPCUnitSettings != null)
            {
                using (List <NPCSetting> .Enumerator enumerator = this.CurrentMap.NPCUnitSettings.GetEnumerator())
                {
                    while (enumerator.MoveNext())
                    {
                        NPCSetting current = enumerator.Current;
                        grid.set((int)current.pos.x, (int)current.pos.y, Color32.op_Implicit(instance1.Colors.Enemy));
                    }
                }
            }
            this.m_SceneRoot.ShowGridLayer(0, grid, true);
        }
Example #3
0
        public bool Initialize(BattleCore core, MapParam param)
        {
            this.mBattle         = core;
            this.MapSceneName    = param.mapSceneName;
            this.BattleSceneName = param.battleSceneName;
            this.EventSceneName  = param.eventSceneName;
            this.BGMName         = param.bgmName;
            this.mWinMonitorCondition.Clear();
            this.mLoseMonitorCondition.Clear();
            if (string.IsNullOrEmpty(param.mapSceneName))
            {
                DebugUtility.LogError("not found mapdata.");
                return(false);
            }
            string path1 = AssetPath.LocalMap(param.mapSceneName);
            string src1  = AssetManager.LoadTextData(path1);

            if (src1 == null)
            {
                DebugUtility.LogError("Failed to load " + path1);
                return(false);
            }
            if (!this.Deserialize(JSONParser.parseJSONObject <JSON_Map>(src1)))
            {
                DebugUtility.LogError("Failed to load " + path1);
                return(false);
            }
            string path2 = AssetPath.LocalMap(param.mapSetName);
            string src2  = AssetManager.LoadTextData(path2);

            if (src2 == null)
            {
                DebugUtility.LogError("マップ配置情報\"" + path2 + "\"に存在しない");
                return(false);
            }
            JSON_MapUnit jsonObject = JSONParser.parseJSONObject <JSON_MapUnit>(src2);

            if (jsonObject == null)
            {
                DebugUtility.LogError("マップ配置情報\"" + path2 + "\"のパースに失敗");
                return(false);
            }
            if (jsonObject.enemy == null && jsonObject.arena == null)
            {
                DebugUtility.LogError("敵ユニットの配置情報がマップ配置情報\"" + path2 + "\"に存在しない");
                return(false);
            }
            if (jsonObject.party != null)
            {
                this.mPartyUnitSettings = new List <UnitSetting>(jsonObject.party.Length);
                for (int index = 0; index < jsonObject.party.Length; ++index)
                {
                    this.mPartyUnitSettings.Add(new UnitSetting(jsonObject.party[index]));
                }
            }
            if (jsonObject.party_subs != null && jsonObject.party_subs.Length != 0)
            {
                this.mPartyUnitSubSettings = new List <UnitSubSetting>(jsonObject.party_subs.Length);
                foreach (JSON_MapPartySubCT partySub in jsonObject.party_subs)
                {
                    this.mPartyUnitSubSettings.Add(new UnitSubSetting(partySub));
                }
            }
            if (jsonObject.tricks != null && jsonObject.tricks.Length != 0)
            {
                this.mTrickSettings = new List <TrickSetting>(jsonObject.tricks.Length);
                foreach (JSON_MapTrick trick in jsonObject.tricks)
                {
                    this.mTrickSettings.Add(new TrickSetting(trick));
                }
            }
            if (jsonObject.enemy != null)
            {
                jsonObject.enemy      = jsonObject.ReplacedRandEnemy(this.mRandDeckResult, true);
                this.mNPCUnitSettings = new List <NPCSetting>(jsonObject.enemy.Length);
                for (int index = 0; index < jsonObject.enemy.Length; ++index)
                {
                    this.mNPCUnitSettings.Add(new NPCSetting(jsonObject.enemy[index]));
                }
            }
            if (jsonObject.arena != null)
            {
                this.mArenaUnitSettings = new List <UnitSetting>(jsonObject.arena.Length);
                for (int index = 0; index < jsonObject.arena.Length; ++index)
                {
                    UnitSetting unitSetting = new UnitSetting();
                    unitSetting.uniqname          = (OString)jsonObject.arena[index].name;
                    unitSetting.ai                = (OString)jsonObject.arena[index].ai;
                    unitSetting.pos.x             = (OInt)jsonObject.arena[index].x;
                    unitSetting.pos.y             = (OInt)jsonObject.arena[index].y;
                    unitSetting.dir               = (OInt)jsonObject.arena[index].dir;
                    unitSetting.waitEntryClock    = (OInt)jsonObject.arena[index].wait_e;
                    unitSetting.waitMoveTurn      = (OInt)jsonObject.arena[index].wait_m;
                    unitSetting.waitExitTurn      = (OInt)jsonObject.arena[index].wait_exit;
                    unitSetting.startCtCalc       = (eMapUnitCtCalcType)jsonObject.arena[index].ct_calc;
                    unitSetting.startCtVal        = (OInt)jsonObject.arena[index].ct_val;
                    unitSetting.DisableFirceVoice = jsonObject.arena[index].fvoff != 0;
                    unitSetting.side              = (OInt)1;
                    unitSetting.ai_pos.x          = (OInt)jsonObject.arena[index].ai_x;
                    unitSetting.ai_pos.y          = (OInt)jsonObject.arena[index].ai_y;
                    unitSetting.ai_len            = (OInt)jsonObject.arena[index].ai_len;
                    unitSetting.parent            = (OString)jsonObject.arena[index].parent;
                    if (jsonObject.arena[index].trg != null)
                    {
                        unitSetting.trigger = new EventTrigger();
                        unitSetting.trigger.Deserialize(jsonObject.arena[index].trg);
                    }
                    this.mArenaUnitSettings.Add(unitSetting);
                }
            }
            if (jsonObject.w_cond != null)
            {
                jsonObject.w_cond.CopyTo(this.mWinMonitorCondition);
            }
            if (jsonObject.l_cond != null)
            {
                jsonObject.l_cond.CopyTo(this.mLoseMonitorCondition);
            }
            if (jsonObject.gs != null)
            {
                this.mGimmickEvents = new List <JSON_GimmickEvent>((IEnumerable <JSON_GimmickEvent>)jsonObject.gs);
            }
            return(true);
        }
        private void UpdateSelectGrid()
        {
            if (this.m_SelectGrid.x < 0 || this.m_SelectGrid.y < 0 || !this.m_Ready)
            {
                return;
            }
            if (this.m_SelectParty < 0)
            {
                for (int index = 0; index < this.m_Units.Count; ++index)
                {
                    TacticsUnitController unit = this.m_Units[index];
                    if (unit.Unit.x == this.m_SelectGrid.x && unit.Unit.y == this.m_SelectGrid.y)
                    {
                        this.m_SelectParty = index;
                        break;
                    }
                }
                if (this.m_SelectParty < 0)
                {
                    return;
                }
                this.UpdateUnitStatus(0, false);
            }
            else
            {
                MyPhoton   instance = PunMonoSingleton <MyPhoton> .Instance;
                List <int> intList  = this.CheckExistUnit(this.m_SelectGrid.x, this.m_SelectGrid.y);
                if (intList.Count > 0)
                {
                    int num = intList[0];
                    for (int index = 0; index < intList.Count; ++index)
                    {
                        if (this.m_Units[intList[index]].Unit.OwnerPlayerIndex == instance.MyPlayerIndex)
                        {
                            num = intList[index];
                            break;
                        }
                    }
                    this.m_SelectParty = num;
                    this.UpdateUnitStatus(0, true);
                    MonoSingleton <MySound> .Instance.PlaySEOneShot("SE_0005", 0.0f);
                }
                else
                {
                    if (this.TowerMode && (this.m_Units[this.m_SelectParty].Unit.Side != EUnitSide.Player || this.m_Units[this.m_SelectParty].Unit.OwnerPlayerIndex != instance.MyPlayerIndex))
                    {
                        return;
                    }
                    using (List <UnitSetting> .Enumerator enumerator = this.CurrentMap.PartyUnitSettings.GetEnumerator())
                    {
                        while (enumerator.MoveNext())
                        {
                            UnitSetting current = enumerator.Current;
                            if (this.CheckExistUnit((int)current.pos.x, (int)current.pos.y).Count <= 0 && (int)current.pos.x == this.m_SelectGrid.x && (int)current.pos.y == this.m_SelectGrid.y)
                            {
                                this.m_Units[this.m_SelectParty].Unit.x = (int)current.pos.x;
                                this.m_Units[this.m_SelectParty].Unit.y = (int)current.pos.y;
                                this.CalcPosition(this.m_Units[this.m_SelectParty]);
                                this.UpdateUnitStatus(0, true);
                                MonoSingleton <MySound> .Instance.PlaySEOneShot("SE_0002", 0.0f);

                                if (!this.TowerMode)
                                {
                                    break;
                                }
                                this.SendPlacementInfo();
                                break;
                            }
                        }
                    }
                }
            }
        }