Exemplo n.º 1
0
        PointF Velocity; //Stores the Horizontal and Vertical components of its velocity

        #endregion Fields

        #region Constructors

        public WumpusDisk(Player ToHit, PointF InitialPosition, float Rotation)
            : base("WumpusDisk" + Count, "Disk1.png", 32, 32)
        {
            Count++; //Increase the count of the number of arrows we have made
            ZOrder = 10; //Arrows appear in front of everything else.
            this.Position = new PointF(InitialPosition.X, InitialPosition.Y);

            this.ToHit = ToHit;

            Velocity = new PointF(InitialSpeed * (float)Math.Cos((Math.PI / 180.0f) * this.Rotation),
                InitialSpeed * (float)Math.Sin((Math.PI / 180.0f) * this.Rotation)); //Send the arrow along the correct path

            Collision = CollisionTypes.Rectangular;
            CollisionBox = new PointF(16, 16);

            RemoveFrame(0);
            AddFrame("WDisk\\WDisk1.png", 4);
            AddFrame("WDisk\\WDisk2.png", 4);
            AddFrame("WDisk\\WDisk3.png", 4);
            AddFrame("WDisk\\WDisk4.png", 4);
            AddFrame("WDisk\\WDisk5.png", 4);
            AddFrame("WDisk\\WDisk6.png", 4);
            AddFrame("WDisk\\WDisk7.png", 4);
            AddFrame("WDisk\\WDisk8.png", 4);
            GoToFrame(0);
            AnimateForwards();
        }
Exemplo n.º 2
0
        XboxController Pad; //The XBoxController to receive input from

        #endregion Fields

        #region Constructors

        public Player()
            : base("Player", "Player\\Standing.png", 64, 128)
        {
            ScreenWrapping = true;
            Collision = CollisionTypes.Rectangular;
            CollisionBox = new PointFHelp.PointF(128, 128);
            Pad = XboxController.RetrieveController(0);

            RemoveFrame(0);
            AddFrame("Player\\Run1.png", 4);
            AddFrame("Player\\Run2.png", 4);
            AddFrame("Player\\Standing.png", 4);
            AnimateForwards();
        }
Exemplo n.º 3
0
        uint InvincibilityTimer = 60; //This is used to ensure that there is a 1 second time period in which this enemy cannot attack again

        #endregion Fields

        #region Constructors

        public Enemy(Player p)
            : base("Enemy" + Counter, "Enemy.png", 64, 64)
        {
            Position = new PointF(Rand.Next((int)(-Game.Dimensions.X / 2 + 128), (int)(Game.Dimensions.X / 2 - 128)),
                Rand.Next((int)(-Game.Dimensions.Y / 2 + 128), (int)(Game.Dimensions.Y / 2 - 128))); //Spawn the enemy in a random location

            ToTrack = p; //Assign the player to be tracked

            Collision = CollisionTypes.Rectangular; //Enable the collision
            CollisionBox = new PointF(Width, Height);

            Counter++;

            SetFrameDuration(0, 60); //Set the default picture to be 60 frames long
            AddFrame("Enemy2.png", 60); //Add another picture and set that to be 60 frames long
            GoToFrame(0); //Go to the first frame
            AnimateForwards(); //Begin animation
        }
Exemplo n.º 4
0
        public Bat(Player p)
            : base("Bat" + Count, "Bat 1.png", 128, 64)
        {
            Position = new PointF(Rand.Next((int)(-Game.Dimensions.X / 2 + 128), (int)(Game.Dimensions.X / 2 - 128)),
                Rand.Next((int)(-Game.Dimensions.Y / 2 + 128), (int)(Game.Dimensions.Y / 2 - 128))); //Spawn the enemy in a random location

            Count++;

            ToTrack = p; //Assign the player to be tracked

            Collision = CollisionTypes.Rectangular; //Enable the collision
            CollisionBox = new PointF(Width, Height);

            RemoveFrame(0);
            AddFrame("Bat 1.png", 6);
            AddFrame("Bat 2.png", 6);
            GoToFrame(0);
            AnimateForwards();
        }
Exemplo n.º 5
0
        public override void Update()
        {
            base.Update();

            //Check for collision with the walls
            bool CanMoveUp = true;
            bool CanMoveRight = true;
            bool CanMoveDown = true;
            bool CanMoveLeft = true;
            foreach (Wall w in NWalls)
            {
                if (w.IsCollidedWithGameObject(this))
                {
                    if (this.Position.Y + this.CollisionBox.Y / 2 >= w.Position.Y - w.CollisionBox.Y / 2)
                        CanMoveUp = false;
                }
            }
            foreach (Wall w in NEWalls)
            {
                if (w.IsCollidedWithGameObject(this))
                {
                    if (this.Position.Y + this.CollisionBox.Y / 2 >= w.Position.Y - w.CollisionBox.Y / 2)
                        CanMoveUp = false;
                    if (this.Position.X + this.CollisionBox.X / 2 >= w.Position.X - w.CollisionBox.X / 2)
                        CanMoveRight = false;
                }
            }
            foreach (Wall w in SEWalls)
            {
                if (w.IsCollidedWithGameObject(this))
                {
                    if (this.Position.Y - this.CollisionBox.Y / 2 <= w.Position.Y + w.CollisionBox.Y / 2)
                        CanMoveDown = false;
                    if (this.Position.X + this.CollisionBox.X / 2 >= w.Position.X - w.CollisionBox.X / 2)
                        CanMoveRight = false;
                }
            }
            foreach (Wall w in SWalls)
            {
                if (w.IsCollidedWithGameObject(this))
                {
                    if (this.Position.Y - this.CollisionBox.Y / 2 <= w.Position.Y + w.CollisionBox.Y / 2)
                        CanMoveDown = false;
                }
            }
            foreach (Wall w in SWWalls)
            {
                if (w.IsCollidedWithGameObject(this))
                {

                    if (this.Position.Y - this.CollisionBox.Y / 2 <= w.Position.Y + w.CollisionBox.Y / 2)
                        CanMoveDown = false;
                    if (this.Position.X - this.CollisionBox.X / 2 <= w.Position.X + w.CollisionBox.X / 2)
                        CanMoveLeft = false;
                }
            }
            foreach (Wall w in NWWalls)
            {
                if (w.IsCollidedWithGameObject(this))
                {

                    if (this.Position.Y + this.CollisionBox.Y / 2 >= w.Position.Y - w.CollisionBox.Y / 2)
                        CanMoveUp = false;
                    if (this.Position.X - this.CollisionBox.X / 2 <= w.Position.X + w.CollisionBox.X / 2)
                        CanMoveLeft = false;
                }
            }
            if (EdgeWalls[0].IsCollidedWithGameObject(this))
            {
                if (this.Position.X + this.CollisionBox.X / 2 >= EdgeWalls[0].Position.X - EdgeWalls[0].CollisionBox.X / 2)
                    CanMoveRight = false;
                if (this.Position.Y - this.CollisionBox.Y / 2 <= EdgeWalls[0].Position.Y + EdgeWalls[0].CollisionBox.Y / 2)
                    CanMoveDown = false;
            }
            if (EdgeWalls[1].IsCollidedWithGameObject(this))
            {
                if (this.Position.X + this.CollisionBox.X / 2 >= EdgeWalls[1].Position.X - EdgeWalls[1].CollisionBox.X / 2)
                    CanMoveRight = false;
                if (this.Position.Y + this.CollisionBox.Y / 2 >= EdgeWalls[1].Position.Y - EdgeWalls[1].CollisionBox.Y / 2)
                    CanMoveUp = false;
            }
            if (EdgeWalls[2].IsCollidedWithGameObject(this))
            {
                if (this.Position.X - this.CollisionBox.X / 2 <= EdgeWalls[2].Position.X + EdgeWalls[2].CollisionBox.X / 2)
                    CanMoveLeft = false;
                if (this.Position.Y - this.CollisionBox.Y / 2 <= EdgeWalls[2].Position.Y + EdgeWalls[2].CollisionBox.Y / 2)
                    CanMoveDown = false;
            }
            if (EdgeWalls[3].IsCollidedWithGameObject(this))
            {
                if (this.Position.X - this.CollisionBox.X / 2 <= EdgeWalls[3].Position.X + EdgeWalls[3].CollisionBox.X / 2)
                    CanMoveLeft = false;
                if (this.Position.Y + this.CollisionBox.Y / 2 >= EdgeWalls[3].Position.Y - EdgeWalls[3].CollisionBox.Y / 2)
                    CanMoveUp = false;
            }

            Game.LifeCounter.Text = "  " + Lives;

            PointF XBoxMovement = new PointF((Pad.LeftThumbStick.X / 8192) * 4, (Pad.LeftThumbStick.Y / 8192) * 4); //Get the vector to the point that we want to move to

            bool Moving = false;

            if (((XBoxMovement.X > 0 && CanMoveRight) && (XBoxMovement.Y > 0 && CanMoveUp)) ||
                ((XBoxMovement.X > 0 && CanMoveRight) && (XBoxMovement.Y < 0 && CanMoveDown)) ||
                ((XBoxMovement.X < 0 && CanMoveLeft) && (XBoxMovement.Y > 0 && CanMoveUp)) ||
                ((XBoxMovement.X < 0 && CanMoveLeft) && (XBoxMovement.Y < 0 && CanMoveDown) ||
                ((XBoxMovement.X == 0) && (XBoxMovement.Y > 0 && CanMoveUp)) ||
                ((XBoxMovement.X == 0) && (XBoxMovement.Y < 0 && CanMoveDown)) ||
                ((XBoxMovement.X > 0 && CanMoveRight) && (XBoxMovement.Y == 0)) ||
                ((XBoxMovement.X < 0 && CanMoveLeft) && (XBoxMovement.Y == 0))))
            {
                Position += XBoxMovement; //If we can move in the direction that we need, then we should move!
                Moving = true;
            }

            if (InputManager.IsKeyPressed(Keys.W) && CanMoveUp)
            {
                this.Position.Y += 5;
                Moving = true;
            }
            if (InputManager.IsKeyPressed(Keys.S) && CanMoveDown)
            {
                this.Position.Y -= 5;
                Moving = true;
            }
            if (InputManager.IsKeyPressed(Keys.D) && CanMoveRight)
            {
                this.Position.X += 5;
                Moving = true;
            }
            if (InputManager.IsKeyPressed(Keys.A) && CanMoveLeft)
            {
                this.Position.X -= 5;
                Moving = true;
            }

            if (Moving == false)
                GoToFrame(2);
            if (Lives <= 0)
            {
                Game.watch.Stop();
                uint Time = (uint)(Game.watch.ElapsedMilliseconds * (-0.25 * Cave.Difficulty + 1.5));
                GameStateManager.SetCurrentStateNoInitialize(new GameOver(false, Time));
            }
        }