Esempio n. 1
0
        public Mario(int x, int y)
            : base(ObjectType.OT_Mario)
        {
            FireBalls = new List<FireBall>();
            for (int i = 0; i < 2; i++)
                FireBalls.Add(new FireBall(0, 0));

            for (int i = 0; i < 2; i++)
                AddObject(FireBalls[i]);

            Type = MarioType.MT_Small;
            SetMarioProperties();

            this.x = x * 16;
            this.y = LevelGenerator.LevelHeight - 16 * y - height;
            Visible = true;
            ControlPressed = false;
            Blinking = false;
            BlinkingShow = true;

            Moving = false;
            Jumping = false;
            Direction = MarioDir.MD_Right;

            State = MarioJumpState.J_None;
            MoveState = MarioMoveState.J_None;

            TimerGenerator.AddTimerEventHandler(TimerType.TT_100, OnAnimate);
            TimerGenerator.AddTimerEventHandler(TimerType.TT_50, OnJumpTick);
            TimerGenerator.AddTimerEventHandler(TimerType.TT_50, OnMoveTick);
            TimerGenerator.AddTimerEventHandler(TimerType.TT_50, OnCheckCollisions);
        }
Esempio n. 2
0
        public void OnMoveTick(Object sender, EventArgs e)
        {
            if (y > LevelGenerator.CurrentLevel.height + 50)
            {
                MarioDie();
            }

            if (MoveState != MarioMoveState.J_None && MoveState != MarioMoveState.J_Stopping)
            {
                Moving = true;
                SetDirections();
                //LevelGenerator.Raise_Event(LevelGenerator.LevelEvent.LE_Check_Collision);
                LevelGenerator.CurrentLevel.Update_ScreensX();

                if (XAdd < 3)
                {
                    XAdd += 0.5;
                }
                if (!IsBrickExistOnSidesLeft())
                {
                    if (MoveState == MarioMoveState.J_Right)
                    {
                        x += 3 + (int)XAdd;
                    }
                }
                if (!IsBrickExistOnSidesRight())
                {
                    if (MoveState == MarioMoveState.J_Left)
                    {
                        x -= 3 + (int)XAdd;
                    }
                }
            }
            if (MoveState == MarioMoveState.J_Stopping)
            {
                Moving = true;
                SetDirections();
                LevelGenerator.CurrentLevel.Update_ScreensX();

                XCount = Math.Sqrt(XCount);

                if (Direction == MarioDir.MD_Right)
                {
                    x += (int)XCount;
                }

                if (Direction == MarioDir.MD_Left)
                {
                    x -= (int)XCount;
                }

                if (XCount < 1.05) // when Standing
                {
                    MoveState = MarioMoveState.J_None;
                    Moving    = false;
                }
            }
        }
Esempio n. 3
0
        public void MarioMove(MarioMoveState s)
        {
            MoveState = s;

            if (Direction != MarioDir.MD_Left)
            {
                if (s == MarioMoveState.J_Left)
                {
                    Direction = MarioDir.MD_Left;
                }
            }

            if (Direction != MarioDir.MD_Right)
            {
                if (s == MarioMoveState.J_Right)
                {
                    Direction = MarioDir.MD_Right;
                }
            }
            // LevelGenerator.Raise_Event(LevelGenerator.LevelEvent.LE_Check_Collision);
        }
Esempio n. 4
0
        public Character(int x, int y)
            : base(ObjectType.OT_Mario)
        {
            FireBalls = new List <FireBall>();
            for (int i = 0; i < 2; i++)
            {
                FireBalls.Add(new FireBall(0, 0));
            }

            for (int i = 0; i < 2; i++)
            {
                AddObject(FireBalls[i]);
            }

            Type = MarioType.MT_Small;
            SetMarioProperties();

            this.x                 = x * 16;
            this.y                 = LevelGenerator.LevelHeight - 16 * y - height;
            Visible                = true;
            UpPressed              = false;
            Blinking               = false;
            BlinkingShow           = true;
            NumberOfCollectedCoins = 0;


            Moving       = true;
            Jumping      = false;
            Direction    = MarioDir.MD_Right;
            EnterPressed = true;


            State     = MarioJumpState.J_None;
            MoveState = MarioMoveState.J_Right;

            TimerGenerator.AddTimerEventHandler(TimerType.TT_100, OnAnimate);
            TimerGenerator.AddTimerEventHandler(TimerType.TT_50, OnJumpTick);
            TimerGenerator.AddTimerEventHandler(TimerType.TT_50, OnMoveTick);
            TimerGenerator.AddTimerEventHandler(TimerType.TT_50, OnCheckCollisions);
        }
Esempio n. 5
0
        public void StopMove()
        {
            if (MoveState != MarioMoveState.J_Stopping)
            {
                switch (MoveState)
                {
                case MarioMoveState.J_Left:
                    Direction = MarioDir.MD_Left; break;

                case MarioMoveState.J_Right:
                    Direction = MarioDir.MD_Right; break;
                }

                MoveState = MarioMoveState.J_Stopping;

                //bug walls
                if (!UpPressed)
                {
                    XCount = 5;
                    XAdd   = 0;
                }
            }
        }
Esempio n. 6
0
        public void OnMoveTick(Object sender, EventArgs e)
        {
            if (y > LevelGenerator.CurrentLevel.height + 50)
            {
                MarioDie();
            }

            if (x == 112.0)
            {
                //StartJump(true, 0);
                //System.Windows.Forms.MessageBox.Show("X : " + Globals.deathPositionX + " Y : " + Globals.deathPositionY);
            }

            if (x == Globals.getDeathPositionX())
            {
                //StartJump(true, 0);
                //System.Windows.Forms.MessageBox.Show("X : " + deathPositionX + " Y : " + deathPositionY);
            }

            if (MoveState != MarioMoveState.J_None && MoveState != MarioMoveState.J_Stopping)
            {
                Moving = true;
                SetDirections();
                //LevelGenerator.Raise_Event(LevelGenerator.LevelEvent.LE_Check_Collision);
                LevelGenerator.CurrentLevel.Update_ScreensX();

                if (XAdd < 3)
                {
                    XAdd += 0.5;
                }
                if (!IsBrickExistOnSidesLeft())
                {
                    if (MoveState == MarioMoveState.J_Right)
                    {
                        x += 3 + (int)XAdd;
                    }
                }
                if (!IsBrickExistOnSidesRight())
                {
                    if (MoveState == MarioMoveState.J_Left)
                    {
                        x -= 3 + (int)XAdd;
                    }
                }

                UpPressed = true;
            }
            if (MoveState == MarioMoveState.J_Stopping)
            {
                Moving = true;
                SetDirections();
                LevelGenerator.CurrentLevel.Update_ScreensX();

                XCount = Math.Sqrt(XCount);

                if (Direction == MarioDir.MD_Right)
                {
                    x += (int)XCount;
                }

                if (Direction == MarioDir.MD_Left)
                {
                    x -= (int)XCount;
                }

                if (XCount < 1.05) // when Standing
                {
                    MoveState = MarioMoveState.J_None;
                    Moving    = false;
                }
            }
        }
Esempio n. 7
0
        public override void Intersection(Collision c, GraphicObject g)
        {
            base.Intersection(c, g);
            switch (g.OT)
            {
            case ObjectType.OT_Exit:
            {
                if (EnterPressed)
                {
                    EnterPressed = false;
                    Moving       = false;
                    MoveState    = MarioMoveState.J_None;
                    //OnLevelCompleted?.Invoke();
                    //StartJump(true, 0);
                    System.Windows.Forms.DialogResult dialog = System.Windows.Forms.MessageBox.Show("You won");
                    if (dialog == System.Windows.Forms.DialogResult.OK)
                    {
                        System.Windows.Forms.Application.Exit();
                    }
                    StopMove();
                }
                break;
            }

            case ObjectType.OT_Goomba:
            {
                if (c.Dir == CollisionDirection.CD_Up)
                {
                    if (((Monster)g).FallDie == false)        // Jump On Goomba with Up Presses
                    {
                        if (UpPressed)
                        {
                            StartJump(true, 0);
                        }
                        else
                        {
                            StartJump(true, -20);
                        }

                        ((Monster)g).GoombaDie();
                    }
                }

                if (c.Dir == CollisionDirection.CD_Left)
                {
                    Globals.setDeathPositionX(x);
                    Globals.deathPositionY = y;
                    //System.Windows.Forms.MessageBox.Show("X : " + Globals.deathPositionX + " Y : " + Globals.deathPositionY);
                }
                break;
            }

            case ObjectType.OT_MovingBlock:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_SolidBlock:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_PipeUp:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_BlockQuestion:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_BlockQuestionHidden:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_Brick:
                goto case ObjectType.OT_Grass;

            case ObjectType.OT_Grass:
            {
                SetDirections();

                if (c.Dir == CollisionDirection.CD_TopLeft)
                {
                    if (g.OT == ObjectType.OT_Brick)
                    {
                        //if (MoveState == MarioMoveState.J_Right)
                        //    x -= (int)XAdd;
                        //if (MoveState == MarioMoveState.J_Left)
                        //    x += (int)XAdd;

                        //Intersection_None();
                    }
                }
                if (c.Dir == CollisionDirection.CD_Up)
                {
                    if (g.OT == ObjectType.OT_MovingBlock)
                    {
                        this.y = g.newy - this.height;
                    }
                    else
                    {
                        if (State != MarioJumpState.J_None)
                        {
                            this.y = g.newy - this.height;
                        }
                    }
                    if (State != MarioJumpState.J_None)
                    {
                        State = MarioJumpState.J_None;
                    }
                    SetDirections();
                }

                if (c.Dir == CollisionDirection.CD_Left)
                {
                    this.x = g.newx - width;
                    //if (g.OT == ObjectType.OT_SolidBlock)
                    //    Intersection_None();
                    if (g.OT == ObjectType.OT_Brick)
                    {
                        //if (MoveState == MarioMoveState.J_Right)
                        //    x -= (int)XAdd;
                        //if (MoveState == MarioMoveState.J_Left)
                        //    x += (int)XAdd;
                        StartJump(true, 0);
                        this.x = g.newx - width;
                    }
                }

                if (c.Dir == CollisionDirection.CD_Down)
                {
                    if (State == MarioJumpState.J_Up)
                    {
                        State         = MarioJumpState.JDown;
                        StartPosition = y;
                        TimeCount     = 0;
                        StartVelocity = 0;
                        if (g.OT == ObjectType.OT_Brick)
                        {
                            if (Type == MarioType.MT_Big || Type == MarioType.MT_Fire)
                            {
                                ((Block)g).BreakBrick();
                            }
                            else
                            {
                            }
                        }
                    }
                }
                if (c.Dir == CollisionDirection.CD_Right)
                {
                    this.x = g.newx + g.width;
                    //if (g.OT == ObjectType.OT_SolidBlock)
                    //    Intersection_None();
                    //XAdd = 0;
                }
                break;
            }
            }
        }
Esempio n. 8
0
        public void StopMove()
        {
            if (MoveState != MarioMoveState.J_Stopping)
            {

                switch (MoveState)
                {
                    case MarioMoveState.J_Left:
                        Direction = MarioDir.MD_Left; break;

                    case MarioMoveState.J_Right:
                        Direction = MarioDir.MD_Right; break;
                }

                MoveState = MarioMoveState.J_Stopping;

                //bug walls
                if (!ControlPressed)
                {
                    XCount = 5;
                    XAdd = 0;
                }
            }
        }
Esempio n. 9
0
        public void OnMoveTick(Object sender, EventArgs e)
        {
            if (y > LevelGenerator.CurrentLevel.height + 50)
            {
                //MessageBox.Show("You Lost...");
                x = 20;
                y = LevelGenerator.LevelHeight - 16 * 1 - height;
                LevelGenerator.CurrentLevel.Update_ScreensX();
                LevelGenerator.CurrentLevel.Update_ScreensY();
            }

            if (MoveState != MarioMoveState.J_None && MoveState != MarioMoveState.J_Stopping)
            {
                Moving = true;
                SetDirections();
                //LevelGenerator.Raise_Event(LevelGenerator.LevelEvent.LE_Check_Collision);
                LevelGenerator.CurrentLevel.Update_ScreensX();

                if (XAdd < 3)
                    XAdd += 0.5;
                if (!IsBrickExistOnSidesLeft())
                {
                    if (MoveState == MarioMoveState.J_Right)
                        x += 3 + (int)XAdd;
                }
                if (!IsBrickExistOnSidesRight())
                {

                    if (MoveState == MarioMoveState.J_Left)
                        x -= 3 + (int)XAdd;
                }
            }
            if (MoveState == MarioMoveState.J_Stopping)
            {
                Moving = true;
                SetDirections();
                LevelGenerator.CurrentLevel.Update_ScreensX();

                XCount = Math.Sqrt(XCount);

                if (Direction == MarioDir.MD_Right)
                    x += (int)XCount;

                if (Direction == MarioDir.MD_Left)
                    x -= (int)XCount;

                if (XCount < 1.05) // when Standing
                {
                    MoveState = MarioMoveState.J_None;
                    Moving = false;
                }
            }
        }
Esempio n. 10
0
        public void MarioMove(MarioMoveState s)
        {
            MoveState = s;

            if (Direction != MarioDir.MD_Left)
                if (s == MarioMoveState.J_Left)
                    Direction = MarioDir.MD_Left;

            if (Direction != MarioDir.MD_Right)
                if (s == MarioMoveState.J_Right)
                    Direction = MarioDir.MD_Right;

            // LevelGenerator.Raise_Event(LevelGenerator.LevelEvent.LE_Check_Collision);
        }