예제 #1
0
    public void Explodes()
    {
        CancelInvoke("Explodes");
        chasePlayer = false;
        Instantiate(boom, transform.position, transform.rotation);
        PS_EnemyExplosion.transform.SetParent(null);
        PS_EnemyExplosion.SetActive(true);
        Destroy(PS_EnemyExplosion, 10f);

        enemy.Die();
    }
예제 #2
0
    /// <summary>
    /// In Update, first we check if the player is inside the detection zone, he's atacked by the enemy
    /// then, if the ennemy is at his default location, he moves with a default pattern
    /// Finally, if the enemy isn't at his defaul location, he goes to it
    /// </summary>
    private void Update()
    {
        randomPointOnCircle = RandomOnUnitSphere();
        if (distToPlayer <= detectionDist)
        {
            /*if(!isNotOnTrack)
             * {
             *  //pour éviter la surcharge d'objet bézier Spline
             *  move.enabled = false;
             *  Object.Destroy(obj: pattern);
             *  nav.enabled = true;
             * }*/

            if (distToPlayer > explodeDist) //  If the enemy too far from player to explode
            {
                nav.destination = player.position;
            }
            else
            {                            // The enemy is close enough to explode
                Instantiate(boom, transform.position, transform.rotation);
                enemy.Die();
            }
        }
        else
        {
            if (isNotOnTrack(transform.position, randomPointOnCircle) && !isOnTrack)
            {
                MoveToLocation(randomPointOnCircle);
            }
            else
            {
                isOnTrack = true;
                Vector3 start  = transform.position;
                Vector3 finish = new Vector3(start.x + 5, start.y, start.z + 5);
                MoveToLocation(finish);

                /*nav.enabled = false;
                *  isNotOnTrack = false;
                *  //we suppose that the game object blueEnemy has already
                *  // a component BezierWalker but empty and disabled
                *  //we add a pattern that we create and we enable the movement.
                *  pattern = BlueEnemyPattern.create(transform.position);
                *  move.spline = pattern;
                *  move.enabled = true;*/
            }
        }
    }