コード例 #1
0
    public virtual IEnumerator CastAbilityBasicCoroutine()
    {
        while (targetObject != null)
        {
            if (!_statsGeneral.CheckCooldown())
            {
                StatsGeneral tempstats = basicAbilityPrefab.GetComponent <StatsGeneral>();

                //Rotate to target
                Quaternion targetRotation = Quaternion.LookRotation(targetObject.transform.position - transform.position);
                targetRotation.x       = 0;
                targetRotation.z       = 0;
                thisTransform.rotation = targetRotation;

                Debug.Log("PEW");

                // Cast ability
                GameObject clone = (GameObject)Instantiate(basicAbilityPrefab, thisTransform.position, thisTransform.rotation);

                cachedAbilityBasicController = clone.GetComponent <AbilityController>();

                // Set target and stats
                cachedAbilityBasicController.SetTargetObject(targetObject);
                cachedAbilityBasicController.GenerateCombatStatistics(_statsGeneral, _statsOffense, _statsDefense);

                // Start global cooldown
                _statsGeneral.StartGlobalCooldown(_statsOffense._combatAttackSpeed);
            }
            yield return(null);
        }
    }