Esempio n. 1
0
 // Start is called before the first frame update
 void Start()
 {
     soundManager    = GameObject.Find("SoundManager").GetComponent <SoundManager>();
     anim            = GameObject.Find("character").GetComponent <Animator>();
     abilityManager  = GameObject.Find("AbilitySystem").GetComponent <AbilitySwitch>();
     airAbility      = abilityManager.transform.Find("AirAbility").GetComponent <AirAbility>();
     manaManager     = GameObject.Find("ManaSystem").GetComponent <ManaManager>();
     jumpProgressBar = jumpChargeBar.transform.Find("Progress").GetComponent <Image>();
     jumpChargeBar.SetActive(false);
     jumpText.enabled = false;
     canJump          = true;
 }
Esempio n. 2
0
    void ChargeJump()
    {
        Rigidbody     rb            = gameObject.GetComponent <Rigidbody>();
        AbilitySwitch abilitySwitch = GameObject.Find("AbilitySystem").GetComponent <AbilitySwitch>();

        if (isGrounded)
        {
            if (Input.GetMouseButtonDown(1))
            {
                canJump = true;
            }

            if (Input.GetMouseButton(1))
            {
                abilitySwitch.enabled = false;
                airAbility.enabled    = false;
                rb.velocity           = Vector3.zero;

                if (jumpCharge < 1200f)
                {
                    jumpText.enabled = true;
                    jumpChargeBar.SetActive(true);
                    jumpCharge += Time.deltaTime * 800f;
                    jumpProgressBar.fillAmount = jumpCharge / 1200f;
                }
            }

            if (Input.GetMouseButtonDown(0) && canJump)
            {
                canJump          = !canJump;
                jumpCharge       = 0f;
                jumpText.enabled = false;
                jumpChargeBar.SetActive(false);
                abilitySwitch.enabled = true;
            }

            if (Input.GetMouseButtonUp(1))
            {
                airAbility.enabled = true;
                discharge          = true;
                jumpText.enabled   = false;
                jumpChargeBar.SetActive(false);
                abilitySwitch.enabled = true;

                manaManager.currManaAmount -= 20f;
            }
        }
    }
    // Notifies all subscribed switches that a switch was activated
    public void Notify(Weather weather)
    {
        AbilitySwitch?.Invoke(weather);

        _playerAbility.ActivateAbility(weather);
    }