public void HandleGoombaCollision(Goomba goomba)
        {
            goomba1 = goomba;
            CollisionDirection Direction = DetectCollisionDirection(koopa1.Destination, goomba1.Destination);

            if (commandDict[typeof(Goomba)].ContainsKey(Direction))
            {
                commandDict[typeof(Goomba)][Direction].Execute();
            }
        }
Esempio n. 2
0
        public override void xCollision(Sprite s)
        {
            switch (s.name)
            {
            case "gps":
            case "brick":
            case "itemBlock":
            {
                if (positionRectangle.Left < s.positionRectangle.Left)
                {
                    positionRectangle.X = s.positionRectangle.Left - positionRectangle.Width;
                    xVelocity           = 0;
                }
                else if (positionRectangle.Right > s.positionRectangle.Right)
                {
                    positionRectangle.X = s.positionRectangle.Right;
                    xVelocity           = 0;
                }
                break;
            }

            case "bigMushoom":
            {
                if (level == Level.Small)
                {
                    startTranformation();
                }
                s.canRemove = true;
                break;
            }

            case "flower":
            {
                if (level == Level.Big)
                {
                    startTranformation(2);
                }
                if (level == Level.Small)
                {
                    startTranformation();
                }
                s.canRemove = true;
                break;
            }

            case "star":
            {
                startTranformation(3);
                s.canRemove = true;
                break;
            }

            case "goomba":
            {
                Goomba g = s as Goomba;
                if (isInvisible)
                {
                    g.die(true);
                }
                else
                if (!HurtInvisible)
                {
                    startTranformation(1);
                }
                break;
            }

            case "turtle":
            {
                Turtle t = s as Turtle;
                if (t.state == Turtle.State.alive)
                {
                    if (isInvisible)
                    {
                        t.die();
                    }
                    else
                    if (!HurtInvisible)
                    {
                        startTranformation(1);
                    }
                    break;
                }
                else
                {
                    if (t.stoping)
                    {
                        if (positionRectangle.Left < s.positionRectangle.Left)
                        {
                            positionRectangle.X = s.positionRectangle.X - positionRectangle.Width - 1;
                            t.kick(true);
                        }
                        else
                        {
                            positionRectangle.X = s.positionRectangle.X + s.positionRectangle.Width + 1;
                            t.kick(false);
                        }
                    }
                    else
                    {
                        if (isInvisible)
                        {
                            t.die();
                        }
                        else
                        if (!HurtInvisible)
                        {
                            startTranformation(1);
                        }
                        break;
                    }
                }
                break;
            }

            case "pole":
            {
                Pole p = s as Pole;
                p.slide();
                pole  = p;
                state = State.SlidingDown;
                break;
            }
            }
        }
Esempio n. 3
0
        public override void yCollision(Sprite s)
        {
            switch (s.name)
            {
            case "gps":
            {
                if (positionRectangle.Bottom > s.positionRectangle.Top)
                {
                    positionRectangle.Y = s.positionRectangle.Top - positionRectangle.Height;
                    yVelocity           = 0;
                    if (state == State.SlidingDown)
                    {
                        state = State.Slided;
                    }
                    else if (state == State.FallFormBase)
                    {
                        state = State.WalkingtoCastle;
                    }
                    else
                    {
                        state = State.Walking;
                    }
                }
                break;
            }

            case "brick":
            {
                if (positionRectangle.Top < s.positionRectangle.Top)
                {
                    positionRectangle.Y = s.positionRectangle.Top - positionRectangle.Height;
                    yVelocity           = 0;
                    state = State.Walking;
                }
                else
                {
                    s.yCollision(this);
                    positionRectangle.Y = s.positionRectangle.Bottom;
                    state     = State.Falling;
                    yVelocity = 1;
                }
                break;
            }

            case "itemBlock":
            {
                if (positionRectangle.Top < s.positionRectangle.Top)
                {
                    positionRectangle.Y = s.positionRectangle.Top - positionRectangle.Height;
                    yVelocity           = 0;
                    state = State.Walking;
                }
                else
                {
                    s.yCollision(this);
                    positionRectangle.Y = s.positionRectangle.Bottom;
                    state     = State.Falling;
                    yVelocity = 1;
                }
                break;
            }

            case "bigMushoom":
            {
                if (level == Level.Small)
                {
                    startTranformation();
                }
                s.canRemove = true;
                break;
            }

            case "flower":
            {
                if (level == Level.Big)
                {
                    startTranformation(2);
                }
                if (level == Level.Small)
                {
                    startTranformation();
                }
                s.canRemove = true;
                break;
            }

            case "star":
            {
                startTranformation(3);
                s.canRemove = true;
                break;
            }

            case "goomba":
            {
                Goomba g = s as Goomba;
                if (isInvisible)
                {
                    g.die(true);
                }
                if (positionRectangle.Top < s.positionRectangle.Top)
                {
                    positionRectangle.Y = s.positionRectangle.Top - positionRectangle.Height;
                    yVelocity           = -1;
                    g.die();
                    state = State.Walking;
                }
                else
                {
                    if (!HurtInvisible)
                    {
                        startTranformation(1);
                    }
                    break;
                }
                break;
            }

            case "turtle":
            {
                Turtle t = s as Turtle;
                if (isInvisible)
                {
                    t.die();
                    break;
                }
                if (t.state == Turtle.State.alive)
                {
                    if (positionRectangle.Top < s.positionRectangle.Top)
                    {
                        positionRectangle.Y = s.positionRectangle.Top - positionRectangle.Height;
                        yVelocity           = -1;
                        t.toShell();
                        break;
                    }
                    else
                    {
                        if (!HurtInvisible)
                        {
                            startTranformation(1);
                        }
                        break;
                    }
                }
                else
                {
                    if (positionRectangle.Top < s.positionRectangle.Top)
                    {
                        t.stop();
                    }
                }
                break;
            }
            }
        }