Ejemplo n.º 1
0
    public PatrolMission(SneakEnemyPatrol pEnemy)
    {
        enemy  = pEnemy;
        target = RandomizeNewTarget();

        CheckFinished = () => {
            float distance = Vector2.Distance(enemy.transform.position, target);
            if (distance > lastDistance)
            {
                enemy.transform.position = new Vector2(target.x, enemy.transform.position.y);

                // Randomize new target
                target = RandomizeNewTarget();

                lastDistance = 100000f;
                return(true);
            }
            else
            {
                WalkTowardsTarget();
                lastDistance = distance;
                return(false);
            }
        };
    }
Ejemplo n.º 2
0
    public PatrolMission(SneakEnemyPatrol pEnemy)
    {
        enemy = pEnemy;
        target = RandomizeNewTarget();

        CheckFinished = () => {
            float distance = Vector2.Distance(enemy.transform.position, target);
            if(distance > lastDistance) {
                enemy.transform.position = new Vector2(target.x, enemy.transform.position.y);

                // Randomize new target
                target = RandomizeNewTarget();

                lastDistance = 100000f;
                return true;
            }
            else {
                WalkTowardsTarget();
                lastDistance = distance;
                return false;
            }
        };
    }