// Use this for initialization void Start() { gManager = GameObject.Find("GameManager").GetComponent <Game_Manager>(); source = GetComponent <AudioSource>(); currentHP = maxHP; UpdateHealthBar(); animator.SetInteger("State", 0); StartCoroutine("Sounds"); collider.tag = "Zombie"; player_transform = gManager.GetComponent <Game_Manager>().player; base.Despawn(); }
// Use this for initialization void Start() { handManager = gameObject.GetComponent <HandManager>(); gameManager = gameObject.GetComponent <Game_Manager>(); stateMachine = gameObject.GetComponent <StateMachine>(); fieldManager = gameManager.GetComponent <FieldManager>(); cardsToReshuffle = new List <GameObject>(); selectorsShown = false; selectorBaseScale = availableSelection.transform.localScale; }
public IEnumerator AgentTalk() { agent_call = false; audio_sim.Play(); yield return(new WaitForSeconds(20)); agent_talk = false; audio_sim.Stop(); if (!Game_Manager.night_state) { Game_Manager.GetComponent <Canvas>().CivilianHelped(); } }
// Helper / Util methods private void HandleRespawn() { // We've been teleported to the new position on respawn if (Time.realtimeSinceStartup >= fadeTimer + timeToFade / 2 && fadeTimer != 0) { transform.position = determineRespawnPos(spawnPos.position, 15); // Set player pos to current respawn point Camera_Manager cm = manager.GetComponent <Camera_Manager>(); cm.DeactivateAllCameras(); fadeTimer = -1; cameraRespawnLookingAtPlayer.SetActive(true); } if (Time.realtimeSinceStartup >= fadeTimer + timeToFade && fadeTimer == -1) { fadeTimer = 0; Time.timeScale = 1; state = PLAYER_STATE.ALIVE; // Finally set us back to alive } }
IEnumerator I_InitGame() { #region Debug.Log( "Game Mode : " + PlayerPrefs.GetString("Which_GameMode") + "\nHowManyPlayers : " + PlayerPrefs.GetInt("HowManyPlayers") + "\nDifficulty : " + PlayerPrefs.GetInt("DifficultyChoise") + "\nCar 01 : " + PlayerPrefs.GetInt("Player_0_CarLastSelection") + "\nCar 02 : " + PlayerPrefs.GetInt("Player_1_CarLastSelection") + "\nCar 03 : " + PlayerPrefs.GetInt("Player_2_CarLastSelection") + "\nCar 03 : " + PlayerPrefs.GetInt("Player_3_CarLastSelection")); // --> Find car on scene GameObject[] arrCars = GameObject.FindGameObjectsWithTag("Car"); foreach (GameObject carFind in arrCars) // if there are cars on scene delete them before creating the needed car for this race { if (carFind.GetComponent <CarController> ()) { carFind.gameObject.SetActive(false); Destroy(carFind); } } if (PlayerPrefs.GetString("Which_GameMode") == "Championship") // Championship: Select AI difficulty for current track { championshipM championshipManager = GameObject.Find("championshipManager").GetComponent <championshipM>(); int newDifficulty = championshipManager.champInventory.listOfChampionship[championshipManager.currentSelectedChampionship].AI_Difficulty[championshipManager.currentTrackInTheList]; PlayerPrefs.SetInt("DifficultyChoise", newDifficulty); } if (PlayerPrefs.GetString("Which_GameMode") == "Arcade" || PlayerPrefs.GetString("Which_GameMode") == "Championship") // Arcade or Championship mode is selected { for (var i = 0; i < howManyCarsInRace; i++) { GameObject instance = null; if (i < inventoryItemCar.inventoryItem.Count) { instance = Instantiate(inventoryItemCar.inventoryItem [i].Cars [PlayerPrefs.GetInt("Player_" + i + "_CarLastSelection")]); } //instance = Instantiate(inventoryItemCar.inventoryItem[i].Cars[0]); else { instance = Instantiate(inventoryItemCar.inventoryItem[0].Cars[0]); } instance.name = instance.name.Replace("(Clone)", ""); GameObject tmpPosition = GameObject.Find("Start_Position_0" + (i + 1)); if (tmpPosition) { // if (i < 4) instance.GetComponent <CarController> ().playerNumber = i + 1; // Select the player number // else // instance.GetComponent<CarController>().playerNumber = 3; // Select the player number if (i == 0) { instance.GetComponent <CarAI> ().enabled = false; // Car 1 control by Player 1 } if (i == 1 && PlayerPrefs.GetInt("HowManyPlayers") == 2) { instance.GetComponent <CarAI> ().enabled = false; // Car 2 control by Player 2 if (Player2Position) { Player2Position.SetActive(true); } if (Player2PositionPart2) { Player2PositionPart2.SetActive(true); } if (Player2LapCounter) { Player2LapCounter.SetActive(true); } } if (i == 1 && PlayerPrefs.GetInt("HowManyPlayers") == 1) { instance.GetComponent <CarAI> ().enabled = true; // Car 2 control by CPU if (Player2Position) { Player2Position.SetActive(false); } if (Player2PositionPart2) { Player2PositionPart2.SetActive(false); } if (Player2LapCounter) { Player2LapCounter.SetActive(false); } } if (i > 1) { instance.GetComponent <CarAI> ().enabled = true; // Car 3 and 4 control by CPU } if (tmpPosition) { instance.transform.position = new Vector3(tmpPosition.transform.position.x, tmpPosition.transform.position.y + .15f, tmpPosition.transform.position.z); instance.transform.eulerAngles = tmpPosition.transform.eulerAngles; } while (!instance) { } } } } else if (PlayerPrefs.GetString("Which_GameMode") == "TimeTrial") // Time Trial is selected { GameObject instance = Instantiate(inventoryItemCar.inventoryItem [0].Cars [PlayerPrefs.GetInt("Player_0_CarLastSelection")]); instance.name = instance.name.Replace("(Clone)", ""); GameObject tmpPosition = GameObject.Find("Start_Position_04"); instance.GetComponent <CarController> ().playerNumber = 1; // Select the player number instance.GetComponent <CarAI> ().enabled = false; // Car 1 control by Player 1 if (tmpPosition) { instance.transform.position = new Vector3(tmpPosition.transform.position.x, tmpPosition.transform.position.y + .15f, tmpPosition.transform.position.z); instance.transform.eulerAngles = tmpPosition.transform.eulerAngles; } while (!instance) { } if (Player1Position) { Player1Position.SetActive(false); } if (Player1PositionPart2) { Player1PositionPart2.SetActive(false); } if (Player2Position) { Player2Position.SetActive(false); } if (Player2PositionPart2) { Player2PositionPart2.SetActive(false); } if (Player2LapCounter) { Player2LapCounter.SetActive(false); } } CreateCarList(); // Create car list //if(lapcounter)lapcounter.InitCar (); // Init Lap counter if (countdown && b_UseCountdown) { countdown.b_ActivateCountdown = true; } // Start countdown if needed if (list_Cars [1] != null && cam_P2 && list_Cars [1].gameObject.GetComponent <CarAI> ().enabled == false) { //cam_P2.gameObject.SetActive (true); //cam_P2.InitCamera(list_Cars [1],false); InitSplitScreenPart1(); } if (list_Cars [0] != null && cam_P1) { if (list_Cars [1] != null && list_Cars [1].gameObject.GetComponent <CarAI> ().enabled == false) { InitSplitScreenPart2(); } else { cam_P1.InitCamera(list_Cars [0], false); // Single Camera if (obj_LineSplitScreen_Part_01) { obj_LineSplitScreen_Part_01.SetActive(false); } if (obj_LineSplitScreen_Part_02) { obj_LineSplitScreen_Part_02.SetActive(false); } } } if (canvas_MainMenu && inventoryItemList.inventoryItem[0].b_TestMode == false /*&& PlayerPrefs.GetInt ("TestMode") == 0 */ && !b_TuningZone) { canvas_MainMenu.GoToOtherPageWithHisNumber(5); // Display Pause_Page } b_initDone = true; return(null); #endregion }