예제 #1
0
    public void Spawn(int quantity)
    {
        Vector3    position = path?.GetWaypointByIndexClamped(0) ?? transform.position;
        Quaternion rotation = this.transform.rotation;

        for (int i = 0; i < quantity; i++)
        {
            GameObject unitObject = Instantiate(unitPrefab, position, rotation);
            AI.UnitAI  ai         = unitObject.GetComponent <Unit>()?.ai;
            if (ai != null)
            {
                ai.followPath = path;
            }
        }
    }
예제 #2
0
 public UnitPathFollowing(UnitAI ai)
 {
     this.ai     = ai;
     updateTimer = new Timer(updateInterval);
     updateTimer.SetOnEdge();
 }
예제 #3
0
 public FollowObjectState(UnitAI ai, Transform target, float keepDistance = 1f)
 {
     this.ai           = ai;
     this.target       = target;
     this.keepDistance = keepDistance;
 }
예제 #4
0
 public MoveToPositionState(UnitAI ai, Vector2 destination, AIState nextState)
     : this(ai, destination)
 {
     this.nextState = nextState;
 }
예제 #5
0
 public MoveToPositionState(UnitAI ai, Vector2 destination) : base(0.26f)
 {
     this.ai          = ai;
     this.destination = destination;
 }