public static void Act(Student stud) { ActHandler actHandler = stud.IsAlive; actHandler += stud.CheckDays; actHandler += stud.Info; actHandler += stud.HeadMenu; Action <ConsoleKeyInfo> inputHandler = stud.HPMenu; inputHandler += stud.HappinessMenu; inputHandler += stud.FullnessMenu; inputHandler += stud.MoneyMenu; inputHandler += stud.BottlesMenu; inputHandler += stud.CasinoMenu; inputHandler += stud.ClothesMenu; inputHandler += stud.EducationMenu; if (stud is BusinessStudent) { inputHandler += stud.BusinessMenu; } else if (stud is ItStudent) { inputHandler += stud.ComputerShopping; } else if (stud is SportStudent) { inputHandler += stud.CompetitionMenu; } RunMenu(inputHandler, actHandler); }
public static void RunMenu(Action <ConsoleKeyInfo> inputHandler, ActHandler actHandler) { while (true) { actHandler?.Invoke(); inputHandler?.Invoke(Console.ReadKey()); } }
// Update is called once per frame void Update() { if (!levelIsSuspended) { ActHandler actHandler = null; switch (currentLevel.actRoster[currentActIndex].actType) { case ActType.None: Debug.Log("Empty act: " + currentActIndex); IncrementAct(); break; case ActType.Action: actHandler = HandleAction; break; case ActType.Condition: actHandler = HandleCondition; break; case ActType.Message: //Debug.Log ("HandleMessage @"+Time.frameCount); actHandler = HandleMessage; break; case ActType.Wave: //Debug.Log ("HandleWave @"+Time.frameCount); actHandler = HandleWave; break; default: IncrementAct(); Debug.Log("Invalid act type: " + currentLevel.actRoster[currentActIndex].actType); break; } if (actHandler != null) { //Debug.Log("Act handler is go."); actHandler(); } // } else { // Debug.LogError ("Invalid act type: " + currentAct.actType); // } } }