public void SpawnUnit(PlayerSide playerSide, int spawnSeq, bool sound = true) { GameObject[] target = GameObject.FindGameObjectsWithTag("CatPatrol"); //int xOffset = 1; if (((int)playerSide) > 0) { //xOffset = -1; target = GameObject.FindGameObjectsWithTag("DogPatrol"); } //Vector3 charPosition = new Vector3(headquarters[(int)playerSide].transform.position.x + xOffset * 1.3f, headquarters[(int)playerSide].transform.position.y, headquarters[(int)playerSide].transform.position.z + 2.2f - spawnSeq*1.2f); Vector3 charPosition = new Vector3(target[spawnSeq].transform.position.x, target[spawnSeq].transform.position.y, target[spawnSeq].transform.position.z); Quaternion charRotation = new Quaternion(0, 0, 0, 0); //Instantiate(unitPrefabs[(int)playerSide], unitList); Transform unit = Instantiate(unitPrefabs[(int)playerSide], charPosition, charRotation, unitList).transform; CharMovement charMovement = unit.GetComponent <CharMovement>(); charMovement.gameManager = this; charMovement.uiManager = uiManager; switch (playerSide) { case PlayerSide.Cats: catObjects.Add(charMovement); break; case PlayerSide.Dogs: dogObjects.Add(charMovement); break; } HPBarHandler handler = Instantiate(HPBar, HPBarCanvases.transform).GetComponent <HPBarHandler>(); handler.Init(unit, cam); charMovement.hPBar = handler; if (sound) { audioManager.PlaySoundEffect(audioLibrary.spawned[(int)playerSide]); } }
// Start is called before the first frame update virtual protected void Awake() { emotesController = GetComponentInChildren <EmotesController>(); hpBar = GetComponentInChildren <HPBarHandler>(); rb = GetComponent <Rigidbody2D>(); }