Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        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()
        {
            // 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);
        }