public EncounterController_Test()
        {
            encounterService = new Mock <IEncounterService>();
            var loggerService = new Mock <ILogger <EncounterController> >();
            Mock <IHttpContextAccessor> httpContextAccessorMock = new Mock <IHttpContextAccessor>();

            encounterService.Setup(x => x.GetEncounters(It.IsAny <string>())).ReturnsAsync(GetEncounters());

            encounterController = new EncounterController(loggerService.Object, encounterService.Object, httpContextAccessorMock.Object);
        }
Ejemplo n.º 2
0
    public void RandamEncounter()
    {
        Encounter encounter = Encounter.Instance;

        encounter.backGroundImage = backGroundImage;
        encounter.enemyGroups     = GetEncountEnemy();

        EncounterController.SetEncounterSteps();
        SceneFader.FadeSceneOut();
        SceneController.Instance.Transition("Battle");
    }
Ejemplo n.º 3
0
    public IEnumerator SetUp()
    {
        EncounterController encounter = EncounterController.Instance;

        SetBackGroundImage(encounter.backGroundImage);
        SetPlayAudio(encounter.bgm);
        SetBattleSetting(encounter.canEscape);
        GeneratePlayer();
        GenerateEnemy(encounter.enemyGroups);
        yield break;
    }
Ejemplo n.º 4
0
 private void Awake()
 {
     if (instance == null)
     {
         instance = this;
         DontDestroyOnLoad(gameObject);
     }
     else
     {
         Debug.LogWarning("More then one instance of EncounterController found!");
         Destroy(gameObject);
     }
 }
Ejemplo n.º 5
0
    //戦闘操作
    public void Battle(int id)
    {
        StartCoroutine(enumerator());
        IEnumerator enumerator()
        {
            EncounterController.Encount(id);
            BattleController.isBattle = true;
            yield return(new WaitUntil(() => BattleController.isBattle == false));

            LuaScript.instance.Resume();
            yield break;
        }
    }
Ejemplo n.º 6
0
 void Encount()
 {
     if (!EncounterController.canEncounter)
     {
         return;
     }
     EncounterController.walkingSteps++;
     if (EncounterController.IsEncount)
     {
         //エンカウントする
         EncounterController.Encount(GetEncountEnemy(), backGroundImage, bgm);
     }
 }
Ejemplo n.º 7
0
        public void Initialize(IPluginHost pluginHost)
        {
            Host         = pluginHost;
            FriendlyName = "DBM";
            Name         = AssemblyHelper.Name;
            Icon         = "Logo.png";
            Description  = AssemblyHelper.Description;
            Copyright    = AssemblyHelper.Copyright;
            Version      = AssemblyHelper.Version.ToString();
            Notice       = "";

            EncounterController.initialize();
        }
Ejemplo n.º 8
0
    private void Awake()
    {
        if (Instance != null)
        {
            Destroy(gameObject);
        }

        Instance = FindObjectOfType <EncounterController>();
        if (Instance == null)
        {
            GameObject gameObject = new GameObject("EncounterController");
            Instance = gameObject.AddComponent <EncounterController>();
        }
        DontDestroyOnLoad(this);
    }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        EncounterController myScript = (EncounterController)target;

        if (GUILayout.Button("Snap camera to event"))
        {
            Camera.main.transform.position = myScript.transform.position;
        }
        if (GUILayout.Button("Snap encounter to camera"))
        {
            myScript.transform.position = Camera.main.transform.position;
            CameraUtils.DrawCameraEdgesAt(Selection.activeTransform.position);
        }
    }
Ejemplo n.º 10
0
        private void processRotationAbility()
        {
            Regex rgx;

            if (phases.ContainsKey(_phase))
            {
                if (phases[_phase].rotationAbilities.Any())
                {
                    string debugOut = nextRotationAbility.warningMessage + " warning time. ";
                    if (nextRotationAbility.announceWarning)
                    {
                        string message = parseMessage(nextRotationAbility, nextRotationAbility.warningMessage);

                        tts(message);
                    }

                    RotationAbility tmpAbil = nextRotationAbility;



                    if (!nextRotationEnumerator.MoveNext())
                    {
                        nextRotationEnumerator = phases[_phase].rotationAbilitiesWarningTime.GetEnumerator();
                        nextRotationEnumerator.MoveNext();

                        phases[_phase].phaseStarted = phases[_phase].phaseStarted + phases[_phase].phaseLength;
                    }

                    nextRotationTime    = phases[_phase].phaseStarted + nextRotationEnumerator.Current.Key;
                    nextRotationAbility = nextRotationEnumerator.Current.Value;

                    debugOut += "nextRotationTime: " + nextRotationTime + " nextRotationAbility: " + nextRotationAbility.warningMessage;

                    EncounterController.debug(debugOut, DBMErrorLevel.FineTimings);

                    // Need to call this after moving to the next rotation
                    // otherwise the callback may swap phases, and we'd then skip the first rotation in the next phase
                    if (tmpAbil.warningCallback != null)
                    {
                        _inController = false;
                        tmpAbil.warningCallback(tmpAbil);
                        _inController = true;
                    }
                }
            }
        }
Ejemplo n.º 11
0
    public static void Encount(int id)
    {
        Encounter encounter = Encounter.Instance;
        //encounter.backGroundImage = backGroundImage;
        EnemyData enemyData = GameController.Instance.enemyMasterData.characterData.First(x => x.id == id);

        encounter.enemyGroups = new List <EncountEnemy>()
        {
            new EncountEnemy()
            {
                enemy = enemyData, posiiton = 0
            }
        };
        EncounterController.SetEncounterSteps();
        SceneFader.FadeSceneOut();
        SceneController.Instance.Transition("Battle");
    }
Ejemplo n.º 12
0
    public void Init()
    {
        if (data == null)
        {
            data = new DataController();
        }

        if (encounter == null)
        {
            encounter = GetComponent <EncounterController>();
        }

        if (player == null)
        {
            player = GetComponent <PlayerCharacter>();
        }

        Initialized = true;
        Debug.Log("GC Init " + Initialized);
    }
Ejemplo n.º 13
0
 public static void debug(string message, DBMErrorLevel level = DBMErrorLevel.EncounterErrors, Exception ex = null)
 {
     EncounterController.debug(message, level, ex);
 }
Ejemplo n.º 14
0
 public static void tts(string toRead)
 {
     EncounterController.tts(toRead);
 }
Ejemplo n.º 15
0
        private void testRotationAbilityRegex(string line)
        {
            foreach (KeyValuePair <TimeSpan, RotationAbility> abil in phases[_phase].rotationAbilities)
            {
                if (abil.Value.matchRegex && abil.Value.match != null)
                {
                    Match m = abil.Value.match.Match(line);

                    if (m.Success)
                    {
                        abil.Value.lastMatch.Clear();

                        int lineNumber = abil.Value.lastMatch.Count + 1;

                        abil.Value.lastMatch[lineNumber] = new Dictionary <string, string>();

                        string[] groupNames = abil.Value.match.GetGroupNames();

                        foreach (string groupName in groupNames)
                        {
                            abil.Value.lastMatch[lineNumber][groupName] = m.Groups[groupName].Value;
                        }


                        // Since we matched a rotation ability, we need to check the current time against when the timer was supposed to trigger,
                        // and adjust our timer accordingly so that it doesn't desync.

                        // Some abilities will match multiple times in a row, sometimes one or two seconds apart. Make sure we only process the first.
                        TimeSpan timeSinceLastMatched = (DateTime.Now - abil.Value.lastMatched).Duration();

                        if (timeSinceLastMatched < TimeSpan.FromSeconds(10))
                        {
                            EncounterController.debug(abil.Value.warningMessage + " matched multiple times too fast.", DBMErrorLevel.FineTimings);
                        }
                        else
                        {
                            abil.Value.lastMatched = DateTime.Now;


                            // First, figure out which point in the rotation is closest to our current time


                            TimeSpan closestKey = TimeSpan.Zero;
                            DateTime closest    = DateTime.MinValue;
                            TimeSpan diff       = TimeSpan.MaxValue;



                            foreach (KeyValuePair <TimeSpan, RotationAbility> abil2 in phases[_phase].rotationAbilities)
                            {
                                if (abil2.Value == abil.Value)
                                {
                                    DateTime tmpDT = phases[_phase].phaseStarted + abil2.Key;
                                    DateTime tmpDTLastRotationsTime = tmpDT - phases[_phase].phaseLength;
                                    DateTime tmpDTNextRotationsTime = tmpDT + phases[_phase].phaseLength;

                                    if ((tmpDT - DateTime.Now).Duration() < diff)
                                    {
                                        closest    = tmpDT;
                                        diff       = (tmpDT - DateTime.Now).Duration();
                                        closestKey = abil2.Key;
                                    }
                                    if ((tmpDTLastRotationsTime - DateTime.Now).Duration() < diff)
                                    {
                                        closest    = tmpDTLastRotationsTime;
                                        diff       = (tmpDTLastRotationsTime - DateTime.Now).Duration();
                                        closestKey = abil2.Key;
                                    }
                                    if ((tmpDTNextRotationsTime - DateTime.Now).Duration() < diff)
                                    {
                                        closest    = tmpDTNextRotationsTime;
                                        diff       = (tmpDTNextRotationsTime - DateTime.Now).Duration();
                                        closestKey = abil2.Key;
                                    }
                                }
                            }


                            DateTime abilThisRotationsTime = closest;
                            //abilThisRotationsTime = phases[_phase].phaseStarted + abil.Key;

                            DateTime abilLastRotationsTime = abilThisRotationsTime - phases[_phase].phaseLength;
                            DateTime abilNextRotationsTime = abilThisRotationsTime + phases[_phase].phaseLength;

                            TimeSpan timeBetweenNowAndThisRotationsTime = (DateTime.Now - abilThisRotationsTime).Duration();
                            TimeSpan timeUntilNextRotationsAbil         = (abilNextRotationsTime - DateTime.Now).Duration();
                            TimeSpan timeSinceLastRotationsAbil         = (DateTime.Now - abilLastRotationsTime).Duration();

                            EncounterController.debug(abil.Value.warningMessage + " matched (" + timeSinceLastRotationsAbil + ", " + timeBetweenNowAndThisRotationsTime + ", " + timeUntilNextRotationsAbil + "), phaseStarted: " + phases[_phase].phaseStarted + " nextRotationTime: " + nextRotationTime, DBMErrorLevel.FineTimings);


                            /* * /
                             * if (timeBetweenNowAndThisRotationsTime <= TimeSpan.FromSeconds(10) || abil.Value.uniqueInPhase)
                             * {
                             *  phases[_phase].phaseStarted += timeBetweenNowAndThisRotationsTime;
                             *  nextRotationTime += timeBetweenNowAndThisRotationsTime;
                             *
                             *  EncounterController.debug(" - timeBetweenNowAndThisRotationsTime closest, new phaseStarted: " + phases[_phase].phaseStarted + " new nextRotationTime: " + nextRotationTime, DBMErrorLevel.FineTimings);
                             * }
                             *
                             * /* */
                            if (timeUntilNextRotationsAbil < timeSinceLastRotationsAbil) // already passed this rotation, don't need to check last rotation times
                            {
                                if (timeUntilNextRotationsAbil < timeBetweenNowAndThisRotationsTime)
                                {
                                    if (timeUntilNextRotationsAbil <= TimeSpan.FromSeconds(10) || abil.Value.uniqueInPhase)
                                    {
                                        phases[_phase].phaseStarted += timeUntilNextRotationsAbil;
                                        nextRotationTime            += timeUntilNextRotationsAbil;

                                        EncounterController.debug(" - timeUntilNextRotationsAbil closest, new phaseStarted: " + phases[_phase].phaseStarted + " new nextRotationTime: " + nextRotationTime, DBMErrorLevel.FineTimings);
                                    }
                                }
                                else
                                {
                                    if (timeBetweenNowAndThisRotationsTime <= TimeSpan.FromSeconds(10) || abil.Value.uniqueInPhase)
                                    {
                                        phases[_phase].phaseStarted += timeBetweenNowAndThisRotationsTime;
                                        nextRotationTime            += timeBetweenNowAndThisRotationsTime;

                                        EncounterController.debug(" - timeBetweenNowAndThisRotationsTime closest, new phaseStarted: " + phases[_phase].phaseStarted + " new nextRotationTime: " + nextRotationTime, DBMErrorLevel.FineTimings);
                                    }
                                }
                            }
                            else // haven't passed rotation this rotation, check previous phase time and this rotation, ignore next rotation
                            {
                                if (timeSinceLastRotationsAbil < timeBetweenNowAndThisRotationsTime)
                                {
                                    if (timeSinceLastRotationsAbil <= TimeSpan.FromSeconds(10) || abil.Value.uniqueInPhase)
                                    {
                                        phases[_phase].phaseStarted -= timeSinceLastRotationsAbil;
                                        nextRotationTime            -= timeSinceLastRotationsAbil;

                                        EncounterController.debug(" - timeSinceLastRotationsAbil closest, new phaseStarted: " + phases[_phase].phaseStarted + " new nextRotationTime: " + nextRotationTime, DBMErrorLevel.FineTimings);
                                    }
                                }
                                else
                                {
                                    if (timeBetweenNowAndThisRotationsTime <= TimeSpan.FromSeconds(10) || abil.Value.uniqueInPhase)
                                    {
                                        phases[_phase].phaseStarted -= timeBetweenNowAndThisRotationsTime;
                                        nextRotationTime            -= timeBetweenNowAndThisRotationsTime;

                                        EncounterController.debug(" - timeBetweenNowAndThisRotationsTime closest, new phaseStarted: " + phases[_phase].phaseStarted + " new nextRotationTime: " + nextRotationTime, DBMErrorLevel.FineTimings);
                                    }
                                }
                            }
                            /* */
                        }

                        if (abil.Value.matchCallback != null)
                        {
                            _inController = false;
                            abil.Value.matchCallback(abil.Value, m);
                            _inController = true;
                        }
                    }
                }
            }
        }
Ejemplo n.º 16
0
 // Start is called before the first frame update
 void Start()
 {
     Controller = new EncounterController();
     Controller.initialize();
 }