コード例 #1
0
        void SelectHotbarSituation(int index, bool targetSecondarySituations)
        {
            if (TabletopManager.IsInMansus())
            {
                return;
            }

            var hotbarSituations =
                from situation in this.GetAllSituations()
                where PrimarySituations.Contains(situation.EntityId) != targetSecondarySituations
                orderby situation.RectTransform.position.x
                select situation;

            var targetSituation = hotbarSituations.Skip(index).FirstOrDefault();

            if (!targetSituation)
            {
                return;
            }

            if (targetSituation.SituationController.IsOpen)
            {
                targetSituation.SituationController.CloseWindow();
            }
            else
            {
                targetSituation.SituationController.OpenWindow();
            }
        }
コード例 #2
0
        public static void DoAutomatedAction(SituationController situation)
        {
            // We do not do any automated actions under certain conditions
            if (TabletopManager.IsInMansus() || situation.IsOpen || situation.situationToken as DraggableToken == DraggableToken.itemBeingDragged)
            {
                return;
            }

            switch (situation.SituationClock.State)
            {
            case SituationState.Unstarted:
                HandleUnstarted(situation);
                break;

            case SituationState.FreshlyStarted:
                HandleFreshlyStarted(situation);
                break;

            case SituationState.Ongoing:
                HandleOngoing(situation);
                break;

            case SituationState.RequiringExecution:
                HandleRequiringExecution(situation);
                break;

            case SituationState.Complete:
                HandleComplete(situation);
                break;

            default:
                break;
            }
        }
コード例 #3
0
 static void Postfix()
 {
     Patcher.Run(() =>
     {
         TabletopManager manager = Registry.Retrieve <TabletopManager>();
         if (Input.GetKeyDown(KeyCode.F5))
         {
             if (TabletopManager.IsSafeToAutosave())
             {
                 manager.ForceAutosave();
             }
             else
             {
                 Registry.Retrieve <INotifier>().ShowNotificationWindow("Not now, not yet -", "I can't save while exploring the Mansus or moving cards.");
             }
         }
         else if (Input.GetKeyDown(KeyCode.F9))
         {
             if (SaveState.HasSaved)
             {
                 manager.LoadGame();
             }
             else
             {
                 Registry.Retrieve <INotifier>().ShowNotificationWindow("Faint visions, but no memories", "Was that just a dream? Yet it felt so real. As it stands we have not saved the game yet so there is nothing to load.");
             }
         }
     });
 }
コード例 #4
0
        void StoreRecipe(int index)
        {
            if (TabletopManager.IsInMansus())
            {
                return;
            }

            var situation = this.GetOpenSituation();

            if (situation == null)
            {
                return;
            }

            if (situation.SituationClock.State != SituationState.Unstarted)
            {
                this.Notify("I cannot remember this", "Memory only serves to start the unstarted.");
                return;
            }

            var slots    = situation.situationWindow.GetStartingSlots();
            var elements = slots.Select(x => ValidRecipeSlotOrNull(x)).Select(x => x?.GetElementStackInSlot()?.EntityId);

            this.RecipesByHotkeyIndex[index] = new RecipeConfig
            {
                Situation      = situation.GetTokenId(),
                RecipeElements = elements.ToArray()
            };

            this.Notify("Repetition breeds familiarity", "I will remember this recipe for later.");
        }
コード例 #5
0
        void AutofillSituation()
        {
            if (TabletopManager.IsInMansus())
            {
                return;
            }

            var situation = this.GetOpenSituation();

            if (situation == null)
            {
                return;
            }

            // situationToken is typed ISituationAnchor, but its core type is SituationToken which is a DraggableToken
            var situationDraggable = situation.situationToken as DraggableToken;
            var candidates         = this.GetElementsOrderedByDistance(situationDraggable.RectTransform.anchoredPosition).ToArray();

            var window = situation.situationWindow;

            switch (situation.SituationClock.State)
            {
            case SituationState.Unstarted:
                this.TryFillSlots(() => window.GetStartingSlots(), candidates);
                break;

            case SituationState.Ongoing:
                this.TryFillSlots(() => window.GetOngoingSlots(), candidates);
                break;
            }
        }
コード例 #6
0
        void StoreRecipe(RecipeConfig recipe)
        {
            if (TabletopManager.IsInMansus())
            {
                return;
            }
            var situation = this.GetOpenSituation();

            if (situation == null)
            {
                return;
            }
            var slots    = situation.situationWindow.GetStartingSlots();
            var elements = slots.Select(x => ValidRecipeSlotOrNull(x)).Select(x => x?.GetElementStackInSlot()?.EntityId);

            recipe.Situation      = situation.GetTokenId();
            recipe.RecipeElements = elements.ToArray();
        }
コード例 #7
0
 void Update()
 {
     //检测操作相关的操作
     try
     {
         var situation = this.GetOpenSituation();//当没打开situation时这个函数会报错
         if (!TabletopManager.IsInMansus() && situation != null)
         {
             var Situation = situation.GetTokenId();
             if (Input.GetKeyDown(KeyCode.F1) && situation.SituationClock.State == SituationState.Unstarted) //保存配方
             {
                 if (!Recipes.ContainsKey(Situation))
                 {
                     Recipes[Situation] = new RecipeConfig();
                 }
                 this.StoreRecipe(Recipes[Situation]);
                 this.Notify("automation", "Recipe added");
             }
             if (Input.GetKeyDown(KeyCode.F2))//取消配方
             {
                 Recipes.Remove(Situation);
                 SoundManager.PlaySfx("CardDragFail");
                 this.Notify("automation", "Recipe canceled");
             }
             if (Input.GetKeyDown(KeyCode.F3)) //调试用:立即执行该配方
             {
                 this.Logger.LogError("F3");
                 this.RestoreRecipe(Recipes[Situation], true);
             }
         }
     }catch (Exception e)
     {
     }
     //自动执行
     if (DateTime.Now.Ticks - this.startTime > 10000 * 100)
     {
         startTime = DateTime.Now.Ticks;
         foreach (var item in Recipes.ToList())
         {
             this.RestoreRecipe(item.Value, true);
         }
         startTime = DateTime.Now.Ticks;
     }
 }
コード例 #8
0
        private static void BackupDefaultMansus(TabletopManager tabletop)
        {
            if (DefaultMansus != null)
            {
                return;
            }
            var mapAnimation =
                MansusAnim.GetValue(tabletop) as MapAnimation;
            var doorSlots =
                DoorSlots.GetValue(tabletop.mapTokenContainer) as DoorSlot[];

            DefaultMansus = new Mansus("default")
            {
                Map   = mapAnimation.GetComponent <Image>().sprite,
                Doors = new Dictionary <string, Door>()
            };
            foreach (var door in doorSlots)
            {
                var doorName = door.portalType.ToString().ToLower();
                DefaultMansus.Doors[doorName] = BackupDoor(door);
            }

            Registry.Get <Compendium>().TryAddEntity(DefaultMansus);
        }
コード例 #9
0
        static bool Prefix(ElementStackToken __instance)
        {
            return(Patcher.Run(() =>
            {
                // If neither shift is down give back control to the game immediately
                if (!Input.GetKey(KeyCode.LeftShift) && !Input.GetKey(KeyCode.RightShift))
                {
                    return true;
                }

                // Do not move cards in Mansus. Supporting this could be a future addition
                if (TabletopManager.IsInMansus())
                {
                    return false;
                }

                var stack = __instance;
                var situation = GameBoard.GetOpenSituation();
                List <RecipeSlot> slots = null;

                if (situation == null)
                {
                    foreach (var closedSituation in Positions.GetSituationsRelativeTo(stack))
                    {
                        if (closedSituation.CanAcceptStackWhenClosed(stack))
                        {
                            closedSituation.OpenWindow();
                            situation = closedSituation;
                            break;
                        }
                    }
                }

                if (situation == null)
                {
                    // Let controller handle the fail state
                    SituSlotController.MoveStackIntoSlot(stack, null);
                }
                else
                {
                    var populatedSlot = false;
                    slots = SituSlotController.GetAllEmptySlots(situation);
                    for (int i = 0; i < slots.Count; i++)
                    {
                        if (SituSlotController.StackMatchesSlot(stack, slots[i]))
                        {
                            SituSlotController.MoveStackIntoSlot(stack, slots[i]);
                            populatedSlot = true;
                            break;
                        }
                    }

                    // There is no slot available for us, allow the controller to handle the fail state
                    if (!populatedSlot)
                    {
                        SituSlotController.MoveStackIntoSlot(stack, null);
                    }
                }

                return false;
            }));
        }
コード例 #10
0
        void RestoreRecipe(int index, bool executeOnRestore)
        {
            if (TabletopManager.IsInMansus())
            {
                return;
            }

            RecipeConfig recipe;

            if (!this.RecipesByHotkeyIndex.TryGetValue(index, out recipe))
            {
                return;
            }

            var situation = this.GetSituation(recipe.Situation);

            if (situation == null)
            {
                return;
            }

            switch (situation.SituationClock.State)
            {
            case SituationState.Complete:
                situation.situationWindow.DumpAllResultingCardsToDesktop();
                break;

            case SituationState.Unstarted:
                situation.situationWindow.DumpAllStartingCardsToDesktop();
                break;

            default:
                SoundManager.PlaySfx("CardDragFail");
                this.Notify("I am busy", "I cannot start a recipe while I am busy doing somthing else.");
                return;
            }

            // The first slot is the primary slot, so slot it independently.
            //  A successful slot here may cause new slots to be added.
            var primaryElement = recipe.RecipeElements.FirstOrDefault();

            if (primaryElement != null)
            {
                var slot = situation.situationWindow.GetStartingSlots().FirstOrDefault();
                if (!slot || !this.TryPopulateSlot(slot, primaryElement))
                {
                    this.Notify("Something is missing", "I cannot start this recipe, as I am missing a critical component.");
                    return;
                }
            }

            // Slot the remainder of the elements, now that
            //  the primary has opened up new slots for us.
            var slots = situation.situationWindow.GetStartingSlots();

            for (var i = 1; i < Math.Min(slots.Count, recipe.RecipeElements.Length); i++)
            {
                var element = recipe.RecipeElements[i];
                var slot    = slots[i];
                this.TryPopulateSlot(slot, element);
            }

            if (executeOnRestore)
            {
                situation.AttemptActivateRecipe();
                if (situation.SituationClock.State == SituationState.Unstarted)
                {
                    this.Notify("Something went wrong", "I could not start the recipe.");
                    situation.OpenWindow();
                }

                // If we started the recipe, there is no need to open the window.
            }
            else
            {
                situation.OpenWindow();
            }
        }