Ejemplo n.º 1
0
        public void OnCollision(GameObject other)
        {
            if (other is BaseLongCargo)
            {
                _canJump = true;
                BaseLongCargo baselongcargo = other as BaseLongCargo;

                if (y >= baselongcargo.y)
                {
                    y = baselongcargo.y;
                }
            }

            if (other is BaseLong)
            {
                BaseLong baselong = other as BaseLong;

                if (y >= baselong.y)
                {
                    y = baselong.y;
                }
            }

            if (other is TallLongCargo)
            {
                TallLongCargo talllongcargo = other as TallLongCargo;


                if (y < talllongcargo.y + 20)
                {
                    y = talllongcargo.y;
                }


                if (y > talllongcargo.y + 10)
                {
                    speedY = speedY - 20;

                    if (x > talllongcargo.x)
                    {
                        x = talllongcargo.x + 820;
                    }

                    if (x <= talllongcargo.x)
                    {
                        x = talllongcargo.x - 100;
                    }
                }
            }

            if (other is LongBackground)
            {
                LongBackground longback = other as LongBackground;

                _canJump = false;
            }


            if (other is LongCeiling)
            {
                LongCeiling longceiling = other as LongCeiling;
                _canJump = true;
                if (y >= longceiling.y)
                {
                    y = longceiling.y;
                }
            }

            if (other is BaseShort)
            {
                BaseShort wagon3 = other as BaseShort;
                _canJump = true;
                if (y >= wagon3.y)
                {
                    y = wagon3.y;
                }
            }

            if (other is BaseIntermediateCargo)
            {
                _canJump = true;
                BaseIntermediateCargo baseintermediatecargo = other as BaseIntermediateCargo;

                if (y >= baseintermediatecargo.y)
                {
                    y = baseintermediatecargo.y;
                }
            }

            if (other is BaseIntermediate)
            {
                BaseIntermediate baseintermediate = other as BaseIntermediate;

                if (y >= baseintermediate.y)
                {
                    y = baseintermediate.y;
                }
            }

            if (other is BaseIntermediateCeiling)
            {
                BaseIntermediateCeiling baseintermediateceiling = other as BaseIntermediateCeiling;
                _canJump = true;
                if (y >= baseintermediateceiling.y)
                {
                    y = baseintermediateceiling.y;
                }
            }

            if (other is LongBackgroundLocomotive)
            {
                LongBackgroundLocomotive longbackloco = other as LongBackgroundLocomotive;


                if (y < longbackloco.y + 20)
                {
                    y = longbackloco.y;
                }


                if (y > longbackloco.y + 10)
                {
                    speedY = speedY - 20;

                    if (x > longbackloco.x)
                    {
                        x = longbackloco.x + 820;
                    }

                    if (x <= longbackloco.x)
                    {
                        x = longbackloco.x - 100;
                    }
                }
            }

            if (other is Crate)
            {
                Crate crate = other as Crate;

                if (y > crate.y)
                {
                    if (x > crate.x)
                    {
                        x       = crate.x + 70;
                        crate.x = crate.x - 1;
                        Jump();
                    }

                    if (x < crate.x)
                    {
                        x       = crate.x - 140;
                        crate.x = crate.x + 1;
                        Jump();
                    }
                }


                if (y <= crate.y + 40)
                {
                    y = crate.y - 40;
                }
            }
        }
Ejemplo n.º 2
0
        public void OnCollision(GameObject other)
        {
            if (other is BaseShort)
            {
                _wagonNumber = 1;
                BaseShort baseshort = other as BaseShort;

                if (y >= baseshort.y)
                {
                    y = baseshort.y;
                }

                if (_timer == 0)
                {
                    _canJump = true;
                }
            }

            if (other is BaseLongCargo)
            {
                _wagonNumber = 2;
                BaseLongCargo baselongcargo = other as BaseLongCargo;

                if (y >= baselongcargo.y)
                {
                    y = baselongcargo.y;
                }

                if (_timer == 0)
                {
                    _canJump = true;
                }
            }


            if (other is BaseLong)
            {
                _wagonNumber = 3;
                BaseLong baselong = other as BaseLong;


                if (y >= baselong.y)
                {
                    y = baselong.y;
                }


                _canJump = false;
            }

            if (other is LongCeiling)
            {
                LongCeiling baseceiling = other as LongCeiling;

                if (y <= baseceiling.y + 120)
                {
                    y = baseceiling.y;
                }

                if (y > baseceiling.y)
                {
                    y = baseceiling.y + 170;
                }


                if (_timer == 0)
                {
                    _canJump = true;
                }
            }

            if (other is BaseIntermediateCargo)
            {
                _wagonNumber = 4;

                BaseIntermediateCargo baseintermediatecargo = other as BaseIntermediateCargo;

                if (y >= baseintermediatecargo.y)
                {
                    y = baseintermediatecargo.y;
                }

                if (_timer == 0)
                {
                    _canJump = true;
                }
            }

            if (other is TallLongCargo)
            {
                _wagonNumber = 2;
                TallLongCargo talllongcargo = other as TallLongCargo;

                if (y < talllongcargo.y + 20)
                {
                    y = talllongcargo.y;
                }

                if (_timer == 0)
                {
                    _canJump = true;
                }

                if (y > talllongcargo.y)
                {
                    if (x > talllongcargo.x)
                    {
                        x = talllongcargo.x + 820;
                    }

                    if (x <= talllongcargo.x)
                    {
                        x = talllongcargo.x - 20;
                    }
                }
            }

            if (other is BaseIntermediate)
            {
                _wagonNumber = 5;

                BaseIntermediate baseintermediate = other as BaseIntermediate;

                if (y >= baseintermediate.y)
                {
                    y = baseintermediate.y;
                }

                _canJump = false;
            }

            if (other is BaseIntermediateCeiling)
            {
                BaseIntermediateCeiling baseintermediateceiling = other as BaseIntermediateCeiling;

                if (y <= baseintermediateceiling.y + 120)
                {
                    y = baseintermediateceiling.y;
                }

                if (y > baseintermediateceiling.y)
                {
                    y = baseintermediateceiling.y + 170;
                }

                if (_timer == 0)
                {
                    _canJump = true;
                }
            }

            if (other is LongBackgroundLocomotive)
            {
                _wagonNumber = 2;
                LongBackgroundLocomotive longbackloco = other as LongBackgroundLocomotive;

                if (y < longbackloco.y + 20)
                {
                    y = longbackloco.y;
                }

                if (_timer == 0)
                {
                    _canJump = true;
                }

                if (y > longbackloco.y)
                {
                    if (x > longbackloco.x)
                    {
                        x = longbackloco.x + 820;
                    }

                    if (x <= longbackloco.x)
                    {
                        x = longbackloco.x - 20;
                    }
                }
            }


            if (other is Crate)
            {
                Crate crate = other as Crate;

                if (y > crate.y)
                {
                    if (x > crate.x)
                    {
                        x       = crate.x + 65;
                        crate.x = crate.x - 4;
                    }

                    if (x <= crate.x)
                    {
                        x       = crate.x - 65;
                        crate.x = crate.x + 4;
                    }
                }


                if (y <= crate.y + 40)
                {
                    y = crate.y - 40;
                }


                if (_timer == 0)
                {
                    _canJump = true;
                }
            }
        }
Ejemplo n.º 3
0
        public Level()         //TRAIN SETUP
        {
            background = new Background();
            AddChild(background);

            BaseShort baseshort = new BaseShort(-160, 600);

            AddChild(baseshort);

            BaseLongCargo baselongcargo = new BaseLongCargo(250, 600);

            AddChild(baselongcargo);

            LongBackground longbackground = new LongBackground(1060, 400);

            AddChild(longbackground);

            BaseLong baselong = new BaseLong(1060, 600);

            AddChild(baselong);

            LongCeiling baselongceiling = new LongCeiling(1060, 400);

            AddChild(baselongceiling);

            BaseShort baseshortmiddle = new BaseShort(1870, 600);

            AddChild(baseshortmiddle);

            TallLongCargo talllongcargo = new TallLongCargo(2280, 400);

            AddChild(talllongcargo);

            BaseIntermediateCargo baseintermediatecargo = new BaseIntermediateCargo(3090, 600);

            AddChild(baseintermediatecargo);

            IntermediateBackground intermediatebackground = new IntermediateBackground(3700, 400);

            AddChild(intermediatebackground);

            BaseIntermediate baseintermediate = new BaseIntermediate(3700, 600);

            AddChild(baseintermediate);

            BaseIntermediateCeiling baseintermediateceiling = new BaseIntermediateCeiling(3700, 400);

            AddChild(baseintermediateceiling);

            BaseIntermediateCargo baseintermediatefront = new BaseIntermediateCargo(4310, 600);

            AddChild(baseintermediatefront);

            LongBackgroundLocomotive longlocomotive = new LongBackgroundLocomotive(4920, 400);

            AddChild(longlocomotive);

            Wheel wheel1 = new Wheel(320, 670);

            AddChild(wheel1);

            Wheel wheel2 = new Wheel(410, 670);

            AddChild(wheel2);

            Wheel wheel3 = new Wheel(960, 670);

            AddChild(wheel3);

            Wheel wheel4 = new Wheel(870, 670);

            AddChild(wheel4);

            Crate crate1 = new Crate(380, 560);

            AddChild(crate1);

            Crate crate2 = new Crate(200, 560);

            AddChild(crate2);

            Player player = new Player(this);

            AddChild(player);



            scrollTarget = player;
        }