コード例 #1
0
        public static bool TimedPatch_End2(EndUnit __instance)
        {
            var t        = Traverse.Create(__instance);
            var selected = t.Property("SelectedUnit");

            BM.BattleWinLose.CheckWinLose(BattleEventToggleTime.EndTurn);
            if (BM.BattleWinLose.Type > WinLoseType.None)
            {
                __instance.SendEvent("ENDTURN");
            }
            else if (bTimed)
            {
                WuxiaUnit wuxiaUnit = Timed_Current();
                if (wuxiaUnit != null && wuxiaUnit.IsEndUnit)
                {
                    Timed_EndUnit(wuxiaUnit.IsMoved, UnitIsRest);
                    UpdateTimedUI();
                    if (__instance.CheckIsEndTurn())
                    {
                        __instance.SendEvent("ENDTURN");
                        //base.SelectedUnit = null;
                        selected.SetValue(null);
                        return(false);
                    }
                }
                wuxiaUnit = Timed_Current();
                if (wuxiaUnit != null && wuxiaUnit.faction == Faction.Player)
                {
                    t.Method("FirstUnitSelect").GetValue();       //base.FirstUnitSelect();
                    __instance.SendEvent("FINISHED");
                }
                else
                {
                    selected.SetValue(null);
                    __instance.SendEvent("ENDTURN");
                }
            }
            else if (__instance.CheckIsEndTurn())
            {
                __instance.SendEvent("ENDTURN");
                //base.SelectedUnit = null;
                selected.SetValue(null);
            }
            else
            {
                if (selected.GetValue <WuxiaUnit>() == null)
                {
                    t.Method("FirstUnitSelect").GetValue();       //base.FirstUnitSelect();
                }
                if (selected.GetValue <WuxiaUnit>().IsEndUnit)
                {
                    //__instance.SelectedUnit = __instance.FindNext(false);
                    selected.SetValue(Traverse.Create(__instance).Method("FindNext", false).GetValue <WuxiaUnit>());
                }
                __instance.SendEvent("FINISHED");
            }
            return(false);
        }
コード例 #2
0
        public static bool TimedPatch_End1(EndUnit __instance)
        {
            Console.WriteLine("EndUnit.OnEnable()");
            var t        = Traverse.Create(__instance);
            var selected = t.Property("SelectedUnit");

            if (bTimed && UnitWantWait)   // 处理等待
            {
                UnitWantWait = false;     // 重置等待
                Timed_WaitUnit();
                UpdateTimedUI();
                FSM.UI.CloseMenu();
                FSM.UI.CloseUnitInfo();
                WuxiaUnit wuxiaUnit = Timed_Current();
                if (wuxiaUnit != null && wuxiaUnit.faction == Faction.Player)
                {
                    t.Method("FirstUnitSelect").GetValue();//__instance.FirstUnitSelect();
                    __instance.SendEvent("FINISHED");
                    return(false);
                }
                //__instance.SelectedUnit = null;
                selected.SetValue(null);
                __instance.SendEvent("ENDTURN");
                return(false);
            }
            BM.Time = BattleEventToggleTime.EndUnit;
            BM.OnBattleEvent(BattleEventToggleTime.EndUnit, Array.Empty <object>());
            FSM.UI.CloseMenu();
            FSM.UI.CloseUnitInfo();
            if (!BM.IsEvent)
            {
                if (selected.GetValue <WuxiaUnit>() != null)
                {
                    WuxiaUnit selectedUnit = selected.GetValue <WuxiaUnit>();
                    if (selectedUnit != null)
                    {
                        selectedUnit.OnUnitEnd();
                    }
                    WuxiaUnit selectedUnit2 = selected.GetValue <WuxiaUnit>();
                    if (selectedUnit2 != null)
                    {
                        selectedUnit2.OnTurnEnd();
                    }
                    if (selected.GetValue <WuxiaUnit>()[BattleLiberatedState.InfiniteAction] > 0)
                    {
                        WuxiaUnit selectedUnit3 = selected.GetValue <WuxiaUnit>();
                        if (selectedUnit3 != null)
                        {
                            selectedUnit3.OnTurnStart();
                        }
                    }
                    if (selected.GetValue <WuxiaUnit>()[BattleLiberatedState.Encourage] > 0)
                    {
                        WuxiaUnit selectedUnit4 = selected.GetValue <WuxiaUnit>();
                        if (selectedUnit4 != null)
                        {
                            selectedUnit4.OnTurnStart();
                        }
                    }
                    selected.GetValue <WuxiaUnit>().OnBufferEvent(BufferTiming.EndUnit);
                }
                t.Method("OnUnitEnd").GetValue();//this.OnUnitEnd();
            }
            return(false);
        }