Exemplo n.º 1
0
        private static void SideCollide(DoodleObject avatar, AbsObject obj, bool[] directionsBlocked)
        {
            if (obj is ItemObject)
            {
                switch (((ItemObject)obj).State)
                {
                case "speed":
                    avatar.powerState = new SpeedState(avatar);
                    break;

                case "jump":
                    avatar.powerState = new DoubleState(avatar);
                    break;

                case "propeller":

                    break;

                default:
                    break;
                }
            }
            else
            {
                avatar.ObjectsToNotCollide.Add(obj);
            }
        }
Exemplo n.º 2
0
        private static void BottomCollide(DoodleObject avatar, AbsObject obj, bool[] directionsBlocked)
        {
            avatar.hasDoubleJump = true;
            if ((obj is BlockObject || obj is PlatformObject) && avatar.Velocity.Y >= 0)
            {
                avatar._velocity.Y    = 0;
                directionsBlocked[2]  = true;
                avatar.isGrounded     = true;
                avatar.groundVelocity = obj.Velocity;

                if (avatar.movementState is LeftJumpingIdleState || avatar.movementState is LeftJumpingState || avatar.movementState is LeftFallingState || avatar.movementState is LeftIdleFallingState)
                {
                    avatar.movementState = new LeftIdleState(avatar);
                }
                else if (avatar.movementState is RightJumpingIdleState || avatar.movementState is RightJumpingState || avatar.movementState is RightFallingState || avatar.movementState is RightIdleFallingState)
                {
                    avatar.movementState = new RightIdleState(avatar);
                }
            }
            else if (obj is ItemObject)
            {
                switch (((ItemObject)obj).State)
                {
                case "speed":
                    avatar.powerState = new SpeedState(avatar);
                    break;

                case "jump":
                    avatar.powerState = new DoubleState(avatar);
                    break;

                case "propeller":

                    break;

                default:
                    break;
                }
            }
            else
            {
                avatar.ObjectsToNotCollide.Add(obj);
            }
        }
 public DoodleFallingState(DoodleObject avatar) : base(avatar)
 {
     _avatar = avatar;
 }
Exemplo n.º 4
0
 public DoubleState(DoodleObject avatar)
     : base(avatar)
 {
     avatar.Hitbox = new BoundingBox(new Vector3(avatar.Position.X, avatar.Position.Y, 0),
                                     new Vector3(avatar.Position.X + 55, avatar.Position.Y + 55, 0));
 }
 public AbsPowerStateDoodle(DoodleObject avatar)
 {
     this.avatar   = avatar;
     factory       = new DoodleMetaFactory(this, avatar.content);
     avatar.Sprite = factory.build(avatar.moveState);
 }
Exemplo n.º 6
0
 public AbsDoodleMoveState(DoodleObject avatar)
 {
     this.avatar   = avatar;
     factory       = new DoodleMetaFactory(avatar.powerState, avatar.content);
     avatar.Sprite = factory.build(this);
 }
Exemplo n.º 7
0
 public DoodleIdleLeftState(DoodleObject avatar) : base(avatar)
 {
     _avatar = avatar;
 }
Exemplo n.º 8
0
        public override void LoadContent(ContentManager content)
        {
            font = content.Load <SpriteFont>("temp_font");
            hud  = new HudObject(font);
            string name = "doodle_test.txt";

            token  = new Tokenizer(name, content);
            avatar = new DoodleObject(new Vector2(windowWidth / 2, 3450), content, token.audio);
            camera.LookAt(avatar.Position);
            generator = new Level_Generator(content, camera, avatar, token.audio);
            generator.Initialize(layers[1]);
            //collision requires everything to be in the same list, so the platforms need to be with the avatar
            //changing the level floor to be platforms instead of blocks, no need for a level definition.
            //tokenizer does something with the audio so leaving the token object around for now
            layers[1].Objects.Add(new PlatformObject(new Vector2(0, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(64, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(128, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(192, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(256, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(320, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(384, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(448, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(512, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(576, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(640, 3540), -1, content));
            layers[1].Objects.Add(new PlatformObject(new Vector2(704, 3540), -1, content));
            //layers[1].Objects.Add(new PlatformObject(new Vector2(0, 3400), new Vector2(windowWidth, 3400), -1, content));
            // nvm try and keep avatar at the end of the list
            layers[1].Objects.Add(avatar);
            layers[0].Objects.Add(new VertBGObject(content));

            avatar.hud = hud;
            hud.audio  = avatar.audio;

            keyboard = new KeyboardController();
            gamepad  = new GamepadController();
            keyboard.commandDict.Add(Keys.Z, new MainMenuCommand(graphics, graphicsManager));
            controllers.Add(keyboard);
            controllers.Add(gamepad);
            keyboard.moveCommandDict.Add(Keys.Up, new UpCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.Up, new DownCommand(avatar));
            keyboard.moveCommandDict.Add(Keys.W, new UpCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.W, new DownCommand(avatar));

            keyboard.moveCommandDict.Add(Keys.Down, new DownCommand(avatar));
            keyboard.moveCommandDict.Add(Keys.S, new DownCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.Down, new UpCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.S, new UpCommand(avatar));

            keyboard.moveCommandDict.Add(Keys.Left, new LeftCommand(avatar));
            keyboard.moveCommandDict.Add(Keys.A, new LeftCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.Left, new RightCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.A, new RightCommand(avatar));

            keyboard.moveCommandDict.Add(Keys.Right, new RightCommand(avatar));
            keyboard.moveCommandDict.Add(Keys.D, new RightCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.Right, new LeftCommand(avatar));
            keyboard.releaseCommandDict.Add(Keys.D, new LeftCommand(avatar));

            keyboard.commandDict.Add(Keys.Y, new StandardCommand(avatar));
            keyboard.commandDict.Add(Keys.U, new SuperCommand(avatar));
            keyboard.commandDict.Add(Keys.I, new FireCommand(avatar));
            keyboard.commandDict.Add(Keys.O, new TakeDamageCommand(avatar));
            keyboard.commandDict.Add(Keys.Q, new QuitCommand());
            keyboard.commandDict.Add(Keys.P, new PauseCommand(graphics, hud, avatar.audio, graphicsManager));
            keyboard.commandDict.Add(Keys.M, new MuteCommand(avatar.audio));
            keyboard.commandDict.Add(Keys.Tab, new ThemeCommand(avatar.audio));
            keyboard.commandDict.Add(Keys.R, new ResetDJCommand(graphics, graphicsManager, hud.audio));

            avatar.audio.PlaySound("doodleTheme");
        }
Exemplo n.º 9
0
 public DoodleWalkRightState(DoodleObject avatar) : base(avatar)
 {
     _avatar = avatar;
 }