Exemplo n.º 1
0
    private IEnumerator MoveToPoint(TilePath tilePath)
    {
        OnStartMove.Trigger();
        foreach (var node in tilePath)
        {
            //var lastDist = Vector3.Distance(Position.SetY(0), node.WorldPosition);
            float time = 0;
            OnMoveToBlock.Trigger(node);
            while (true)
            {
                time    += Time.deltaTime * moveSpeed;
                Position = Vector3.Lerp(Position, node, time);

                var dist = Vector3.Distance(Position.SetY(0), node.WorldPosition);

                if (dist <= distanceToNode.Value)
                {
                    GridPosition = node;
                    Position     = node.WorldPosition.SetY(Position);
                    break;
                }

                yield return(null);
            }
        }
        OnStopMove.Trigger();
        MovePlayerCallback.Trigger();
        movingCoroutine = null;
    }
Exemplo n.º 2
0
        /// <summary>
        /// Starts a move operation.
        /// </summary>
        /// <returns>True if the move operation started, false if a move operation was already running.</returns>
        public bool StartDrag(float x, float y)
        {
            if (IsMoving)
            {
                return(false);
            }

            CalculateBounds();

            IsMoving = true;

            originX           = x;
            originY           = y;
            originalSelection = new RectangleF(Selection.X, Selection.Y, Selection.Width, Selection.Height);


            foreach (TransformerItem item in items)
            {
                item.OriginX = item.Item.X;
                item.OriginY = item.Item.Y;
            }

            OnStartMove?.Invoke(this, EventArgs.Empty);

            return(true);
        }
Exemplo n.º 3
0
    public IEnumerator IStarshipMove(Starship starship)
    {
        Starship_Engine         starship_Engine         = starship.GetComponent <Starship_Engine>();
        Starship_RotationEngine starship_RotationEngine = starship.GetComponent <Starship_RotationEngine>();
        Rigidbody rigidbody = starship.GetComponent <Rigidbody>();

        ToStartPosition(starship);

        OnStartMove?.Invoke();
        starship_Engine.SetLockMove(false);
        while (Vector3.Distance(starship.transform.position, endTr.position) > 1f)
        {
            starship_RotationEngine.RotateToTargetWithPlaneLimiter(endTr.position + endTr.forward);

            starship_Engine.Move(MoveDirectionConsideringAngle(1, Vector3.Angle((endTr.position - rigidbody.velocity - starship.transform.position).normalized, starship.RotationPoint.forward))); // Двигаемся

            yield return(new WaitForFixedUpdate());
        }
        starship_Engine.SetLockMove(true);
        OnEndMove?.Invoke();
    }