Example #1
0
        public void MoveToPosition(Vector2 position)
        {
            Vector2   offset        = head.Position - position;
            TileSides newFromArrive = CalculateSideByOffset(offset);

            if (newFromArrive != fromArrive)
            {
                head.SetReadyToRotation(newFromArrive);
            }
            fromArrive = newFromArrive;

            head.MoveForwardChainPosition(position);
        }
Example #2
0
        // ------------------------ Movement -------------------
        public virtual void MoveForwardChainPosition(Vector2 movePos)
        {
            Vector2 backPos = _transform.position;

            _transform.position = movePos;
            if (backTrainElement != null)
            {
                backTrainElement.MoveForwardChainPosition(backPos);
            }
            // define to need rotation
            if (nextRotation)
            {
                SetRotation(rotateDegree);
                nextRotation = false;
                if (backTrainElement != null)
                {
                    backTrainElement.SetReadyToRotation(localFromArrive);
                }
            }
        }