void Update() { PlayerController pc = GlobalGameState.GetPlayerController(); if (!pc) { return; } if (InputMsg.isFocused) { pc.isOnChat = true; // only for window or pc #if UNITY_STANDALONE_WIN || UNITY_STANDALONE_OSX if (Input.GetKey(KeyCode.Return)) { OnClickSendBtn(); } #endif } else { pc.isOnChat = false; } }
public void Collect() { PlaySound(); Hide(); GlobalGameState.CollectCoin(gameObject); Destroy(gameObject, 1f); }
public void KillerDie() { CharacterObject.Die(); bool IsByPlayerWill = false; GlobalGameState.LeaveGame(IsByPlayerWill); }
/// <summary> /// LoadContent will be called once per game and is the place to load /// all of your content. /// </summary> protected override void LoadContent() { Log.EnableConsoleLog = true; Log.SendMessage("CLR: " + Environment.Version); Log.SendMessage("Machine Name: " + Environment.MachineName); Log.SendMessage("RAM for process (bytes): " + Environment.WorkingSet); Log.SendMessage("Number of processors: " + Environment.ProcessorCount); Log.SendMessage("OS x64: " + Environment.Is64BitOperatingSystem); Log.SendMessage("Process x64: " + Environment.Is64BitProcess); Log.SendMessage("OS: " + Environment.OSVersion.VersionString); //Log.EnableFileLog = true; Config.LoadConfigFile(); ScreenWidth = Window.ClientBounds.Width; ScreenHeight = Window.ClientBounds.Height; LoadingBr = new ScreenBr(new Vector2(ScreenWidth, ScreenHeight), 60, 255, GraphicsDevice, 0.001f); LoadingBr.CurrentFrame = 59; // Create a new SpriteBatch, which can be used to draw textures. spriteBatch = new SpriteBatch(GraphicsDevice); GameContent.LoadGameContent(); _GlobalState = GlobalGameState.MainMenu; mainMenu = new MainMenu(new Vector2(ScreenWidth, ScreenHeight), GameContent.UI_MainMenu_LogIn_BackGround, GameContent.UI_MainMenu_LogIn_Button, GameContent.UI_MainMenu_LogIn_EditBox, GameContent.UI_MainMenu_LogIn_ConnIcon, GameContent.UI_MainMenu_MenuBar, GameContent.UI_MainMenu_Button, GameContent.UI_MainMenu_HomeButton, GameContent.UI_MainMenu_MoneyBack, GameContent.UI_MainMenu_RollBack, GameContent.UI_MainMenu_NameBack, GameContent.UI_InfoFont, Color.Black, GraphicsDevice, this, 0.1f); //gameState = new GameState(ScreenWidth, ScreenHeight, GraphicsDevice); KeyBindings.RegisterKeyBind("KEY_MENU", Keys.Escape); Menu = new GameMenu(new Vector2(ScreenWidth, ScreenHeight), this, GameContent.UI_GameMenu_MainBack, GameContent.UI_GameMenu_OptionsBack, GameContent.UI_GameMenu_Button, GameContent.UI_GameMenu_ListBoxBtn, GameContent.UI_GameMenu_ListBoxChoosed, GameContent.UI_GameMenu_ListBoxOpenBtn, GameContent.UI_InfoFont, Color.Black, 0.1f); Menu.Hide(null, gameState, null); }
void Update() { // Change new position by the velocity magnitude (in the direction of transform.forward) and since // we are in the update function we need to multiply by deltatime. _newPos += transform.forward * _velocity.magnitude * Time.deltaTime; // SDet direction to the difference between new position and old position Vector3 _direction = _newPos - _oldPos; // Get the distance which is the magnitude of the direction vector float _distance = _direction.magnitude; // If distance is greater than nothing... if (_distance > 0) { // Define a RayCast RaycastHit _hit; // If the raycast from previous position in the specified direction at (or before) the distance... if (Physics.Raycast(_oldPos, _direction, out _hit, _distance)) { // and if the transform we hit isn't a the ship that fired the weapon and the collider isn't just a trigger... if (_hit.transform != firedBy && !_hit.collider.isTrigger) { // Set the rotation of the impact effect to the normal of the impact surface (we wan't the impact effect to // throw particles out from the object we just hit... Quaternion _rotation = Quaternion.FromToRotation(Vector3.up, _hit.normal); // Instantiate the imapct effect at impact position Instantiate(impactEffect, _hit.point, _rotation); if (!isLocal) { // Trigger the hit on the server GlobalGameState.OnHitObject( this, new GlobalGameState.HitObjectArgs() { hitStrength = 1, hitRaycast = _hit, weaponObject = this.transform, explosionEffect = this.explosionEffect }); } else { // If random number is a small value... if (Random.Range(0, 20) < 2) { // Instantiate the explosion effect at the point of impact Instantiate(explosionEffect, _hit.transform.position, _rotation); // Destroy the game object that we just hit Destroy(_hit.transform.gameObject); } } // Destroy the laser shot game object (on the client too) Destroy(gameObject); } } } // Set the old position tho the current position _oldPos = transform.position; // Set the actual position to the new position transform.position = _newPos; }
public IEnumerator spawnTimers() { while (true) { GlobalGameState state = GameObject.Find("GlobalState").GetComponent <GlobalGameState>(); spawn(); yield return(new WaitForSeconds(state.getSpawnTime())); } }
private void GoToState(GlobalGameState toState) { if (_currentGameState != toState) { print("Going to state " + toState.ToString()); onStateEnter(toState); _currentGameState = toState; } }
void OnTriggerEnter(Collider other) { if (!GlobalGameState.IsPlayerDead && other.gameObject.transform.parent.gameObject.GetComponent <CarController>()) { GlobalGameState.IsPlayerDead = true; Destroy(other.gameObject.transform.parent.gameObject); GlobalGameState.CreateCarLocalGameCar(Vector3.zero); // 0,0,0 re spawn pos is default temp } }
public void Die() { //GlobalGameState.LogText.text = killername + " killed " + gameObject.name; GameObject particleGO = Instantiate(GlobalGameState.KillerDieFX, gameObject.transform.position, Quaternion.identity); if (particleGO && particleGO.GetComponent <ParticleSystem> ()) { particleGO.GetComponent <ParticleSystem> ().Play(); } GlobalGameState.RemoveUser(id); }
public void LeaveRoom() { SocketIOComp.Emit("SERVER:LEAVE"); //GlobalGameState.Disconnect (); GlobalGameState.HandleLeaveGame(); GlobalGameState.HideAllUI(); GlobalGameState.LoginUI.Show(); // set spectate cam on! GlobalGameState.SpectateCam.gameObject.SetActive(false); }
void OnDestroy() { if (networkView.isMine) { // Invoke the event on the controller to respawn me. GlobalGameState.OnPlayerDied(this, new System.EventArgs()); } // Remove this object from the radar, it will be re-added with a respawn if (GlobalGameState.MainRadar != null) { GlobalGameState.MainRadar.RemoveRadarBlip(gameObject); } }
private void onStateEnter(GlobalGameState stateBeingEntered) { if (stateBeingEntered == GlobalGameState.WAIT_TO_BEGIN) { PlaySpaceRoot.gameObject.SetActive(false); AudioManager.Instance.PlayMusic(AudioLibrary.Instance.SplashScreenMusic); } else if (stateBeingEntered == GlobalGameState.PLACE_ELEVATOR) { AudioManager.Instance.StopMusic(); AudioManager.Instance.PlayAmbient(AudioLibrary.Instance.AmbientIntro); AudioManager.Instance.PlayNarrative(AudioLibrary.Instance.NarrativePlaceElevator); } else if (stateBeingEntered == GlobalGameState.SELECT_EXERCISE) { AudioManager.Instance.PlaySoundEffect(AudioLibrary.Instance.ElevatorDoorOpen); AudioManager.Instance.PlayNarrative(AudioLibrary.Instance.NarrativeWelcomeGreeting, 4.3f); StartCoroutine(delayedAnimation(ElevatorDoor, "ElevatorDoorCloseNew", 4.3f)); } else if (stateBeingEntered == GlobalGameState.NICE) { AudioManager.Instance.PlayNarrative(AudioLibrary.Instance.ChosenItem); AudioManager.Instance.PlaySoundEffect(AudioLibrary.Instance.TorsoTransition); } else if (stateBeingEntered == GlobalGameState.PLACE_ELECTRODES) { AudioManager.Instance.PlayNarrative(AudioLibrary.Instance.SensorIntroduction1); } else if (stateBeingEntered == GlobalGameState.PLACE_ELECTRODES_2) { AudioManager.Instance.PlayNarrative(AudioLibrary.Instance.SensorIntroduction2); StartCoroutine(delayedAnimation(ElevatorDoor, "ElevatorDoorOpenNew", 0f)); } else if (stateBeingEntered == GlobalGameState.ROCKET_TRANSITION) { MenuScene.Play("HumanTubeLower"); Rocket.gameObject.SetActive(true); Rocket.transform.localPosition = Vector3.zero; StartCoroutine(delayedAnimation(ElevatorDoor, "ElevatorDoorCloseNew", 1.5f)); AudioManager.Instance.PlayNarrative(AudioLibrary.Instance.SensorSet); AudioManager.Instance.PlaySoundEffect(AudioLibrary.Instance.ElevatorDoorOpen); } else if (stateBeingEntered == GlobalGameState.LAUNCH_ROCKETS) { AudioManager.Instance.PlaySoundEffect(AudioLibrary.Instance.CrowdHospitalWaiting); AudioManager.Instance.PlayAmbient(AudioLibrary.Instance.IndustrialSpaces); RocketLaunchMiniGame.Instance.StartMiniGame(); } }
// Update is called once per frame void Update() { status = GameObject.Find("GlobalState").GetComponent <GlobalGameState>(); if (status.gameOver == false) { if (right) { transform.position -= new Vector3(speed, 0, 0); } else { transform.position += new Vector3(speed, 0, 0); } } }
public static void ChangeLevel(string levelName) { int level = Array.IndexOf(Levels, levelName); if (level == -1) { print("Can't change level to " + level); print("Going to next level"); NextLevel(); return; } print("Changing level to Level=" + levelName); GlobalGameState.CurrentLevel = levelName; GlobalGameState.EnableSceneListener(); SceneManager.LoadScene(levelName); }
public void LeaveGame(bool IsByPlayerWill) { SocketIOComp.Emit("SERVER:LEAVE_GAME"); //GlobalGameState.Disconnect (); GlobalGameState.HandleLeaveGame(); GlobalGameState.HideAllUI(); if (IsByPlayerWill) { GlobalGameState.LobbyUI.ResetLobbyState(); } GlobalGameState.LobbyUI.Show(); GlobalGameState.GameUI.ShowWithOption(GameUIController.GameUIState.Lobby); // set spectate cam on! GlobalGameState.SpectateCam.gameObject.SetActive(true); }
public void OnCollisionEnter2D(Collision2D collision) { GlobalGameState state = GameObject.Find("GlobalState").GetComponent <GlobalGameState>(); if (collision.gameObject.name.Equals("wave(Clone)")) { wave w = collision.gameObject.GetComponent <wave>(); if (state.colorId != w.waveID) { GameObject.Find("Miss").GetComponent <AudioSource>().Play(); state.hits++; if (state.hits == 1) { GameObject.Find("lose4").GetComponent <RectTransform>().localScale = new Vector3(0.10463f, 0.10463f, 0.10463f); } else if (state.hits == 2) { GameObject.Find("lose3").GetComponent <RectTransform>().localScale = new Vector3(0.10463f, 0.10463f, 0.10463f); } else if (state.hits == 3) { GameObject.Find("lose2").GetComponent <RectTransform>().localScale = new Vector3(0.10463f, 0.10463f, 0.10463f); } else if (state.hits == 4) { GameObject.Find("lose1").GetComponent <RectTransform>().localScale = new Vector3(0.10463f, 0.10463f, 0.10463f); } } else { state.score += 100 + (int)((10 * state.getSpeed()) / state.getSpawnTime()); } Destroy(collision.gameObject); if (state.hits == 4) { state.gameOver = true; GameObject.Find("Sounds").GetComponent <AudioSource>().Pause(); GameObject.Find("Boo").GetComponent <AudioSource>().Play(); Invoke("gameOver", 0.1f); } } }
public void Kill(string killername) { GlobalGameState.LogText.text = killername + " killed " + gameObject.name; GameObject particleGO; if (!IsNPC) { particleGO = Instantiate(GlobalGameState.BlenderPlayerKillFX, gameObject.transform.position, Quaternion.identity); } else { particleGO = Instantiate(GlobalGameState.BlenderNPCKillFX, gameObject.transform.position, Quaternion.identity); } if (particleGO && particleGO.GetComponent <ParticleSystem> ()) { particleGO.GetComponent <ParticleSystem> ().Play(); } GlobalGameState.RemoveUser(id); }
public void Update() { _ending = ApplicationState.Ending; if (_ending != NoEnding) { if (!_endingActive) { _endingActive = true; ToggleCameras(); RunEnding(); } if (Input.GetButtonDown("Jump")) { RestartGame(); } if (Input.GetKey(KeyCode.Escape)) { GlobalGameState.LoadMainMenu(); } } }
protected abstract Task InternalSaveAsync(GlobalGameState gameState);
public async Task SaveAsync(GlobalGameState gameState) { await InternalSaveAsync(gameState); }
public void StartGame() { GlobalGameState.RestartGame(); }
public void GoToTitleScreen() { GlobalGameState.LoadMainMenu(); }
public void LeaveGame() { bool IsByPlayerWill = true; GlobalGameState.LeaveGame(IsByPlayerWill); }
void spawn() { int rand = (int)Random.Range(0, 6); GlobalGameState state = GameObject.Find("GlobalState").GetComponent <GlobalGameState>(); cloneLeft = null; cloneRight = null; switch (rand) { case 0: //purple cloneRight = Instantiate(toClone, spawnRight, Quaternion.identity) as GameObject; //cloneLeft.GetComponent<SpriteRenderer>().color = purple; cloneRight.GetComponent <SpriteRenderer>().color = purple; break; case 1: //yellow cloneLeft = Instantiate(toClone, spawnLeft, Quaternion.identity) as GameObject; cloneLeft.GetComponent <SpriteRenderer>().color = yellow; //cloneRight.GetComponent<SpriteRenderer>().color = yellow; break; case 2: //red cloneLeft = Instantiate(toClone, spawnLeft, Quaternion.identity) as GameObject; cloneLeft.GetComponent <SpriteRenderer>().color = red; //cloneRight.GetComponent<SpriteRenderer>().color = red; break; case 3: //blue cloneLeft = Instantiate(toClone, spawnLeft, Quaternion.identity) as GameObject; cloneLeft.GetComponent <SpriteRenderer>().color = blue; //cloneRight.GetComponent<SpriteRenderer>().color = blue; break; case 4: //green cloneRight = Instantiate(toClone, spawnRight, Quaternion.identity) as GameObject; //cloneLeft.GetComponent<SpriteRenderer>().color = green; cloneRight.GetComponent <SpriteRenderer>().color = green; break; case 5: //orange cloneRight = Instantiate(toClone, spawnRight, Quaternion.identity) as GameObject; //cloneLeft.GetComponent<SpriteRenderer>().color = orange; cloneRight.GetComponent <SpriteRenderer>().color = orange; break; } if (cloneLeft != null) { cloneLeft.AddComponent <waveMove>(); cloneLeft.GetComponent <waveMove>().right = false; cloneLeft.GetComponent <waveMove>().speed = state.getSpeed(); cloneLeft.transform.Rotate(0, 180, 0); cloneLeft.GetComponent <wave>().waveID = rand; } if (cloneRight != null) { cloneRight.AddComponent <waveMove>(); cloneRight.GetComponent <waveMove>().right = true; cloneRight.GetComponent <waveMove>().speed = state.getSpeed(); cloneRight.GetComponent <wave>().waveID = rand; } }
// ReSharper disable once MemberCanBeMadeStatic.Local // @bhaertlein - Methods provided to UnityEngine.Invoke() can not be `static` private void TrueDeath() { GlobalGameState.PlayerDeath(); }
public void Hide() { gameObject.SetActive(false); GlobalGameState.ResumeGame(); }
/// <summary> /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. /// </summary> /// <param name="gameTime">Provides a snapshot of timing values.</param> protected override void Update(GameTime gameTime) { if (Window.ClientBounds.Width != ScreenWidth || Window.ClientBounds.Height != ScreenHeight) { ScreenWidth = Window.ClientBounds.Width; // TODO: ON RESIZE ScreenHeight = Window.ClientBounds.Height; if (gameState != null) { gameState.Resize(ScreenWidth, ScreenHeight); } } MouseControl.Update(); KeyBindings.Update(); if (mainMenu != null && _GlobalState == GlobalGameState.MainMenu) { Menu.Update(null, null, mainMenu); mainMenu.Update(Menu); } if (gameState != null && _GlobalState == GlobalGameState.Game) { Menu.Update(gameState.UI, gameState, mainMenu); gameState.Update(Menu); } else { Menu.Update(null, gameState, mainMenu); } //Window.Title = gameState.watch.Elapsed.ToString() + "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y) + "|ZOOM|" + gameState.cam.Zoom.ToString() + "|POS|" + gameState.cam.Position.ToString(); Window.Title = "|--|" + Convert.ToString(Mouse.GetState().X) + "||" + Convert.ToString(Mouse.GetState().Y); LoadingBr.UpdateAnims(); if (IsLoadToGame) { LoadingIterations++; if (LoadingIterations == 60) { _GlobalState = GlobalGameState.Game; LoadingBr.ScreenBrUp(); } if (LoadingIterations == 120) { IsLoadToGame = false; } } if (IsLoadToMenu) { LoadingIterations++; if (LoadingIterations == 60) { _GlobalState = GlobalGameState.MainMenu; mainMenu.ReturnFromGame(); gameState = null; LoadingBr.ScreenBrUp(); } if (LoadingIterations == 120) { IsLoadToMenu = false; } } base.Update(gameTime); }
// Update is called once per frame void Update() { GlobalGameState state = GameObject.Find("GlobalState").GetComponent <GlobalGameState>(); Color updateColor = Color.white; //keypresses if (Input.GetKeyDown("a")) { lastKey = "a"; keysPressed[0] = true; } else if (Input.GetKeyDown("s")) { lastKey = "s"; keysPressed[1] = true; } else if (Input.GetKeyDown("d")) { lastKey = "d"; keysPressed[2] = true; } else if (Input.GetKeyDown("j")) { lastKey = "j"; keysPressed[3] = true; } else if (Input.GetKeyDown("k")) { lastKey = "k"; keysPressed[4] = true; } else if (Input.GetKeyDown("l")) { lastKey = "l"; keysPressed[5] = true; } //key ups if (Input.GetKeyUp("a")) { keysPressed[0] = false; } else if (Input.GetKeyUp("s")) { keysPressed[1] = false; } else if (Input.GetKeyUp("d")) { keysPressed[2] = false; } else if (Input.GetKeyUp("j")) { keysPressed[3] = false; } else if (Input.GetKeyUp("k")) { keysPressed[4] = false; } else if (Input.GetKeyUp("l")) { keysPressed[5] = false; } if (!Input.anyKey) { lastKey = " "; } updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), updateColor, false); updateOpacity(GameObject.Find("lightRed").GetComponent <SpriteRenderer>(), updateColor, false); updateOpacity(GameObject.Find("lightYellow").GetComponent <SpriteRenderer>(), updateColor, false); updateOpacity(GameObject.Find("lightBlue").GetComponent <SpriteRenderer>(), updateColor, false); updateOpacity(GameObject.Find("lightGreen").GetComponent <SpriteRenderer>(), updateColor, false); updateOpacity(GameObject.Find("lightOrange").GetComponent <SpriteRenderer>(), updateColor, false); updateOpacity(GameObject.Find("lightPurple").GetComponent <SpriteRenderer>(), updateColor, false); switch (lastKey) { case "a": if (keysPressed[0] == true) { updateColor = red; updateOpacity(GameObject.Find("lightRed").GetComponent <SpriteRenderer>(), updateColor, true); updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), redS, true); state.colorId = 2; } break; case "s": if (keysPressed[1] == true) { updateColor = yellow; updateOpacity(GameObject.Find("lightYellow").GetComponent <SpriteRenderer>(), updateColor, true); updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), yellowS, true); state.colorId = 1; } break; case "d": if (keysPressed[2] == true) { updateColor = blue; updateOpacity(GameObject.Find("lightBlue").GetComponent <SpriteRenderer>(), updateColor, true); updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), blueS, true); state.colorId = 3; } break; case "j": if (keysPressed[3] == true) { updateColor = green; updateOpacity(GameObject.Find("lightGreen").GetComponent <SpriteRenderer>(), updateColor, true); updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), greenS, true); state.colorId = 4; } break; case "k": if (keysPressed[4] == true) { updateColor = orange; updateOpacity(GameObject.Find("lightOrange").GetComponent <SpriteRenderer>(), updateColor, true); updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), orangeS, true); state.colorId = 5; } break; case "l": if (keysPressed[5] == true) { updateColor = purple; updateOpacity(GameObject.Find("lightPurple").GetComponent <SpriteRenderer>(), updateColor, true); updateOpacity(GameObject.Find("lightMain").GetComponent <SpriteRenderer>(), purpleS, true); state.colorId = 0; } break; case " ": state.colorId = 6; break; } }
public void LeaveRoom() { GlobalGameState.LeaveRoom(); }
private void RestartGame() { ApplicationState.Ending = 0; _endingActive = false; GlobalGameState.RestartGame(); }