Ejemplo n.º 1
0
    IEnumerator playerUpdate()
    {
        while (!entityVisual.modelLoaded)
        {
            yield return(null);
        }
        while (BeAlive())
        {
            pathSensor.TakeSample(this);
            if (pathSensor.IsDirty && pathSensor.Value)
            {
                currentPath?.Clear();
                AcceptPathChange();
            }
            if (currentPath == null || currentPath.Count == 0)
            {
                if (currentPath?.Count == 0)
                {
                    currentPath = null;
                    onReachDst();
                    entityVisual.SetAniStatus(EntityAnimStatus.Idle);
                    if (GameEntityMgr.GetSelectedEntity() == this)
                    {
                        ShowEyeSight();
                    }
                }
                //yield return new WaitForSeconds(0.5f);
                yield return(new WaitForEndOfFrame());
            }

            if (currentPath != null && currentPath.Count > 0)
            {
                if (controllRemote.PTiliMove(1))
                {
                    if (currentPath.Count == 1)
                    {
                        //yield return movefromApoint2Bpoint(currentPath[0], currentPath[0]);
                        currentPath.RemoveAt(0);
                    }
                    else
                    {
                        ICell start = currentPath[0];
                        ICell next  = currentPath[1];
                        yield return(movefromApoint2Bpoint(start, next));

                        currentPath.RemoveAt(0);
                    }
                }
                else
                {
                    currentPath.Clear();
                }
            }
        }
    }