示例#1
0
 private void OnDestroy()
 {
     if (!myGameController.isGameFailed())
     {
         if (!myGameController.isScrolling)
         {
             myGameController.gameSuspended = false;
         }
         myGameController.afterAttack();
         myWarningController.isImageDisplay(true);
         myWarningController.nextAttackWarning(myEnemy.getNextAttackNumber());
         if (transform.position.y < 0f)
         {
             myTowerScrollScript.scrollBack(destoriedHeight);
         }
     }
 }
示例#2
0
    void attack()
    {
        if (nextAttackNumber == -1)
        {
            nextAttackNumber = Random.Range(0, 3);
        }

        thisAttackNumber = nextAttackNumber;
        //enemy cannot attack a tower twice consecutively
        Vector3 startPosition = new Vector3(towerX[thisAttackNumber], dropHeight, 0);

        if (attackMaterial == null)
        {
            attackMaterial = GameObject.Instantiate(attackMaterialPreafab, startPosition, Quaternion.identity);
        }

        while (nextAttackNumber == thisAttackNumber)
        {
            nextAttackNumber = Random.Range(0, 3);
        }
        myWarningController.isImageDisplay(false);
    }