Ejemplo n.º 1
0
        public override void Start()
        {
            base.Start();

            AudioManager.InitPlayScene();
            //AudioManager.Load();

            //GfxManager.Load(); fatto in Game
            IsLoadingCheckpoint = false;
            IsPaused            = false;
            Player = null;

            Rect.Debug              = false;
            Circle.Debug            = false;
            PhysicsManager.RayDebug = false;

            Vector2 screenCenter = new Vector2(Game.Window.Width / 2, Game.Window.Height / 2);

            CameraManager.Init(screenCenter, screenCenter);
            CameraManager.AddCamera("GUI", 0f);

            PhysicsManager.Init();
            GuiManager.Init();
            ItemPickableManager.Init();
            BackgroundManager.Init(new Vector2(0, -158));

            GfxManager.LoadTiledMap("Assets/Tiles/level.tmx");

            // CameraManager.mainCamera.position = Player.Position;  //togliere
            CameraManager.SetTarget(Player);

            AudioManager.SetDefaultClipBackground("defaultClipBackground");
        }
Ejemplo n.º 2
0
        public Bar(Vector2 position, string textureName = "playerBar", float maxValue = 100, int height = 0) : base(position, textureName, DrawManager.Layer.GUI)
        {
            barWidth = texture.Width;
            value    = MaxValue = maxValue;
            //sprite.scale = new Vector2(texture.Width, 1);

            frameTexture   = GfxManager.GetSpritesheet("barFrame").Item1;
            frame          = new Sprite(frameTexture.Width, frameTexture.Height);
            frame.position = position;
        }
Ejemplo n.º 3
0
        public Circle(Vector2 offset, RigidBody owner, float ray)
        {
            relativePosition = offset;
            RigidBody        = owner;
            Ray = ray;

            if (Debug)
            {
                IsActive       = true;
                circleCollider = new Sprite(ray * 2, ray * 2);
                texture        = GfxManager.GetSpritesheet("circle").Item1;
                Layer          = DrawManager.Layer.Foreground;
                DrawManager.AddItem(this);
                UpdateManager.AddItem(this);
            }
        }
Ejemplo n.º 4
0
        public Rect(Vector2 offset, RigidBody owner, float width, float height)
        {
            relativePosition = offset;
            RigidBody        = owner;
            HalfWidth        = width / 2;
            HalfHeight       = height / 2;

            if (Debug)
            {
                IsActive     = true;
                rectCollider = new Sprite(width, height);
                texture      = GfxManager.GetSpritesheet("rectangle").Item1;
                Layer        = DrawManager.Layer.Foreground;
                DrawManager.AddItem(this);
                UpdateManager.AddItem(this);
            }
        }
Ejemplo n.º 5
0
        public GameObject(
            Vector2 spritePosition, string spriteSheetName,
            DrawManager.Layer drawLayer = DrawManager.Layer.Playground)
        {
            Tuple <Texture, List <Animation> > ss = GfxManager.GetSpritesheet(spriteSheetName);

            texture    = ss.Item1;
            animations = ss.Item2;
            Animation  = animations[0];
            sprite     = new Sprite(Animation.FrameWidth, Animation.FrameHeight);
            //texture = GfxManager.GetTexture(textureName);
            //sprite = new Sprite(spriteWidth>0 ? spriteWidth : texture.Width, spriteHeight>0 ? spriteHeight : texture.Height);
            sprite.position = spritePosition;
            sprite.pivot    = new Vector2(Width / 2, Height / 2);
            //Animation = new Animation((int)sprite.Width, (int)sprite.Height, cols, rows, fps, loop);
            layer    = drawLayer;
            IsActive = true;
            UpdateManager.AddItem(this);
            DrawManager.AddItem(this);
            GameManager.Destoyables.Add(this);
        }
Ejemplo n.º 6
0
        private void CreateTextures()
        {
            int numLevel = 3;

            textures = new Texture[numLevel];

            for (int i = 0; i < numLevel; i++)
            {
                switch ((Level)i)
                {
                case Level.FIRST:
                    textures[i] = GfxManager.GetSpritesheet("akuFirstLevel").Item1;
                    break;

                case Level.SECOND:
                    textures[i] = GfxManager.GetSpritesheet("akuSecondLevel").Item1;
                    break;

                case Level.THIRD:
                    textures[i] = GfxManager.GetSpritesheet("akuSecondLevel").Item1;
                    break;
                }
            }
        }
Ejemplo n.º 7
0
        public static void Play()
        {
            AudioManager.InitClips();
            AudioManager.Load();
            GfxManager.Load();

            Scene logoScene = new LogoScene();
            Scene menuScene = new MenuScene();

            Scene playScene = new PlayScene();
            Scene gameOver  = new GameOverScene();

            logoScene.NextScene = menuScene;
            menuScene.NextScene = playScene;

            playScene.PreviousScene = menuScene;
            playScene.NextScene     = gameOver;

            gameOver.NextScene = null;

            CurrScene = logoScene;

            CurrScene.Start();

            while (Window.IsOpened)
            {
                //float fps = 1 / Window.deltaTime;
                //Console.SetCursorPosition(0, 0);
                //if (fps < 59)
                //    Console.Write((1 / Window.deltaTime) + "                   ");

                //Input
                InputManager.Update();

                if (Window.GetKey(KeyCode.Esc))
                {
                    break;
                }

                if (!CurrScene.IsPlaying)
                {
                    if (SceneToLoad == SceneLoad.Next)
                    {
                        if (CurrScene.NextScene != null)
                        {
                            CurrScene.OnExit();
                            CurrScene = CurrScene.NextScene;
                            CurrScene.Start();
                        }
                        else
                        {
                            return;
                        }
                    }
                    else
                    {
                        if (CurrScene.PreviousScene != null)
                        {
                            CurrScene.OnExit();
                            CurrScene = CurrScene.PreviousScene;
                            CurrScene.Start();
                            SceneToLoad = SceneLoad.Next;
                        }
                        else
                        {
                            return;
                        }
                    }
                }

                CurrScene.Input();
                CurrScene.Update();
                CurrScene.Draw();

                Window.Update();
            }
        }