Exemplo n.º 1
0
    private IEnumerator JumpCharge()
    {
        float chargeTime = 0.0f;

        while (Input.GetKey(KeyCode.Space))
        {
            chargeTime += Time.deltaTime;
            if (chargeTime > m_JumpMaxChargeTime)
            {
                chargeTime = m_JumpMaxChargeTime;
            }
            m_Model.localScale = new Vector3(1, Mathf.Lerp(1.0f, m_JumpMaxSquashAmount, Interpolation.CubicOut(chargeTime / m_JumpMaxChargeTime)), 1);
            yield return(null);
        }
        m_Model.localScale = Vector3.one;

        float chargePercentage = Interpolation.CubicOut(chargeTime / m_JumpMaxChargeTime);
        float force            = Mathf.Lerp(m_JumpMinForce, m_JumpMaxForce, chargePercentage);
        //calculate velocity from force
        Vector3 velocity = transform.up * force;

        velocity      += transform.forward * m_Speed;
        m_CurrentState = PlayerState.Airborne;
        m_AirVelocity  = velocity;
    }
Exemplo n.º 2
0
    public override void Charge()
    {
        charge += Time.deltaTime / AttackSpeed;
        charge  = Mathf.Min(charge, 1.0f);

        float   t        = Interpolation.CubicOut(charge);
        Vector3 spearPos = Interpolation.BezierCurve(StartPos, spearChargePos.localPosition, t);

        spearModel.transform.localPosition = spearPos;
        this.currentDamage    = Mathf.Lerp(MinDamage, Damage, charge);//charge == 1 ? Damage : MinDamage;
        this.currentKnockback = charge == 1 ? Knockback : MinKnockback;
    }
Exemplo n.º 3
0
    public override void Charge()
    {
        if (!currArrow)
        {
            currArrow = GameObject.Instantiate(ArrowPrefab, this.transform);
            //currArrow = arrowPool.Create();
            //currArrow.transform.SetParent(this.transform);
        }

        charge += Time.deltaTime / AttackSpeed;
        charge  = Mathf.Min(charge, 1.0f);

        float   t        = Interpolation.CubicOut(charge);
        Vector3 arrowPos = Interpolation.BezierCurve(this.transform.position, ChargedArrowPos.position, t);

        currArrow.transform.position = arrowPos;
    }
Exemplo n.º 4
0
    private IEnumerator CameraDeathAnimation()
    {
        // Play Sound
        string[] sounds =
        {
            "ceramic_shatter1",
            "ceramic_shatter2",
            "ceramic_shatter3",
        };
        AudioManager.Instance.PlaySoundAtLocation(sounds[Random.Range(0, sounds.Length)], ESoundChannel.SFX, transform.position);

        // Disable Player
        this.enabled      = false;
        collider.enabled  = false;
        health.Resistance = DamageType.BASIC | DamageType.EXPLOSIVE | DamageType.FIRE | DamageType.ICE | DamageType.LIGHTNING | DamageType.EARTH | DamageType.TRUE;

        // Enable Broken Pot
        brokenPot.transform.parent = null;
        brokenPot.gameObject.SetActive(true);
        LevelManager.Instance.MoveToScene(brokenPot.gameObject);
        brokenPot.Explode(3.0f, this.camera.transform.position);

        // Explosion Effect?
        int layermask = PhysicsCollisionMatrix.Instance.MaskForLayer(this.gameObject.layer);

        Collider[] colliders = Physics.OverlapSphere(Player.Instance.transform.position, 2.0f, layermask);
        foreach (Collider c in colliders)
        {
            Enemy enemy = c.GetComponentInChildren <Enemy>();
            if (enemy == null)
            {
                enemy = c.GetComponentInParent <Enemy>();
            }
            if (enemy != null)
            {
                Vector3 dir = c.transform.position - Player.Instance.transform.position;
                dir = dir.normalized;
                enemy.Knockback(dir * 5, 1.0f);
            }
        }

        // Deparent camera
        this.camera.transform.parent = null;

        // Hide Weapon
        Weapon currWeapon = GetCurrentWeapon();

        currWeapon.gameObject.SetActive(false);
        currWeapon.transform.SetParent(WeaponParent.transform, false);

        PlayerHud.Instance.DisablePlayerHud();
        DeathScreen.Instance.EnableDeathScreen();

        // Determine Camera Destination
        float   length    = 1.0f;
        float   startTime = Time.time;
        Vector3 startPos  = -this.transform.forward + camera.transform.position;

        Vector3 endPos = -this.transform.forward * CameraDeathDistance;

        endPos  = Quaternion.Euler(CameraDeathRotation, 0.0f, 0.0f) * endPos;
        endPos += camera.transform.position;

        while (Time.time < startTime + length)
        {
            float t = (Time.time - startTime) / length;

            Time.timeScale = Mathf.Max(1 - t, MinDeathTimeScale);

            float alpha = Mathf.Lerp(0, 128, t);
            DeathScreen.Instance.SetBackgroundAlpha(alpha);

            t = Interpolation.CubicOut(t);
            Vector3 pos = Vector3.Lerp(startPos, endPos, t);
            this.camera.transform.position = pos;
            this.camera.transform.LookAt(this.transform);

            if (InputManager.GetButtonDown("UI_Submit"))
            {
                Respawn();
            }

            yield return(null);
        }

        DeathScreen.Instance.SetBackgroundAlpha(128);
        Time.timeScale = 0.0f;

        // Check for restart
        while (true)
        {
            if (InputManager.GetButtonDown("UI_Submit"))
            {
                Respawn();
            }

            yield return(null);
        }
    }