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;
            }
        }
        private static void HandleOngoing(SituationController situation)
        {
            var emptySlot = SituSlotController.GetFirstEmptyRecipeSlot(situation);

            if (emptySlot != null)
            {
                PopulateSlotWithNearbyStacks(situation, emptySlot);
            }
        }
        public static bool PopulateSlotWithNearbyStacks(SituationController situation, RecipeSlot slotToFill)
        {
            // Trying to fill all the slots
            var candidateStacks = Positions.GetAdjacentStacks(situation, Mod.AutomationDistance);

            foreach (var stack in candidateStacks)
            {
                if (SituSlotController.StackMatchesSlot(stack, slotToFill))
                {
                    var tokenAndSlot = new TokenAndSlot
                    {
                        RecipeSlot = slotToFill,
                        Token      = situation.situationToken as SituationToken
                    };
                    SituSlotController.FillSlotEventually(tokenAndSlot, stack as ElementStackToken);
                    return(true); // Successfully found a token for this slot
                }
            }
            return(false); // Failed to find a token for this slot
        }
        void DumpSituationStatus(SituationController controller)
        {
            this.Logger.LogInfo("- state: " + controller.SituationClock.State);
            this.Logger.LogInfo("- time remaining: " + controller.SituationClock.TimeRemaining);

            var storedAspects = this.AspectsToString(controller.GetAspectsInSituation());

            this.Logger.LogInfo("- stored aspects: " + storedAspects);

            this.Logger.LogInfo("- starting slots:");
            this.DumpSlots(controller.situationWindow.GetStartingSlots());

            this.Logger.LogInfo("- ongoing slots:");
            this.DumpSlots(controller.situationWindow.GetOngoingSlots());

            this.Logger.LogInfo("- stored stacks");
            this.DumpElements(controller.GetStoredStacks());

            this.Logger.LogInfo("- output stacks");
            this.DumpElements(controller.GetOutputStacks());
        }
        private static void HandleUnstarted(SituationController situation)
        {
            // Do nothing if we are paused
            if (Registry.Retrieve <TabletopManager>().GetPausedState())
            {
                return;
            }

            // Do nothing until at least a second has passed since last completion for smoother UX
            situationLastCompletionTimes.TryGetValue(situation, out DateTime lastCompletionTime);
            if ((lastCompletionTime != null) && ((DateTime.Now - lastCompletionTime).TotalSeconds < 1.2))
            {
                return;
            }

            var emptySlot = SituSlotController.GetFirstEmptyRecipeSlot(situation);

            // If no more slots can be filled we can try to activate the recipe
            if (emptySlot == null)
            {
                situation.AttemptActivateRecipe();
                return;
            }

            // Try to fill the slot and return if successful
            if (PopulateSlotWithNearbyStacks(situation, emptySlot))
            {
                return;
            }

            // We have slots to fill but nothing to fill them with. Possibly we already filled our primary slot
            // and just cannot find any "extra" cards. If that's the case we can activate the recipe with partially filled slots.
            var primarySlot = (situation.situationWindow as SituationWindow).GetPrimarySlot();

            if (primarySlot != null && primarySlot.GetElementStackInSlot() != null)
            {
                situation.AttemptActivateRecipe();
            }
        }
 private static void HandleFreshlyStarted(SituationController situation)
 {
     return;
 }
 public static bool IsAutomated(SituationController situation)
 {
     return(automatedSituations.Contains(situation));
 }
 private static void MansusEntryPostfix(SituationController situation, Transform origin, PortalEffect effect)
 {
     GreatWorkAPI.Events.FireEvent(new MansusEvent.Entry.Post(situation, origin, effect));
 }
 void StartPainting(SituationController situation)
 {
     // TODO: Explore putting cards in slots.
     // See RecipeSlot.OnDrop for a good example on how to do this.
 }
Example #10
0
        /// <summary>
        /// LoadContent will be called once per game and is the place to load
        /// all of your content.
        /// </summary>
        protected override void LoadContent()
        {
            // Create a new SpriteBatch, which can be used to draw textures.
            spriteBatch = new SpriteBatch(GraphicsDevice);

            // Set mouse visable.
            this.IsMouseVisible = true;

            conversationController = new ConversationController();
            conversationController.loadFromLibrary(1, Content, spriteBatch);

            oldKeyboardState = Keyboard.GetState();
            oldMouse         = Mouse.GetState();

            MouseLocation = new Vector2(Mouse.GetState().X, Mouse.GetState().Y);

            Character DefaultCharacter = new Character(Content, (int)Constants.CharacterType.Basic);
            Character Steve            = new Character(Content, (int)Constants.CharacterType.Flyer);
            Character Stan             = new Character(Content, (int)Constants.CharacterType.Horse);

            Stan.CharacterController = (int)Constants.CharacterControllerType.Enemy;
            PlayerCharacters         = new List <Character>();
            PlayerCharacters.Add(Steve);
            PlayerCharacters.Add(Stan);

            characterController = new CharacterController();
            characterController.addCharacter(DefaultCharacter);
            characterController.addCharacter(Steve);
            characterController.addCharacter(Stan);
            characterController.moveCharacter(Steve, 2, 2);
            characterController.moveCharacter(Stan, 1, 1);
            characterController.moveCharacter(DefaultCharacter, 0, 0);

            situationController = new SituationController();
            //situationController.loadSituation(0, mapController, characterController, conversationController, Content, spriteBatch);
            List <Texture2D> temp = new List <Texture2D>();

            temp.Add(this.Content.Load <Texture2D>("top32"));
            temp.Add(this.Content.Load <Texture2D>("mid32"));
            temp.Add(this.Content.Load <Texture2D>("bot32"));

            CharacterMenu = new CharacterMenu(temp, this.Content.Load <SpriteFont>("segoe"));

            ////Trader = new Character(Content, (int)Constants.CharacterController.Neutral);
            //ItemLogic.giveTo(Trader, new Item("Steve Spear", 1, 30, (int)Constants.ItemSlot.Weapon));
            //Trader.Items[0].ItemModifier.Mana = 400;
            //ItemLogic.giveTo(Trader, new Item("Steve Stick", 1, 30, (int)Constants.ItemSlot.Weapon));
            //ItemLogic.giveTo(Trader, new Item("Steve Legsicles", 1, 30, (int)Constants.ItemSlot.Legs));
            //ItemLogic.giveTo(Trader, new Item("Steve Chesticles", 1, 30, (int)Constants.ItemSlot.Chest));
            //ItemLogic.giveTo(Trader, new Item("Health Potion", 30, 30, (int)Constants.ItemSlot.Consumable));
            //ItemLogic.giveTo(Trader, new Item("Health Potion", 2, 30, (int)Constants.ItemSlot.Consumable));
            //ItemLogic.giveTo(Trader, new Item("Hurt Potion", 100, 30, (int)Constants.ItemSlot.Consumable));

            //ItemLogic.giveToFrom(characterController.AllCharacters[0], Trader, Trader.Items[4]);
            //ItemLogic.giveToFrom(characterController.AllCharacters[0], Trader, Trader.Items[4]);
            //ItemLogic.giveToFrom(characterController.AllCharacters[0], Trader, Trader.Items[4]);
            ////ItemLogic.equipItem(characterController.AllCharacters[0], characterController.AllCharacters[0].Items[0]);

            //Console.WriteLine(Trader.listInventory());

            //Console.WriteLine(characterController.AllCharacters[0].listInventory());

            //Console.WriteLine(characterController.AllCharacters[0].TotalModifier.Mana);
            // TODO: use this.Content to load your game content here
        }
 public Post(SituationController situation, Transform origin, PortalEffect effect) : base(situation, origin, effect)
 {
 }
 public Entry(SituationController situation, Transform origin, PortalEffect effect)
 {
     Situation = situation;
     Origin    = origin;
     Effect    = effect;
 }