Пример #1
0
 private void Start()
 {
     staticMoveCooldown = moveCooldown;
     lives.Add(GameObject.Find("Life 1"));
     lives.Add(GameObject.Find("Life 2"));
     lives.Add(GameObject.Find("Life 3"));
     audioSource           = transform.GetComponent <AudioSource>();
     tilemapFlashingScript = GameObject.Find("Tilemap").GetComponent <FlashingScript>();
 }
Пример #2
0
    // Every 10 seconds, select a random ship that would be special for 7 seconds. If player hits the ship while it's in that state, player gains rapid fire.
    private void SpecialShip()
    {
        specialShipTimer += Time.deltaTime;
        if (specialShipTimer >= 10f)
        {
            specialShipTimer = 0f;
            bool exitCondition             = false;
            List <GameObject> tempShipList = enemyShips;
            GameObject        ship;
            int n = 0;

            // Taking care of edge cases (no ships remaining, ship count is 0, only one ship remaining but it's in a dying state).
            for (int i = 0; i < tempShipList.Count; ++i)
            {
                if (i == tempShipList.Count - 1)
                {
                    if (!tempShipList[i].activeSelf || tempShipList[i].GetComponent <EnemyShipScript>().deathBool)
                    {
                        exitCondition = true;
                    }
                }
                if (tempShipList[i].activeSelf && !tempShipList[i].GetComponent <EnemyShipScript>().deathBool)
                {
                    break;
                }
            }
            if (tempShipList.Count == 0)
            {
                exitCondition = true;
            }

            // Since the ship count is not that big, it takes about ~35 iterations to get to the ship when there is only one left.
            // Considering this fires only each 10 seconds - not a big deal.
            while (!exitCondition)
            {
                ++n;
                ship = tempShipList[Random.Range(0, tempShipList.Count)];
                EnemyShipScript shipScript = ship.GetComponent <EnemyShipScript>();
                if (ship.activeSelf && !shipScript.deathBool && !shipScript.isSpecial)
                {
                    FlashingScript flashingScript = ship.GetComponent <FlashingScript>();
                    flashingScript.colorSaturation = 0.3f;
                    flashingScript.colorBool       = true;
                    shipScript.isSpecial           = true;
                    exitCondition = true;
                }
            }
        }
    }
Пример #3
0
 // Start is called before the first frame update
 void Awake()
 {
     boltFlasher          = gameObject.GetComponent <FlashingScript>();
     boltCollider         = gameObject.GetComponent <Collider2D>();
     boltCollider.enabled = false;
 }