Пример #1
0
        public void moveCharacter(MyCharacterController characterCtrl, Vector3 destination)
        {
            Vector3         currentPos  = characterCtrl.getPos();
            List <SSAction> action_list = new List <SSAction>();

            if (destination.y < currentPos.y)
            {
                Vector3 middlePos = new Vector3()
                {
                    x = destination.x, y = currentPos.y, z = destination.z
                };
                SSAction action1 = CCMoveToAction.GetSSAction(middlePos, characterCtrl.movingSpeed);
                SSAction action2 = CCMoveToAction.GetSSAction(destination, characterCtrl.movingSpeed);

                action_list.Add(action1);
                action_list.Add(action2);
                SSAction seqAction = CCSequenceAction.GetSSAction(1, 0, action_list);
                this.RunAction(characterCtrl.getGameObj(), seqAction, this);
            }
            else if (destination.y > currentPos.y)
            {
                Vector3 middlePos = new Vector3()
                {
                    x = currentPos.x, y = destination.y, z = currentPos.z
                };
                SSAction action1 = CCMoveToAction.GetSSAction(middlePos, characterCtrl.movingSpeed);
                SSAction action2 = CCMoveToAction.GetSSAction(destination, characterCtrl.movingSpeed);

                action_list.Add(action1);
                action_list.Add(action2);
                SSAction seqAction = CCSequenceAction.GetSSAction(1, 0, action_list);
                this.RunAction(characterCtrl.getGameObj(), seqAction, this);
            }
        }
        public static CCSequenceAction GetSSAction(int repeat, int start, List <SSAction> sequence)
        {
            CCSequenceAction action = ScriptableObject.CreateInstance <CCSequenceAction>();

            action.repeat   = repeat;
            action.sequence = sequence;
            action.start    = start;
            return(action);
        }