コード例 #1
0
        public Player LoadPlayer(ContentManager content, int width, int height, int deadWidth, int deadHeight)
        {
            if (side == Player.Side.Left)
            {
                position.X -= width;
            }

            Player player;

            Animation playerAnimation = new Animation();
            Texture2D playerTexture   = content.Load <Texture2D>("Graphics\\" + characterName.ToLower());

            // Frame dimensions: 39x - 45y
            playerAnimation.Initialize(playerTexture, position, width, height, 0, 0, 100, Color.White, 1f, true);

            Animation deadAnimation = new Animation();
            Texture2D deadTexture   = content.Load <Texture2D>("Graphics\\" + characterName.ToLower() + "_flying");

            deadAnimation.Initialize(deadTexture, position, deadWidth, deadHeight, 0, 3, 100, Color.White, 1f, false);

            Texture2D measureBar = content.Load <Texture2D>("Graphics\\measure_bar");
            Texture2D aimTexture = content.Load <Texture2D>("Graphics\\aim");
            Aim       aim        = new Aim(aimTexture, 30, 9, 50);

            Texture2D appearanceSmokeTexture = content.Load <Texture2D>("Graphics\\appearance_smoking");

            switch (characterName.ToLower())
            {
            case "dwarf":
                Animation boozeAnimation = new Animation();
                Texture2D boozeTexture   = content.Load <Texture2D>("Graphics\\booze");
                boozeAnimation.Initialize(boozeTexture, position, 9, 9, 0, 4, 100, Color.White, 1f, true);

                Animation lighterAnimation = new Animation();
                Texture2D lighterTexture   = content.Load <Texture2D>("Graphics\\lighter");
                lighterAnimation.Initialize(lighterTexture, position, 4, 7, 0, 4, 100, Color.White, 1f, true);

                Animation fireSpitAnimation = new Animation();
                Texture2D fireSpitTexture   = content.Load <Texture2D>("Graphics\\lighter_on_fire");
                fireSpitAnimation.Initialize(fireSpitTexture, position, 46, 32, 0, 4, 100, Color.White, 1f, true);

                FireSpitting fireSpitting = new FireSpitting(boozeAnimation, lighterAnimation, fireSpitAnimation, 2f, 100, 2f);

                Texture2D boozeSpinTexture = content.Load <Texture2D>("Graphics\\spinning_booze");

                //SpinningBooze boozeSpinning = new SpinningBooze(boozeSpinAnimation, 0.3f, 25, 5);

                player = new Dwarf(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0, 4, 5, new Vector2(6, 33),
                                   side, input, fireSpitting, boozeSpinTexture);
                break;

            case "dove":
                Animation sandwichAnimation = new Animation();
                Texture2D sandwichTexture   = content.Load <Texture2D>("Graphics\\sandwich");
                sandwichAnimation.Initialize(sandwichTexture, position, 9, 9, 0, 5, 400, Color.White, 1f, true);

                Animation stinkAnimation = new Animation();
                Texture2D stinkTexture   = content.Load <Texture2D>("Graphics\\stink");
                stinkAnimation.Initialize(stinkTexture, position, 45, 45, 0, 6, 100, Color.White, 1f, true);

                Texture2D pooTexture = content.Load <Texture2D>("Graphics\\poo");

                Texture2D forkTexture   = content.Load <Texture2D>("Graphics\\fork");
                Animation forkAnimation = new Animation();
                forkAnimation.Initialize(forkTexture, new Vector2(0, 0), 18, 18, 0, 7, 50, Color.White, 1f, true);

                Projectile fork = new Projectile(forkAnimation, 0, 30, 10);

                player = new Dove(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.5f, 5, 5, new Vector2(3, 39),
                                  side, input, sandwichAnimation, pooTexture, 4, stinkAnimation, fork);
                break;

            case "skinny":
                Animation spaceshipAnimation = new Animation();
                Texture2D spaceshipTexture   = content.Load <Texture2D>("Graphics\\spaceship");
                spaceshipAnimation.Initialize(spaceshipTexture, position, 57, 30, 0, 4, 50, Color.White, 1f, true);

                Texture2D spaceshoot = content.Load <Texture2D>("Graphics\\spaceshoot");
                Texture2D crazyRay   = content.Load <Texture2D>("Graphics\\crazy_ray");

                Animation disappearanceAnimation = new Animation();
                Texture2D disappearanceTexture   = content.Load <Texture2D>("Graphics\\skinny_teleport");
                disappearanceAnimation.Initialize(disappearanceTexture, position, width, height, 0, 6, 50, Color.White, 1f, true);

                Animation appearanceSmokeAnimation = new Animation();
                appearanceSmokeAnimation.Initialize(appearanceSmokeTexture, position, 57, 57, 0, 8, 40, Color.White, 1f, true);

                Teleport tp = new Teleport(disappearanceAnimation, appearanceSmokeAnimation, 100f);

                player = new Skinny(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.2f, 5, 5, new Vector2(6, 30),
                                    side, input, spaceshipAnimation, spaceshoot, crazyRay, tp, 0.7f);
                break;

            case "goat":
                Animation disillusionRaysAnimation = new Animation();
                Texture2D disillusionRaysTexture   = content.Load <Texture2D>("Graphics\\appearance_ray");
                disillusionRaysAnimation.Initialize(disillusionRaysTexture, position, 33, 48, 0, 3, 50, Color.White, 1f, true);

                Texture2D heart        = content.Load <Texture2D>("Graphics\\heart");
                Texture2D disconnected = content.Load <Texture2D>("Graphics\\disconnected");

                Love luv = new Love(heart, disillusionRaysAnimation);
                RoutesConfiguration routesConfig = new RoutesConfiguration(appearanceSmokeTexture);

                player = new Goat(playerAnimation, deadAnimation, aim, measureBar, playerID, 100, 100, 0.15f, 5, 5, new Vector2(6, 30),
                                  side, input, disconnected, luv, routesConfig);
                break;

            default:
                player = null;
                break;
            }

            return(player);
        }