Example #1
0
            public static Action GenerateAction(ActionName actionName)
            {
                Action action;

                switch (actionName)
                {
                case ActionName.CastSkill:
                    action = new CastSkillAction();
                    break;

                default:
                    throw new Exception(string.Format($"Not recognized action name of '{actionName}'"));
                }

                return(action);
            }
Example #2
0
            private bool IsSpawnerContainMonsterId(string monsterId)
            {
                for (int i = 0; i < spawn.actions.Count; i++)
                {
                    if (spawn.actions[i].IsSpawnAction())
                    {
                        CastSkillAction castSkillAction = spawn.actions[i] as CastSkillAction;
                        foreach (ChallengePreset challengePreset in castSkillAction.challengePresets)
                        {
                            if (!string.IsNullOrEmpty(challengePreset.path) && challengePreset.path.Contains(monsterId))
                            {
                                return(true);
                            }
                        }
                    }
                }

                return(false);
            }
            private float CalculateChallengeMinTime(Challenge challenge)
            {
                float challengeMinTime = 0;

                switch (challenge.trigger.ShowTriggerName())
                {
                case TriggerName.WaitForSeconds:
                    challengeMinTime = (challenge.trigger as TimeTrigger).waitTime;
                    break;

                case TriggerName.WaitForEvent:
                    EventTrigger eventTrigger = challenge.trigger as EventTrigger;
                    int          eventId      = eventTrigger.eventId;
                    challengeMinTime = trackerMinWaitTimeByEventID.ContainsKey(eventId)
                                                        ? trackerMinWaitTimeByEventID[eventId]
                                                        : 0;
                    challengeMinTime += eventTrigger.waitTime;
                    break;
                }

                if (challenge.IsSpawner())
                {
                    CalculateTrackerMinWaitTime(challenge.spawn.trackers, challengeMinTime);

                    float spawnerMinTime = 0;
                    foreach (Action action in challenge.spawn.actions)
                    {
                        if (action.IsSpawnAction())
                        {
                            CastSkillAction spawnAction = action as CastSkillAction;
                            float           triggerTime = 0;
                            float           spawnTime   = 0;

                            switch (spawnAction.ShowTriggerCondition())
                            {
                            case ActionTriggerCondition.Time:
                                triggerTime = spawnAction.waitTime;
                                break;

                            case ActionTriggerCondition.ByEvent:
                                triggerTime = trackerMinWaitTimeByEventID.ContainsKey(spawnAction.eventId)
                                                                                ? trackerMinWaitTimeByEventID[spawnAction.eventId]
                                                                                : 0;
                                triggerTime += spawnAction.waitTime;
                                break;
                            }

                            foreach (ChallengePreset challengePreset in spawnAction.challengePresets)
                            {
                                spawnTime = Mathf.Max(spawnTime,
                                                      challengePreset.delay + (challengePreset.count - 1) * challengePreset.interval);

                                // DLog.Log($"{challengeMinTime + action.waitTime + challengePreset.delay}s");
                                CalculateTrackerMinWaitTime(challengePreset.trackers, challengeMinTime + action.waitTime + challengePreset.delay);
                            }

                            spawnerMinTime = Mathf.Max(triggerTime + spawnTime, spawnerMinTime);
                        }
                    }

                    challengeMinTime += spawnerMinTime;
                }
                else
                {
                    CalculateTrackerMinWaitTime(challenge.spawn.trackers, challengeMinTime);
                }

                return(challengeMinTime);
            }