protected override void OnKeyPress(KeyPressEventArgs e) { if (CurrentScene != null) { CurrentScene.OnKeyPress(e); } }
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(); } } } }
public void restoreCurrentSceneObjects(GamePersistence.GameLoadInitiated gameLoadEvent, bool restoreData) { IsInstantiating = true; CurrentScene.restoreScene(gameLoadEvent, restoreData); LoadStaticData(); IsInstantiating = false; }
void InputManager_OnPointerWheelChanged(Vector2 position, Input.PointerType pointerType, GameTime gameTime) { lock (lockObj) { CurrentScene?.PointerWheelChanged(position, gameTime); } }
/// <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(); } }
void UpdateChapter() { if (currentScene != null) { CurrentScene.SceneUpdate(); } }
void OnInitialize() { //初期起動シーン取得 changeSceneType = CurrentScene.GetSceneType(); CommonFSM.Instance.SendFsmEvent("INITIALIZED"); }
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; } } }
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(); } }
private void PlayFinalScene() { string firstSceneId = GetFirstScene().Id; Player.ResetPlayerData(firstSceneId); CurrentScene.Play(); }
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); } }
/// <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(); }
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!"); } }
/// <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; } }
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; }
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++; } } }
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; }
public void PointerMoved(Vector2 scaledPosition, PointerType pointerType, GameTime gameTime) { lock (lockObj) { CurrentScene?.PointerMoved(scaledPosition, gameTime); } }
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(); }
void InputManager_OnKeyReleased(Microsoft.Xna.Framework.Input.Keys key, GameTime gameTime) { lock (lockObj) { CurrentScene?.KeyReleased(key, gameTime); } }
private void Start() { renderer = transform.GetChild(0).GetComponent <SpriteRenderer>(); shadowRenderer = transform.GetChild(1).GetComponent <SpriteRenderer>(); CurrentScene.Instance().RegisterNewFood(transform); }
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); }
// 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); } } }
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); }
/// <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"); //} }
//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); } }