Esempio n. 1
0
        //specific AI
        public override void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
        {
            if (vitalStatus == VitalStatus.Alive)
            {
                if (player.isPlayerAt(xLoc, yLoc - 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc - 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc + 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc, yLoc + 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(50, 500);
                }

                //else if (player.isPlayerNear(xLoc, yLoc - 5) == true) { SwitchDirection(Moving.Up, normal); }
                //else if (player.isPlayerNear(xLoc - 5, yLoc) == true) { SwitchDirection(Moving.Left, normal); }
                //else if (player.isPlayerNear(xLoc + 5, yLoc) == true) { SwitchDirection(Moving.Right, normal); }
                //else if (player.isPlayerNear(xLoc, yLoc + 5) == true) { SwitchDirection(Moving.Down, normal); }

                else
                {
                    int pos = rnd.Next(1, 6);
                    if (pos == 2)
                    {
                        Move(Moving.Left);
                    }
                    if (pos == 3)
                    {
                        Move(Moving.Right);
                    }
                    if (pos == 4)
                    {
                        Move(Moving.Down);
                    }
                    if (pos == 5)
                    {
                        Move(Moving.Up);
                    }
                }

                base.Update(map, player, camera, itemManager, enemyManager);
            }
            //I think I have said it to much already.. see other enemy classes.....
            else
            {
                SwitchVitalStatus(VitalStatus.Dead);
                if (!gaveGold)
                {
                    player.GainMoney(goldAmountToGive);
                    gaveGold = true;
                }
            }
        }
Esempio n. 2
0
        public override void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
        {
            //specific AI
            if (vitalStatus == VitalStatus.Alive)
            {
                if (player.isPlayerAt(xLoc, yLoc - 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else if (player.isPlayerAt(xLoc - 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else if (player.isPlayerAt(xLoc + 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else if (player.isPlayerAt(xLoc, yLoc + 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(700, 100);
                }
                else
                {
                    int pos = rnd.Next(1, 8);
                    if (pos == 2)
                    {
                        Move(Moving.Left);
                    }
                    if ((pos >= 3) && (pos <= 4))
                    {
                        Move(Moving.Right);
                    }
                    if ((pos >= 5) && (pos <= 6))
                    {
                        Move(Moving.Up);
                    }
                    if (pos == 7)
                    {
                        Move(Moving.Down);
                    }
                }

                base.Update(map, player, camera, itemManager, enemyManager);
            }
            //"if its not alive its dead"
            else
            {
                SwitchVitalStatus(VitalStatus.Dead);
                if (!gaveGold)
                {
                    player.GainMoney(goldAmountToGive);
                    gaveGold = true;
                }
            }
        }
Esempio n. 3
0
 //update method with specific enemy AI behavior, anything else is taken from the main enemy class
 public override void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
 {
     //if it is alive it moves and attacks.....
     if (vitalStatus == VitalStatus.Alive)
     {
         //actually attacks player
         if (player.isPlayerAt(xLoc, yLoc - 1) == true)
         {
             player.TakeDamage(attackDamage); Console.Beep(100, 150);
         }
         else if (player.isPlayerAt(xLoc - 1, yLoc) == true)
         {
             player.TakeDamage(attackDamage); Console.Beep(100, 150);
         }
         else if (player.isPlayerAt(xLoc + 1, yLoc) == true)
         {
             player.TakeDamage(attackDamage); Console.Beep(100, 150);
         }
         else if (player.isPlayerAt(xLoc, yLoc + 1) == true)
         {
             player.TakeDamage(attackDamage); Console.Beep(100, 150);
         }
         else
         {
             int pos = rnd.Next(1, 4);
             if (pos == 2)
             {
                 Move(Moving.Left);
             }
             if (pos == 3)
             {
                 Move(Moving.Right);
             }
         }
         base.Update(map, player, camera, itemManager, enemyManager);
     }
     //if its not alive its dead.......
     else
     {
         SwitchVitalStatus(VitalStatus.Dead);
         if (!gaveGold)
         {
             player.GainMoney(goldAmountToGive);
             gaveGold = true;
         }
     }
 }
Esempio n. 4
0
        //behavior every enemy has.....
        public virtual void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
        {
            Console.CursorVisible = false;
            if (vitalStatus == VitalStatus.Alive)
            {
                if (map.IsWallAt(xLoc - 1, yLoc) == true)
                {
                    Move(Moving.Right);
                }
                if (map.IsWallAt(xLoc + 1, yLoc) == true)
                {
                    Move(Moving.Left);
                }
                if (map.IsWallAt(xLoc, yLoc - 1) == true)
                {
                    Move(Moving.Down);
                }
                if (map.IsWallAt(xLoc, yLoc + 1) == true)
                {
                    Move(Moving.Up);
                }

                //was causing crashes!!
                //if (itemManager.IsItemAt(xLoc - 1, yLoc) == true) { Move(Moving.Right); }
                //if (itemManager.IsItemAt(xLoc + 1, yLoc) == true) { Move(Moving.Left); }
                //if (itemManager.IsItemAt(xLoc, yLoc - 1) == true) { Move(Moving.Down); }
                //if (itemManager.IsItemAt(xLoc, yLoc + 1) == true) { Move(Moving.Up); }

                //if (enemyManager.IsEnemyAt(xLoc - 1, yLoc) == true) { Move(Moving.Right); }
                //if (enemyManager.IsEnemyAt(xLoc + 1, yLoc) == true) { Move(Moving.Left); }
                //if (enemyManager.IsEnemyAt(xLoc, yLoc - 1) == true) { Move(Moving.Down); }
                //if (enemyManager.IsEnemyAt(xLoc, yLoc + 1) == true) { Move(Moving.Up); }
            }
            else
            {
                if (!gaveGold)
                {
                    player.GainMoney(goldAmountToGive);
                    gaveGold = true;
                }
                SwitchVitalStatus(VitalStatus.Dead);
            }
        }
Esempio n. 5
0
        public void SellMenu()
        {
            for (bool sellMenuOpen = true; sellMenuOpen == true;)
            {
                Console.Clear();
                Console.WriteLine(Global.shopName + ": " + Global.shopEnterMessage);
                Console.WriteLine();
                inventory.SellInventoryDisplay(player, shopKeeper);
                Console.WriteLine();
                Console.WriteLine(Global.shopName + "'s Gold: " + shopKeeper.CheckMoney() + "      " + player.name + "'s Gold: " + player.CheckMoney());
                Console.WriteLine();
                Console.WriteLine("To sell an item, press the related number of said item + enter.");
                Console.WriteLine();
                Console.WriteLine("E + enter) Exit");
                Console.WriteLine();

                string input = Console.ReadLine();
                for (int x = 0; x < inventory.InventorySize(); x++)
                {
                    if (input == "e")
                    {
                        sellMenuOpen = false;
                        return;
                    }
                    else if (Global.isNumeric(input) && int.Parse(input) <= inventory.InventorySize())
                    {
                        if (Convert.ToInt16(input) == x + 1)// - 48 == x + 1)
                        {
                            if (inventory.InventorySlots(x) != null)
                            {
                                if (inventory.InventorySlots(x).itemType == Item.ItemType.Key || inventory.InventorySlots(x).itemType == Item.ItemType.Valuable)
                                {
                                    Console.Clear();
                                    Console.WriteLine("You cannot sell this item.");
                                    Console.WriteLine("Press any key to continue.");
                                    Console.ReadKey(true);
                                    return;
                                }
                                else
                                {
                                    for (bool inputCheck = false; inputCheck == false;)
                                    {
                                        if (shopKeeper.CheckMoney() >= inventory.InventorySlots(x).CheckPrice())
                                        {
                                            Console.Clear();
                                            Console.WriteLine("Do you want to sell " + inventory.InventorySlots(x).CheckName() + " for " + inventory.InventorySlots(x).CheckPrice() + "?");
                                            Console.WriteLine(Global.shopName + "'s Gold: " + shopKeeper.CheckMoney() + "      " + player.name + "'s Gold: " + player.CheckMoney());
                                            Console.WriteLine("Y) Yes     N) No");
                                            ConsoleKeyInfo secondaryInput = Console.ReadKey(true);

                                            if (secondaryInput.Key == ConsoleKey.Y)
                                            {
                                                player.GainMoney(inventory.InventorySlots(x).CheckPrice());
                                                shopKeeper.LoseMoney(inventory.InventorySlots(x).CheckPrice());
                                                inventory.removeItemFromInventory(x);
                                                inputCheck = true;
                                            }
                                            else if (secondaryInput.Key == ConsoleKey.N)
                                            {
                                                inputCheck = true;
                                            }
                                        }
                                        else
                                        {
                                            Console.Clear();
                                            Console.WriteLine("The " + Global.shopName + " cannot afford the original price of " + inventory.InventorySlots(x).CheckPrice() + ".");
                                            Console.WriteLine("Do you still want to sell " + inventory.InventorySlots(x).CheckName() + " for " + shopKeeper.CheckMoney() + "?");
                                            Console.WriteLine(Global.shopName + "'s Gold: " + shopKeeper.CheckMoney() + "      " + player.name + "'s Gold: " + player.CheckMoney());
                                            Console.WriteLine("Y) Yes     N) No");
                                            ConsoleKeyInfo secondaryInput = Console.ReadKey(true);

                                            if (secondaryInput.Key == ConsoleKey.Y)
                                            {
                                                player.GainMoney(shopKeeper.CheckMoney());
                                                shopKeeper.LoseMoney(shopKeeper.CheckMoney());
                                                inventory.removeItemFromInventory(x);
                                                inputCheck = true;
                                            }
                                            else if (secondaryInput.Key == ConsoleKey.N)
                                            {
                                                inputCheck = true;
                                            }
                                        }
                                    }
                                }
                                sellMenuOpen = false;
                            }
                        }
                    }
                }
            }
        }
        public override void Update(Map map, Player player, Camera camera, ItemManager itemManager, EnemyManager enemyManager)
        {
            if (vitalStatus == VitalStatus.Alive)
            {
                //attacks player differently and specific AI
                if (player.isPlayerAt(xLoc, yLoc - 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc - 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc + 1, yLoc) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }
                else if (player.isPlayerAt(xLoc, yLoc + 1) == true)
                {
                    player.TakeDamage(attackDamage); Console.Beep(400, 100);
                }

                //wanted to implement enemy following player but didn't figure it out
                //else if (player.isPlayerNear(xLoc, yLoc - 10) == true) { SwitchDirection(Moving.Up, fast); }
                //else if (player.isPlayerNear(xLoc - 10, yLoc) == true) { SwitchDirection(Moving.Left, fast); }
                //else if (player.isPlayerNear(xLoc + 10, yLoc) == true) { SwitchDirection(Moving.Right, fast); }
                //else if (player.isPlayerNear(xLoc, yLoc + 10) == true) { SwitchDirection(Moving.Down, fast); }

                else
                {
                    int pos = rnd.Next(1, 8);
                    if (pos == 2)
                    {
                        Move(Moving.Up);
                    }
                    if ((pos >= 3) && (pos <= 4))
                    {
                        Move(Moving.Down);
                    }
                    if ((pos >= 5) && (pos <= 6))
                    {
                        Move(Moving.Up);
                    }
                    if (pos == 7)
                    {
                        Move(Moving.Down);
                    }
                }
                //normal behavior
                base.Update(map, player, camera, itemManager, enemyManager);
            }
            //if its not alive its dead.....
            else
            {
                SwitchVitalStatus(VitalStatus.Dead);
                if (!gaveGold)
                {
                    player.GainMoney(goldAmountToGive);
                    gaveGold = true;
                }
            }
        }