Пример #1
0
        private IEnumerator Lerp(Vector3 start, Vector3 end, float timeToMove, TurnInfo info)
        {
            float t = 0;

            while (t <= timeToMove)
            {
                transform.position = Vector3.Lerp(start, end, t);
                t = t + Time.deltaTime / timeToMove;
                yield return(null);
            }

            transform.position = end;
            info.Finish();
        }
Пример #2
0
        private TurnInfo DoMove(Vector2Int dir, TurnInfo info)
        {
            //tests
            if (dir.magnitude != 1)
            {
                Debug.LogError("invalid movement for move: " + dir, gameObject);
            }

            if (status == AgentStatus.Dead)
            {
                info.turnTaken = false;
                return(info);
            }

            List <Agent> pushing = new List <Agent>();

            if (CanMoveInDir(dir, ref pushing))
            {
                info.blockPlayerMovement = true;
                info.endOfMoveAction    += MoveEnded;
                facingDirection          = dir;
                StartCoroutine(Lerp(transform.position, transform.position + new Vector3(dir.x, dir.y, 0), 0.33f, info));
                foreach (Agent m in pushing)
                {
                    m.Move(dir, false);                     //dont use the move of an agent that gets pushed.
                }

                gridElement.OnNewPosition();
            }
            else
            {
                info.turnTaken = false;
            }

            return(info);
        }
Пример #3
0
 protected virtual void MoveEnded(TurnInfo turn)
 {
     gridElement.OnNewPosition();
 }