Ejemplo n.º 1
0
        private void DefineContext(PhaseList list)
        {
            AbilityContext.instance = this;

            AbilityContext.phaseList = list;

            AbilityContext.originator = m_Originator;
            AbilityContext.target     = m_Target;
        }
Ejemplo n.º 2
0
        public void ScheduleList()
        {
            PhaseList list = AbilityContext.instance.IDToPhaseList(id);

            if (list != null)
            {
                AbilityContext.instance.RunList(list);
            }
        }
Ejemplo n.º 3
0
        public void RunList()
        {
            PhaseList list = AbilityContext.instance.IDToPhaseList(id);

            if (list != null)
            {
                list.OnUpdate();
            }
        }
Ejemplo n.º 4
0
 internal void RunList(PhaseList list)
 {
     for (int p = 0; p < phaseLists.Length; p++)
     {
         if (phaseLists[p] == list)
         {
             m_LastList.Push(p);
             return;
         }
     }
 }
Ejemplo n.º 5
0
        internal PhaseList Clone()
        {
            PhaseList clone = new PhaseList(id);

            clone.title          = title;
            clone.instant        = instant;
            clone.m_CurrentPhase = m_CurrentPhase;

            clone.phases = new Phases.PhaseCore[phases.Length];
            for (int p = 0; p < phases.Length; p++)
            {
                clone.phases[p] = ScriptableObject.Instantiate <Phases.PhaseCore>(phases[p]);
            }

            return(clone);
        }
Ejemplo n.º 6
0
        private void Update()
        {
            if (isDying && IsDead())
            {
                Reset();
                return;
            }

            if (!isUpdating || isDying)
            {
                return;
            }

            PhaseList list = phaseLists[m_LastList.Peek()];

            DefineContext(list);
            Result result = list.OnUpdate();

            switch (result)
            {
            case Result.Success:
                m_LastList.Pop();
                // If default list is finished init ability dying
                if (m_LastList.Count <= 0)
                {
                    isDying = true;
                    return;
                }
                break;

            case Result.Running:
                // If the list was instant then rerun
                if (list.instant)
                {
                    Update();
                }
                break;

            case Result.Fail:
                isDying = true;
                break;
            }
        }