コード例 #1
0
    public virtual void ActivateSkill(SkillExecute sk, int index)
    {
        if (entityAnimator.GetFloat("attackCancelFloat") < 1f)
        {
            if (!sk.onCooldown)
            {
                if (!usingSkill)
                {
                    //PlayerManager.Instance.ZoomCameraInAndOut();
                    //SHOULD ONLY BE CALLED AFTER SKILL GOES ON COOLDOWN, EG. Stance change only goes on cooldown after the duration is over

                    try
                    {
                        skillUI.OnSkillUse(index);
                    }
                    catch
                    {
                        Debug.Log("skill UI not updating correctly");
                    }

                    try
                    {
                        _playerManager.StopAttacking();
                    }
                    catch
                    {
                        Debug.Log("Playermanager.StopAttacking");
                    }
                    //SKILL SHOULD DETERMINE WHICH ANIMATION TO USE
                    //Currently uses animation length to determine skill duration, probably should work other way around?

                    try
                    {
                        sk.Execute(sk.animationClip.length);
                    }
                    catch
                    {
                        try { sk.Execute(); }
                        catch { Debug.Log("Skill Execute"); }
                        Debug.Log("No skill animation!");
                    }

                    try
                    {
                        var ps = Instantiate(defaultParticles, VFXPoint.position, Quaternion.identity);
                        Destroy(ps, 0.5f);
                    }
                    catch { Debug.Log("Particles"); }
                    try
                    {
                        AddInvulnerability(sk.iFrameDuration);
                    }
                    catch
                    {
                        Debug.Log("Iframe");
                    }
                    try
                    {
                        StartCoroutine(GoOnCooldown(sk));
                    }
                    catch
                    {
                        Debug.Log("Cooldown");
                    }
                }
                else
                {
                    Debug.Log("Using a skill!");
                }
            }
            else
            {
                Debug.Log("Skill on Cooldown!");
            }
        }
        else
        {
            Debug.Log("Animation in progress!");
        }
    }