示例#1
0
        public override async void _Ready()
        {
            // Parent is a MarginContainer, next parent is VirtualControls
            parent      = (VirtualControls)GetParent().GetParent();
            defaultFont = SimpleDefaultFont.Regular;

            // Create background
            background = new Background();
            AddChild(background);

            // Create handle
            handle = new Handle();
            background.AddChild(handle);

            // Check for touchscreen mode
            if (parent.VisibilityMode == VisibilityModeEnum.TouchscreenOnly && !OS.HasTouchscreenUiHint())
            {
                Hide();
            }

            // Wait for next frame to store original position
            await ToSignal(GetTree(), "idle_frame");

            background.OriginalPosition = background.RectPosition;
        }
示例#2
0
        public void AddCharacterSelection(string response)
        {
            CharacterSelect = new CharacterSelectHUD(DrawHelper.CenteredToScreenWidth(720), 400);
            CharacterSelect.Init(response);

            Background.AddChild(CharacterSelect);
        }
示例#3
0
        public void initTitle()
        {
            this.Camera2D.SetViewFromViewport();

            logo          = new SpriteUV(new TextureInfo("/Application/data/logo.png"));
            logo.Scale    = logo.TextureInfo.TextureSizef * 1.8f;
            logo.Pivot    = new Vector2(0.5f, 0.5f);
            logo.Position = new Vector2((960.0f / 2.0f), (540.0f / 2.0f) + 80f);

            sprite_button_newgame          = new SpriteUV(new TextureInfo("/Application/data/button_newgame.png"));
            sprite_button_newgame.Scale    = sprite_button_newgame.TextureInfo.TextureSizef * 1.2f;
            sprite_button_newgame.Position = new Vector2((960.0f / 5.0f), (540.0f / 4.0f) - sprite_button_newgame.TextureInfo.TextureSizef.Y / 2.0f);

            sprite_button_tutorial          = new SpriteUV(new TextureInfo("/Application/data/button_tutorial.png"));
            sprite_button_tutorial.Scale    = sprite_button_newgame.TextureInfo.TextureSizef * 1.2f;
            sprite_button_tutorial.Position = new Vector2((960.0f / 2.0f), (540.0f / 4.0f) - sprite_button_newgame.TextureInfo.TextureSizef.Y / 2.0f);

            sprite_button_autoaim          = new SpriteUV(new TextureInfo("/Application/data/button_autoaimon.png"));
            sprite_button_autoaim.Scale    = sprite_button_newgame.TextureInfo.TextureSizef * 1.2f;
            sprite_button_autoaim.Position = new Vector2((960.0f / 2.0f) + (960.0f / 3.5f), (540.0f / 4.0f) - sprite_button_newgame.TextureInfo.TextureSizef.Y / 2.0f);

            sprite_button_newgame.Pivot  = new Vector2(0.5f, 0.5f);
            sprite_button_autoaim.Pivot  = new Vector2(0.5f, 0.5f);
            sprite_button_tutorial.Pivot = new Vector2(0.5f, 0.5f);

            Foreground.AddChild(sprite_button_newgame);
            Foreground.AddChild(sprite_button_tutorial);
            Foreground.AddChild(sprite_button_autoaim);
            Foreground.AddChild(logo);


            var tex     = new Texture2D("/Application/data/tiles/simple5.png", false);
            var texture = new TextureInfo(tex, new Vector2i(1, 13));

            menuBackground = new SpriteList(texture);

            int menuBackgroundWidth  = 100;
            int menuBackgroundHeight = 50;


            //mini background discofloor
            for (int x = 0; x < 30; x++)
            {
                for (int y = 0; y < 17; y++)
                {
                    SpriteTile bgTile = new SpriteTile(texture);
                    bgTile.TileIndex1D = Support.random.Next(4, 13);
                    bgTile.Position    = new Vector2((float)x * 32.0f, (float)y * 32.0f);
                    bgTile.Scale       = bgTile.TextureInfo.TileSizeInPixelsf * 2.0f;
                    bgTile.ScheduleInterval((dt) => { bgTile.TileIndex1D = Support.random.Next(4, 13); }, 0.2f, -1);
                    menuBackground.AddChild(bgTile);
                }
            }

            Background.AddChild(menuBackground);
        }
示例#4
0
        public void initLevelSelect()
        {
            this.levelSelection = 0;

            this.Camera2D.SetViewFromViewport();

            //labels
            labels = new List <Support.CustomLabel> ();


            //mini background discofloor

            var tex     = new Texture2D("/Application/data/tiles/simple5.png", false);
            var texture = new TextureInfo(tex, new Vector2i(1, 13));

            var menuBackground = new SpriteList(texture);

            for (int x = 0; x < 30; x++)
            {
                for (int y = 0; y < 17; y++)
                {
                    SpriteTile bgTile = new SpriteTile(texture);
                    bgTile.TileIndex1D = Support.random.Next(4, 13);
                    bgTile.Position    = new Vector2((float)x * 32.0f, (float)y * 32.0f);
                    bgTile.Scale       = bgTile.TextureInfo.TileSizeInPixelsf * 2.0f;
                    bgTile.ScheduleInterval((dt) => {
                        bgTile.TileIndex1D = Support.random.Next(4, 13);
                    }, 0.2f, -1);
                    menuBackground.AddChild(bgTile);
                }
            }

            Background.AddChild(menuBackground);



            for (int i = 0; i < MapManager.Instance.predefinedMaps.Count; i++)
            {
                //add thumbnail
                float newX        = 960.0f / 2.0f + i * (thumbnailSize + thumbnailSpacing);
                float scaleFactor = FMath.Clamp(thumbnailSize - FMath.Abs((960.0f / 2.0f) - newX) / 4.0f, 0.0f, thumbnailSize);
                MapManager.Instance.predefinedMaps [i].thumbnailSprite.Scale    = new Vector2(scaleFactor, scaleFactor);
                MapManager.Instance.predefinedMaps [i].thumbnailSprite.Position = new Vector2(newX, 544.0f / 2.0f);

                Foreground.AddChild(MapManager.Instance.predefinedMaps [i].thumbnailSprite);

                //add label:
                var tempLabel = new Support.CustomLabel(new Vector2(newX, 544.0f / 2.0f - thumbnailSize * 0.6f), "Level " + (i + 1) + "\nHighscore: 0", SceneManager.UIFontMap);
                labels.Add(tempLabel);

                Foreground.AddChild(tempLabel);
            }
        }
示例#5
0
        public void gameTick(float dt)
        {
            if (player == null)
            {
                player = new Player();
                World.AddChild(player);


                foreach (SpriteList sl in dungeon1.spriteList)
                {
                    Background.AddChild(sl);
                }
            }
            else
            {
                setCameraPosition();
            }
        }
示例#6
0
        public void initGame()
        {
            cameraHeight = (float)Convert.ToDouble(Support.GameParameters["StartingCameraHeight"]);

            //set view close to the scene
            this.Camera2D.SetViewFromHeightAndCenter(cameraHeight, Sce.PlayStation.HighLevel.GameEngine2D.Base.Math._00);



            //add all sprites loaded from the map
            foreach (SpriteList sl in MapManager.Instance.currentMap.spriteList)
            {
                Background.AddChild(sl);
            }

            //load the fire texture for the bullet
            Bullet.fireTexture = new Texture2D("/Application/data/tiles/fire.png", false);

            //texture for the points marker
            pointMarker.texture = new Texture2D("/Application/data/points100.png", false);

            //texture for the ammo marker
            ammoMarker.texture = new Texture2D("/Application/data/plusammo.png", false);

            Player.Instance = new Player();
            Foreground.AddChild(Player.Instance);

            //create the list for bullets
            bulletList = new List <Bullet>();

            //create ammo packs
            ammoList = new List <AmmoItem>();
            List <MapTile> list = MapManager.Instance.currentMap.returnTilesOfType(MapTile.Types.floor);

            //add a specified number of ammo packs
            for (int i = 0; i < AmmoItem.noOfAmmoToGenerate; i++)
            {
                AmmoItem a = new AmmoItem(list[Support.random.Next(0, list.Count - 1)].position);
                ammoList.Add(a);
                World.AddChild(a);
            }

            //create the quad tree
            quadTree = new QuadTree(new Vector2(MapManager.Instance.currentMap.width / 2.0f, MapManager.Instance.currentMap.height / 2.0f), new Vector2(MapManager.Instance.currentMap.width / 2.0f, MapManager.Instance.currentMap.height / 2.0f));

            //create enemies
            var tex = new Texture2D("/Application/data/tiles/enemy_sword2.png", false);

            tex.SetFilter(TextureFilterMode.Disabled);
            tex.SetWrap(TextureWrapMode.ClampToEdge);
            var texture = new TextureInfo(tex, new Vector2i(25, 1));

            //spritelist for the enemies
            enemySpriteList = new SpriteList(texture)
            {
                BlendMode = BlendMode.Normal
            };
            //spriteList.EnableLocalTransform = true;


            enemyList = new List <Enemy>();
            list      = MapManager.Instance.currentMap.returnTilesOfType(MapTile.Types.floor);

            //generate a given number of enemies
            for (int i = 0; i < BasicEnemy.noOfEnemiesToGenerate; i++)
            {
                Enemy e = new BasicEnemy(list[Support.random.Next(0, list.Count - 1)].position, texture);
                enemyList.Add(e);
                enemySpriteList.AddChild(((BasicEnemy)e).sprite);
                EffectsLayer.AddChild(e);
                quadTree.insert(e);
            }


            Foreground.AddChild(enemySpriteList);

            ui = new UI();
            Interface.AddChild(ui);


            //add an enemy spawner every second
            Sce.PlayStation.HighLevel.GameEngine2D.Scheduler.Instance.Schedule(this, (dt) => {
                list = MapManager.Instance.currentMap.returnTilesOfType(MapTile.Types.floor);
                EnemySpawnPoint esp = new EnemySpawnPoint(list[Support.random.Next(0, list.Count - 1)].position);
                World.AddChild(esp);


                ;
            }, 1.0f, false, -1);
        }