예제 #1
0
        public GameStateEntryMenu(Game1 g, ContentManager c, NetworkInterface ni)
        {
            Game = g;
            Content = c;
            ih = new InputHandler();
            net = ni;

            instructions = new Sprite("instructions.png", Content, new Vector2(0, 0), false);
            float insSclA = (2 * Game1.SCREEN_HEIGHT / 3) / instructions.size.Y;
            float insMidX = (Game1.SCREEN_WIDTH / 2) - ((instructions.size.X * insSclA) / 2);
            instructions.move(new Vector2(insMidX, 0));

            playersReady = new bool[8];

            playerSlides = new float[8];

            readyWait = 3000;
            getReady = new Sprite("ready.png", Content, Vector2.Zero, false);
            getReady.move(new Vector2(
                (Game1.SCREEN_WIDTH / 2) - (getReady.size.X / 2),
                (Game1.SCREEN_HEIGHT / 2) - (getReady.size.Y / 2)));

            numberSprites = new Sprite[8];
            string[] nsNames = new String[8] {"one","two","three","four","five","six","seven","eight"};
            Vector2 firstLocation = new Vector2(Game1.SCREEN_WIDTH / 16, 0);
            for (int x = 0; x < 8; x++)
            {
                Vector2 loc = firstLocation + new Vector2((Game1.SCREEN_WIDTH / 8) * x, 
                    (Game1.SCREEN_HEIGHT + (instructions.size.Y * insSclA)) / 2);
                numberSprites[x] = new Sprite(nsNames[x] + ".png", Content, loc, false);
                numberSprites[x].move(new Vector2(-1 * (numberSprites[x].size.X / 2), 0));
            }

            playerColors = new Color[8];
            Random ra = new Random(Environment.TickCount);
            for (int x = 0; x < 8; x++)
            {
                playerColors[x] = new Color(ra.Next(255), ra.Next(255), ra.Next(255));
            }
            whiteTexture = new Texture2D(Game1.graphics.GraphicsDevice, 1, 1);
            Color[] whiteData = new Color[1] {Color.White};
            whiteTexture.SetData(whiteData);

            playReadySF = true;
            ready = Content.Load<SoundEffect>("ready");
            entry = Content.Load<SoundEffect>("playerjoin");
        }
예제 #2
0
파일: Game1.cs 프로젝트: andrewbarry1/8p4c
        protected override void LoadContent()
        {
            spriteBatch = new SpriteBatch(GraphicsDevice);
			whiteTexture = new Texture2D (GraphicsDevice, 1, 1);
			Color[] whiteData = new Color[1];
			whiteData [0] = Color.White;
			whiteTexture.SetData (whiteData);
            SCREEN_WIDTH = GraphicsDevice.DisplayMode.Width;
            SCREEN_HEIGHT = GraphicsDevice.DisplayMode.Height;
            graphics.PreferredBackBufferHeight = SCREEN_HEIGHT;
            graphics.PreferredBackBufferWidth = SCREEN_WIDTH;
            graphics.ApplyChanges();

            fightMusic = Content.Load<Song>("combat");
            bgColor = 175;

            ni = new NetworkInterface("ws://8p4c.andrewbarry.me/ws", Content);
            ni.setOnReady(sendHello);
            states.Push(new GameStateEntryMenu(this, Content, ni));
            MediaPlayer.Play(fightMusic);
        }
예제 #3
0
        public GameStateFighting(ContentManager c, Game1 g, Color[] pColors, NetworkInterface ni) {

            net = ni;

            shakeAmnt = Vector2.Zero;

            ra = new Random(Environment.TickCount);

            Content = c;
            Game = g;
            ih = new InputHandler();
            camera = new Camera();
            camera.setPosition(Vector2.Zero);

            go = new Sprite("go.png", Content, Vector2.Zero, false);
            go.move(new Vector2(
                (Game1.SCREEN_WIDTH / 2) - (go.size.X / 2),
                (Game1.SCREEN_HEIGHT / 2) - (go.size.Y / 2)));
            goTimer = 250;

            winner = new Sprite("game.png", Content, Vector2.Zero, false);
            winner.move(new Vector2(
                (Game1.SCREEN_WIDTH / 2) - (winner.size.X / 2),
                (Game1.SCREEN_HEIGHT / 2) - (winner.size.Y / 2)));
            winnerTime = 751;

            platform = new Sprite("platform.png", Content, Vector2.Zero, false);
            playerOne = new Player("player.png", Content, Vector2.Zero);
            p1Field = new Sprite("force.png", Content, Vector2.Zero, false);
            playerOneNumber = 0;
            playerTwo = new Player("player.png", Content, Vector2.Zero);
            p2Field = new Sprite("force.png", Content, Vector2.Zero, false);
            playerTwoNumber = 0;

            extraFields = new List<Sprite>();
            extraFieldTimes = new List<float>();
            extraFieldColors = new List<Color>();

            playerColors = pColors;
            scores = new int[8];

            matchList = new Vector2[28] {
                mv(0,7), mv(1,6), mv(2,5), mv(3,4),
                mv(0,6), mv(5,7), mv(4,1), mv(3,2),
                mv(0,5), mv(6,4), mv(7,3), mv(1,2),
                mv(0,4), mv(3,5), mv(2,6), mv(1,7),
                mv(0,3), mv(4,2), mv(5,1), mv(6,7),
                mv(0,2), mv(1,3), mv(7,4), mv(6,5),
                mv(0,1), mv(2,7), mv(3,6), mv(4,5)
            };
            matchList = shuffle(matchList);
            currentMatch = -1;

            fieldMultiplier = 1f;

            suddenDeath = new Sprite("suddendeath.png", Content, Vector2.Zero, false);
            suddenDeath.position = new Vector2(
                (Game1.SCREEN_WIDTH / 2) - (suddenDeath.size.X / 2), 50);

            playedGSE = false;

            controllerNumbers = new Dictionary<int, int>();
            controllerNumbers.Add(0, 1);
            controllerNumbers.Add(1, 1);
            controllerNumbers.Add(2, 2);
            controllerNumbers.Add(3, 2);
            controllerNumbers.Add(4, 3);
            controllerNumbers.Add(5, 3);
            controllerNumbers.Add(6, 4);
            controllerNumbers.Add(7, 4);

            camera.move(new Vector2(-350, (Game1.SCREEN_WIDTH / 5)));

            goSF = Content.Load<SoundEffect>("go");
            sdSF = Content.Load<SoundEffect>("suddendeath");
            gameSF = Content.Load<SoundEffect>("game");
            jumpSF = Content.Load<SoundEffect>("jump");
            fieldSF = Content.Load<SoundEffect>("field");

            prepareMatch();
        }