///<summary>set battleStarted to be True</summary> public void startBattle() { AgentPreset preset; initEnemyNumber = inspector.getCurrentEnemys().Length; initKnightNumber = inspector.getCurrentKnights().Length; int numberOfSpace = inspector.getCurrentUnits().Length *2; foreach (GameObject unit in inspector.getCurrentUnits()) { if (unit.TryGetComponent <AgentPreset>(out preset)) { if (preset.AgentType == "Unit") { dynamic obj = preset.refer(numberOfSpace, AcademyInner.resetParameters); unit.SetActive(true); unit.SendMessage("initRefer", obj, SendMessageOptions.RequireReceiver); } else { Type anytype = Type.GetType(preset.AgentType); if (anytype != null) { Component script = unit.AddComponent(anytype); dynamic obj = preset.refer(numberOfSpace, AcademyInner.resetParameters); Debug.Log($"{anytype.Name} / {script.name} / {obj}"); unit.SetActive(true); script.SendMessage("initRefer", obj, SendMessageOptions.RequireReceiver); } else { Debug.LogError("There was invalid Agent type string which couldn't converted to type object "); } } } } print($"Start:{knightUnits.Length}/{enemyUnits.Length}"); //show the new UI cam.onStart(); StartCoroutine(battleUI()); battleStarted = true; //Hardcoded rewarding algorithm, need to be adjusted AllInitLives = 0; }