Example #1
0
    private void OnUnitReached(GuardMovementUnit unitReached)
    {
        transform.position = startPosition + unitReached.GetPoint();
        isFirstMove        = true;

        IncrementNextUnit(unitReached);
    }
Example #2
0
    protected override void Move(GuardMovementUnit curUnit)
    {
        // Get the current move point;
        Vector2 curTargetPos = startPosition + curUnit.GetPoint();

        Vector2 curMoveDir = (curTargetPos - (Vector2)transform.position).normalized;

        // Once we reach our destination
        if (!isFirstMove && curMoveDir != lastMoveDir)
        {
            OnUnitReached(curUnit);
            return;
        }

        isFirstMove = false;
        lastMoveDir = curMoveDir;
        FaceDirection(curMoveDir);
        IncrementPosition(curMoveDir);
    }
Example #3
0
    // Called 0th
    // Domestic Initialization
    private void Update()
    {
        // Don't move if we have no path
        if (moveUnits.Length == 0)
        {
            return;
        }
        // Don't move if we shouldn't
        if (!shouldMove)
        {
            return;
        }
        // Wait
        if (waitTimer < timeToWait)
        {
            waitTimer += Time.deltaTime;
            return;
        }

        GuardMovementUnit curUnit = moveUnits[curIndex];

        Move(curUnit);
    }
Example #4
0
 protected abstract void Move(GuardMovementUnit curUnit);
Example #5
0
 /// <summary>
 /// Increments the index to the next one and updates the waiting timer
 /// using the given unit.
 /// </summary>
 protected void IncrementNextUnit(GuardMovementUnit unitReached)
 {
     curIndex   = GetNextIndex();
     waitTimer  = 0;
     timeToWait = unitReached.GetWaitTime();
 }
Example #6
0
 protected override void Move(GuardMovementUnit curUnit)
 {
     FaceDirection(curUnit.GetPoint());
     IncrementNextUnit(curUnit);
 }