예제 #1
0
    private void DoRandomStuff(Transform transform, InputQueueComponent iqc, MovementComponent movement)
    {
        if (transform.position.y < 0)
        {
            if (movement.currentMovement != Vector3.down)
            {
                SetMovementDirection(Vector3.up, iqc.inputQueue);
                return;
            }
            else
            {
                if (TryToSetMovementDirection(Vector3.left, iqc.inputQueue, transform))
                {
                    return;
                }
            }
        }
        else if (transform.position.y > 0)
        {
            if (TryToSetMovementDirection(Vector3.down, iqc.inputQueue, transform))
            {
                return;
            }
        }

        List <Vector3> listOfDirections = new List <Vector3>()
        {
            Vector3.forward, Vector3.left, Vector3.right, Vector3.back
        };

        while (listOfDirections.Count > 0)
        {
            int     randomIndex = r.Next(0, listOfDirections.Count);
            Vector3 direction   = listOfDirections[randomIndex];
            listOfDirections.RemoveAt(randomIndex);
            if (TryToSetMovementDirection(direction, iqc.inputQueue, transform))
            {
                return;
            }
        }
    }
예제 #2
0
 public override void Move(Transform transform, InputQueueComponent iqc, MovementComponent movement)
 {
     DoRandomStuff(transform, iqc, movement);
 }
예제 #3
0
 public abstract void Move(Transform transform, InputQueueComponent iqc, MovementComponent movement);