Example #1
0
 public KoopaGoombaBottomCollision(ICollision side, Game1 game)
 {
     Side   = side;
     Koopa  = (IKoopa)Side.TopOrLeft;
     Goomba = (Goomba)Side.BottomOrRight;
     Game   = game;
 }
 public KoopaObjectCollision(IKoopa koopa, ICollision side, Game1 game)
 {
     this.koopa     = koopa;
     this.side      = side;
     this.collision = side.Collision;
     Game           = game;
 }
 public MarioKoopaRightCollision(ICollision side, Game1 game)
 {
     Game  = game;
     Side  = side;
     Mario = (IMario)Side.BottomOrRight;
     Koopa = (IKoopa)Side.TopOrLeft;
 }
Example #4
0
        public Koopa(TileMap level, Vector2 initPos, IKoopa type) : base(level, initPos) {
            Type = type;
            TextureType = typeof(Koopa);
            CollisionBox.ColorType = typeof(Koopa);

            switch (Type) {
                case RedKoopa _:
                    Sprite = new KoopaSprite(2, 7, 9, 7, true, this);
                    break;
                case GreenKoopa _:
                    Sprite = new KoopaSprite(2, 7, 2, 0, true, this);
                    break;
                case RedShell _:
                    Sprite = new KoopaSprite(2, 7, 13, 9, true, this);
                    break;
                case GreenShell _:
                    Sprite = new KoopaSprite(2, 7, 7, 2, true, this);
                    break;
                case RedProjectile _:
                    Sprite = new KoopaSprite(2, 7, 13, 9, true, this);
                    break;
                case GreenProjectile _:
                    Sprite = new KoopaSprite(2, 7, 7, 2, true, this);
                    break;
            }
        }
Example #5
0
 public KoopaKoopaCollision(ICollision side, Game1 game)
 {
     this.koopaOne  = (IKoopa)side.TopOrLeft;
     this.koopaTwo  = (IKoopa)side.BottomOrRight;
     this.side      = side;
     this.collision = side.Collision;
     Game           = game;
 }
Example #6
0
 public KoopaPhysics(IKoopa koopa)
 {
     Koopa        = koopa;
     GravityCoef  = PhysicsUtilites.GlobalGravityCoef;
     MaxPosition  = new Vector2(PhysicsUtilites.XMaxPosition, PhysicsUtilites.YMaxPosition);
     MinPosition  = new Vector2(PhysicsUtilites.XMinPosition, PhysicsUtilites.YMinPosition);
     XMaxVelocity = PhysicsUtilites.KoopaMaxVelocityX;
     YMaxVelocity = PhysicsUtilites.KoopaMaxVelocityY;
     XMinVelocity = PhysicsUtilites.KoopaMinVelocityX;
     YMinVelocity = PhysicsUtilites.KoopaMinVelocityY;
     XVelocity    = PhysicsUtilites.EnemyInitVelocity;
     YVelocity    = 0;
 }
Example #7
0
 public KoopaBlockCollision(IKoopa koopa, ICollision side, Game1 game)
 {
     Game       = game;
     this.koopa = koopa;
     this.side  = side;
     collision  = side.Collision;
     if (side.BottomOrRight is IBlock)
     {
         block = (IBlock)side.BottomOrRight;
     }
     else
     {
         block = (IBlock)side.TopOrLeft;
     }
 }
Example #8
0
        public override void CollideTop(CollidableObject obj) {
            if (obj is Avatar) {
                if (Type is GreenKoopa) {
                    Type = new GreenShell();
                    GreenShell();

                } else if (Type is RedKoopa) {
                    Type = new RedShell();
                    RedShell();

                } else if (Type is GreenProjectile) {
                    GreenShell();
                } else if (Type is RedProjectile) {
                    RedShell();
                }

            } else if (obj is Fireball) {
                Die();
            }
        }
Example #9
0
 static private bool deadlyShell(IKoopa koopa)
 {
     return(koopa.Health == KoopaStateMachine.KoopaHealth.Shelled && koopa.Physics.IsMovingX());
 }
Example #10
0
        public void Draw(SpriteBatch spriteBatch)
        {
            if (Game.DebugMode)
            {
                switch (GetObject)
                {
                //Blocks
                case "BrickBlock":
                    objBlock = new Block(new Vector2(0, 0), new BrickBlockState());
                    objBlock.draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                case "FloorBlock":
                    objBlock = new Block(new Vector2(0, 0), new FloorBlockState());
                    objBlock.draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                case "HardBlock":
                    objBlock = new Block(new Vector2(0, 0), new HardBlockState());
                    objBlock.draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                case "QuestionBlock":
                    objBlock = new Block(new Vector2(0, 0), new QuestionBlockState());
                    objBlock.draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                case "UsedBlock":
                    objBlock = new Block(new Vector2(0, 0), new UsedBlockState());
                    objBlock.draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                //Items
                case "Coin":
                    objItem = new Coin(new Vector2(0, 0));
                    objItem.draw(spriteBatch, Game.mouse.GetMousePosition);
                    break;

                case "FireFlower":
                    objItem = new FireFlower(new Vector2(0, 0));
                    objItem.draw(spriteBatch, Game.mouse.GetMousePosition);
                    break;

                case "Mushroom":
                    objItem = new Mushroom(new Vector2(0, 0));
                    objItem.draw(spriteBatch, Game.mouse.GetMousePosition);
                    break;

                case "OneUp":
                    objItem = new OneUp(new Vector2(0, 0));
                    objItem.draw(spriteBatch, Game.mouse.GetMousePosition);
                    break;

                case "Star":
                    objItem = new Star(new Vector2(0, 0));
                    objItem.draw(spriteBatch, Game.mouse.GetMousePosition);
                    break;

                //Enemies
                case "Goomba":
                    objGoomba = new Goomba(new Vector2(0, 0));
                    objGoomba.Draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                case "Koopa":
                    objKoopa = new Koopa(new Vector2(0, 0));
                    objKoopa.Draw(spriteBatch, Game.mouse.GetMousePosition, Color.White);
                    break;

                default:
                    break;
                }
            }
        }
 public KoopaObjectCollisionHandler(ICollision side, IKoopa koopa, Game1 game)
 {
     this.koopa = koopa;
     Side       = side;
     Game       = game;
 }
Example #12
0
 public KoopaBlockCollisionHandler(ICollision side, IKoopa koopa, Game1 game)
 {
     Side       = side;
     this.koopa = koopa;
     Game       = game;
 }
Example #13
0
        public override void Update(GameTime gameTime) {
            if (isDead) {
                if (timeDied.TotalSeconds == 0) {
                    timeDied = gameTime.TotalGameTime;
                } else if (gameTime.TotalGameTime > timeDied + new TimeSpan(0, 0, 0, 0, 500)) {
                    ToBeRemoved = true;
                }
            }

            if (isGreenShell && !lGreenCollide && !rGreenCollide) {
                lGreenCollide = false;
                rGreenCollide = false;
                if (greenShellTime.TotalSeconds == 0) {
                    greenShellTime = gameTime.TotalGameTime;
                } else if (gameTime.TotalGameTime > greenShellTime + new TimeSpan(0, 0, 0, 0, 4000)) {
                    Type = new GreenKoopa();
                    GreenKoopa();
                    isGreenShell = false;
                }
            }
            if (isRedShell && !lRedCollide && !rRedCollide) {
                lRedCollide = false;
                rRedCollide = false;
                if (redShellTime.TotalSeconds == 0) {
                    redShellTime = gameTime.TotalGameTime;
                } else if (gameTime.TotalGameTime > redShellTime + new TimeSpan(0, 0, 0, 0, 4000)) {
                    Type = new RedKoopa();
                    RedKoopa();
                    isRedShell = false;
                }
            }
            if (isGreenProjectile && (lGreenCollide || rGreenCollide)) {
                Type = new GreenProjectile();
                GreenProjectile();
                if (lGreenCollide) {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                } else if (rGreenCollide) {
                    _velocity.X = -1;
                    (Sprite as KoopaSprite).FaceLeft();
                } else {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                }

                if (Position.X == 0) {
                    CollideLeft(this);
                }

                if (Position.X == (Level.MapWidth - 16)) {
                    CollideRight(this);
                }
                if (leftCol) {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                } else if (rightCol) {
                    _velocity.X = -1;
                    (Sprite as KoopaSprite).FaceLeft();
                } else {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                }
            }
            if (isRedShell && (lRedCollide || rRedCollide)) {
                Type = new RedProjectile();
                RedProjectile();
                if (lRedCollide == true) {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                } else if (rRedCollide == true) {
                    _velocity.X = -1;
                    (Sprite as KoopaSprite).FaceLeft();
                } else {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                }

                if (Position.X == 0) {
                    CollideLeft(this);
                }

                if (Position.X == (Level.MapWidth - 16)) {
                    CollideRight(this);
                }
                if (leftCol) {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                } else if (rightCol) {
                    _velocity.X = -1;
                    (Sprite as KoopaSprite).FaceLeft();
                } else {
                    _velocity.X = 1;
                    (Sprite as KoopaSprite).FaceRight();
                }

            }

            if (Type is GreenKoopa || Type is RedKoopa) {
                if ((Position.X >= Level.Avatar.Position.X + (Game1.ScreenWidth / 2) + 50 && Position.X >= Game1.ScreenWidth) || (Position.X <= Level.Avatar.Position.X - (Game1.ScreenWidth / 2) - 50 && Position.X <= Level.MapWidth - Game1.ScreenWidth)) {
                    _velocity.X = 0;
                } else {
                    if (Level.Avatar.Position.X <= Position.X && collisionCount == 0) {
                        CollideRight(this);
                        collisionCount++;
                    }

                    if (leftCol) {
                        _velocity.X = .5f;
                        (Sprite as KoopaSprite).FaceRight();
                    } else if (rightCol) {
                        _velocity.X = -.5f;
                        (Sprite as KoopaSprite).FaceLeft();
                    } else {
                        _velocity.X = .5f;
                        (Sprite as KoopaSprite).FaceRight();
                    }

                    if (Position.X == 0) {
                        CollideLeft(this);
                    }

                    if (Position.X == (Level.MapWidth - 16)) {
                        CollideRight(this);
                    }
                }
            }

            base.Update(gameTime);
        }