コード例 #1
0
        private IEnumerator DelayedEffect(AbilityData data, Action finished)
        {
            yield return(new WaitForSeconds(delay));

            if (abortIfCancelled && data.IsCancelled())
            {
                yield break;
            }
            foreach (var effect in delayedEffects)
            {
                effect.StartEffect(data, finished);
            }
        }
コード例 #2
0
        private IEnumerator Targeting(AbilityData data, PlayerController playerController, Action finished)
        {
            playerController.enabled = false;
            if (targetingPrefabInstance == null)
            {
                targetingPrefabInstance = Instantiate(targetingPrefab);
            }
            else
            {
                targetingPrefabInstance.gameObject.SetActive(true);
            }

            targetingPrefabInstance.localScale = new Vector3(areaOfEffectRadius * 2, 1f, areaOfEffectRadius * 2);

            while (!data.IsCancelled())
            {
                if (Input.GetMouseButton(1) || Input.GetKey(KeyCode.Escape))
                {
                    data.Cancel();
                    break;
                }

                Cursor.SetCursor(cursorTexture, cursorHotspot, CursorMode.Auto);
                RaycastHit raycastHit = new RaycastHit();

                if (Physics.Raycast(PlayerController.GetMouseRay(), out raycastHit, 1000, layerMask))
                {
                    targetingPrefabInstance.position = raycastHit.point;

                    if (Input.GetMouseButtonDown(0))
                    {
                        // Wait until the player stops clicking to avoid moving.
                        yield return(new WaitWhile(() => Input.GetMouseButton(0)));

                        data.SetTargetedPoint(raycastHit.point);
                        data.SetTargets(GetGameObjectsInRadius(raycastHit.point));
                        break;
                    }
                }
                yield return(null);
            }
            targetingPrefabInstance.gameObject.SetActive(false);
            playerController.enabled = true;
            finished();
        }