// Shield public void Power3() { // find the ship GameObject shield = GameObject.FindWithTag("Shield"); GameObject powerUps = GameObject.Find("PowerUps"); // if no shield then spawn one if (shield == null) { SpawnShield shieldScript = powerUps.GetComponent <SpawnShield> (); shieldScript.Spawn(); } }
public void NextCharacter(int playerID) { Player player = players[playerID]; if (player.characterSelectionPrefab == null) { selectedChar[playerID] = 0; player.characterSelectionPrefab = gm.allCharacterPrefabs[0]; } else { selectedChar[playerID]++; if (selectedChar[playerID] > gm.allCharacterPrefabs.Length - 1) { selectedChar[playerID] = 0; } player.characterSelectionPrefab = gm.allCharacterPrefabs[selectedChar[playerID]]; Destroy(player.activeCharacterInScene); } player.activeCharacterInScene = Instantiate(gm.allCharacterPrefabs[selectedChar[playerID]], players[playerID].transform); GameObject playerCharacter = player.activeCharacterInScene; playerCharacter.transform.position = spawnPoints[playerID].position; player.activeCharacterInSceneCharacterScript = player.activeCharacterInScene.GetComponent <BaseCharacter>(); player.activeCharacterInSceneCharacterScript.inputButton = player.inputButton; player.activeCharacterInSceneCharacterScript.myPlayerInfo = player; player.activeCharacterInScene.GetComponent <PlayerVisuals>().myPlayerInfo = player; playerCharacter.GetComponentInChildren <HitBox>().myCharacter = player.activeCharacterInSceneCharacterScript; playerCharacter.GetComponentInChildren <HitBox>().myPlayerID = playerID; // playerCharacter.GetComponentInChildren<HitBox>().activeGameMode = activeGameMode; SpawnShield sheild = playerCharacter.GetComponentInChildren <SpawnShield>(); sheild.myCharacter = player.activeCharacterInSceneCharacterScript; sheild.PopShield(); DisableCharacterForUI(player.activeCharacterInScene); }
void OnTriggerEnter2D(Collider2D other) { // cant be destroyed from the ship or powerups and is on a timmer if (other.gameObject.tag != "Ship" && other.gameObject.tag != "PowerUp01" && other.gameObject.tag != "PowerUp02" && other.gameObject.tag != "PowerUp03" && other.gameObject.tag != "PowerUp04" && other.gameObject.tag != "Boundary") { if (other.gameObject.tag != "Boss") { Destroy(other.gameObject); } GameObject powerUps = GameObject.Find("PowerUps"); SpawnShield script = powerUps.GetComponent <SpawnShield>(); if (script.isImmune == false) { Destroy(gameObject); } } }