Beispiel #1
0
        public void Cast(IAbilityUser originator, params IAbilityUser[] targets)
        {
            if (instanceManager == null || !unlocked)
            {
                return;
            }

            string id = originator.GetInstanceID() + "";

            if (targets.Length <= 0)
            {
                if (!instanceManager.IsCastLegitimate(id))
                {
                    return;
                }
                instanceManager.RequestInstance(id).Cast(originator, null);
            }

            for (int t = 0; t < targets.Length; t++)
            {
                if (!instanceManager.IsCastLegitimate(id))
                {
                    return;
                }
                instanceManager.RequestInstance(id).Cast(originator, targets[t]);
            }
        }
        internal void Cast(IAbilityUser originator, IAbilityUser target)
        {
            m_CachedID   = originator.GetInstanceID() + "";
            m_Originator = originator;
            m_Target     = target;

            m_LastList = new Stack <int>();
            m_LastList.Push(0);

            transform.position = Vector3.zero;

            for (int s = 0; s < subInstanceLinks.Length; s++)
            {
                SubInstanceLink link = subInstanceLinks[s];

                // Set the correct spawn position
                switch (link.spawn)
                {
                case SubInstanceLink.Spawn.Originator:
                    link.obj.transform.position = originator.GetCenter() + link.spawnOffset;
                    break;

                case SubInstanceLink.Spawn.Target:
                    link.obj.transform.position = target.GetCenter() + link.spawnOffset;
                    break;

                case SubInstanceLink.Spawn.Zero:
                    link.obj.transform.position = link.spawnOffset;
                    break;
                }

                // Start particle system
                if (link.particleSystem != null)
                {
                    link.particleSystem.Play();
                }

                // Show mesh renderer
                if (link.meshRenderer != null)
                {
                    link.meshRenderer.enabled = true;
                }
                for (int r = 0; r < link.meshRendererAll.Length; r++)
                {
                    if (link.meshRendererAll[r] != null)
                    {
                        link.meshRendererAll[r].enabled = true;
                    }
                }

                if (target != null)
                {
                    link.direction = (target.GetCenter() - originator.GetCenter()).normalized;
                }
                else
                {
                    link.direction = Vector3.zero;
                }

                subInstanceLinks[s].obj.SetActive(true);
            }

            for (int v = 0; v < sharedVariables.Length; v++)
            {
                sharedVariables[v].RestoreDefault();
            }

            for (int p = 0; p < phaseLists.Length; p++)
            {
                DefineContext(phaseLists[p]);
                phaseLists[p].OnCast();
            }

            isUpdating = true;
        }