Esempio n. 1
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Koopa2 koopa = (Koopa2)gameObject1;

            if (koopa.State.GetType() == typeof(KoopaSideDeathState))
            {
                return;
            }
            Goomba2 goomba = (Goomba2)gameObject2;

            if (!goomba.Alive)
            {
                return;
            }

            if (koopa.State.GetType() == typeof(KoopaDeadState) &&
                koopa.Velocity.X != GameUtilities.StationaryVelocity)
            {
                ScoringSystem.Player1Score.AddPointsForEnemyHitByShell(gameObject1);
                goomba.Terminate("LEFT");
                return;
            }

            koopa.Location = new Vector2(koopa.Location.X - GameUtilities.SinglePixel, koopa.Location.Y);
            koopa.ChangeDirection();
            goomba.ChangeDirection();
        }
Esempio n. 2
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Goomba2 goomba = (Goomba2)gameObject1;
            if (!goomba.Alive)
            {
                return;
            }
            if (gameObject2.GetType() == typeof(LPipeBottom) ||
                gameObject2.GetType() == typeof(LPipeBottomLeft))
            {
                return;
            }
            int goombaPreY = (int)(goomba.Location.Y - (goomba.Velocity.Y - GameUtilities.SinglePixel));
            if (goombaPreY + goomba.Destination.Height <= gameObject2.Location.Y)
            {
                return;
            }

            else if (goombaPreY > gameObject2.Location.Y + gameObject2.Destination.Height)
            {
                return;
            }
            if (goomba.Velocity.X > GameUtilities.StationaryVelocity)
            {
                goomba.ChangeDirection();
            }
        }
Esempio n. 3
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            IMario  mario  = (IMario)gameObject1;
            Goomba2 goomba = (Goomba2)gameObject2;

            if (mario.State.MarioShape == MarioState.MarioShapeEnums.Dead ||
                mario.IsProtected || !goomba.Alive)
            {
                return;
            }

            int marioPreY = (int)(mario.Destination.Y - (mario.Velocity.Y - GameUtilities.SinglePixel));

            if (marioPreY + mario.Destination.Height < gameObject2.Destination.Y)
            {
                ICollisionCommand TopCommand = new MarioGoombaCollisionTop();

                TopCommand.Execute(gameObject1, gameObject2);
                return;
            }

            else if (marioPreY > gameObject2.Destination.Y + gameObject2.Destination.Height)
            {
                ICollisionCommand BottomCommand = new MarioGoombaCollisionBottom();
                BottomCommand.Execute(gameObject1, gameObject2);
                return;
            }

            if (goomba.Alive)
            {
                if (mario.State.IsStar == true)
                {
                    ScoringSystem.PlayerScore(mario.Player).AddPointsForSpecialGoombaHit(gameObject2);
                    goomba.Terminate("RIGHT");
                }
                else
                {
                    goomba.ChangeDirection();
                    switch (mario.State.MarioShape)
                    {
                    case MarioState.MarioShapeEnums.Small:
                        mario.State.Terminated();
                        break;

                    case MarioState.MarioShapeEnums.Big:
                        mario.IsProtected = true;
                        GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario);
                        SoundManager.Instance.PlayPipeSound();
                        break;

                    case MarioState.MarioShapeEnums.Fire:
                        mario.IsProtected = true;
                        GameUtilities.GameObjectManager.MarioTransition(mario.State.MarioShape, MarioState.MarioShapeEnums.Small, mario);
                        SoundManager.Instance.PlayPipeSound();
                        break;
                    }
                }
            }
        }
Esempio n. 4
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Goomba2 goomba1 = (Goomba2)gameObject1;
            Horse   horse   = (Horse)gameObject2;

            goomba1.Location = new Vector2(goomba1.Location.X + GameUtilities.SinglePixel, goomba1.Location.Y);
            goomba1.ChangeDirection();
            horse.ChangeDirection();
        }
Esempio n. 5
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Horse horse1 = (Horse)gameObject1;

            if (horse1.Alive == false)
            {
                return;
            }
            Goomba2 goomba2 = (Goomba2)gameObject2;

            horse1.Location = new Vector2(horse1.Location.X - GameUtilities.SinglePixel, horse1.Location.Y);
            horse1.ChangeDirection();
            goomba2.ChangeDirection();
        }
Esempio n. 6
0
        public void Execute(IGameObject gameObject1, IGameObject gameObject2)
        {
            Goomba2 goomba     = (Goomba2)gameObject1;
            int     goombaPreY = (int)(goomba.Location.Y - (goomba.Velocity.Y - GameUtilities.SinglePixel));

            if (goombaPreY + goomba.Destination.Height <= gameObject2.Location.Y)
            {
                return;
            }

            else if (goombaPreY > gameObject2.Location.Y + gameObject2.Destination.Height)
            {
                return;
            }
            if (goomba.Velocity.X < GameUtilities.StationaryVelocity)
            {
                goomba.ChangeDirection();
            }
        }
Esempio n. 7
0
        public bool SpawnEnemy(GameObjectType.ObjectType type)
        {
            // if the spawner is not in the game screen dont use it
            if (!hasBeenInView)
            {
                return(false);
            }

            // if an enemy hasnt recently been spawned allow one to be spawned
            else if (bufferVelocity.X == GameUtilities.StationaryVelocity)
            {
                Vector2 spawnLocation;
                if (RightFacing)
                {
                    spawnLocation = new Vector2(Location.X + Destination.Width - horizontalOffset, Location.Y + verticalOffset);//  + Destination.X- 17 * GameUtilities.SinglePixel
                }
                else
                {
                    spawnLocation = new Vector2(Location.X, Location.Y + verticalOffset);
                }

                IEnemy newEnemy;
                switch (type)
                {
                case GameObjectType.ObjectType.Goomba:
                    newEnemy = new Goomba2(spawnLocation);
                    break;

                case GameObjectType.ObjectType.Koopa:
                    newEnemy = new Koopa2(spawnLocation);
                    break;

                case GameObjectType.ObjectType.Horse:
                    newEnemy = new Horse(spawnLocation);
                    break;

                default:
                    newEnemy = new Goomba2(spawnLocation);
                    break;
                }

                // makes sure the enemy is moving in the right direction
                if (newEnemy.Velocity.X > GameUtilities.StationaryVelocity && RightFacing == false)
                {
                    newEnemy.ChangeDirection();
                }

                else if (newEnemy.Velocity.X < GameUtilities.StationaryVelocity && RightFacing == true)
                {
                    newEnemy.ChangeDirection();
                }

                bufferVelocity = newEnemy.Velocity;
                GameUtilities.GameObjectManager.AddEnemy(newEnemy);
                return(true);
            }
            else
            {
                return(false);
            }
        }