コード例 #1
0
        //private void LookTowardsCursor()
        //{
        //1st method:
        //float mouseInput = Input.GetAxis("Mouse X");
        //Vector3 lookhere = new Vector3(0, mouseInput, 0);
        //transform.Rotate(lookhere);
        //2nd method:
        //float h = 2f * Input.GetAxis("Mouse X");
        //float v = 2f * Input.GetAxis("Mouse Y");
        //transform.Rotate(v, h, 0);
        //}

        private void ScanForDefensiveMovementKeyUp()
        {
            if (Input.GetKey("w") && !shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                float directionV = 1f;
                float directionH = 0f;
                character.Dodge(directionV, directionH);
            }

            if (Input.GetKeyUp("w") && shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                if (abilities.GetCurrentStamina() >= abilities.getRollingCost)
                {
                    abilities.ConsumeStamina(abilities.getRollingCost);
                    float directionV = 2f;
                    float directionH = 0f;
                    character.Dodge(directionV, directionH);
                }
                else
                {
                    float directionV = 1f;
                    float directionH = 0f;
                    character.Dodge(directionV, directionH);
                }
            }

            if (Input.GetKey("s") && !shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                float directionV = -1f;
                float directionH = 0f;
                character.Dodge(directionV, directionH);
            }

            if (Input.GetKeyUp("s") && shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                if (abilities.GetCurrentStamina() >= abilities.getRollingCost)
                {
                    abilities.ConsumeStamina(abilities.getRollingCost);
                    float directionV = -2f;
                    float directionH = 0f;
                    character.Dodge(directionV, directionH);
                }
                else
                {
                    float directionV = -1f;
                    float directionH = 0f;
                    character.Dodge(directionV, directionH);
                }
            }

            if (Input.GetKey("a") && !shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                float directionV = 0f;
                float directionH = -1f;
                character.Dodge(directionV, directionH);
            }

            if (Input.GetKeyUp("a") && shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                if (abilities.GetCurrentStamina() >= abilities.getDodgeCost)
                {
                    abilities.ConsumeStamina(abilities.getDodgeCost);
                    float directionV = 0f;
                    float directionH = -2f;
                    character.Dodge(directionV, directionH);
                }
                else
                {
                    float directionV = 0f;
                    float directionH = -1f;
                    character.Dodge(directionV, directionH);
                }
            }

            if (Input.GetKey("d") && !shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                float directionV = 0f;
                float directionH = 1f;
                character.Dodge(directionV, directionH);
            }

            if (Input.GetKeyUp("d") && shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                if (abilities.GetCurrentStamina() >= abilities.getDodgeCost)
                {
                    abilities.ConsumeStamina(abilities.getDodgeCost);
                    float directionV = 0f;
                    float directionH = 2f;
                    character.Dodge(directionV, directionH);
                }
                else
                {
                    float directionV = 0f;
                    float directionH = 1f;
                    character.Dodge(directionV, directionH);
                }
            }

            if (Input.GetKeyUp("x") && !shiftPressed && !character.IsDefending && !character.IsAttacking)
            {
                character.Rest();
            }

            if (Input.GetMouseButtonUp(0) && shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                weaponSystem.AttackOnce();
            }

            if (Input.GetMouseButtonUp(1) && shiftPressed && !character.IsDefending && !character.IsAttacking && !character.IsResting)
            {
                weaponSystem.Combo();
            }
        }