public void test_revert_bad_order() { Character c1 = new Character("Somebody"), c2 = new Character("Someone Else"); Guid c1_guid = Guid.NewGuid(), c2_guid = Guid.NewGuid(); ActionCharacterSet a1 = new ActionCharacterSet(c1_guid, null, c1), a2 = new ActionCharacterSet(c2_guid, null, c2), a3 = new ActionCharacterSet(c1_guid, c1, null); CampaignState state = new CampaignState(); Entry ent = new Entry(42, DateTime.Now, "Do all the things"); ent.actions.Add(a1); ent.actions.Add(a2); ent.actions.Add(a3); ent.apply(state); ent.actions[0] = a3; ent.actions[1] = a1; ent.actions[2] = a2; try { ent.revert(state); } catch (ArgumentException e) { Assert.IsTrue(e.Data.Contains("action_index")); Assert.AreEqual(e.Data["action_index"], 1); throw; } }
public SimpleCharacterWindow(CampaignState state, Guid?guid = null) { this.valid = false; this.state = state.copy(); this.actions = new List <EntryAction>(); if (guid is null) { ActionCharacterSet add_action = new ActionCharacterSet(Guid.NewGuid(), null, new Character("")); this.actions.Add(add_action); this.character = add_action.to; } else { this.character = this.state.characters.characters[guid.Value]; } this.guid = guid; this.property_rows = new ObservableCollection <PropertyRow>(); this.populate_property_rows(this.property_rows, new List <string>(), this.character.properties); this.selected_path = null; this.selected_prop = null; this.selected_member = null; InitializeComponent(); this.name_box.Text = this.character.name; this.properties_list.ItemsSource = this.property_rows; }
public void test_revert_topics_only() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); Guid topic1 = Guid.NewGuid(), topic2 = Guid.NewGuid(), topic3 = Guid.NewGuid(); Dictionary <Guid, int> adjust_topics = new Dictionary <Guid, int>() { [topic2] = -2, [topic3] = 1, }; Note note = new Note("Some note", ent.guid, new HashSet <Guid>() { topic1, topic2 }); CampaignState state = new CampaignState(); Guid note_guid = state.notes.add_note(note); ActionNoteUpdate action = new ActionNoteUpdate(note_guid, null, null, adjust_topics); action.apply(state, ent); action.revert(state, ent); Assert.AreEqual(note.contents, "Some note"); Assert.AreEqual(note.topics.Count, 2); Assert.IsTrue(note.topics.Contains(topic1)); Assert.IsTrue(note.topics.Contains(topic2)); Assert.AreEqual(note.topics.contents[topic2], 2); }
public async Task <bool> ActivateNode() { // Verify the Node is ready. if (!await RunNodeReadiness()) { return(false); } // Get Current Tile Data byte[] wtData = this.worldContent.GetWorldTileData(this.currentZone, this.character.curX, this.character.curY); // Identify Level Data at this node: int coordId = Coords.MapToInt(this.character.curX, this.character.curY); string levelId = this.currentZone.nodes.ContainsKey(coordId.ToString()) ? this.currentZone.nodes[coordId.ToString()] : ""; // If the level is valid, we can enter the level. bool isWon = this.campaign.IsLevelWon(this.campaign.zoneId, levelId); // Grant Character Their World Equipment On Casual or Beaten Nodes (after scene generated) if (!isWon && (wtData[5] != (byte)OTerrainObjects.NodeCasual && wtData[5] != (byte)OTerrainObjects.NodeWon)) { CampaignState campaign = Systems.handler.campaignState; campaign.SetUpgrades(0, 0, 0, 0, 0, 0, 0); campaign.SaveCampaign(); } SceneTransition.ToLevel(this.worldData.id, levelId, true); return(true); }
public void DisplayEvent(CampaignState campaignState) { int currentDepth = campaignState.depth; JSONObject eventObject = DataRetriever.GetRandomEventByDepth(currentDepth); gameObject.SetActive(true); eventTitle.text = eventObject.GetField(EVENT_NAME).str; eventDescription.text = eventObject.GetField(EVENT_DESCRIPTION).str.Replace("\\n", "\n"); availableOutcomes = eventObject.GetField(OUTCOMES_ARRAY).list; int numberOfOutcomes = availableOutcomes.Count; for (int i = 0; i < outcomeButtons.Length; i++) { Button outcomeButton = outcomeButtons[i]; outcomeButton.onClick.RemoveAllListeners(); if (i < numberOfOutcomes) { outcomeButton.onClick.AddListener(GenerateButtonListener(i)); outcomeButton.gameObject.SetActive(true); Text buttonText = buttonTexts[i]; buttonText.text = availableOutcomes[i].GetField(OUTCOME_BUTTON_TEXT).str; } else { outcomeButton.gameObject.SetActive(false); } } }
public static void ResetWorld() { ConsoleTrack.possibleTabs = "Example: `reset world`"; ConsoleTrack.helpText = "Reset the entire world, losing any progress made."; if (ConsoleTrack.activate) { WorldScene scene = (WorldScene)Systems.scene; CampaignState campaign = scene.campaign; StartNodeFormat start = scene.worldData.start; // Adjust Campaign Level Status campaign.levelStatus = new Dictionary <byte, Dictionary <string, CampaignLevelStatus> >(); // Reload Campaign State campaign.SetWorld(campaign.worldId); campaign.SetZone(campaign.zoneId); campaign.SetPosition(campaign.curX, campaign.curY, campaign.lastDir); campaign.SetLives(campaign.lives); campaign.SetWounds(campaign.health, campaign.armor); campaign.SetHead(campaign.head); campaign.SetUpgrades(campaign.suit, campaign.hat, campaign.shoes, campaign.powerAtt, campaign.powerMob, campaign.health, campaign.armor); campaign.SetLevelStatus(campaign.levelStatus); // Update Campaign Positions campaign.lastDir = (byte)DirCardinal.None; campaign.curX = start.x; campaign.curY = start.y; campaign.zoneId = start.zoneId; // Update Character scene.character.SetCharacter(campaign); } }
public WorldScene() : base() { // UI State UIHandler.SetUIOptions(false, false); UIHandler.SetMenu(null, false); // Prepare Components this.worldUI = new WorldUI(this); this.playerInput = Systems.localServer.MyPlayer.input; this.campaign = Systems.handler.campaignState; this.atlas = Systems.mapper.atlas[(byte)AtlasGroup.World]; // Prepare Mapper Data this.WorldTerrain = Systems.mapper.WorldTerrain; this.WorldLayers = Systems.mapper.WorldLayers; this.WorldObjects = new Dictionary <byte, string>(); this.WorldCharacters = Systems.mapper.WorldCharacters; this.PrepareWorldObjects(); // Prepare World Content this.worldContent = Systems.handler.worldContent; this.worldData = this.worldContent.data; // Prepare Campaign Details this.campaign.LoadCampaign(Systems.handler.worldContent.worldId, this.worldData.start); // Load World Character this.character = new WorldChar(this); }
/// <summary> /// saves the game state with no scenario state data (ie: only the campaign state is saved), use for NEW campaigns and saving a campaign when a scenario was just finished (flushes the unneeded scenario data) /// </summary> public bool SaveCampaignState(int saveIndex, CampaignState campaignState) { if (saveIndex == -1) { Debug.Log("SaveCampaignState() ERROR::saveIndex is -1"); return(false); } this.campaignState = campaignState; string fullPath = GetFullSavePath("SAVE" + saveIndex + ".sav"); string output = JsonConvert.SerializeObject(this, Formatting.Indented, new Vector3Converter()); try { using (var stream = File.CreateText(fullPath)) { stream.Write(output); } Debug.Log("SaveCampaignState()::SLOT " + saveIndex); Debug.Log(fullPath); return(true); } catch { Debug.Log("Could not save the state"); return(false); } }
public CharacterListControl(ActionCallback change_callback) { this.change_callback = change_callback; this.char_sheet = new CharacterSheet(); this.state = null; this.character_rows = null; InitializeComponent(); }
public InventoryListControl(ActionCallback change_callback) { this.change_callback = change_callback; this.save_state = null; this.state = null; this.inventory_rows = null; InitializeComponent(); }
void OnCampaignStateChange(CampaignState newCampaignState) { UpdateHealthDisplay(newCampaignState.player.CurrentHealth); UpdateInventoryDisplay(newCampaignState.inventory); depthText.text = newCampaignState.depth.ToString(); depthNameText.text = DataRetriever.GetDepthName(newCampaignState.depth); }
private void ApplyShouldUndress() { if (CampaignState.CurrentGameStarted()) { EquipmentHelper.AssignHeroEquipmentFromEquipment(new Hero(GameData.Instance.GameContext.Heroes.Player).ToTwHero(), new Equipment(true)); } else { GameData.Instance.GameContext.Heroes.Player.Equipments = new List <IEquipments>(); } }
public void SetCharacter(CampaignState campaign) { // Assign Character Details based on Campaign State this.faceRight = true; this.head = Head.GetHeadBySubType(campaign.head); this.hat = Hat.GetHatBySubType(campaign.hat); this.suit = Suit.GetSuitBySubType(campaign.suit); // Position Character this.PlaceAtPosition(campaign.curX, campaign.curY); }
public void test_apply_sparse() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); Task task = new Task(Guid.NewGuid(), "Some task"), new_task = new Task(task.entry_guid, "Some updated task", "Do something detailed"); CampaignState state = new CampaignState(); Guid task_guid = state.tasks.add_task(task); ActionTaskUpdate action = new ActionTaskUpdate(task_guid, task, new_task, false, true, false, false, false); action.apply(state, ent); Assert.AreEqual(task.name, "Some task"); Assert.AreEqual(task.description, "Do something detailed"); }
public void set_state( CampaignSave save_state, CampaignState state, decimal timestamp, Dictionary <Guid, Topic> topics = null, Dictionary <Guid, int> topic_refs = null, Dictionary <Guid, ExternalNote> notes = null ) { this.topic_cache.Clear(); if (topics is not null) { this.topics = topics; } else { this.topics = new Dictionary <Guid, Topic>(save_state.domain.topics); } if (topic_refs is not null) { this.topic_refs = topic_refs; } else { this.topic_refs = new Dictionary <Guid, int>(save_state.topic_refs); } if (notes is not null) { this.notes = notes; } else { this.notes = new Dictionary <Guid, ExternalNote>(save_state.domain.notes); } this.save_state = save_state; this.state = state; this.now = timestamp; this.populate_topic_rows(); if (this.state is null) { this.add_but.IsEnabled = false; this.rem_but.IsEnabled = false; this.view_but.IsEnabled = false; this.note_add_but.IsEnabled = false; this.external_note_add_but.IsEnabled = false; } else { this.add_but.IsEnabled = true; this.note_add_but.IsEnabled = true; this.external_note_add_but.IsEnabled = true; } }
public void BeginCampaign() { mainMenuController.gameObject.SetActive(false); mapController.gameObject.SetActive(true); EntityData player = ScriptableObject.Instantiate(playerData); CurrentCampaign = new CampaignState(new Inventory(), new Map(1), player); DataRetriever.UpdateDepthData(CurrentCampaign.depth); GameStateDelegates.OnCampaignStateUpdated(CurrentCampaign); InitializeFirstMap(); }
public void test_revert() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); Note note = new Note("Some note", ent.guid); Guid note_guid = Guid.NewGuid(); ActionNoteCreate action = new ActionNoteCreate(note_guid, note); CampaignState state = new CampaignState(); action.apply(state, ent); action.revert(state, ent); Assert.AreEqual(state.notes.notes.Count, 0); Assert.AreEqual(state.notes.active_notes.Count, 0); }
public void test_revert() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); Task task = new Task(ent.guid, "Some task"); Guid task_guid = Guid.NewGuid(); ActionTaskCreate action = new ActionTaskCreate(task_guid, task); CampaignState state = new CampaignState(); action.apply(state, ent); action.revert(state, ent); Assert.AreEqual(state.tasks.tasks.Count, 0); Assert.AreEqual(state.tasks.active_tasks.Count, 0); }
public void test_revert() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event"); Guid event_guid = Guid.NewGuid(); ActionCalendarEventCreate action = new ActionCalendarEventCreate(event_guid, evt); CampaignState state = new CampaignState(); action.apply(state, ent); action.revert(state, ent); Assert.AreEqual(state.events.events.Count, 0); Assert.AreEqual(state.events.active_events.Count, 0); }
public void test_apply() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); Note note = new Note("Some note", ent.guid); CampaignState state = new CampaignState(); Guid note_guid = state.notes.add_note(note); ActionNoteRemove action = new ActionNoteRemove(note_guid); action.apply(state, ent); Assert.AreEqual(state.notes.notes.Count, 1); Assert.IsTrue(state.notes.notes.ContainsKey(note_guid)); Assert.AreEqual(state.notes.notes[note_guid].contents, "Some note"); Assert.AreEqual(state.notes.active_notes.Count, 0); }
public void test_apply() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); Task task = new Task(ent.guid, "Some task"); CampaignState state = new CampaignState(); Guid task_guid = state.tasks.add_task(task); ActionTaskRemove action = new ActionTaskRemove(task_guid); action.apply(state, ent); Assert.AreEqual(state.tasks.tasks.Count, 1); Assert.IsTrue(state.tasks.tasks.ContainsKey(task_guid)); Assert.AreEqual(state.tasks.tasks[task_guid].name, "Some task"); Assert.AreEqual(state.tasks.active_tasks.Count, 0); }
public override void rebase(CampaignState state) { if (!state.characters.characters.ContainsKey(this.guid)) { throw new ArgumentOutOfRangeException(); } try { CharProperty prop = state.characters.characters[this.guid].get_property(this.path); this.from = prop.copy(); } catch (ArgumentOutOfRangeException) { this.from = null; } }
public void set_state(CampaignState state) { this.state = state; if (this.state is null) { this.add_but.IsEnabled = false; this.rem_but.IsEnabled = false; this.view_but.IsEnabled = false; this.character_rows.Clear(); return; } this.populate_character_rows(); this.add_but.IsEnabled = true; }
public void test_apply() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event"); CampaignState state = new CampaignState(); Guid event_guid = state.events.add_event(evt); ActionCalendarEventRemove action = new ActionCalendarEventRemove(event_guid); action.apply(state, ent); Assert.AreEqual(state.events.events.Count, 1); Assert.IsTrue(state.events.events.ContainsKey(event_guid)); Assert.AreEqual(state.events.events[event_guid].name, "Some event"); Assert.AreEqual(state.events.active_events.Count, 0); }
public void UpdateMapState(CampaignState campaign) { Map map = campaign.CurrentMap; map.nodeLayers.ForEach(layer => layer.ForEach(node => node.NodeController.DeactivateHighlight())); if (campaign.CurrentPlayerNode != currentPlayerNode) { lastPlayerNode = currentPlayerNode; if (lastPlayerNode != null) { lastPlayerNode.NodeController.RevertSprite(); } currentPlayerNode = campaign.CurrentPlayerNode; currentPlayerNode.NodeController.UpdateHighlight(playerNodeColor); currentPlayerNode.NodeController.SwapSprite(campaign.player.entitySprite); foreach (Transform path in paths) { LineRenderer pathRenderer = path.GetComponent <LineRenderer>(); pathRenderer.startColor = defaultPathColor; pathRenderer.endColor = defaultPathColor; } foreach (MapNode child in currentPlayerNode.children) { child.NodeController.UpdateHighlight(potentialDestinationColor); LineRenderer pathToChild = currentPlayerNode.NodeController.GetPath(child); pathToChild.startColor = potentialPathColor; pathToChild.endColor = potentialPathColor; } int pastPlayerNodeCount = campaign.pastPlayerNodes.Count; for (int i = 0; i < pastPlayerNodeCount; i++) { MapNode pastNode = campaign.pastPlayerNodes[i]; MapNode nextNode = campaign.CurrentPlayerNode; if (i < pastPlayerNodeCount - 1) { nextNode = campaign.pastPlayerNodes[i + 1]; } LineRenderer pastPath = pastNode.NodeController.GetPath(nextNode); pastPath.startColor = pastPathColor; pastPath.endColor = pastPathColor; } } }
public void set_state(CampaignSave save_state, CampaignState state) { this.save_state = save_state; this.state = state; if (this.state is null) { this.add_but.IsEnabled = false; this.rem_but.IsEnabled = false; this.view_but.IsEnabled = false; this.inventory_rows.Clear(); return; } this.populate_inventory_rows(); this.add_but.IsEnabled = true; }
public void test_apply_sparse() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event"), new_task = new CalendarEvent(evt.entry_guid, 0, "Some updated event", "Some updated thing"); CampaignState state = new CampaignState(); Guid event_guid = state.events.add_event(evt); ActionCalendarEventUpdate action = new ActionCalendarEventUpdate(event_guid, evt, new_task, false, false, true, false); action.apply(state, ent); Assert.AreEqual(evt.timestamp, 42); Assert.AreEqual(evt.name, "Some event"); Assert.AreEqual(evt.description, "Some updated thing"); Assert.IsNull(evt.interval); }
public void test_rebase() { Task task = new Task(Guid.NewGuid(), "Some task", "Do a thing", 42), new_task = new Task(task.entry_guid, "Some updated task", "Do an updated thing", 84); task.failed = true; new_task.completed_guid = Guid.NewGuid(); CampaignState state = new CampaignState(); Guid task_guid = state.tasks.add_task(task); ActionTaskUpdate action = new ActionTaskUpdate(task_guid, task, new_task, true, true, true, true, true); action.from.description = "Do a modified thing"; action.rebase(state); Assert.AreEqual(action.from.description, "Do a thing"); }
public TopicListControl(ActionCallback change_callback, Guid?entry_guid = null) { this.change_callback = change_callback; this.entry_guid = entry_guid; this.topics = null; this.topic_refs = null; this.notes = null; this.save_state = null; this.state = null; this.now = 0; this.topic_rows = new List <TopicRow>(); this.topic_cache = new Dictionary <Guid, List <EntityRow> >(); InitializeComponent(); this.topic_list.ItemsSource = this.topic_rows; }
public void test_revert() { Entry ent = new Entry(42, DateTime.Now, "Some Entry"); CalendarEvent evt = new CalendarEvent(Guid.NewGuid(), 42, "Some event", "Something", 86400), new_evt = new CalendarEvent(evt.entry_guid, 84, "Some updated event", "Some updated thing"); CampaignState state = new CampaignState(); Guid event_guid = state.events.add_event(evt); ActionCalendarEventUpdate action = new ActionCalendarEventUpdate(event_guid, evt, new_evt, true, true, true, true); action.apply(state, ent); action.revert(state, ent); Assert.AreEqual(evt.timestamp, 42); Assert.AreEqual(evt.name, "Some event"); Assert.AreEqual(evt.description, "Something"); Assert.AreEqual(evt.interval, 86400); }