Пример #1
0
        /// <summary> Generates event name for custom action </summary>
        /// <param name="modelElement"></param>
        /// <param name="eventDirection"></param>
        /// <param name="actionName"></param>
        /// <param name="phaseAction"></param>
        /// <returns></returns>
        public static string GetEventCode(string path, string[] actionName, PhaseAction phaseAction, EventDirection eventDirection)
        {
            var template = eventDirection == EventDirection.In
                ? EventHandlerDefinitions.PhaseActionTemplates[phaseAction].InEventNameTemplate
                : EventHandlerDefinitions.PhaseActionTemplates[phaseAction].OutEventNameTemplate;

            return(GetEventOrHandlerName(path, actionName, template));
        }
Пример #2
0
    public IEnumerator startActionBackground(PhaseAction action)
    {
        int startedPhase = currentPhase;

        while (currentPhase == startedPhase)
        {
            action.behavior.enabled = true;
            if (action.cooldownFrames > 0)
            {
                yield return(StartCoroutine(startAction(action, false)));
            }
            else
            {
                yield return(new WaitForEndOfFrame());
            }
        }
    }
Пример #3
0
    public IEnumerator startAction(PhaseAction action, bool startNewOnFinish)
    {
        action.behavior.enabled       = true;
        action.behavior.actionRunning = true;
        int startedPhase = currentPhase;

        if (action.independent || action.behavior == bossPhases[currentPhase].repeatingBehaviour)
        {
            while (action.behavior.actionRunning)
            {
                yield return(new WaitForEndOfFrame());
            }
        }
        else
        {
            for (int i = 0; i < action.runFrames; i++)
            {
                if (currentPhase != startedPhase)
                {
                    yield break;
                }
                yield return(new WaitForEndOfFrame());
            }
        }
        for (int i = 0; i < ((action.behavior == bossPhases[currentPhase].repeatingBehaviour) ? 0 : action.cooldownFrames); i++)
        {
            if (currentPhase != startedPhase)
            {
                yield break;
            }
            yield return(new WaitForEndOfFrame());
        }
        if (startNewOnFinish)
        {
            ChangeAction();
        }
    }
Пример #4
0
 public void ChangeAction()
 {
     if (currentAction.behavior != null)
     {
         currentAction.behavior.enabled = false;                                                     //disables the current action
     }
     if (bossPhases[currentPhase].repeatingBehaviour != null &&
         currentAction.behavior != bossPhases[currentPhase].repeatingBehaviour)
     {
         currentAction.behavior = bossPhases[currentPhase].repeatingBehaviour;                       //if there's a repeating beahior it will choose it if it wasnt the previous action running
     }
     // else if (actionQueue.Any()) { currentAction = actionQueue[0]; actionQueue.RemoveAt(0); }        // im pretty sure this is never used but i was afraid to eras it in case you wanted to modify it
     else if (bossPhases[currentPhase].PossibleActions.Count > 1)
     {                                                                                               //if there is more than one possible action then it randomly chooses one of them
         if (bossPhases[currentPhase].repeatingBehaviour != null)
         {
             currentAction = bossPhases[currentPhase].PossibleActions.Where(x => !x.Equals(currentAction)).ElementAt(rand.Next(bossPhases[currentPhase].PossibleActions.Count));
         }
         else
         {
             currentAction = bossPhases[currentPhase].PossibleActions.Where(x => !x.Equals(currentAction)).ElementAt(rand.Next(bossPhases[currentPhase].PossibleActions.Count - 1));
         }
     }
     else if (bossPhases[currentPhase].PossibleActions.Count != 0)
     {
         currentAction = bossPhases[currentPhase].PossibleActions.FirstOrDefault();                                                                           //otherwise it chooses the first one
     }
     if (currentAction.behavior != null)
     {
         StartCoroutine(startAction(currentAction, true));
     }
     else
     {
         Debug.Log("BBC Error: Cannot start null behavior!");
     }
 }
 public void SetPhaseAction(PhaseAction phaseAction)
 {
     _phaseAction = phaseAction;
 }
 public override PhaseAction ProducePhaseAction()
 {
     var retval = _phaseAction;
     _phaseAction = null;
     return retval;
 }
Пример #7
0
 /// <summary> Generates event name for standard action </summary>
 /// <param name="modelElement"></param>
 /// <param name="eventDirection"></param>
 /// <param name="eventAction"></param>
 /// <param name="phaseAction"></param>
 /// <returns></returns>
 public static string GetEventCode(string path, EventAction eventAction, PhaseAction phaseAction, EventDirection eventDirection)
 {
     return(GetEventCode(path, StandardActionsNames[eventAction], phaseAction, eventDirection));
 }
Пример #8
0
 public void AddAction(PhaseAction action)
 {
     _acitons.Add(action);
 }