示例#1
0
 public void PrintAtTargetInvocationList()
 {
     if (AtDestination != null)
     {
         Debug.LogWarning("Invocation count movement: " + AtDestination.GetInvocationList().Length);
     }
 }
示例#2
0
 public int GetTargetInvocationCount()
 {
     if (AtDestination != null)
     {
         return(AtDestination.GetInvocationList().Length);
     }
     return(-1);
 }
示例#3
0
    private void Update()
    {
        if (hasTarget && path != null)
        {
            //Moving between nodes
            if (hasTarget && !interruptPath)
            {
                transform.position = Vector2.MoveTowards(transform.position, path[pathIndex].GetFloatPosition(), walkSpeed);
            }

            //At a node
            if (hasTarget && !interruptPath && (Vector2.Distance(transform.position, path[pathIndex].GetFloatPosition()) < 0.001f + targetOffsetDistance))
            {
                pathIndex++;
                if (pathIndex >= path.Count)
                {//At final node
                    hasTarget            = false;
                    targetOffsetDistance = 0;
                    if (AtDestination != null)
                    {
                        //PrintAtTargetInvocationList();
                        AtDestination.Invoke(this, new EventArgs());
                    }
                }
                GetComponent <Vision>().Scan();
            }

            if (hasTarget)
            {
                InfoBox.pathLength = path.Count;
                InfoBox.playerTile = transform.position.ToString();
                InfoBox.targetTile = path[pathIndex].position.ToString();
                InfoBox.stepsLeft  = path.Count - pathIndex;
            }
        }
        TemporaryWalkOnMouseClick();
    }