Esempio n. 1
0
        static void Update_Creature(Creature c)
        {
            c.message.Clear(); //Monsters shouldn't need to keep messages
            string action = c.mind.DecideAction(currentLevel, c); //Decide action

            #region Perform Action

            #region Move Actions
            List<String> actionList = new List<String>();
            actionList.Add("Move 1");
            actionList.Add("Move 2");
            actionList.Add("Move 3");
            actionList.Add("Move 4");
            actionList.Add("Move 5");
            actionList.Add("Move 6");
            actionList.Add("Move 7");
            actionList.Add("Move 8");
            actionList.Add("Move 9");

            for (int k = 0; k <= 8; k++)
            {
                if (action == actionList[k])
                {
                    c.Move(currentLevel, k + 1);
                }
            }

            actionList.Clear();
            #endregion

            #region Item Management Actions
            if (action == "Pick Up")
            {
                currentLevel = c.PickUp(currentLevel);
            }

            if (action == "Unwield")
                c.Unwield();

            if (action.StartsWith("Wield"))
            {
                while (action.StartsWith("Wield"))
                    action = action.Remove(0, 6); //Clip everything but the index

                Weapon targetItem = (Weapon)c.inventory[int.Parse(action)];
                c.Wield(targetItem);
            }

            if (action == "Remove")
                c.RemoveAll();

            if (action.StartsWith("Wear"))
            {
                while (action.StartsWith("Wear"))
                    action = action.Remove(0, 5); //Clip everything but the index

                Armor targetItem = (Armor)c.inventory[int.Parse(action)];
                c.Wear(targetItem);
            }

            if (action.StartsWith("Eat")) //If it starts with "Eat"
            {
                action = action.Remove(0, 4); //Clip everything but the index
                Item targetItem = c.inventory[int.Parse(action)];
                c.Eat(currentLevel, targetItem); //Eat the given item
            }
            #endregion

            #region Melee Attack
            if (action.StartsWith("Attack"))
            {
                action = action.Remove(0, 7);
                currentLevel = c.MeleeAttack(currentLevel, Direction.Parse(action));
            }
            #endregion
            #endregion
        }