Exemplo n.º 1
0
        static bool projectile_CollisionAction(MoveableObject sender, CollisionEventArgs e)
        {
            bool allow = true;

            try
            {
                if (e.CollidingObject.Name.StartsWith("MO_Enemy"))
                {
                    int index = Int32.Parse(e.CollidingObject.Name.Split('y')[1]);
                    e.CollidingObject.ChangeBackColor(ProChar.GetInvertedColor(e.CollidingObject.Symbol.ForeColor));
                    e.CollidingObject.ChangeBackColor(ProChar.GetInvertedColor(e.CollidingObject.Symbol.BackColor));

                    region.SetDrawObject(((MoveableObject)e.CollidingObject).StandingTile);
                    nonfixObject[index].Name = "";
                    allow = false;
                }
            }
            catch { return(allow); }
            return(allow);
        }
Exemplo n.º 2
0
        static bool Enemy_CollisionAction(MoveableObject sender, CollisionEventArgs e)
        {
            bool allow = true;

            if (e.CollidingObject.ObjectType == "Player")
            {
                if (health > 1)
                {
                    health--;
                    UpdateHealth();
                }
                else
                {
                    health--;
                    Alive = false;
                    UpdateHealth();
                    int width = 13, height = 5;
                    int x = region.Width / 2 - width, y = (region.Height / 2 - height / 2) - 5;

                    Window gameOver = new Window(screen, x, y, width, height, "Game", "YOU LOOSE", ConsoleColor.White, ConsoleColor.Black, ConsoleColor.Yellow, ConsoleColor.Red);
                    gameOver.Show();
                    Console.ReadKey(true);
                }
                allow = false;
            }
            else if (e.CollidingObject.ObjectType == "projectile")
            {
                MoveableObject currentEnemy = sender as MoveableObject;
                int            index        = Int32.Parse(currentEnemy.Name.Split('y')[1]);
                currentEnemy.ChangeBackColor(ProChar.GetInvertedColor(e.CollidingObject.Symbol.ForeColor));
                currentEnemy.ChangeBackColor(ProChar.GetInvertedColor(e.CollidingObject.Symbol.BackColor));

                region.SetDrawObject(currentEnemy.StandingTile);
                nonfixObject[index].Name = "";
                allow = false;
            }

            return(allow);
        }