protected override void OnKeyPress(KeyPressEventArgs e)
 {
     if (CurrentScene != null)
     {
         CurrentScene.OnKeyPress(e);
     }
 }
示例#2
0
 public override void Update(GameTime gameTime)
 {
     base.Update(gameTime);
     if (m_SceneChanges.ContainsKey(CurrentScene))
     {
         foreach (SceneChange sc in m_SceneChanges[CurrentScene])
         {
             if (sc.ChangeNow(gameTime))
             {
                 m_NextScene = sc.To;
                 if (CurrentScene != null)
                 {
                     CurrentScene.OnExit();
                     StopMainTune(m_NextScene);
                     CurrentScene.StopTune();
                 }
                 CurrentScene           = m_NextScene;
                 CurrentScene.StartTime = gameTime.TotalRealTime();
                 CurrentScene.Reset();
                 CurrentScene.OnEnter();
                 CurrentScene.StartTune();
                 StartMainTune();
             }
         }
     }
 }
示例#3
0
 public void restoreCurrentSceneObjects(GamePersistence.GameLoadInitiated gameLoadEvent, bool restoreData)
 {
     IsInstantiating = true;
     CurrentScene.restoreScene(gameLoadEvent, restoreData);
     LoadStaticData();
     IsInstantiating = false;
 }
示例#4
0
 void InputManager_OnPointerWheelChanged(Vector2 position, Input.PointerType pointerType, GameTime gameTime)
 {
     lock (lockObj)
     {
         CurrentScene?.PointerWheelChanged(position, gameTime);
     }
 }
示例#5
0
 /// <summary>
 /// Draw the current scene.
 /// If the game allow virtual resolution, render it with the virtual resolution
 /// else render it normally.
 /// </summary>
 public void Draw(SpriteBatch spriteBatch, GameTime time)
 {
     if (GraphicsManager.Instance.AllowVirtualResolution)
     {
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.SetRenderTarget(GraphicsManager.Instance.RenderVirtualResolution);
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.DepthStencilState = new DepthStencilState()
         {
             DepthBufferEnable = true
         };
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Clear(Color.CornflowerBlue);
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, CameraManager.Instance.Transform);
         CurrentScene.Draw(time);
         spriteBatch.End();
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.SetRenderTarget(null);
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Clear(Color.Black);
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.PointClamp, DepthStencilState.Default, RasterizerState.CullNone, null, Matrix.CreateScale(GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / GraphicsManager.Instance.VirtualResolution.X, GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / GraphicsManager.Instance.VirtualResolution.X, 1f) * Matrix.CreateTranslation(GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Width / 2, GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Viewport.Height / 2, 0));
         spriteBatch.Draw(GraphicsManager.Instance.RenderVirtualResolution, new Vector2(0, 0), null, Color.White, 0f, new Vector2(GraphicsManager.Instance.RenderVirtualResolution.Width / 2, GraphicsManager.Instance.RenderVirtualResolution.Height / 2), 1f, SpriteEffects.None, 0f);
         spriteBatch.End();
     }
     else
     {
         GraphicsManager.Instance.GraphicsDeviceManager.GraphicsDevice.Clear(Color.CornflowerBlue);
         spriteBatch.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend, SamplerState.LinearClamp, DepthStencilState.Default, RasterizerState.CullNone);
         CurrentScene.Draw(time);
         spriteBatch.End();
     }
 }
示例#6
0
 void UpdateChapter()
 {
     if (currentScene != null)
     {
         CurrentScene.SceneUpdate();
     }
 }
示例#7
0
    void OnInitialize()
    {
        //初期起動シーン取得
        changeSceneType = CurrentScene.GetSceneType();

        CommonFSM.Instance.SendFsmEvent("INITIALIZED");
    }
示例#8
0
        private static void UpdateTransitions()
        {
            if (!transitionInProgress)
            {
                return;
            }

            if (!exitCompleted)
            {
                if (exitTransition == null)
                {
                    LoadNextScene();

                    enterTransition?.Begin();
                    exitCompleted = true;

                    if (enterTransition == null)
                    {
                        transitionInProgress = false;
                        exitCompleted        = false;
                    }
                }
                else
                {
                    exitTransition.Update();

                    if (exitTransition.Done)
                    {
                        CurrentScene.OnExit();

                        exitTransition.Reset();
                        exitTransition = null;

                        LoadNextScene();

                        enterTransition?.Begin();
                        exitCompleted = true;

                        if (enterTransition == null)
                        {
                            transitionInProgress = false;
                            exitCompleted        = false;
                        }
                    }
                }
            }
            else
            {
                enterTransition.Update();

                if (enterTransition.Done)
                {
                    enterTransition.Reset();
                    enterTransition = null;

                    transitionInProgress = false;
                    exitCompleted        = false;
                }
            }
        }
示例#9
0
        public void UnloadResources()
        {
            _loadRequestsCDC.Clear();

            if (CurrentScene != null)
            {
                CurrentScene.Dispose();
                CurrentScene = null;
            }

            if (CurrentObject != null)
            {
                CurrentObject.Dispose();
                CurrentObject = null;
            }

            while (Resources.Count > 1)
            {
                RenderResource resource = Resources[Resources.Keys[1]];
                Resources.Remove(Resources.Keys[1]);
                CurrentObject?.UpdateModels();
                CurrentScene?.UpdateModels();
                resource.Dispose();
            }
        }
示例#10
0
        private void PlayFinalScene()
        {
            string firstSceneId = GetFirstScene().Id;

            Player.ResetPlayerData(firstSceneId);
            CurrentScene.Play();
        }
示例#11
0
        static Game()
        {
            window  = new Window(1280, 720, "Run!", false);
            gravity = 400.0f;
            window.SetVSync(false);
            window.SetDefaultOrthographicSize(9);

            UnitSize    = window.Height / window.CurrentOrthoGraphicSize;
            ScreeCenter = new Vector2(window.Width / 2, window.Height / 2);

            //scenes creation
            PlayScene playScene = new PlayScene();

            //scenes config

            CurrentScene = playScene;
            CurrentScene.Start();


            string[] joysticks = window.Joysticks;

            for (int i = 0; i < joysticks.Length; i++)
            {
                if (joysticks[i] != null && joysticks[i] != "Unmapped Controller")
                {
                    NumJoysticks++;
                }
            }
        }
 private void OnMouseMove(object sender, MouseMoveEventArgs e)
 {
     if (CurrentScene != null)
     {
         CurrentScene.OnMouseMove(e);
     }
 }
 protected override void OnUpdateFrame(FrameEventArgs e)
 {
     if (CurrentScene != null)
     {
         CurrentScene.OnUpdateFrame(e);
     }
 }
 protected override void OnMouseEnter(EventArgs e)
 {
     if (CurrentScene != null)
     {
         CurrentScene.OnMouseEnter(e);
     }
 }
示例#15
0
        /// <summary>
        /// 更新処理を行う。
        /// </summary>
        public static void Update()
        {
            if (core == null)
            {
                return;
            }

            core.BeginDrawing();

            layerProfiler.Refresh();

            if (CurrentScene != null && CurrentScene.IsAlive)
            {
                CurrentScene.Update();

                foreach (var item in CurrentScene.Layers)
                {
                    layerProfiler.Record(item.Name, item.ObjectCount, item.TimeForUpdate);
                }
            }

            CommitChanges();

            if (CurrentScene != null)
            {
                CurrentScene.Draw();
            }

            transitionState.Update();
            transitionState.Draw();

            core.Draw();

            core.EndDrawing();
        }
示例#16
0
        private void LoadScene(string identifier, Dictionary <string, Object> parameters)
        {
            bool sceneFound = false;

            foreach (CEScene scene in Scenes)
            {
                foreach (ICESceneDrawable dr in scene.Drawables)
                {
                    dr.ToRemove = true;
                }

                if (scene.Identifier == identifier && !sceneFound)
                {
                    if (CurrentScene != null)
                    {
                        CurrentScene.OnQuit();
                    }

                    sceneFound = true;

                    CurrentScene = scene;

                    CurrentScene.Initialize();
                    CurrentScene.Load(parameters);
                }
            }

            if (!sceneFound)
            {
                Console.WriteLine("[CEGame] : The scene you're trying to load doesn't exist!");
            }
        }
示例#17
0
        /// <summary>
        /// Updates the particle emitter.
        /// </summary>
        /// <param name="gameTime"></param>
        public void Update(GameTime gameTime)
        {
            if (!isEmitting)
            {
                return;
            }
            Debug.Instance.AssertStrict(isLoaded, "Particle Emitter not initialized...");
            timer += Time.Instance.DeltaTime;

            int numParticles = (int)Math.Round(SpawnRate * timer);

            if (numParticles > 0)
            {
                for (int i = 0; i < numParticles; i++)
                {
                    float    scale = (float)(random.NextDouble() * (MaxScale - MinScale) + MinScale);
                    Particle p     = (Particle)Activator.CreateInstance(typeof(T), timeToLive);
                    p.Position = Holder.Position;
                    p.Scale    = new Vector2(scale, scale);
                    p.SetTexturePath(paths);
                    CurrentScene.AddObject(p);
                }
                timer = 0;
            }
        }
示例#18
0
 public void PrepareNextScene(ISceneBase Caller, ISceneBase nextscene, Dictionary <string, object> param, Dictionary <string, object> previousparam)
 {
     NextScene               = nextscene;
     NextScene.Device        = Device;
     NextScene.Sprite        = Sprite;
     NextScene.Sound         = Sound;
     NextScene.SceneManager  = this;
     NextScene.Param         = param == null ? new Dictionary <string, object>() : param;
     NextScene.PreviousParam = GlobalPool.ContainsKey(NextScene.GetType()) ? GlobalPool[NextScene.GetType()] : new Dictionary <string, object>();
     if (previousparam != null)
     {
         if (GlobalPool.ContainsKey(Caller.GetType()))
         {
             GlobalPool[Caller.GetType()] = previousparam;
         }
         else
         {
             GlobalPool.Add(Caller.GetType(), previousparam);
         }
     }
     LoadingThread = new Thread(new ThreadStart(nextscene.Load));
     LoadingThread.Start();
     CurrentScene.Dispose();
     CurrentScene = null;
 }
示例#19
0
        static Game()
        {
            window  = new Window(1280, 600, "Run!", false);
            gravity = 400.0f;
            window.SetVSync(false);

            //scenes creation
            PlayScene playScene = new PlayScene();

            //scenes config

            CurrentScene = playScene;
            CurrentScene.Start();


            string[] joysticks = Game.window.Joysticks;

            for (int i = 0; i < joysticks.Length; i++)
            {
                if (joysticks[i] != null && joysticks[i] != "Unmapped Controller")
                {
                    NumJoysticks++;
                }
            }
        }
示例#20
0
        private void CheckForMouseEvents()
        {
            var mouseData = TCODMouse.getStatus();

            if (mouseData.CellVelocityX != 0 || mouseData.CellVelocityY != 0)
            {
                CurrentScene.MouseMoved(mouseData);
            }
            if (mouseData.WheelDown || mouseData.WheelUp)
            {
                CurrentScene.MouseWheel(mouseData);
            }
            if (mouseData.LeftButton != previousMouseData.LeftButton)
            {
                CurrentScene.MouseLeftButton(mouseData);
            }
            if (mouseData.MiddleButton != previousMouseData.MiddleButton)
            {
                CurrentScene.MouseMiddleButton(mouseData);
            }
            if (mouseData.RightButton != previousMouseData.RightButton)
            {
                CurrentScene.MouseRightButton(mouseData);
            }
            previousMouseData = mouseData;
        }
示例#21
0
 public void PointerMoved(Vector2 scaledPosition, PointerType pointerType, GameTime gameTime)
 {
     lock (lockObj)
     {
         CurrentScene?.PointerMoved(scaledPosition, gameTime);
     }
 }
示例#22
0
        public void Start()
        {
            isRunning = true;
            while (isRunning)
            {
                // Check for scene change
                if (sceneChanged)
                {
                    CurrentScene = newScene;
                    newScene     = null;
                    sceneChanged = false;
                }

                // Check if the game is still running.
                if (TCODConsole.isWindowClosed() || CurrentScene == null)
                {
                    Stop();
                    break;
                }

                // Update
                CurrentScene.Update(TCODSystem.getLastFrameLength());

                // Render
                TCODConsole.root.clear();
                CurrentScene.Render(TCODSystem.getLastFrameLength());
                TCODConsole.flush();

                // Handle user input
                CheckForKeyboardEvents();
                CheckForMouseEvents();
            }
            CleanUp();
        }
示例#23
0
 void InputManager_OnKeyReleased(Microsoft.Xna.Framework.Input.Keys key, GameTime gameTime)
 {
     lock (lockObj)
     {
         CurrentScene?.KeyReleased(key, gameTime);
     }
 }
示例#24
0
文件: Food.cs 项目: maryphun/Blob
    private void Start()
    {
        renderer       = transform.GetChild(0).GetComponent <SpriteRenderer>();
        shadowRenderer = transform.GetChild(1).GetComponent <SpriteRenderer>();

        CurrentScene.Instance().RegisterNewFood(transform);
    }
示例#25
0
        public override void InitGame()
        {
            base.InitGame();
            FPS = 60;

            //var player = CurrentScene.AddChild(new TestPlayer());
            //player.PositionOffset.X = 64;
            //player.PositionOffset.Y = 64;

            var floor = CurrentScene.AddChild(new StaticBody());

            floor.PositionOffset.Y = 128;
            floor.PositionOffset.X = 512;
            floor.ScaleOffset     *= 6;
            floor.AddChild(new CollisionShape().SetAsRegularShape(7, 16));

            floor.AddChild(new StaticSprite("mario", 16, 16));
            floor.Name = "Floor";
            CurrentScene.BackgroundColor = Color.Goldenrod;

            CurrentScene.AddChildren(TileMap.LoadSceneFromFile("funni", RenderLayers.TileLayer).GetEntities());

            var tileSet = CurrentScene["Tile Layer 1"] as TileMap;

            tileSet.CollisionActive = true;
            tileSet.SetCameraBounds();
            //tileSet.ColorOffset = Color.Black;

            Input.SetAction("move_left", Keys.Left, Buttons.LeftThumbstickLeft);
            Input.SetAction("move_right", Keys.Right, Buttons.LeftThumbstickRight);
            Input.SetAction("move_up", Keys.Up, Buttons.LeftThumbstickUp);
            Input.SetAction("move_down", Keys.Down, Buttons.LeftThumbstickDown);
            Input.SetAction("fire", Keys.Space, Buttons.A);
            Input.SetAction("ShowPhysics", Keys.F, Buttons.B);
        }
示例#26
0
文件: Food.cs 项目: maryphun/Blob
    // Update is called once per frame
    void Update()
    {
        lastingTime -= Time.deltaTime;

        if (lastingTime <= 1.0f)
        {
            // update transparent
            Color tmp = renderer.color;
            tmp.a          = lastingTime;
            renderer.color = tmp;

            tmp   = shadowRenderer.color;
            tmp.a = lastingTime;
            if (shadowRenderer.color.a > tmp.a)
            {
                shadowRenderer.color = tmp;
            }


            if (lastingTime <= 0.0f)
            {
                CurrentScene.Instance().UnregisterFood(transform);
                Destroy(gameObject);
            }
        }
    }
示例#27
0
    public SaveableScene prepareNextScene(string sceneName, List <IRestorableGameObject> transferToNextScene, bool loadScene = true)
    {
        SaveableScene result = getScene(sceneName);

        FirstTimeSceneLoaded = !loadScene;
        ///check if the scene is loaded already
        if (result == null)
        {
            ///if the scene was not loaded, check if it is even existing as a file in the game folder
            if (sceneExists(sceneName))
            {
                ///if the scene exists in a file load it
                result = GameDataController.LoadSaveable <SaveableScene>(FolderSystem.getSceneSavePath(GameName, sceneName));
                /////create new Scene list. Since its marked as "NonSerialized" its null after loading
                //AllScenes = new List<SaveableScene>();
                addScene(result);
            }
            else
            {
                ///if the scene doesnt exist in file, create a new scene
                result = addNewScene(sceneName);
                ///since the scene was not existing already, "KeepExistingObjects"
                ///is set to true, as the scene objects
                ///should not be deleted when first entering a scene
                FirstTimeSceneLoaded = true;
            }
        }
        CurrentScene = result;
        CurrentScene.initiateLoadedScene();

        CurrentScene.TransferedObjectTree = transferToNextScene;
        return(result);
    }
示例#28
0
    /// <summary>
    /// Called when the scene changes and things need to update on scene change
    /// </summary>
    /// <param name="scene">the new scene</param>
    /// <param name="mode">loaded scene mode</param>
    void OnLevelLoaded(Scene scene, LoadSceneMode mode)
    {
        //update event system axis
        InputManager.Instance.UpdateEventSystemAxis();

        //get scene reference
        CurrentScene = sceneDict.Keys.First(t => sceneDict[t] == scene.name);

        //change soundtracks if needed
        if (soundtrackDict.ContainsKey(CurrentScene))
        {
            if (!(soundtrackDict[CurrentScene] == AudioManager.Instance.WhatMusicIsPlaying()))
            {
                AudioManager.Instance.PlayMusic(soundtrackDict[CurrentScene]);
            }
        }
        else
        {
            Debug.Log("MySceneManager sountrackDict does not contain key " + CurrentScene.ToString() + " for changing sountracks!");
            AudioManager.Instance.StopMusic();
        }

        //set the editor status if the scene is the level editor
        //if (CurrentScene == Scenes.LevelEditor)
        //{
        //    GameManager.Instance.IsLevelEditor = true;
        //    Debug.Log("level editor scene");
        //}
    }
示例#29
0
    //public bool _thisIsIntro;
    //public bool _thisIsMain;
    //public bool _thisIsEnd;

    //public static bool _thisIsTheIntroScene;
    //public static bool _thisIsTheMainScene;
    //public static bool _thisIsTheEndScene;


    //public GameObject _playerIntro;
    //public GameObject _playerMain;
    //public GameObject _introSceneLoadObj;
    //public GameObject _mainSceneLoadObj;
    //public GameObject _endSceneLoadObj;

    //public static GameObject _introSceneLoad;
    //public static GameObject _mainSceneLoad;
    //public static GameObject _endSceneLoad;

    //public GameObject _menuObj;

    //public GameObject _escapeHouseText;


    private void Awake()
    {
        _introEnvironment = _introEnvironmentObj;
        _introSceneTimer  = _introSceneTimerCounter;

        _logoSceneTimer = _logoSceneTimerCounter;

        _sceneToLoad = _sceneToLoadObj;

        _currentSceneStatic = _currentScene;

        //_introSceneLoad = _introSceneLoadObj;
        //_mainSceneLoad = _mainSceneLoadObj;
        //_endSceneLoad = _endSceneLoadObj;

        //_thisIsTheIntroScene = _thisIsIntro;
        //_thisIsTheMainScene = _thisIsMain;
        //_thisIsTheEndScene = _thisIsEnd;
        //XRSettings.eyeTextureResolutionScale = 1.8f;

        if (_currentSceneStatic == CurrentScene.logoScene)
        {
            StartCoroutine(StartLogo());
        }

        if (_currentSceneStatic == CurrentScene.introScene)
        {
            _introEnvironment.SetActive(false);
        }

        instance = this;
    }
 private void OnMouseButtonDown(object sender, MouseButtonEventArgs e)
 {
     if (CurrentScene != null)
     {
         CurrentScene.OnMouseButtonDown(e);
     }
 }