コード例 #1
0
    void PokeBehaviour()
    {
        if (currentPhase != Phases.Poke)
        {
            return;
        }

        if (firstPosition == Vector3.zero)
        {
            firstPosition = transform.position;
        }
        switch (phaseState)
        {
        case phaseStates.Charge:
            sprite.sprite = chargeSprite;
            if (startDirection == Vector3.zero)
            {
                startDirection = (transform.position - player.transform.position).normalized;
                float blendModule = UnityEngine.Random.Range(0f, 1f);
                if (isRight)
                {
                    startDirection = ((new Vector3(-startDirection.y, startDirection.x) * blendModule) + (startDirection * (1 - blendModule))).normalized;
                }
                else
                {
                    startDirection = ((new Vector3(startDirection.y, -startDirection.x) * blendModule) + (startDirection * (1 - blendModule))).normalized;
                }
                startDirection *= pokeDistance / 2;
            }
            transform.right    = Vector3.Lerp(transform.right, (player.transform.position - transform.position) * (1 + -2 * Convert.ToInt32(!isRight)), rotationSpeed * Time.deltaTime * 100);
            startPosition      = player.transform.position + player.swordOffset + startDirection;
            transform.position = Vector3.Lerp(firstPosition, startPosition, chargeMovement.Evaluate(elapsed / pokeChargeTime));
            break;

        case phaseStates.Action:
            sprite.sprite = pokeSprite;
            if (pokePosition == Vector3.zero)
            {
                pokePosition = player.transform.position + player.swordOffset + (transform.position - player.transform.position).normalized * pokeDistance / -2;
            }
            transform.position = Vector3.Lerp(startPosition, pokePosition, pokeMovement.Evaluate(elapsed / pokeTime));
            break;

        default:
            phaseState = phaseStates.Charge;
            break;
        }
        elapsed += Time.deltaTime;
    }
コード例 #2
0
    IEnumerator Clap()
    {
        currentPhase = Phases.Clap;
        for (int i = 0; i < clapAmount; i++)
        {
            firstPosition = Vector3.zero;
            startPosition = Vector3.zero;
            pokePosition  = Vector3.zero;
            elapsed       = 0;
            phaseState    = phaseStates.Charge;
            yield return(new WaitForSeconds(clapChargeTime));

            elapsed    = 0;
            canAttack  = true;
            phaseState = phaseStates.Action;
            yield return(new WaitForSeconds(clapTime));

            canAttack = false;
        }
        DetermineNextPhase();
    }
コード例 #3
0
    void ClapBehaviour()
    {
        if (currentPhase != Phases.Clap)
        {
            return;
        }

        if (firstPosition == Vector3.zero)
        {
            firstPosition = transform.position;
        }
        switch (phaseState)
        {
        case phaseStates.Charge:
            sprite.sprite      = chargeSprite;
            transform.right    = Vector3.Lerp(transform.right, (player.transform.position - transform.position) * (1 + -2 * Convert.ToInt32(!isRight)), rotationSpeed * Time.deltaTime * 100);
            startPosition      = new Vector3(clapOffset.x - (clapOffset.x * 2 * Convert.ToInt32(isRight)), clapOffset.y);
            transform.position = Vector3.Lerp(firstPosition, startPosition, chargeMovement.Evaluate(elapsed / clapChargeTime));
            break;

        case phaseStates.Action:
            sprite.sprite = clapSprite;
            //transform.rotation = Quaternion.Lerp(transform.rotation, Quaternion.identity, rotationSpeed * Time.deltaTime * 100);
            transform.up = Vector3.Lerp(transform.up, Vector3.up, rotationSpeed * Time.deltaTime * 100);
            if (pokePosition == Vector3.zero)
            {
                pokePosition = player.transform.position + player.swordOffset;
            }
            transform.position = new Vector3(Mathf.Lerp(startPosition.x, player.transform.position.x, ClapMovementX.Evaluate(elapsed / clapTime)), Mathf.Lerp(startPosition.y, pokePosition.y, ClapMovementY.Evaluate(elapsed / clapTime)));
            break;

        default:
            phaseState = phaseStates.Charge;
            break;
        }
        elapsed += Time.deltaTime;
    }