예제 #1
0
        void DrawText(Vector3 referencePosition, PlatformNode currentAction, int index)
        {
            Vector3 TextPosition = referencePosition + currentAction.position;

            style.fontSize         = 25;
            style.normal.textColor = Color.white;
            Handles.Label(TextPosition, index.ToString(), style);
        }
예제 #2
0
        protected override void Awake()
        {
            base.Awake();

            updateInitialPosition = false;
            initialPosition       = transform.position;

            actionState = ActionState.Ready;

            currentActionIndex = 0;
            currentAction      = actionsList[0];
        }
예제 #3
0
        void DrawHandle(Vector3 referencePosition, PlatformNode currentAction)
        {
            float radius = 0.5f;

            Handles.color = Color.white;

            Handles.DrawWireDisc(referencePosition + currentAction.position, -Vector3.forward, radius);


            Vector3[] lines = new Vector3[] {
                referencePosition + currentAction.position + Vector3.up * radius,
                referencePosition + currentAction.position - Vector3.up * radius,
                referencePosition + currentAction.position + Vector3.right * radius,
                referencePosition + currentAction.position - Vector3.right * radius
            };

            Handles.DrawLines(lines);

            //Position Handle
            currentAction.position = Handles.PositionHandle(
                referencePosition + currentAction.position, Quaternion.identity) - referencePosition;
        }
예제 #4
0
        protected override void UpdateBehaviour(float dt)
        {
            switch (actionState)
            {
            case ActionState.Idle:

                break;

            case ActionState.Ready:

                SetTargets();


                actionState = ActionState.Working;


                break;

            case ActionState.Working:

                time += dt * globalSpeedModifier;
                if (time >= currentAction.targetTime)
                {
                    actionState = ActionState.Done;

                    time = 0;
                }
                else
                {
                    if (move)
                    {
                        CalculatePosition();
                    }

                    if (rotate)
                    {
                        CalculateRotation();
                    }
                }


                break;

            case ActionState.Done:

                time = 0;

                if (positiveSequenceDirection)
                {
                    if (currentActionIndex != (actionsList.Count - 1))
                    {
                        currentActionIndex++;
                        actionState = ActionState.Ready;
                    }
                    else
                    {
                        switch (sequenceType)
                        {
                        case SequenceType.Loop:

                            currentActionIndex = 0;
                            actionState        = ActionState.Ready;

                            break;

                        case SequenceType.Rewind:

                            currentActionIndex--;
                            positiveSequenceDirection = false;
                            actionState = ActionState.Ready;

                            break;

                        case SequenceType.OneWay:

                            actionState = ActionState.Idle;

                            break;
                        }
                    }
                }
                else
                {
                    if (currentActionIndex != 0)
                    {
                        currentActionIndex--;
                        actionState = ActionState.Ready;
                    }
                    else
                    {
                        switch (sequenceType)
                        {
                        case SequenceType.Loop:

                            currentActionIndex = actionsList.Count - 1;
                            actionState        = ActionState.Ready;

                            break;

                        case SequenceType.Rewind:

                            currentActionIndex++;
                            positiveSequenceDirection = true;
                            actionState = ActionState.Ready;

                            break;

                        case SequenceType.OneWay:

                            actionState = ActionState.Idle;

                            break;
                        }
                    }
                }

                currentAction = actionsList[currentActionIndex];

                break;
            }
        }