Ejemplo n.º 1
0
 private void StopChaining()
 {
     StopCoroutine(endChainingCoroutine);
     endChainingCoroutine = null;
     isChaining           = false;
     currentFightMove     = null;
 }
Ejemplo n.º 2
0
        public override IEnumerator DoInteraction(Character character, CharacterMove move)
        {
            yield return(new WaitForSeconds(timeStep.x));

            character.SetVulnerabilityFrame(true);
            yield return(new WaitForSeconds(timeStep.y));

            character.SetVulnerabilityFrame(false);
        }
Ejemplo n.º 3
0
        private IEnumerator RunChainingFightMove(float duration)
        {
            yield return(new WaitForSeconds(duration));

            Debug.Log("RunChainingFightMove ended after " + duration + " seconds.");
            isChaining       = false;
            currentFightMove = null;
            BackToStandAnimation();
        }
Ejemplo n.º 4
0
        public override IEnumerator DoInteraction(Character character, CharacterMove move)
        {
            yield return(new WaitForSeconds(timeStep.x));

            character.SetDamageFrame(true, damageRatio);
            yield return(new WaitForSeconds(timeStep.y));

            character.SetDamageFrame(false);
        }
Ejemplo n.º 5
0
        private IEnumerator RunFightMove(CharacterMove move)
        {
            foreach (MoveInteraction interaction in move.GetInteractions())
            {
                if (interaction.CanCancel())
                {
                    cancelableInteractionCoroutine.Add(StartCoroutine(interaction.DoInteraction(this, move)));
                }
                else
                {
                    StartCoroutine(interaction.DoInteraction(this, move));
                }
            }
            yield return(new WaitForSeconds(move.animationDuration));

            Debug.Log("RunFightMove end after " + move.animationDuration + " seconds.");
            cancelableInteractionCoroutine.Clear();
            isFightMoving = false;
            isAttacking   = false;
            if (currentFightMove.chainMoves.Length > 0)
            {
                isChaining           = true;
                endChainingCoroutine = StartCoroutine(RunChainingFightMove(0.3f));
            }
            else
            {
                currentFightMove = null;
                BackToStandAnimation();
            }
            // use buffered command
            switch (inputBuffer)
            {
            case InputCommand.Attack:
                Attack();
                break;

            case InputCommand.Bash:
                Bash();
                break;

            case InputCommand.Dash:
                Dash(inputBufferDirection);
                break;

            default:
                break;
            }
            if (inputBuffer != InputCommand.None)
            {
                inputBuffer = InputCommand.None;
                StopCoroutine(inputBufferCleanRoutine);
                inputBufferCleanRoutine = null;
            }
        }
Ejemplo n.º 6
0
 private void StartFightMove(CharacterMove move, bool isAttackMove = false)
 {
     currentEnergy -= move.energyCost;
     isMoving       = false;
     if (isFightMoving)
     {
         StopFightMove();
     }
     else if (isChaining)
     {
         StopChaining();
     }
     isFightMoving    = true;
     isAttacking      = isAttackMove;
     currentFightMove = move;
     StartAnimation(move.animationName);
     runFightMoveCoroutine = StartCoroutine(RunFightMove(move));
 }
Ejemplo n.º 7
0
 private void StopFightMove()
 {
     StopCoroutine(runFightMoveCoroutine);
     foreach (Coroutine coroutine in cancelableInteractionCoroutine)
     {
         StopCoroutine(coroutine);
     }
     isFightMoving      = false;
     damageFrame        = false;
     evasionFrame       = false;
     vulnerabilityFrame = false;
     if (isChaining)
     {
         StopCoroutine(endChainingCoroutine);
         endChainingCoroutine = null;
         isChaining           = false;
     }
     isAttacking      = false;
     currentFightMove = null;
 }
Ejemplo n.º 8
0
        public override IEnumerator DoInteraction(Character character, CharacterMove move)
        {
            float elapsedTime = 0;
            float timeOverflow;

            while (elapsedTime < timeStep.x)   // while not in displacement
            {
                yield return(null);

                elapsedTime += Time.deltaTime;
            }
            timeOverflow = elapsedTime - timeStep.x;
            if (timeOverflow > timeStep.y)   // just apply movement, and skip to next displacement
            {
                character.ApplyDisplacement(distance);
            }
            else
            {
                character.ApplyDisplacement(distance * timeOverflow / timeStep.y);
                float endTime = timeStep.x + timeStep.y;
                while (elapsedTime < endTime)
                {
                    yield return(null);

                    elapsedTime += Time.deltaTime;
                    if (elapsedTime < endTime)
                    {
                        character.ApplyDisplacement(distance * Time.deltaTime / timeStep.y);
                    }
                    else
                    {
                        timeOverflow = (timeStep.x + timeStep.y) - (elapsedTime - Time.deltaTime);
                        character.ApplyDisplacement(distance * timeOverflow / timeStep.y);
                    }
                }
            }
        }
Ejemplo n.º 9
0
 public abstract IEnumerator DoInteraction(Character character, CharacterMove move);
Ejemplo n.º 10
0
 public override IEnumerator DoInteraction(Character character, CharacterMove move)
 {
     return(pattern.DoPattern(character, character.transform, this));
 }
Ejemplo n.º 11
0
        public override IEnumerator DoInteraction(Character character, CharacterMove move)
        {
            yield return(new WaitForSeconds(timeStep.x));

            character.PlayAudioClip(clip);
        }