void Update() { if (_manager == null) { _manager = FindObjectOfType<AnimalGameManager>(); Debug.Log("It was null"); } //Debug.Log("its not null anymore"); }
public virtual void Awake() { // Set up the reference text = GetComponent<Text>(); // Reset the score. _score = 0; // create new timer /* _timer = gameObject.AddComponent<Timer>(); _timer.SetTimer(_levelLength); _timer._isPaused = false; */ // Get GameManager _gameManager = transform.GetComponent<AnimalGameManager>(); }
// Use this for initialization void Start() { // makes sure there is a game manager present // Note: should be present in all World_* scripts if (FindObjectOfType<AnimalGameManager>() == null) { _manager = gameObject.AddComponent<AnimalGameManager>(); } else { _manager = FindObjectOfType<AnimalGameManager>().GetComponent<AnimalGameManager>(); } // _charSelect = FindObjectOfType<CharacterSelection>().GetComponent<CharacterSelection>(); // swap = gameObject.AddComponent<SceneSwapper>(); }
public override void OnGameOver() { text.text = "Game Over!!"; text.fontSize = 50; _gameOver = true; // checks if there is a manager in the scene if (_gameManager == null) _gameManager = FindObjectOfType<AnimalGameManager>(); // if there isn't then we add one if (_gameManager == null) _gameManager = gameObject.AddComponent<AnimalGameManager>(); // handles glitch where player consistently gets points before returning // to main game if (!_alreadyGavePoints) { _alreadyGavePoints = true; _gameManager.AddCoins(_score); } // save points _gameManager.Save(); }
// Use this for initialization void Start() { // makes sure there is a game manager present // Note: should be present in all World_* scripts if (FindObjectOfType<AnimalGameManager>() == null) { //_manager = gameObject.AddComponent<AnimalGameManager>(); GameObject newManager = new GameObject(); newManager.name = "manager"; newManager = Instantiate(newManager) as GameObject; newManager.AddComponent<AnimalGameManager>(); _manager = newManager.GetComponent<AnimalGameManager>(); _manager.Load(); } else { _manager = FindObjectOfType<AnimalGameManager>().GetComponent<AnimalGameManager>(); } // instantiates player at spawnpoint _manager.InstantiatePlayer(); _manager.PlayerAnimalObject.transform.position = GameObject.FindGameObjectWithTag("PlayerSpawnPoint").transform.position; Debug.Log("before load"); PrintLoadedData(); _manager.Load(); Debug.Log("after load"); PrintLoadedData(); StartCoroutine("BeginAi", 1f); // spawns Ui elements _uiSpawner = gameObject.AddComponent<UISpawner>(); _uiSpawner.SpawnUI(); // assigns Ui elements World_MainGame_UI _buttonSetup = gameObject.AddComponent<World_MainGame_UI>(); _buttonSetup.SetupButtons(); }
public void PurchaseFood(GameObject selection) { gameManager = FindObjectOfType<AnimalGameManager>(); int balance = gameManager.GetCoins(); if (isAble(balance, selection.GetComponent<IFood>().cost)) { gameManager.AddCoins(-selection.GetComponent<IFood>().cost); UpdateAvailablity(selection.name); } else { //PRINT ERROR - play mini games to earn coin to use on foods and toys //insuffientCoins = GameObject.FindObjectOfType<Canvas>().GetComponent<UIController>().insufficientCoinsTxt; insuffientCoins = (GameObject.Find("CanvasMain(Clone)").GetComponent("UIController") as UIController).insufficientCoinsTxt; insuffientCoins.SetActive(true); StartCoroutine(RemoveErrorMessage()); } }
// Use this for initialization void Start() { // makes sure there is a game manager present // Note: should be present in all World_* scripts if (FindObjectOfType<AnimalGameManager>() == null) { //_gameManager = gameObject.AddComponent<AnimalGameManager>(); GameObject newManager = new GameObject(); newManager.name = "manager"; newManager = Instantiate(newManager) as GameObject; newManager.AddComponent<AnimalGameManager>(); _gameManager = newManager.GetComponent<AnimalGameManager>(); _gameManager.Load(); } else { _gameManager = FindObjectOfType<AnimalGameManager>().GetComponent<AnimalGameManager>(); } // instantiates player at spawnpoint _gameManager.InstantiatePlayer(); _gameManager.PlayerAnimalObject.transform.position = GameObject.FindGameObjectWithTag("PlayerSpawnPoint").transform.position; // slows player down to playable speed _gameManager.PlayerAnimalObject.GetComponent<Player1StickMovement>()._speed = .15f; // spawns Ui elements _uiSpawner = gameObject.AddComponent<UISpawner>(); _uiSpawner.SpawnUI(); // assigns Ui elements World_MiniGame_01_UI _buttonSetup = gameObject.AddComponent<World_MiniGame_01_UI>(); _buttonSetup.SetupButtons(); _buttonSetup.SetupPanels(); }
void Awake() { Debug.Log("The Animal Game Manager Awakens"); // creates a singleton if (_manager == null) { DontDestroyOnLoad(gameObject); _manager = this; } else if (_manager != this) { Destroy(gameObject); } // adds spawner _playerSpawner = gameObject.AddComponent<PlayerSpawner>(); // clears player reference _player = null; // loads player's info _newGame = !Load(); if (_player == null) { Debug.Log("THE PLAYER IS NULL"); } else { Debug.Log("PLAYER NOT NULL"); } }
void SetupMoveAction() { gameManager = FindObjectOfType<AnimalGameManager>(); player = GameObject.FindGameObjectWithTag("Player"); playerScript = player.GetComponent("Character") as Character; anim = player.GetComponent<Animator>(); nav = GetComponent<NavMeshAgent>(); nav.enabled = true; }
void Awake() { playerTrans = GameObject.FindGameObjectWithTag("Player").transform; // makes sure there is a game manager present // Note: should be present in all World_* scripts if (FindObjectOfType<AnimalGameManager>() == null) { //_gameManager = gameObject.AddComponent<AnimalGameManager>(); GameObject newManager = new GameObject(); newManager.name = "manager"; newManager = Instantiate(newManager) as GameObject; newManager.AddComponent<AnimalGameManager>(); _gameManager = newManager.GetComponent<AnimalGameManager>(); _gameManager.Load(); } else { _gameManager = FindObjectOfType<AnimalGameManager>().GetComponent<AnimalGameManager>(); } // instantiates player at spawnpoint _gameManager.InstantiatePlayer(); _gameManager.PlayerAnimalObject.transform.position = GameObject.Find("StartPoint").transform.position; //_gameManager.PlayerAnimalObject.transform.parent = (GameObject.Find("Player").transform.parent); _gameManager.PlayerAnimalObject.transform.parent = (GameObject.Find("Player").transform); _gameManager.PlayerAnimalObject.GetComponent<Rigidbody>().isKinematic = true; //Destroy(GetComponent<Rigidbody>()); platforms = new ArrayList(); fallinItems = new ArrayList(); SpawnPlatforms(25.0f); StartGame(); }
// Use this for initialization void Start() { _manager = FindObjectOfType<AnimalGameManager>(); //SpawnPlayer(); }