Example #1
0
	// Update is called once per frame
    public GameObject UseWand(string fireButton, bool fired)
    {
        GameObject bullet = HandleInput(fireButton, fired);

        // Update time
        if (chargeState == CHARGESTATES.CHARGING)
        {
            float drainAmount = Time.deltaTime / timeToMaxCharge;

                chargeTimer += drainAmount;
                if (chargeTimer >= 1f)
                {
                    chargeTimer = 1f;
                    chargeState = CHARGESTATES.FULLCHARGE;
                    if (onChargeStateChange != null) onChargeStateChange(CHARGESTATES.FULLCHARGE);
                }
        }

        // Calc angle between spellborders
        float newAngle = Mathf.Lerp(spellborder_startAngle, spellborder_endAngle, EaseOut(charge));
        // Now rotate the borders
        spellBorder_left.transform.localRotation = Quaternion.AngleAxis(-newAngle, Vector3.up);
        spellBorder_right.transform.localRotation = Quaternion.AngleAxis(newAngle, Vector3.up);
        // set width on borders
        spellBorder_left.transform.localScale = new Vector3(Mathf.Lerp(startWidth, endWidth, charge), 1f, 1f);
        spellBorder_right.transform.localScale = new Vector3(Mathf.Lerp(startWidth, endWidth, charge), 1f, 1f);
		return bullet;
    }
Example #2
0
 void ActivateCharge()
 {
     chargeState = CHARGESTATES.CHARGING;
     chargeTimer = 0f;
     spellBorder_left.SetActive(true);
     spellBorder_left.transform.localRotation = Quaternion.AngleAxis(-spellborder_startAngle, Vector3.up);
     spellBorder_left.transform.localScale = new Vector3(startWidth, 1f, 1f);
     spellBorder_right.SetActive(true);
     spellBorder_right.transform.localRotation = Quaternion.AngleAxis(spellborder_startAngle, Vector3.up);
     spellBorder_right.transform.localScale = new Vector3(startWidth, 1f, 1f);
     if (onChargeStateChange != null) onChargeStateChange(CHARGESTATES.CHARGING);
 }
Example #3
0
 void DeactivateCharge()
 {
     chargeState = CHARGESTATES.IDLE;
     spellBorder_left.SetActive(false);
     spellBorder_right.SetActive(false);
     if (onChargeStateChange != null) onChargeStateChange(CHARGESTATES.IDLE);
 }