// Use this for initialization void Awake() { uiScript = FindObjectOfType <IngameUIScript>(); defaultColour = gameObject.transform.GetChild(0).GetChild(0).GetChild(0).gameObject.GetComponent <MeshRenderer>().material.color; renderer = gameObject.transform.GetChild(0).GetChild(0).GetChild(0).gameObject.GetComponent <Renderer>(); playerMove = gameObject.GetComponent <WheelDrive>(); rb = gameObject.GetComponent <Rigidbody>(); }
// Use this for initialization void Start() { touchControl = GameObject.Find("PlayerManager").GetComponent <TouchControl>(); playerManager = GameObject.Find("PlayerManager").GetComponent <PlayerManager>(); tileManager = GameObject.Find("TileManager").GetComponent <TileManager>(); gridManager = GameObject.Find("GridManager").GetComponent <GridManager>(); ingameUI = GameObject.Find("IngameUI").GetComponent <IngameUIScript>(); }
void Awake() { gridManager = GameObject.Find("GridManager").GetComponent <GridManager>(); buildManager = GameObject.Find("BuildManager").GetComponent <BuildManager>(); playerManager = GameObject.Find("PlayerManager").GetComponent <PlayerManager>(); tileManager = GameObject.Find("TileManager").GetComponent <TileManager>(); towerManager = GameObject.Find("TowerManager").GetComponent <TowerManager>(); ingameUI = GameObject.Find("IngameUI").GetComponent <IngameUIScript>(); if (mShowDebugLine) { GameObject go = new GameObject("DebugLine"); go.transform.parent = transform; mDebugLine = go.AddComponent <LineRenderer>(); mDebugLine.material = new Material(Shader.Find("Mobile/Particles/Additive")); mDebugLine.SetColors(mLineColor, mLineColor); mDebugLine.SetVertexCount(2); mDebugLine.SetWidth(0.01f, 0.01f); mDebugLine.enabled = false; } }
//Call this when the player collects the item //destroy the item, and reset the spawner public void Collect(int a_playerIndex = 0) { isSpawned = false; isPickedUp = true; timeUntilRespawn = Random.Range(minRespawnTime, maxRespawnTime); Destroy(gameObject.transform.GetChild(0).gameObject); //loading InGameUIScript here just in case it hasn't been loaded if (inGameUIScript == null) { inGameUIScript = FindObjectOfType <IngameUIScript>(); } inGameUIMultiScript = FindObjectOfType <IngameUIMultiScript>(); //tell the ui that you've collected this item type (MOVE THIS LINE INTO WHERE THE PLAYER COLLECTS IT) //check if we are in Multi or Single mode by checking if the script is active GameStateID currState = GameObject.Find("GameManager").GetComponent <GameStateManagerScript>().currState; //if we are playing single play mode if (currState == GameStateID.InGame) { //set single play mode's IngameUI to change the item icon inGameUIScript.SetCollectedItem(currActivatedItemNum); } //if we are playing multi play mode if (currState == GameStateID.InGameMuilti) { //set multi play mode's IngameUI to change the item icon inGameUIMultiScript.SetCollectedItem(currActivatedItemNum, a_playerIndex); } totalPickedUpTimes++; }
void Start() { gridManager = GameObject.Find("GridManager").GetComponent <GridManager>(); ingameUI = GameObject.Find("IngameUI").GetComponent <IngameUIScript>(); }