示例#1
0
    public void InvederExploded(int xIndex, int yIndex)
    {
        aliveInvaders[xIndex, yIndex] = false;

        // Check if column is empty
        bool empty = true;

        for (int y = 0; y < ySize; y++)
        {
            if (aliveInvaders[xIndex, y])
            {
                empty = false;
                break;
            }
        }
        // if so remove from aliveColumnsList;
        if (empty)
        {
            aliveColumns.Remove(xIndex);
        }

        currentInvaderCount--;//Double Shooting explodes 2 invaders 2 times fix this!!!!!!!!!!!!!

        if (currentInvaderCount == 0)
        {
            GameManager.Instance.DefeatedWave();
        }

        // Determine current attack style
        float currentPercantage = (float)currentInvaderCount / (float)TotalInvaderCount;

        if (currentPercantage < currentAttackStyle.invaderPercentage)
        {
            if (currentAttackStyleIndex < attackStyles.Length - 1)
            {
                currentAttackStyle = attackStyles[++currentAttackStyleIndex];

                Debug.Log("Current Attack style: " + currentAttackStyle.name);
                Debug.Log("Current Attack index: " + currentAttackStyleIndex);
            }
        }
    }
示例#2
0
    IEnumerator LoadInvadersSlowly()
    {
        invadersSpawningFinished = false;
        GameManager.Instance.PauseGame();

        WaitForSeconds sec = new WaitForSeconds(0.03f);

        aliveInvaders = new bool[xSize, ySize];
        aliveColumns  = new List <int>(xSize);
        for (int i = 0; i < xSize; i++)
        {
            //aliveColumns[i] = i;
            aliveColumns.Add(i);
        }

        currentAttackStyle = attackStyles[0];

        float yPos = yOffset + transform.position.y;

        for (int y = 0; y < ySize; y++)
        {
            float xPos = xOffset + transform.position.x;

            InvaderType type = SelectType(y);

            for (int x = 0; x < xSize; x++)
            {
                CreateInvader(xPos, yPos, type, x, y);
                yield return(sec);

                aliveInvaders[x, y] = true;

                xPos = xPos + xCellSize;
            }
            yPos = yPos + yCellSize;
        }
        currentInvaderCount      = TotalInvaderCount;
        invadersSpawningFinished = true;
        GameManager.Instance.UnpauseGame();
    }