public void AddPower() { powerCount++; if (powerCount <= maxSprites) { floatingText.DespawnText(); GameObject newImageObject = new GameObject("BatteryImage" + powerImageList.Count); SpriteRenderer newBatteryImage = newImageObject.AddComponent <SpriteRenderer>(); newImageObject.transform.position = anchor.position; newImageObject.transform.SetParent(transform); newImageObject.transform.localScale = Vector3.one * scale; newImageObject.transform.position += new Vector3(spacing * powerImageList.Count, 0, 0); newBatteryImage.sprite = powerSprite; newBatteryImage.sortingOrder = sortingLayer; powerImageList.Add(newBatteryImage); } else if (powerCount == maxSprites + 1) { HideIcons(); floatingText.SpawnText("x" + powerCount, 100); } else { floatingText.SpawnText("x" + powerCount, 100); } }
public void EndGame() { floatingText.DespawnText(); this.enabled = false; }