예제 #1
0
 void Update()
 {
     if (_manager == null)
     {
         _manager = FindObjectOfType<AnimalGameManager>();
         Debug.Log("It was null");
     }
     //Debug.Log("its not null anymore");
 }
예제 #2
0
        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>();
        }
예제 #3
0
 // 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>();
 }
예제 #4
0
        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();
        }
예제 #5
0
        // 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();
        }
예제 #6
0
        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());
            }
        }
예제 #7
0
        // 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();
        }
예제 #8
0
        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");
            }
        }
예제 #9
0
 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;
 }
예제 #10
0
        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();
        }
예제 #11
0
 // Use this for initialization
 void Start()
 {
     _manager = FindObjectOfType<AnimalGameManager>();
     //SpawnPlayer();
 }