public void MainController_IntialiseNewGame() { //FileReadWriter frw = new FileReadWriter(); //frw.WriteSaveDataFile("eventCatalogue", gs.GetEM().ParseCatalogueToString()); //frw.WriteSaveDataFile("itemCatalogue", gs.GetPCM().GetItemCatalogue().ParseToString()); //frw.WriteSaveDataFile("discoveryCatalogue", gs.GetDM().ParseCatalogueToString()); MainController mc = new MainController(); //Assert.IsTrue(mc.InitialiseNewGame(), "New game should be succesfully initialized"); mc.InitialiseNewGame(); GameState workingGS = mc.GetGameState(); PCModel workingPCM = workingGS.GetPCM(); LocationModel workingLM = workingGS.GetLM(); EventModel workingEM = workingGS.GetEM(); DiscoveryModel workingDM = workingGS.GetDM(); EventCatalogue ec = workingEM.GetEventCatalogue(); String workingEventCat = workingEM.ParseCatalogueToString(); String workingDiscCat = workingDM.ParseCatalogueToString(); String workingItemCat = workingPCM.GetItemCatalogue().ParseToString(); Assert.AreEqual(eventCatalogue, workingEventCat, "Event catalogues should match"); Assert.AreEqual(discoveryCatalogue, workingDiscCat, "Discovery catalogues should match"); Assert.AreEqual(itemCatalogue, workingItemCat, "Item catalogues should match"); Assert.AreEqual(512, workingLM.GetUnvisited().Count, "Should be 1024 unvisited nodes"); }
/// <summary> /// this invokes the game started event, and starts the timer for the game. /// </summary> public void StartGame() { //resets round time. currentTime = _roundTime; EventCatalogue.InvokeGameStartedEvent(); StartCoroutine(GameTimer()); }
/// <summary> /// Saves the highscore /// </summary> public void SaveHighScore() { EventCatalogue.OnUpdateTimer(_currentScore); if (_currentScore > _keyHandler.GetKey(StaticVariables.HIGH_SCORE)) { _keyHandler.SetKey(StaticVariables.HIGH_SCORE, _currentScore); } _currentScore = 0; }
public void EventCatalogue_CheckStringIsValid() { foreach (Tuple <String, String> test in validStrings) { Assert.IsTrue(EventCatalogue.IsValidEventCatalogue(test.Item1), test.Item2); } foreach (Tuple <String, String> test in invalidStrings) { Assert.IsFalse(EventCatalogue.IsValidEventCatalogue(test.Item1), test.Item2); } }
private List <DateTime> GetDates() { EventCatalogue ec = new EventCatalogue(); List <Event> evts = ec.GetAllItems().Result; List <DateTime> dates = new List <DateTime>(); foreach (Event evt in evts) { dates.Add(evt.StartTime.Date); } return(dates); }
public void EventCatalogue_ParseToString() { String validCat = EventCatalogue.TAG; foreach (Tuple <String, String> eventTest in validEvents) { validCat += "^" + eventTest.Item1; } evc = new EventCatalogue(validCat); Assert.AreEqual(validCat, evc.ParseToString(), "Strings should match"); }
/// <summary> /// Function checks if and with how many finger the user is touching the screen, and then invokes corresponding event. /// </summary> private void CheckInput() { // we're only checking for a single touch right now, when needed this could easily be extended to support more touches. switch (Input.touchCount) { case 0: // no input received, do nothing. break; case 1: EventCatalogue.InvokeSingleTouchEvent(); break; } }
public void EventCatalogue_ParseFromString() { String validCat = EventCatalogue.TAG; foreach (Tuple <String, String> eventTest in validEvents) { validCat += "^" + eventTest.Item1; } evc = new EventCatalogue(validCat); for (int i = 1; i <= validEvents.Count; i++) { Assert.AreEqual(validEvents[i - 1].Item1, evc.GetEvent(i).ParseToString(), "Events should match for event " + i); } }
/// <summary> /// this function functions as the game timer, and will call the game ended event once the max round time has been reached. /// </summary> /// <returns></returns> private IEnumerator GameTimer() { while (currentTime > 0) { currentTime -= Time.deltaTime; EventCatalogue.OnUpdateTimer((int)currentTime); yield return(new WaitForSeconds(0)); } EventCatalogue.OnUpdateTimer(0); yield return(new WaitForSeconds(0)); EndGame(); }
public void EventModel_ParseFromString() { EventModel em = new EventModel(validStrings[2].Item1, validCat[2].Item1, validEvents[0].Item1); EventCatalogue ec = new EventCatalogue(validCat[2].Item1); Assert.AreEqual(ec.ParseToString(), em.GetEventCatalogue().ParseToString()); Event eve = new Event(validEvents[0].Item1); Event temp = em.GetCurrentEvent(); Assert.AreEqual(eve.GetEventID(), em.GetCurrentEventID(), "Event IDs should match"); Assert.AreEqual(eve.GetEventText(), em.GetCurrentEventText(), "Event text should match"); Assert.AreEqual(eve.ParseToString(), temp.ParseToString(), "Strings of parsed events should match"); HashSet <int> used = em.GetUsedEvents(); for (int i = 1; i < 8; i++) { Assert.IsTrue(used.Contains(i), "Used should contain " + i); } }
public MainWindow() { InitializeComponent(); activeEffectsList = new BindingList <string>(); BindingSource activeSource = new BindingSource(); activeSource.DataSource = activeEffectsList; activeSelect.DataSource = activeSource; String aes = ReadFile("activeEffects.txt"); if (aes != "") { String[] aesElem = aes.Split('^'); for (int i = 1; i < aesElem.Length; i++) { activeEffectsList.Add(aesElem[i]); } } passiveEffectsList = new BindingList <string>(); BindingSource passiveSource = new BindingSource(); passiveSource.DataSource = passiveEffectsList; passiveSelect.DataSource = passiveSource; String pes = ReadFile("passiveEffects.txt"); if (pes != "") { String[] pesElem = pes.Split('^'); for (int i = 1; i < pesElem.Length; i++) { passiveEffectsList.Add(pesElem[i]); } } itemActiveList = new BindingList <string>(); BindingSource itemActiveSource = new BindingSource(); itemActiveSource.DataSource = itemActiveList; activeEffects.DataSource = itemActiveSource; itemPassiveList = new BindingList <string>(); BindingSource itemPassiveSource = new BindingSource(); itemPassiveSource.DataSource = itemPassiveList; passiveEffects.DataSource = itemPassiveSource; requirementsList = new BindingList <int>(); BindingSource requirementsSource = new BindingSource(); requirementsSource.DataSource = requirementsList; requirements.DataSource = requirementsSource; resources = new List <String>(); resources.Add(PlayerCharacter.HEALTH); resources.Add(PlayerCharacter.HUNGER); resources.Add(PlayerCharacter.THIRST); resources.Add(PlayerCharacter.SANITY); activeResource.DataSource = resources; passiveResource.DataSource = resources; eventResource.DataSource = resources; iconList = new SortedList <string, Image>(); iconFileNames = new BindingList <string>(); BindingSource fileNameSource = new BindingSource(); fileNameSource.DataSource = iconFileNames; iconSelect.DataSource = fileNameSource; DirectoryInfo dir = new DirectoryInfo(@"C:\Items\"); FileInfo[] imageFiles = dir.GetFiles("*.png"); for (int i = 0; i < imageFiles.Length; i++) { Image image = Image.FromFile(@"C:\Items\" + imageFiles[i].Name); iconList.Add(imageFiles[i].Name, image); iconFileNames.Add(imageFiles[i].Name); } itemList = new SortedList <int, Item>(); String filename = "itemCatalogue.txt"; String file = ReadFile(filename); if (ItemCatalogue.IsValidItemCatalogue(file)) { itemCatalogue = new ItemCatalogue(file); } else { itemCatalogue = new ItemCatalogue(""); } foreach (Item item in itemCatalogue.GetItems()) { itemList.Add(item.GetID(), item); } itemCatList = new BindingList <string>(); BindingSource itemCatListSource = new BindingSource(); itemCatListSource.DataSource = itemCatList; itemCatalogueList.DataSource = itemCatListSource; eventItemCatalogue.DataSource = itemCatListSource; itemResource.DataSource = itemCatListSource; foreach (Item item in itemCatalogue.GetItems()) { itemCatList.Add(String.Format("{0}:{1}", item.itemID, item.name)); } prEffectsList = new BindingList <String>(); itemEffectsList = new BindingList <string>(); BindingSource prEffectListSource = new BindingSource(); prEffectListSource.DataSource = prEffectsList; prEffectSelect.DataSource = prEffectListSource; BindingSource itemEffectListSource = new BindingSource(); itemEffectListSource.DataSource = itemEffectsList; itemEffectSelect.DataSource = itemEffectListSource; String ies = ReadFile("itemEffects.txt"); if (ies != "") { String[] iesElem = ies.Split('^'); for (int i = 1; i < iesElem.Length; i++) { itemEffectsList.Add(iesElem[i]); } } String pres = ReadFile("prEffects.txt"); if (pres != "") { String[] presElem = pres.Split('^'); for (int i = 1; i < presElem.Length; i++) { prEffectsList.Add(presElem[i]); } } sel_ItemEffectsList = new BindingList <String>(); sel_PREffectsList = new BindingList <String>(); BindingSource sel_pr = new BindingSource(); sel_pr.DataSource = sel_PREffectsList; prEffects.DataSource = sel_pr; BindingSource sel_item = new BindingSource(); sel_item.DataSource = sel_ItemEffectsList; itemEffects.DataSource = sel_item; optionsList = new BindingList <String>(); BindingSource optionsSource = new BindingSource(); optionsSource.DataSource = optionsList; options.DataSource = optionsSource; String eventFilename = "eventCatalogue.txt"; String eventfile = ReadFile(eventFilename); if (EventCatalogue.IsValidEventCatalogue(eventfile)) { eventCatalogue = new EventCatalogue(eventfile); } else { eventCatalogue = new EventCatalogue(""); } eventCat = new BindingList <String>(); foreach (Event ev in eventCatalogue.GetEvents()) { eventCat.Add(ev.GetEventID() + ":" + ev.GetEventText()); } BindingSource eventCatSource = new BindingSource(); eventCatSource.DataSource = eventCat; eventCreatorCatalogue.DataSource = eventCatSource; }
/// <summary> /// Decrements _currentScore /// </summary> /// <param name="decrementValue"></param> public void DecrementScore(int decrementValue) { _currentScore -= decrementValue; EventCatalogue.OnUpdateScoreEvent(_currentScore); }
/// <summary> /// Increments _currentScore /// </summary> /// <param name="incrementValue"></param> public void IncrementScore(int incrementValue) { _currentScore += incrementValue; EventCatalogue.OnSetHighScoreUiEvent(_currentScore); }
/// <summary> /// This function calls the event that ends the game. /// </summary> private void EndGame() { EventCatalogue.InvokeGameEndedEvent(); }
/// <summary> /// this resumes the game timer and time based behaviours resulting in the game continuing from where it was paused. /// </summary> public void ResumeGame() { Time.timeScale = 1; EventCatalogue.InvokeGameResumedEvent(); }
/// <summary> /// this pauses the game timer and time based behaviours resulting in the game staying stationary, besides maybe the shaders. /// </summary> public void PauseGame() { Time.timeScale = 0; EventCatalogue.InvokeGamePausedEvent(); }