コード例 #1
0
    private void MoveCible()
    {
        distance = Vector2.Distance(transform.position, waypoints[waypointIndex].position);

        if (distance < 1)
        {
            waypointIndex++;

            if (waypointIndex < waypoints.Length)
            {
                destinationSetter.target = waypoints[waypointIndex].transform;
            }
            else
            {
                if (waveConfig.dieAtEnd)
                {
                    EnnemySpawner ennemySpawner = FindObjectOfType <EnnemySpawner>(); //Send to the ennemy spawn that he has been destroyed
                    for (int i = 0; i < ennemyAlive; i++)
                    {
                        ennemySpawner.EnnemyDestroyed();
                    }
                    Destroy();
                }
            }
        }
    }
コード例 #2
0
    public IEnumerator destruction(bool destroyedByPlayer)
    {
        if (reactor != null)
        {
            reactor.SetActive(false);
        }

        //Disable collision with other projectiles
        col.enabled = false;

        //Say to the ennemyspawner it was destroyed
        ennemySpawner.EnnemyDestroyed();
        isDestroyed = true;

        if (squad != null)
        {
            StartCoroutine(squad.imDestroyed());
        }

        //Give scrap and uwCharge to the player as reward
        if (destroyedByPlayer)
        {
            Battleship battleship = FindObjectOfType <Battleship>();
            battleship.chargeOverdrive(overdriveCharge);

            //Reward
            int scrapValue      = Random.Range(minScrapValue, maxScrapValue);
            int energyCoreValue = 0;

            int energyCoreDropChance = Random.Range(0, 100);
            if (energyCoreDropChance <= chancePercToDropEnergyCore)
            {
                energyCoreValue = 1;
            }

            ennemySpawner.scrapsToWin     += scrapValue;
            ennemySpawner.energyCoreToWin += energyCoreValue;
        }

        //animator.SetBool("isDead", true);
        animator.Play("Explosion");

        yield return(new WaitForSeconds(0.5f));

        Destroy(gameObject);
    }