public override void Load()
        {
            // Создаем фон
            bgContainer = new Sprite();
            bgLayers = new Sprite[3];
            AddChild(bgContainer);
            for (int i = 0; i < 3; ++i)
            {
                bgLayers[i] = new Sprite();

                var bmp1 = new Bitmap(Assets.GetBitmapData("assets/background/1/" + (i + 1).ToString(), true));
                var bmp2 = new Bitmap(Assets.GetBitmapData("assets/background/1/" + (i + 1).ToString(), true));

                bmp2.X = bmp1.Width;

                bgLayers[i].AddChild(bmp1);
                bgLayers[i].AddChild(bmp2);

                bgContainer.AddChild(bgLayers[i]);
            }
            // Интерфейс Меню
            guiContainer = new Sprite();
            AddChild(guiContainer);
            // Лого
            logo = new Bitmap(Assets.GetBitmapData("assets/logo", true));
            //            logo.font = Assets.GetFont("assets/MainFont");
            //            logo.text = "MULTIPLANES";
            logo.X = GameMain.ScreenWidth / 2 - logo.Width / 2;
            logo.Y = 10 / GameMain.mainScale;
            time = 0;
            guiContainer.AddChild(logo);
            // Кнопка join
            joinButton = new TextField();
            joinButton.font = Assets.GetFont("assets/MainFont");
            joinButton.text = "Join game";
            joinButton.ScaleX = joinButton.ScaleY = 0.5f;
            joinButton.X = GameMain.ScreenWidth / 2 - joinButton.Width / 2;
            joinButton.Y = GameMain.ScreenHeight / 2 + joinButton.Height;
            guiContainer.AddChild(joinButton);
            // Самолетик
            plane = new Bitmap(Assets.GetBitmapData("assets/plane_red"));
            plane.Y = (joinButton.Y + (logo.Y + logo.Height)) / 2 - plane.Height / 2;
            plane.X = GameMain.ScreenWidth / 2 - plane.Width / 2;
            guiContainer.AddChild(plane);
            // Кнопка host
            hostButton = new TextField();
            hostButton.font = joinButton.font;
            hostButton.text = "Host game";
            hostButton.ScaleX = hostButton.ScaleY = 0.5f;
            hostButton.X = GameMain.ScreenWidth / 2 - hostButton.Width / 2;
            hostButton.Y = joinButton.Y + joinButton.Height;
            guiContainer.AddChild(hostButton);
            joinButton.AddEventListener(Event.TOUCH_END, joinGameEvent);
            hostButton.AddEventListener(Event.TOUCH_END, hostGameEvent);
        }
        public override void Load()
        {
            bgContainer = new Sprite();
            bgLayers = new Sprite[3];
            AddChild(bgContainer);
            for (int i = 0; i < 3; ++i)
            {
                bgLayers[i] = new Sprite();

                var bmp1 = new Bitmap(Assets.GetBitmapData("assets/background/1/" + (i + 1).ToString(), true));
                var bmp2 = new Bitmap(Assets.GetBitmapData("assets/background/1/" + (i + 1).ToString(), true));

                bmp2.X = bmp1.Width;

                bgLayers[i].AddChild(bmp1);
                bgLayers[i].AddChild(bmp2);

                bgContainer.AddChild(bgLayers[i]);
            }
            // GUI
            guiContainer = new Sprite();
            AddChild(guiContainer);

            NetPeerConfiguration config = new NetPeerConfiguration("multiplanes-network");
            client = new NetClient(config);
            client.Start();
            client.DiscoverLocalPeers(14242);
            client.DiscoverKnownPeer(GameClient.NET_ADRESS, GameClient.NET_PORT);

            nick = NickGenerator.GenerateNick(client.UniqueIdentifier);

            var screenNameLabel = new TextField();
            screenNameLabel.font = Assets.GetFont("assets/MainFont");
            screenNameLabel.text = "HOST GAME";
            screenNameLabel.X = GameMain.ScreenWidth / 2 - screenNameLabel.Width / 2;
            screenNameLabel.Y = 10 / GameMain.mainScale;
            guiContainer.AddChild(screenNameLabel);

            var roomNameLabel = new TextField();
            roomNameLabel.font = screenNameLabel.font;
            roomNameLabel.text = "Room name: " + nick;
            roomNameLabel.X = GameMain.ScreenWidth * 0.1f;
            roomNameLabel.Y = GameMain.ScreenHeight / 2 - roomNameLabel.Height / 2;
            roomNameLabel.ScaleX = roomNameLabel.ScaleY = 0.5f;
            guiContainer.AddChild(roomNameLabel);

            waitLabel = new TextField();
            waitLabel.font = roomNameLabel.font;
            waitLabel.text = "Waiting for other player to connect. . .";
            waitLabel.X = roomNameLabel.X;
            waitLabel.Y = roomNameLabel.Y + roomNameLabel.Height;
            waitLabel.ScaleX = waitLabel.ScaleY = 0.25f;
            guiContainer.AddChild(waitLabel);
        }
Exemplo n.º 3
0
        public override void Load()
        {
            var background = new MenuBackground();
            AddChild(background);

            float ActualWidth = stage.StageWidth / GameMain.mainScale / 2f;
            float ActualHeight = stage.StageHeight / GameMain.mainScale / 2f;

            Levels = new Bitmap[CountLevels];

            float widthBitmap = GiveCurrentData();

            float heightBitmap = stage.StageHeight / 4;

            for (int k = 0; k < Levels.Length; k++)
            {
                Bitmap bmp = new Bitmap(Assets.GetBitmapData(String.Format("{0}", k + 1)));
                bmp.ScaleX = widthBitmap / bmp.Width / GameMain.mainScale;
                bmp.ScaleY = widthBitmap / bmp.Height / GameMain.mainScale;

                bmp.X = (leftContain + (widthBitmap + space) * k) / GameMain.mainScale;
                bmp.Y = 200 / GameMain.mainScale;

                AddChild(bmp);
                Levels[k] = bmp;

                bmp.AddEventListener(Event.TOUCH_END, levelButtonClick);
            }

            logoSelectLevel = new Bitmap(Assets.GetBitmapData("selectLevelLogo"));
            logoSelectLevel.ScaleX = logoSelectLevel.ScaleY = 1.25f;
            logoSelectLevel.X = stage.StageWidth / GameMain.mainScale / 2f - logoSelectLevel.Width / 2f;
            logoSelectLevel.Y = 5;
            AddChild(logoSelectLevel);

            buttonBack = new TextField();
            buttonBack.text = "Back";
            buttonBack.font = Assets.GetFont("MainFont");
            buttonBack.ScaleX = buttonBack.ScaleY = 2f;

            buttonBack.X = logoSelectLevel.X + logoSelectLevel.Width / 2 - buttonBack.Width / 2;
            buttonBack.Y = Levels[0].Y + Levels[0].Height + 50f / GameMain.mainScale;
            AddChild(buttonBack);

            buttonBack.AddEventListener(Event.TOUCH_END, backToMenu);
        }
        public HostLabel(string nick, long uid, SpriteFont font)
        {
            this.nick = nick;
            this.uid = uid;

            nameField = new TextField();
            nameField.font = font;
            nameField.text = "Room name: " + nick;
            AddChild(nameField);

            uidField = new TextField();
            uidField.font = font;
            uidField.text = "Room UID: " + NetUtility.ToHexString(uid);
            uidField.ScaleX = uidField.ScaleY = 0.5f;
            uidField.Y = nameField.Height;
            AddChild(uidField);

            isSelected = false;
        }
Exemplo n.º 5
0
        public override void Load()
        {
            ActualWidth = stage.StageWidth / GameMain.mainScale / 2f;
            ActualHeight = stage.StageHeight / GameMain.mainScale / 2f;

            //Фон
            /*BitmapData backGr = Assets.GetBitmapData("Image");
            Bitmap bitmap1 = new Bitmap(backGr);
            AddChild(bitmap1);
            // Center bitmap
            bitmap1.X = 0;
            bitmap1.Y = 0;

            //bitmap1.ScaleX = stage.StageWidth / (bitmap1.Width * GameMain.mainScale);
            bitmap1.ScaleY = stage.StageHeight / (bitmap1.Height * GameMain.mainScale);
            bitmap1.ScaleX = bitmap1.ScaleY;*/

            var background = new MenuBackground();
            AddChild(background);

            //Логотип
            BitmapData texture = Assets.GetBitmapData("Logo");
            bitmap = new Bitmap(texture);
            AddChild(bitmap);
            // Center bitmap
            bitmap.ScaleX = bitmap.ScaleY = 0.1f;
            bitmap.X = ActualWidth;// - bitmap.Width / 2f;
            bitmap.Y = ActualHeight;// - bitmap.Height / 2f;

            //Старт гейм
            joinButton = new TextField();
            joinButton.font = Assets.GetFont("MainFont");
            joinButton.text = "Start game";
            joinButton.textColor = Color.White;
            //joinButton.ScaleX = joinButton.ScaleY = 2f / GameMain.mainScale;
            joinButton.X = ActualWidth - joinButton.Width / 2;
            joinButton.Y = ActualHeight * 2;//ActualHeight + joinButton.Height
            AddChild(joinButton);
            joinButton.AddEventListener(Event.TOUCH_END, changeLevels);
        }
Exemplo n.º 6
0
        public Player(string nick = "NoName", bool isLocal = false)
        {
            string planeColor = (isLocal) ? "red" : "blue";

            HP = MAX_HP;

            bmp = new Bitmap(Assets.GetBitmapData("assets/plane_" + planeColor, false));
            bmp.X = -bmp.Width / 2;
            bmp.Y = -bmp.Height / 2;
            AddChild(bmp);

            this.isLocal = isLocal;
            this.nick = nick;

            name = new TextField();
            name.font = Assets.GetFont("assets/MainFont");
            name.text = nick;
            name.ScaleX = name.ScaleY = 0.3f;
            name.X = bmp.X - (name.Width / 2);
            name.Y = bmp.Y - bmp.Height - name.Height;
            //            AddChild(name);
        }
        public override void Load()
        {
            worldContainer = new Sprite();
            AddChild(worldContainer);

            bullets = new List<Bullet>();
            reloadTime = 0;

            // Фон
            bgLayers = new Sprite[3];
            bgContainer = new Sprite();
            worldContainer.AddChild(bgContainer);

            LoadBackground(levelNumber);

            // Игра
            gameContainer = new Sprite();
            worldContainer.AddChild(gameContainer);

            localPlayer = new Player(localNick, true);
            remotePlayer = new Player(remoteNick, false);
            if (isHost)
            {
                localPlayer.X = localPlayer.Y = remotePlayer.Y = 10;
                remotePlayer.X = WORLD_WIDTH - GameMain.ScreenWidth / 2;
                remotePlayer.Rotation = 180;
                remotePlayer.ScaleY = -1;
            }
            else
            {
                remotePlayer.X = remotePlayer.Y = localPlayer.Y = 10;
                localPlayer.X = WORLD_WIDTH - GameMain.ScreenWidth / 2;
                localPlayer.Rotation = 180;
                localPlayer.ScaleY = -1;
            }
            gameContainer.AddChild(localPlayer);
            gameContainer.AddChild(remotePlayer);

            // Интерфейс
            guiContainer = new Sprite();
            AddChild(guiContainer);

            #if __MOBILE__
            // Кнопка тормоза
            decelerateButton = new Bitmap(Assets.GetBitmapData("assets/ui/down"));
            decelerateButton.Y = GameMain.ScreenHeight - decelerateButton.Height;
            guiContainer.AddChild(decelerateButton);
            decelerateButton.AddEventListener(Event.TOUCH_MOVE, onDecelerateBegin);
            decelerateButton.AddEventListener(Event.TOUCH_END, onDecelerateEnd);
            // Кнопка вправо
            rightButton = new Bitmap(Assets.GetBitmapData("assets/ui/right"));
            rightButton.X = GameMain.ScreenWidth - rightButton.Width;
            rightButton.Y = decelerateButton.Y;
            guiContainer.AddChild(rightButton);
            rightButton.AddEventListener(Event.TOUCH_MOVE, onRotateBegin);
            rightButton.AddEventListener(Event.TOUCH_END, onRotateEnd);
            // Кнопка вправо
            leftButton = new Bitmap(Assets.GetBitmapData("assets/ui/left"));
            leftButton.X = rightButton.X - leftButton.Width;
            leftButton.Y = rightButton.Y;
            guiContainer.AddChild(leftButton);
            leftButton.AddEventListener(Event.TOUCH_MOVE, onRotateBegin);
            leftButton.AddEventListener(Event.TOUCH_END, onRotateEnd);
            // Кнопка стрельбы
            fireButton = new Bitmap(Assets.GetBitmapData("assets/ui/fire"));
            fireButton.X = decelerateButton.X + decelerateButton.Width;
            fireButton.Y = decelerateButton.Y;
            guiContainer.AddChild(fireButton);
            fireButton.AddEventListener(Event.TOUCH_END, onFireBegin);
            leftButton.color = rightButton.color = decelerateButton.color = fireButton.color = new Color(Color.DarkGray, 20);
            #endif

            if (isHost)
                ChangeLevel();

            resultLabel = new TextField();
            resultLabel.font = Assets.GetFont("assets/MainFont");
            resultLabel.visible = false;

            countLabel = new TextField();
            countLabel.font = resultLabel.font;
            countLabel.visible = false;

            guiContainer.AddChild(resultLabel);
            guiContainer.AddChild(countLabel);
        }
        public override void Load()
        {
            // Background
            bgContainer = new Sprite();
            bgLayers = new Sprite[3];
            AddChild(bgContainer);
            for (int i = 0; i < 3; ++i)
            {
                bgLayers[i] = new Sprite();

                var bmp1 = new Bitmap(Assets.GetBitmapData("assets/background/1/" + (i + 1).ToString(), true));
                var bmp2 = new Bitmap(Assets.GetBitmapData("assets/background/1/" + (i + 1).ToString(), true));

                bmp2.X = bmp1.Width;

                bgLayers[i].AddChild(bmp1);
                bgLayers[i].AddChild(bmp2);

                bgContainer.AddChild(bgLayers[i]);
            }
            // GUI
            guiContainer = new Sprite();
            AddChild(guiContainer);

            hosts = new List<HostLabel>();

            font = Assets.GetFont("assets/MainFont");

            var screenNameLabel = new TextField();
            screenNameLabel.font = font;
            screenNameLabel.text = "JOIN GAME";
            screenNameLabel.X = GameMain.ScreenWidth / 2 - screenNameLabel.Width / 2;
            screenNameLabel.Y = 10 / GameMain.mainScale;
            guiContainer.AddChild(screenNameLabel);

            pointerLabel = new TextField();
            pointerLabel.font = screenNameLabel.font;
            pointerLabel.text = "Select a game to join";
            pointerLabel.ScaleX = pointerLabel.ScaleY = 0.4f;
            pointerLabel.X = GameMain.ScreenWidth / 2 - pointerLabel.Width / 2;
            pointerLabel.Y = screenNameLabel.Y + screenNameLabel.Height;
            guiContainer.AddChild(pointerLabel);

            connectButton = new TextField();
            connectButton.font = font;
            connectButton.text = "Connect";
            connectButton.ScaleX = connectButton.ScaleY = 0.5f;
            connectButton.X = GameMain.ScreenWidth * 0.25f - connectButton.Width / 2;
            connectButton.Y = GameMain.ScreenHeight - connectButton.Height;
            connectButton.textColor = Color.DarkGray;
            guiContainer.AddChild(connectButton);

            refreshButton = new TextField();
            refreshButton.font = font;
            refreshButton.text = "Refresh";
            refreshButton.ScaleX = refreshButton.ScaleY = 0.5f;
            refreshButton.X = GameMain.ScreenWidth * 0.75f - refreshButton.Width / 2;
            refreshButton.Y = connectButton.Y;
            guiContainer.AddChild(refreshButton);

            connectButton.AddEventListener(Event.TOUCH_END, onButtonDown);
            refreshButton.AddEventListener(Event.TOUCH_END, onButtonDown);

            NetPeerConfiguration config = new NetPeerConfiguration("multiplanes-network");
            client = new NetClient(config);
            client.Start();
            nick = NickGenerator.GenerateNick((client.UniqueIdentifier));
            client.DiscoverLocalPeers(14242);
            client.DiscoverKnownPeer(GameClient.NET_ADRESS, GameClient.NET_PORT);
        }
Exemplo n.º 9
0
        public override void Load()
        {
            random = new Random();

            background = new GameBackground();
            AddChild(background);
            background.Y += GameMain.ScreenHeight * 0.2f;
            gameContainer = new Sprite();
            AddChild(gameContainer);

            player = new Player();
            player.X = 5 * Level.TILE_SIZE;
            player.Y = 5 * Level.TILE_SIZE;

            objects = new List<MovingObject>();
            objects.Add(player);
            bullets = new List<Bullet>();

            particleTexture = Assets.GetBitmapData("blood");
            particles = new List<Particle>();

            level = new Level(1);

            gameContainer.AddChild(level);

            gameInterface = new GameInterface();
            #if __MOBILE__
            AddChild(gameInterface);
            gameInterface.left.AddEventListener(Event.TOUCH_BEGIN, buttonTouchBegin);
            gameInterface.right.AddEventListener(Event.TOUCH_BEGIN, buttonTouchBegin);
            gameInterface.up.AddEventListener(Event.TOUCH_BEGIN, buttonTouchBegin);
            gameInterface.left.AddEventListener(Event.TOUCH_END, buttonTouchEnd);
            gameInterface.right.AddEventListener(Event.TOUCH_END, buttonTouchEnd);
            gameInterface.up.AddEventListener(Event.TOUCH_END, buttonTouchEnd);
            gameInterface.fire.AddEventListener(Event.TOUCH_BEGIN, buttonTouchBegin);
            #endif
            inputX = 0;
            inputY = 0;

            tutorText = new TextField();
            tutorText.font = Assets.GetFont("MainFont");
            tutorText.text = "JUMP!!!";
            tutorText.X = (PHYS_BEGIN + 1) * Level.TILE_SIZE;
            tutorText.Y = 5 * Level.TILE_SIZE;

            gameContainer.AddChild(player);

            var zombie = new Zombie(player);
            gameContainer.AddChild(zombie);
            objects.Add(zombie);
            zombie.X = 5 * Level.TILE_SIZE;
            zombie.Y = 5 * Level.TILE_SIZE;

            zombie = new Zombie(player);
            gameContainer.AddChild(zombie);
            objects.Add(zombie);
            zombie.X = 10 * Level.TILE_SIZE;
            zombie.Y = 6 * Level.TILE_SIZE;

            zombie = new Zombie(player);
            gameContainer.AddChild(zombie);
            objects.Add(zombie);
            zombie.X = 11 * Level.TILE_SIZE;
            zombie.Y = 5 * Level.TILE_SIZE;

            var zombie2 = new Bug(player);
            gameContainer.AddChild(zombie2);
            objects.Add(zombie2);
            zombie2.X = 7 * Level.TILE_SIZE;
            zombie2.Y = 4 * Level.TILE_SIZE;

            zombie2 = new Bug(player);
            gameContainer.AddChild(zombie2);
            objects.Add(zombie2);
            zombie2.X = 15 * Level.TILE_SIZE;
            zombie2.Y = 9 * Level.TILE_SIZE;

            zombie = new Zombie(player);
            gameContainer.AddChild(zombie);
            objects.Add(zombie);
            zombie.X = 30 * Level.TILE_SIZE;
            zombie.Y = 5 * Level.TILE_SIZE;

            zombie = new Zombie(player);
            gameContainer.AddChild(zombie);
            objects.Add(zombie);
            zombie.X = 32 * Level.TILE_SIZE;
            zombie.Y = 6 * Level.TILE_SIZE;

            zombie = new Zombie(player);
            gameContainer.AddChild(zombie);
            objects.Add(zombie);
            zombie.X = 35 * Level.TILE_SIZE;
            zombie.Y = 5 * Level.TILE_SIZE;

            zombie2 = new Bug(player);
            gameContainer.AddChild(zombie2);
            objects.Add(zombie2);
            zombie2.X = 40 * Level.TILE_SIZE;
            zombie2.Y = 8 * Level.TILE_SIZE;

            zombie2 = new Bug(player);
            gameContainer.AddChild(zombie2);
            objects.Add(zombie2);
            zombie2.X = 55 * Level.TILE_SIZE;
            zombie2.Y = 9 * Level.TILE_SIZE;

            gameContainer.AddChild(tutorText);
        }