コード例 #1
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();
        }
コード例 #2
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();
        }
コード例 #3
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();
        }