// Use this for initialization IEnumerator Start() { yield return(new WaitForFixedUpdate()); // Allocations PlayerScripts = new GPlayer[GInputManager.NumConnectedControllers]; PlayerInfos = new FPlayerInfo[GInputManager.NumConnectedControllers]; PlayerActions = new GPlayerActions[GInputManager.NumConnectedControllers]; PlayerTextureSizes = new Vector2[GInputManager.NumConnectedControllers]; // GameObject and Script setup PlayerObjects = GameObject.FindGameObjectsWithTag("Player"); for (int PlayerObjectIdx = 0; PlayerObjectIdx < PlayerObjects.Length; ++PlayerObjectIdx) { PlayerScripts[PlayerObjectIdx] = PlayerObjects[PlayerObjectIdx].GetComponent <GPlayer>(); PlayerActions[PlayerObjectIdx] = PlayerObjects[PlayerObjectIdx].GetComponent <GPlayerActions>(); PlayerInfos[PlayerObjectIdx] = PlayerScripts[PlayerObjectIdx].GetPlayerInfo(); SpriteRenderer SprtRenderer = PlayerObjects[PlayerObjectIdx].GetComponent <SpriteRenderer>(); PlayerTextureSizes[PlayerObjectIdx] = new Vector2(SprtRenderer.bounds.size.x, SprtRenderer.bounds.size.y); Debug.Log(PlayerTextureSizes[PlayerObjectIdx]); } PersistentData = GameObject.Find("PersistentData").GetComponent <GPersistentData>(); HealthBarWidth = (int)(Healthbars[0].width * HealthBarScale); HealthBarHeight = (int)(Healthbars[0].height * HealthBarScale); HealthBarPadding = 5; bInitialized = true; }
// Use this for initialization void Start() { PersistentData = GameObject.Find("PersistentData").GetComponent <GPersistentData>(); ScreenHalfWidth = Screen.width / 2; ScreenHalfHeight = Screen.height / 2; }
// Use this for initialization void Start() { PersistentData = GameObject.Find("PersistentData").GetComponent <GPersistentData>(); InitializePlayerData(); InputManager = GameObject.Find("InputManager").GetComponent <GInputManager>(); }
// Use this for initialization void Start() { // GameObject finds PersistentDataObject = GameObject.Find("PersistentData").GetComponent <GPersistentData>(); // Late Allocations PlayerPrefabs = new GameObject[PersistentDataObject.PlayerData.Length]; for (int PlayerIdx = 0; PlayerIdx < PersistentDataObject.PlayerData.Length; ++PlayerIdx) { GameObject CurrentPlayerObject = null; Texture2D Texture = PersistentDataObject.PlayerData[PlayerIdx].SelectedCharacterTexture; CurrentPlayerObject = GameObject.Instantiate(Resources.Load("Prefabs/Characters/PlayerPrefab")) as GameObject; CurrentPlayerObject.GetComponent <SpriteRenderer>().sprite = Sprite.Create(Texture, new Rect(0, 0, Texture.width, Texture.height), new Vector2(0.5f, 0.5f)); // DEBUG::For camera testing purposes, otherwise all characters move the same way from the same input if (PlayerIdx > 0) { CurrentPlayerObject.GetComponent <GCharacterController>().enabled = false; } CurrentPlayerObject.name = PersistentDataObject.PlayerData[PlayerIdx].PlayerTitle; PlayerPrefabs[PlayerIdx] = CurrentPlayerObject; } // Determine which player controller to enable on each player object. for (int PlayerIdx = 0; PlayerIdx < PersistentDataObject.PlayerData.Length; ++PlayerIdx) { FCharacterSelectData PlayerInfo = PersistentDataObject.PlayerData[PlayerIdx]; if (PlayerInfo.IsXBoxController()) { GameObject.Find(PlayerInfo.PlayerTitle).GetComponent <GCharacterXboxController>().enabled = true; } else { GameObject.Find(PlayerInfo.PlayerTitle).GetComponent <GCharacterController>().enabled = true; } } GBattleCam BattleCamScript = Camera.main.GetComponent <GBattleCam>(); if (BattleCamScript) { BattleCamScript.enabled = true; } DefaultTimeScale = UnityEngine.Time.timeScale; GameSlowTimeScale = 0.4f; WeaponSpawnTime = Random.Range(30.0f, 60.0f); }
// Use this for initialization void Start() { LoadedObjects = new List <GameObject>(); /*Input Manager*/ GameObject InputManager = Instantiate <GameObject>(Resources.Load("Prefabs/Core/InputManager") as GameObject); InputManager.name = "InputManager"; LoadedObjects.Add(InputManager); /*Persistent Data*/ GameObject PersistentData = Instantiate <GameObject>(Resources.Load("Prefabs/Core/PersistentData") as GameObject); PersistentData.name = "PersistentData"; GPersistentData PersistentDataScript = PersistentData.GetComponent <GPersistentData>(); PersistentDataScript.bDebugEnabled = this.bDebugEnabled; LoadedObjects.Add(PersistentData); Application.LoadLevel("Scene_StartMenu"); }