Example #1
0
        public override float CalculateLeftTime()
        {
            float normalized_time = NormalizedTime;
            float speed           = Combatant.Animator.speed;

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            MoveController.CombatantMoveState move_state = Combatant.GetMoveState();
            int current_state_hash       = Combatant.MoveController.GetCurrentAnimHash();
            int this_state_hash          = AnimatorStateNameHash;
            AnimatorStateInfo state_info = Combatant.MoveController.GetCurrentStateInfo();

            if (this_state_hash != current_state_hash)
            {// just new
                normalized_time = NormalizedTime;
                speed           = move.Speed;
            }
            else if (move_state != MoveController.CombatantMoveState.kHitReaction)
            {// leaving
                normalized_time = 1.0f;
            }
            else if (current_state_hash != state_info.fullPathHash)
            {// blending
                normalized_time = NormalizedTime;
                speed           = move.Speed;
            }
            else if (NormalizedTime > 0.0f && state_info.normalizedTime >= NormalizedTime)
            {// not repeat
                normalized_time = state_info.normalizedTime;
            }

            float left_time = move._animationClip.length * (1.0f - normalized_time);

            return(left_time / speed);
        }
Example #2
0
        public void SetupMove(string move_name, string animator_state_name, float start_time, float blend_frame)
        {
            MoveEditor.Move move = Combatant.MoveController.GetMoveIfExists(move_name);
            if (move == null)
            {
                EB.Debug.LogError("move not found");
                Stop();
                return;
            }

            if (move._moveState != MoveController.CombatantMoveState.kHitReaction)
            {
                EB.Debug.LogError("move state not match");
                Stop();
                return;
            }

            int anim_hash = Animator.StringToHash(animator_state_name);

            // set state and default move and auto cross to default animation
            Combatant.MoveController.TransitionTo(move._moveState);
            // set real move
            Combatant.MoveController.SetMove(move);
            // force cross fade to real animator state
            Combatant.MoveController.m_reaction_hash = anim_hash;
            Combatant.MoveController.CrossFade(anim_hash, blend_frame / move.NumFrames, 0, start_time);
        }
Example #3
0
        public override void Start()
        {
            base.Start();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = FlowUpFrame;
            NormalizedTime = StartFrame / move.NumFrames;

            EndFrame          = FlowTopFrame;
            EndNormalizedTime = EndFrame / move.NumFrames;

            SetupMove(MoveName, AnimatorStateName, NormalizedTime);

            if (IsReachedFlowPoint())
            {
                End();
                return;
            }

            //EB.Debug.Log("FlowUpActionState.Start: NormalizedTime = {0}, EndNormalizedTime = {1}", NormalizedTime, EndNormalizedTime);

            float flowuppoint_offset = Combatant.CurrentMove._yOffsetCurve.Evaluate(FlowUpFrame);
            float flowpoint_offset   = Combatant.CurrentMove._yOffsetCurve.Evaluate(FlowTopFrame);

            float anim_distance   = flowpoint_offset - flowuppoint_offset;
            float actual_distance = (FlowTopPoint.y - Combatant.OriginPosition.y) - flowuppoint_offset;

            Scale = actual_distance / anim_distance;

            Vector3 current_position = Combatant.transform.position;

            current_position.y           = flowuppoint_offset + Combatant.OriginPosition.y;
            Combatant.transform.position = current_position;
        }
Example #4
0
        public override float CalculateLeftTime()
        {
            float normalized_time = NormalizedTime;
            float speed           = Combatant.Animator.speed;

            MoveEditor.Move move = Combatant.MoveController.GetMoveByState(MoveController.CombatantMoveState.kBackward);

            MoveController.CombatantMoveState move_state = Combatant.GetMoveState();
            int state_hash = Combatant.MoveController.GetCurrentAnimHash();
            AnimatorStateInfo state_info = Combatant.MoveController.GetCurrentStateInfo();

            if (MoveController.m_backward_hash != state_hash)
            {
                normalized_time = NormalizedTime;
                speed           = move.Speed;
            }
            else if (move_state != MoveController.CombatantMoveState.kBackward)
            {
                normalized_time = 1.0f;
            }
            else if (state_hash != state_info.fullPathHash)
            {
                normalized_time = NormalizedTime;
                speed           = move.Speed;
            }
            else if (NormalizedTime > 0.0f && state_info.normalizedTime >= NormalizedTime)
            {
                normalized_time = state_info.normalizedTime;
            }

            float left_time = move._animationClip.length * (1.0f - normalized_time);

            return(left_time / speed);
        }
Example #5
0
        public override void Start()
        {
            base.Start();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = FlowTopFrame;
            NormalizedTime = StartFrame / move.NumFrames;

            EndFrame          = FlowLandFrame;
            EndNormalizedTime = EndFrame / move.NumFrames;

            SetupMove(MoveName, AnimatorStateName, NormalizedTime);

            if (IsReachedLandPoint())
            {
                End();
                return;
            }

            //EB.Debug.Log("FlowDownActionState.Start: NormalizedTime = {0}, EndNormalizedTime = {1}", NormalizedTime, EndNormalizedTime);

            float flow_point = Combatant.CurrentMove._yOffsetCurve.Evaluate(FlowTopFrame);
            float land_point = Combatant.CurrentMove._yOffsetCurve.Evaluate(FlowLandFrame);

            float anim_distance   = flow_point - land_point;
            float actual_distance = (FlowTopPoint.y - Combatant.OriginPosition.y) - land_point;

            Scale = actual_distance / anim_distance;
        }
Example #6
0
        public override void Start()
        {
            if (MoveName == "")
            {
                MoveName = "SKILL_normalattack";
                skipmove = true;
            }
            else
            {
                skipmove = false;
            }

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            // set state and default move and auto cross to default animation
            Combatant.MoveController.TransitionTo(MoveController.CombatantMoveState.kAttackTarget);
            // set real move
            Combatant.MoveController.SetMove(move);
            // force cross fade to real animator state
            Combatant.MoveController.m_attack_hash = AnimatorStateNameHash;
            Combatant.MoveController.CrossFade(Combatant.MoveController.m_attack_hash, 0.0f, 0, NormalizedTime);

            //HealthBar2D health_bar = Combatant.HealthBar;
            //if (health_bar != null)
            //{
            //    //health_bar.HideHealthBar(true); //by pj 关闭技能隐藏血条的功能
            //}
            var health_bar = Combatant.HealthBar;

            if (health_bar != null)
            {
                //health_bar.OnHandleMessage("HideHealthBar", true);  //by pj 关闭技能隐藏血条的功能
            }
        }
Example #7
0
        public override void Start()
        {
            base.Start();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            EndFrame          = FlowUpFrame;
            EndNormalizedTime = EndFrame / move.NumFrames;

            SetupMove(MoveName, AnimatorStateName, NormalizedTime);

            //EB.Debug.Log("FlowStartActionState.Start: NormalizedTime = {0}, EndNormalizedTime = {1}", NormalizedTime, EndNormalizedTime);

            Combatant.transform.position = Combatant.OriginPosition;

            //HealthBar2D health_bar = Combatant.HealthBar;
            //if (health_bar != null)
            //{
            //    health_bar.HideHealthBar(false);
            //}
            var health_bar = Combatant.HealthBar;

            if (health_bar != null)
            {
                health_bar.OnHandleMessage("HideHealthBar", false);
            }
        }
Example #8
0
        public void Update()
        {
            if (mScaleCharacter && !mScaled && mCurrent != null && mCurrent.character != null)
            {
                DoScaleCharacter();

                mScaled = true;
            }

            if (needToTransitionToIdle || needToSetStateAfterMove != MoveController.CombatantMoveState.kIdle)
            {
                if (mCurrent != null && mCurrent.character != null)
                {
                    MoveController    moveController = mCurrent.character.GetComponent <MoveController>();
                    AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();
                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveByState(needToSetStateAfterMove);
                        moveController.TransitionTo(needToSetStateAfterMove);
                        moveController.m_lobby_hash = Animator.StringToHash(string.Format("Lobby.{0}", theMove.name));
                        moveController.SetMove(theMove);
                        moveController.CrossFade(moveController.GetCurrentAnimHash(), 0.2f, 0, 0f);
                        needToTransitionToIdle  = false;
                        needToSetStateAfterMove = MoveController.CombatantMoveState.kIdle;
                    }
                }
            }
        }
Example #9
0
    public void TransitionTo(CombatantMoveState state)
    {
        if (!m_IsInitialized)
        {
            if (state != CombatantMoveState.kIdle)
            {
                EB.Debug.LogError("TransitionTo: {0} not initialized", state);
            }
            return;
        }

        if ((int)m_CurrentState == (int)state)
        {
            return;
        }
        // don't delete me - i'm awesome for debugging
        //EB.Debug.Log (myName + " " + m_state + " -> " + state);
        MoveEditor.Move nextMove = GetMoveByState(state);
        if (nextMove == null)
        {
            EB.Debug.LogError("TransitionTo: move not found for state {0}", state);
            return;
        }

        SetMove(nextMove);
        m_Animator.SetInteger("State", (int)state);

        CurrentState = state;

        if (m_AvatarComponent != null)
        {
            m_AvatarComponent.FullPathHash = GetCurrentAnimHash();
        }
    }
Example #10
0
        public ReturnActionState(Combatant combatant)
            : base(combatant)
        {
            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = ReturnFrame;
            NormalizedTime = StartFrame / move.NumFrames;
        }
Example #11
0
        public BackStartActionState(Combatant combatant)
            : base(combatant)
        {
            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            EndFrame          = BackFrame;
            EndNormalizedTime = EndFrame / move.NumFrames;
        }
Example #12
0
 public void SetMove(string move)
 {
     MoveEditor.Move theMove = GetMoveIfExists(move);
     if (theMove != null)
     {
         SetMove(theMove);
     }
 }
Example #13
0
 public void TransitionToMoveByName(string moveName)
 {
     MoveEditor.Move theMove = moveController.GetMoveIfExists(moveName);
     if (theMove != null)
     {
         TransitionToMove(theMove);
     }
 }
Example #14
0
    void TransitionToMove(MoveEditor.Move theMove)
    {
        moveController.TransitionTo(MoveController.CombatantMoveState.kLobby);
        moveController.m_lobby_hash = Animator.StringToHash("Lobby." + theMove.name);
        moveController.SetMove(theMove);
        moveController.CrossFade(moveController.m_lobby_hash, kLobbyAnimTransitionTime / theMove._animationClip.length, 0, 0.0f);

        randomIdleTriggerTime = UnityEngine.Random.Range(randomIdleTriggerTimeMin, randomIdleTriggerTimeMax);
    }
Example #15
0
        public override void Init(Combatant combatant)
        {
            base.Init(combatant);

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = ReturnFrame;
            NormalizedTime = StartFrame / move.NumFrames;
        }
Example #16
0
        public override void Init(Combatant combatant)
        {
            base.Init(combatant);

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            EndFrame          = BackFrame;
            EndNormalizedTime = EndFrame / move.NumFrames;
        }
Example #17
0
 public MoveEditor.Move GetMove(string move, bool useDefaultIfNecessary)
 {
     MoveEditor.Move theMove = GetMoveIfExists(move);
     if (theMove == null && m_Moves.Length > 0 && useDefaultIfNecessary)
     {
         //Debug.LogError (gameObject.name + " trying to play move " + move + " but doesn't have it defined!");
         theMove = m_Moves[0];
     }
     return(theMove);
 }
Example #18
0
        public LieActionState(Combatant combatant)
            : base(combatant)
        {
            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = LieFrame;
            NormalizedTime = StartFrame / move.NumFrames;

            EndFrame          = StandUpFrame;
            EndNormalizedTime = EndFrame / move.NumFrames;
        }
Example #19
0
        protected void InitBackPoint()
        {
            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            BackFrame    = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.BackStart, move);
            CollideFrame = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.BackCollideStart, move);
            ReturnFrame  = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.BackReturnStart, move);

            if (CombatLogic.Instance.IsPlayerOrChallengerSide(Combatant.Index.TeamIndex))
            {
                float back_y = move._yOffsetCurve.Evaluate(BackFrame) + Combatant.OriginPosition.y;
                float back_z = move._zOffsetCurve.Evaluate(BackFrame) + Combatant.OriginPosition.z;
                BackPoint = new Vector3(0, back_y, back_z);

                float collide_y = move._yOffsetCurve.Evaluate(CollideFrame) + Combatant.OriginPosition.y;
                float collide_z = move._zOffsetCurve.Evaluate(CollideFrame) + Combatant.OriginPosition.z;
                CollidePoint = new Vector3(0, collide_y, collide_z);

                float return_y = move._yOffsetCurve.Evaluate(ReturnFrame) + Combatant.OriginPosition.y;
                float return_z = move._zOffsetCurve.Evaluate(ReturnFrame) + Combatant.OriginPosition.z;
                ReturnPoint = new Vector3(0, return_y, return_z);
            }
            else
            {
                float back_y = move._yOffsetCurve.Evaluate(BackFrame) + Combatant.OriginPosition.y;
                float back_z = -move._zOffsetCurve.Evaluate(BackFrame) + Combatant.OriginPosition.z;
                BackPoint = new Vector3(0, back_y, back_z);

                float collide_y = move._yOffsetCurve.Evaluate(CollideFrame) + Combatant.OriginPosition.y;
                float collide_z = -move._zOffsetCurve.Evaluate(CollideFrame) + Combatant.OriginPosition.z;
                CollidePoint = new Vector3(0, collide_y, collide_z);

                float return_y = move._yOffsetCurve.Evaluate(ReturnFrame) + Combatant.OriginPosition.y;
                float return_z = -move._zOffsetCurve.Evaluate(ReturnFrame) + Combatant.OriginPosition.z;
                ReturnPoint = new Vector3(0, return_y, return_z);
            }

            Transform back_wall_transform = Combatant.transform.parent.parent.Find("BackWall");

            if (back_wall_transform != null)
            {
                Vector3 collide_point = back_wall_transform.position;

                collide_point.x = 0;
                CollidePoint    = collide_point;

                collide_point.y = 0;
                ReturnPoint     = collide_point;
            }
        }
Example #20
0
        public DownActionState(Combatant combatant)
            : base(combatant)
        {
            MoveName = downMoveName;

            InitDownPoint();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = 0.0f;
            NormalizedTime = 0.0f;

            EndFrame          = move.NumFrames;
            EndNormalizedTime = 1.0f - timeEpsilon;
        }
Example #21
0
        protected void InitDownPoint()
        {
            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            LieFrame     = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.DownLieStart, move);
            StandUpFrame = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.DownStandUpStart, move);

            float lie_y_offset = move._yOffsetCurve.Evaluate(LieFrame);
            float lie_z_offset = move._zOffsetCurve.Evaluate(LieFrame);

            float lie_y = lie_y_offset + Combatant.OriginPosition.y;
            float lie_z = lie_z_offset + Combatant.OriginPosition.z;

            LiePoint = new Vector3(Combatant.OriginPosition.x, lie_y, lie_z);
        }
Example #22
0
        public override void Start()
        {
            base.Start();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = FlowLandFrame;
            NormalizedTime = StartFrame / move.NumFrames;

            SetupMove(MoveName, AnimatorStateName, NormalizedTime);

            Vector3 current_position = Combatant.transform.position;

            current_position.y           = FlowLandPoint.y;
            Combatant.transform.position = current_position;
        }
Example #23
0
        public override void Start()
        {
            base.Start();

            InitFlowPoint();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            Scale = 1.0f;

            StartFrame     = 0.0f;
            NormalizedTime = 0.0f;

            EndFrame          = move.NumFrames;
            EndNormalizedTime = 1.0f - timeEpsilon;
        }
Example #24
0
        public override void Init(Combatant combatant)
        {
            base.Init(combatant);

            MoveName = downMoveName;

            InitDownPoint();

            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            StartFrame     = 0.0f;
            NormalizedTime = 0.0f;

            EndFrame          = move.NumFrames;
            EndNormalizedTime = 1.0f - timeEpsilon;
        }
Example #25
0
 public void SetMove(MoveEditor.Move theMove)
 {
     m_CurrentMove = theMove;
     if (m_MoveMotion != null)
     {
         m_MoveMotion.ToNormalState();
     }
     if (m_MoveEventDispatcher != null)
     {
         m_MoveEventDispatcher.SetMove(theMove, 0.0f);
     }
     if (m_Animator)
     {
         m_Animator.speed = m_CurrentMove.Speed;
     }
 }
Example #26
0
    void OnEnable()
    {
        if (m_IsInitialized)
        {
            MoveEditor.Move currentMove = m_CurrentMove;
            if (m_CurrentState != CombatantMoveState.kIdle)
            {
                TransitionTo(m_CurrentState);
                SetMove(currentMove);
            }

            if (GetCurrentAnimHash() != m_idle_hash)
            {
                CrossFade(GetCurrentAnimHash(), 0, 0, 0);
            }
        }
    }
Example #27
0
        public new void Update()
        {
            if (mScaleCharacter && !mScaled && (mCurrent != null && mCurrent.character != null || mCurrentOther != null && mCurrentOther.character != null))
            {
                DoScaleCharacter();

                mScaled = true;
            }

            if (mCurrent != null && mCurrent.character != null)
            {
                MoveController    moveController = mCurrent.character.GetComponent <MoveController>();
                AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();

                if (!((int)moveController.CurrentState == (int)MoveController.CombatantMoveState.kReady))
                {
                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveIfExists("Ready");
                        moveController.TransitionTo(MoveController.CombatantMoveState.kReady);
                        moveController.m_lobby_hash = Animator.StringToHash(string.Format("Lobby.{0}", theMove.name));
                        moveController.SetMove(theMove);
                        moveController.CrossFade(MoveController.m_ready_hash, 0.2f, 0, 0f);
                    }
                }
            }

            if (mCurrentOther != null && mCurrentOther.character != null)
            {
                MoveController    moveController = mCurrentOther.character.GetComponent <MoveController>();
                AnimatorStateInfo asi            = moveController.GetCurrentStateInfo();

                if (!((int)moveController.CurrentState == (int)MoveController.CombatantMoveState.kReady))
                {
                    if (asi.normalizedTime >= 1)
                    {
                        MoveEditor.Move theMove = moveController.GetMoveIfExists("Ready");
                        moveController.TransitionTo(MoveController.CombatantMoveState.kReady);
                        moveController.m_lobby_hash = Animator.StringToHash(string.Format("Lobby.{0}", theMove.name));
                        moveController.SetMove(theMove);
                        moveController.CrossFade(MoveController.m_ready_hash, 0.2f, 0, 0f);
                    }
                }
            }
        }
Example #28
0
        static StackObject *SetMove_6(ILIntepreter __intp, StackObject *__esp, IList <object> __mStack, CLRMethod __method, bool isNewObj)
        {
            ILRuntime.Runtime.Enviorment.AppDomain __domain = __intp.AppDomain;
            StackObject *ptr_of_this_method;
            StackObject *__ret = ILIntepreter.Minus(__esp, 2);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 1);
            MoveEditor.Move @theMove = (MoveEditor.Move) typeof(MoveEditor.Move).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));
            __intp.Free(ptr_of_this_method);

            ptr_of_this_method = ILIntepreter.Minus(__esp, 2);
            global::MoveController instance_of_this_method = (global::MoveController)typeof(global::MoveController).CheckCLRTypes(StackObject.ToObject(ptr_of_this_method, __domain, __mStack));

            __intp.Free(ptr_of_this_method);

            instance_of_this_method.SetMove(@theMove);

            return(__ret);
        }
Example #29
0
        public void SetupMoveUseDefault(string move_name, string animator_state_name, float start_time)
        {
            MoveEditor.Move move = Combatant.MoveController.GetMoveIfExists(move_name);
            if (move == null)
            {
                move = Combatant.MoveController.GetMoveByState(MoveController.CombatantMoveState.kHitReaction);
                if (move == null)
                {
                    EB.Debug.LogError("move not found");
                    Stop();
                    return;
                }

                move_name           = move.name;
                animator_state_name = "Base Layer." + move_name;
                start_time          = 0.0f;
            }

            SetupMove(move_name, animator_state_name, start_time);
        }
Example #30
0
        protected void InitFlowPoint()
        {
            MoveEditor.Move move = Combatant.MoveController.GetMove(MoveName, false);

            FlowUpFrame   = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.FlowUpStart, move);
            FlowTopFrame  = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.FlowDownStart, move);
            FlowLandFrame = Combatant.MoveController.GetFrameByCombatType(MoveEditor.CombatEventInfo.CombatEventType.FlowLandStart, move);

            float flowup_y = move._yOffsetCurve.Evaluate(FlowUpFrame) + Combatant.OriginPosition.y;

            FlowUpPoint = new Vector3(0, flowup_y, 0);

            float flowtop_y = move._yOffsetCurve.Evaluate(FlowTopFrame) + Combatant.OriginPosition.y;

            FlowTopPoint = new Vector3(0, flowtop_y, 0);

            Transform flow_height_transform = null;

            if (FlowHeight == eHeightType.LITTLE)
            {
                flow_height_transform = Combatant.transform.parent.parent.Find("LittleFlow");
            }
            else if (FlowHeight == eHeightType.LARGE)
            {
                flow_height_transform = Combatant.transform.parent.parent.Find("LargeFlow");
            }
            if (flow_height_transform != null)
            {
                Vector3 flow_point = flow_height_transform.position;
                flow_point.x = 0;
                flow_point.z = 0;

                FlowTopPoint = flow_point;
            }

            float flowland_y = move._yOffsetCurve.Evaluate(FlowLandFrame) + Combatant.OriginPosition.y;

            FlowLandPoint = new Vector3(0, flowland_y, 0);
        }