public void SetRepliesText(TalkNode node) { SelectedReply = 0; ValidReplies.Clear(); foreach (TextLabel label in TalkLabels) label.Caption = ""; foreach (TalkReply reply in CurrentNode.Replies) { if (reply.IsConditionFulfilled()) { if (ValidReplies.Count > TalkLabels.Count) throw new Exception("Zbyt dużo możliwych odpowiedzi"); TalkLabels[ValidReplies.Count].Caption = reply.Text[0].Text; ValidReplies.Add(reply); } } }
public TalkEdge(TalkNode target) { Condits = new List <Condition>(); TalkNode = target; base.Conditions += (() => Other); }
// @@ funkcja odpowiedzialna za obsługę rozmowy public void HandleConversation() { TextRemainingTime -= Engine.FixedTimeStep; if (TalkState == HumanTalkState.LISTENING) { if (TextRemainingTime <= 0) { TextIndex++; if (TextIndex == CurrentNode.Text.Count) { if (CurrentNode.Replies.Count == 0) { SwitchState(HumanControllerState.FREE); // zakończenie rozmowy przez npc'a } else { SetRepliesText(CurrentNode); SwitchTalkState(HumanTalkState.CHOOSING_REPLY); } } else { BeginTextDisplay(CurrentNode.Text[TextIndex]); } } else if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_SPACE)) { TextRemainingTime = 0; Engine.Singleton.SoundManager.StopDialog(); } } else if (TalkState == HumanTalkState.REPLYING) { if (TextRemainingTime <= 0) { TextIndex++; if (TextIndex == CurrentReply.Text.Count) { if (CurrentReply.IsEnding) { SwitchState(HumanControllerState.FREE); } else { TalkNode Tymczas = new TalkNode(); Tymczas.WhoSays = CurrentNode.WhoSays; CurrentNode = CurrentReply.Reaction.PickNode(Tymczas.WhoSays); SwitchTalkState(HumanTalkState.PAUSE); } } else { BeginTextDisplay(CurrentReply.Text[TextIndex]); } } else if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_SPACE) && !CurrentReply.IsEnding) { TextRemainingTime = 0; Engine.Singleton.SoundManager.StopDialog(); } } else if (TalkState == HumanTalkState.PAUSE) { if (TextRemainingTime <= 0) { SwitchTalkState(HumanTalkState.LISTENING); } } else if (TalkState == HumanTalkState.CHOOSING_REPLY) { if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_S)) { SelectedReply++; if (SelectedReply == ValidReplies.Count) SelectedReply = 0; } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_W)) { SelectedReply--; if (SelectedReply == -1) SelectedReply = ValidReplies.Count - 1; } UpdateRepliesColours(); if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_SPACE)) { CurrentReply = ValidReplies[SelectedReply]; SwitchTalkState(HumanTalkState.REPLYING); } } }
// @@ funkcja odpowiedzialna za całokształt poruszania się private void HandleMovement() { Character.TurnDelta = -Engine.Singleton.Mouse.MouseState.X.rel * 0.1f * MouseSpeed; // obracanie postaci Degree akt = Engine.Singleton.GameCamera.Angle; Degree zmiana; if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_U)) { long currentTime = Engine.Singleton.Root.Timer.Milliseconds / 1000; Console.WriteLine(currentTime); Activity Walk = new Activity(); Walk.v3 = new Vector3(6.42f, -1.0f, 9); Walk.Type = ActivityType.WALK; Activity Walk2 = new Activity(); Walk2.v3 = new Vector3(-9.3f, -1.07f, 8.94f); Walk2.Type = ActivityType.WALK; Activity Wait = new Activity(); Wait.i = 5; Wait.Type = ActivityType.WAIT; if (FocusObject is Character) { (FocusObject as Character).Activities.Repeat = true; (FocusObject as Character).Activities.Activities.Add(Walk); (FocusObject as Character).Activities.Activities.Add(Walk2); (FocusObject as Character).Activities.Activities.Add(Wait); } } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_F4)) { Engine.Singleton.CurrentLevel.ToggleWaypoints(); } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_F5)) // quick save { if (System.IO.Directory.Exists("Saves\\QuickSave")) System.IO.Directory.Delete("Saves\\QuickSave", true); Engine.Singleton.CopyAll(new System.IO.DirectoryInfo("Saves\\AutoSave"), new System.IO.DirectoryInfo("Saves\\QuickSave")); Engine.Singleton.AutoSave("QuickSave"); } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_F9)) // quick load Engine.Singleton.Load("QuickSave"); if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_J)) { if (FocusObject is Character) { (FocusObject as Character).obejdz = true; } } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_I)) WIXA_W_KARCZMIE_MODE = !WIXA_W_KARCZMIE_MODE; if (!InvertMouse) // ruszanie kamerą (góra i dół) zmiana = new Degree(Engine.Singleton.Mouse.MouseState.Y.rel * 0.1f * MouseSpeed); else zmiana = new Degree(-Engine.Singleton.Mouse.MouseState.Y.rel * 0.1f * MouseSpeed); if (zmiana + akt < new Degree(70) && zmiana + akt > new Degree(-45)) Engine.Singleton.GameCamera.Angle += zmiana; if (Engine.Singleton.Mouse.MouseState.Z.rel != 0) { if (Engine.Singleton.GameCamera.Distance -(float)Engine.Singleton.Mouse.MouseState.Z.rel * 0.005f < 10.0f && Engine.Singleton.GameCamera.Distance - (float)Engine.Singleton.Mouse.MouseState.Z.rel * 0.005f > 2.0f) Engine.Singleton.GameCamera.Distance -= (float)Engine.Singleton.Mouse.MouseState.Z.rel *0.005f; } if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_F)) // podnoszenie, otwieranie, itp. { if (FocusObject != null) { if (FocusObject is Described) { if ((FocusObject as Described).IsPickable) Character.TryPick(FocusObject as Described); else if ((FocusObject as Described).IsContainer) // czy jest kontenerem { HUDContainer.Container = (FocusObject as Described).Container; SwitchState(HumanControllerState.CONTAINER); } else // AKTYWATOR!!!!!! WOLOLO! { (FocusObject as Described).PerformAkt = true; } } if (FocusObject is Character) { if ((FocusObject as Character).IsContainer) // czy człowiek jest kontenerem { HUDContainer.Container.Contains = (FocusObject as Character).Inventory; HUDContainer.Container.Gold = (int)((FocusObject as Character).Profile.Gold); SwitchState(HumanControllerState.CONTAINER); } } if (FocusObject is Enemy) { if ((FocusObject as Enemy).IsContainer) // czy człowiek jest kontenerem { HUDContainer.Container.Contains = (FocusObject as Enemy).DropPrize.ItemsList; Character.Profile.Gold += (ulong)(FocusObject as Enemy).DropPrize.AmountGold; (FocusObject as Enemy).DropPrize.AmountGold = 0; SwitchState(HumanControllerState.CONTAINER); } } } } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_C)) SwitchState(HumanControllerState.STATS); if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_K)) Character.Statistics.aktualnaZywotnosc = Character.Statistics.Zywotnosc; //SwitchState(HumanControllerState.CREATOR_STATS); if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_Z)) // tzw. skok Character.Position = new Vector3(Character.Position.x, Character.Position.y + 1, Character.Position.z); if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_X)) // wypisanie w konsoli aktualnej pozycji postaci { Console.Write("Pozycja: "); Console.Write(Character.Position.x); Console.Write(", "); Console.Write(Character.Position.y); Console.Write(", "); Console.WriteLine(Character.Position.z); } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_B)) // wypisanie w konsoli aktywnych kłestów { Console.WriteLine("Aktywne Questy: "); foreach (Quest Q in Engine.Singleton.HumanController.Character.ActiveQuests.Quests) { if (!Q.IsFinished) { Console.Write("- "); Console.Write(Q.Name); if (Q.isDone) Console.Write(" DONE \n"); else Console.Write(" NOTdone \n"); } } //Console.WriteLine(Engine.Singleton.HumanController.Character.Quests.Count); } if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_SPACE)) // @@ rozpoczęcie rozmowy { if (FocusObject != null) { if (Character.TalkPerm && FocusObject.TalkRoot != null) { if (FocusObject is Character) { FocusObject.TalkRoot.WhoSays = (FocusObject as Character); (FocusObject as Character).TurnTo(Character.Position); if ((FocusObject as Character).Activities.InProgress) { (FocusObject as Character).Activities.Paused = true; (FocusObject as Character).Activities.InProgress = false; (FocusObject as Character).Waiting = false; (FocusObject as Character).FollowPathOrder = false; } } CurrentNode = FocusObject.TalkRoot.PickNode(); SwitchState(HumanControllerState.TALK); } } } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_TAB) // @@ Otwarcie ekwipunku && Character.InventoryPerm) SwitchState(HumanControllerState.INVENTORY); if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_A)) // { Character.MoveRightOrder = false; Character.MoveLeftOrder = true; Character.MoveOrder = false; Character.RunOrder = false; Character.MoveOrderBack = false; } else Character.MoveLeftOrder = false; if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_D)) { Character.MoveRightOrder = true; Character.MoveLeftOrder = false; Character.MoveOrder = false; Character.RunOrder = false; Character.MoveOrderBack = false; } else Character.MoveRightOrder = false; if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_L)) HUD.ToggleLog(); if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_W)) // chodzenie do przodu +bieganie { Character.MoveOrder = true; Character.MoveOrderBack = false; Character.MoveRightOrder = false; Character.MoveLeftOrder = false; if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_LSHIFT)) { if (!Character.RunOrder) Character.RunOrder = true; else Character.RunOrder = false; } } else { Character.MoveOrder = false; Character.RunOrder = false; } if (Engine.Singleton.Keyboard.IsKeyDown(MOIS.KeyCode.KC_S)) // "chodzenie" do tyłu. W aktualnej wersji { // przesuwanie o wektor przeciwny w osiach Character.MoveOrder = false; // x i z do wektora skierowanego do przodu Character.MoveOrderBack = true; // postaci (zwyczajny brak odpowiedniej animacji) Character.MoveRightOrder = false; Character.MoveLeftOrder = false; } else Character.MoveOrderBack = false; if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_F12)) SwitchState(HumanControllerState.CONSOLE); if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_COMMA)) // poprzednia piosenka Engine.Singleton.SoundManager.PreviousBGM(); else if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_PERIOD)) // następna piosenka Engine.Singleton.SoundManager.NextBGM(); if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_SLASH)) Engine.Singleton.SoundManager.TogglePauseBGM(); if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_H)) // wyświetlanie i chowanie HUD'a { HUD.ToggleVisibility(); } if (Engine.Singleton.IsKeyTyped(MOIS.KeyCode.KC_E)) // @@@ Wyciąganie i chowanie miecza. { if (Character.Sword != null && !Character.Sword.InUse) { Character.MoveOrder = false; Character.RunOrder = false; Character.MoveOrderBack = false; Character.GetSwordOrder = true; HUD.DrawLog = true; } else if (Character.Sword != null && Character.Sword.InUse) { Character.MoveOrder = false; Character.RunOrder = false; Character.MoveOrderBack = false; Character.HideSwordOrder = true; HUD.DrawLog = false; } } if (Engine.Singleton.Mouse.MouseState.ButtonDown(MOIS.MouseButtonID.MB_Left)) { if (Character.Contact != null) { if (Character.Contact is ISomethingMoving) { if ((Character.Contact as ISomethingMoving).FriendlyType != Gra.Character.FriendType.FRIENDLY && (Character.Contact as ISomethingMoving).State != Enemy.StateTypes.DEAD) { if (Character.Sword != null && Character.Sword.InUse) { if ((Character.Contact as ISomethingMoving).FriendlyType == Gra.Character.FriendType.NEUTRAL) (Character.Contact as ISomethingMoving).FriendlyType = Gra.Character.FriendType.ENEMY; Character.MoveLeftOrder = false; Character.MoveRightOrder = false; Character.MoveOrder = false; Character.MoveOrderBack = false; AddedToKillList = false; Character.FocusedEnemy = (ISomethingMoving)Character.Contact; SwitchState(HumanControllerState.ATTACK); } } } } } if (Character.Contact != null && Character.Contact.Exists) { FocusObject = Character.Contact as SelectableObject; string lol = null; if (FocusObject is ISomethingMoving) { } if (FocusObject.IsContainer == true) lol = "\n(Otworz)"; TargetLabel.Caption = FocusObject.DisplayName + lol; TargetLabel.Position3D = FocusObject.Position + FocusObject.DisplayNameOffset; TargetLabel.IsVisible = true; } else { FocusObject = null; TargetLabel.IsVisible = false; } if (Character.Contacts.Count > 0) { ColLabel.SetColor(ColourValue.Red, ColourValue.Red); } else ColLabel.SetColor(ColourValue.Green, ColourValue.Green); }
public Conversations() { D = new Dictionary <String, Dialog>(); if (File.Exists("Media\\Others\\Dialogi.xml")) { XmlDocument File1 = new XmlDocument(); File1.Load("Media\\Others\\Dialogi.xml"); XmlElement root = File1.DocumentElement; XmlNodeList Items = root.SelectNodes("//Dialogs//Dialog"); foreach (XmlNode item in Items) { Dialog justDialog = new Dialog(); XmlNodeList TalkReactions = item["Reactions"].ChildNodes; foreach (XmlNode tr in TalkReactions) { TalkReaction justReaction = new TalkReaction(); justDialog.Reactions.Add(tr["TalkReactionID"].InnerText, justReaction); } XmlNodeList TalkReplies = item["Replies"].ChildNodes; foreach (XmlNode rep in TalkReplies) { TalkReply justReply = new TalkReply(); justReply.IsEnding = bool.Parse(rep["IsEnding"].InnerText); float dur = float.Parse(rep["Duration"].InnerText); justReply.Text.Add(new TalkText((rep["Text"].InnerText), dur, rep["Sound"].InnerText)); if (!justReply.IsEnding) { justReply.Reaction = justDialog.Reactions[rep["TalkReaction"].InnerText]; } justDialog.Replies.Add(rep["TalkReplyID"].InnerText, justReply); } XmlNodeList TalkNodes = item["Nodes"].ChildNodes; foreach (XmlNode tn in TalkNodes) { TalkNode justNode = new TalkNode(); float dur = float.Parse(tn["Duration"].InnerText); justNode.Text.Add(new TalkText((tn["Text"].InnerText), dur, tn["Sound"].InnerText)); XmlNodeList RepliesInNode = tn["NodeReplies"].ChildNodes; foreach (XmlNode rin in RepliesInNode) { justNode.Replies.Add(justDialog.Replies[rin["ReplyID"].InnerText]); } XmlNodeList ActionsInNode = tn["Actions"].ChildNodes; List <ActionType> actionList = new List <ActionType>(); foreach (XmlNode ain in ActionsInNode) { actionList.Add((ActionType)int.Parse(ain["ActionType"].InnerText)); } justNode.AddActions(actionList); if (tn["TalkEdges"].ChildNodes.Count > 0) { XmlNodeList nodelist = tn["TalkEdges"].ChildNodes; foreach (XmlNode nod in nodelist) { justDialog.EdgesToNodes.Add(nod["TalkEdgeID"].InnerText, tn["TalkNodeID"].InnerText); } } justNode.Quest = tn["QuestID"].InnerText; if (tn["PrizeNPC"].InnerText != "") { justNode.PrizeNPC = PrizeManager.P[tn["PrizeNPC"].InnerText]; } if (tn["PrizePlayer"].InnerText != "") { justNode.PrizePlayer = PrizeManager.P[tn["PrizePlayer"].InnerText]; } if (tn["PrizePlayerRemove"].InnerText != "") { justNode.PrizePlayerRemove = PrizeManager.P[tn["PrizePlayerRemove"].InnerText]; } if (tn["Activator"].InnerText != "" && tn["Activator"].InnerText != null) { justNode.Activatorr = tn["Activator"].InnerText; } else { justNode.Activatorr = ""; } justNode.PrzypiszMetode(); justNode.DialogID = item["DialogID"].InnerText; justDialog.Nodes.Add(tn["TalkNodeID"].InnerText, justNode); } XmlNodeList TalkEdges = item["Edges"].ChildNodes; foreach (XmlNode te in TalkEdges) { TalkEdge justEdge = new TalkEdge(justDialog.Nodes[te["ToWhere"].InnerText]); justEdge.ID = te["TalkEdgeID"].InnerText; XmlNodeList ConditionsInEdge = te["Conditions"].ChildNodes; List <Condition> listaWarunkow = new List <Condition>(); foreach (XmlNode cin in ConditionsInEdge) { listaWarunkow.Add((Condition)int.Parse(cin["ConditionType"].InnerText)); } justEdge.AddConditions(listaWarunkow); while (justDialog.EdgesToNodes.ContainsKey(te["TalkEdgeID"].InnerText)) { justDialog.Nodes[justDialog.EdgesToNodes[te["TalkEdgeID"].InnerText]].Edges.Add(justEdge); justDialog.EdgesToNodes.Remove(te["TalkEdgeID"].InnerText); } justEdge.Quest = te["ConditionQuestID"].InnerText; justEdge.AmountGold = int.Parse(te["GoldRequired"].InnerText); justDialog.Edges.Add(te["TalkEdgeID"].InnerText, justEdge); justDialog.Reactions[te["FromWhere"].InnerText].Edges.Add(justDialog.Edges[te["TalkEdgeID"].InnerText]); } justDialog.ID = item["DialogID"].InnerText; D.Add(item["DialogID"].InnerText, justDialog); } } }
public TalkEdge(TalkNode target) { Condits = new List<Condition>(); TalkNode = target; base.Conditions += (() => Other); }
public Conversations() { D = new Dictionary<String, Dialog>(); if (File.Exists("Media\\Others\\Dialogi.xml")) { XmlDocument File1 = new XmlDocument(); File1.Load("Media\\Others\\Dialogi.xml"); XmlElement root = File1.DocumentElement; XmlNodeList Items = root.SelectNodes("//Dialogs//Dialog"); foreach (XmlNode item in Items) { Dialog justDialog = new Dialog(); XmlNodeList TalkReactions = item["Reactions"].ChildNodes; foreach (XmlNode tr in TalkReactions) { TalkReaction justReaction = new TalkReaction(); justDialog.Reactions.Add(tr["TalkReactionID"].InnerText, justReaction); } XmlNodeList TalkReplies = item["Replies"].ChildNodes; foreach (XmlNode rep in TalkReplies) { TalkReply justReply = new TalkReply(); justReply.IsEnding = bool.Parse(rep["IsEnding"].InnerText); float dur = float.Parse(rep["Duration"].InnerText); justReply.Text.Add(new TalkText((rep["Text"].InnerText), dur, rep["Sound"].InnerText)); if (!justReply.IsEnding) justReply.Reaction = justDialog.Reactions[rep["TalkReaction"].InnerText]; justDialog.Replies.Add(rep["TalkReplyID"].InnerText, justReply); } XmlNodeList TalkNodes = item["Nodes"].ChildNodes; foreach (XmlNode tn in TalkNodes) { TalkNode justNode = new TalkNode(); float dur = float.Parse(tn["Duration"].InnerText); justNode.Text.Add(new TalkText((tn["Text"].InnerText), dur, tn["Sound"].InnerText)); XmlNodeList RepliesInNode = tn["NodeReplies"].ChildNodes; foreach (XmlNode rin in RepliesInNode) { justNode.Replies.Add(justDialog.Replies[rin["ReplyID"].InnerText]); } XmlNodeList ActionsInNode = tn["Actions"].ChildNodes; List<ActionType> actionList = new List<ActionType>(); foreach (XmlNode ain in ActionsInNode) { actionList.Add((ActionType)int.Parse(ain["ActionType"].InnerText)); } justNode.AddActions(actionList); if (tn["TalkEdges"].ChildNodes.Count > 0) { XmlNodeList nodelist = tn["TalkEdges"].ChildNodes; foreach (XmlNode nod in nodelist) justDialog.EdgesToNodes.Add(nod["TalkEdgeID"].InnerText, tn["TalkNodeID"].InnerText); } justNode.Quest = tn["QuestID"].InnerText; if (tn["PrizeNPC"].InnerText != "") justNode.PrizeNPC = PrizeManager.P[tn["PrizeNPC"].InnerText]; if (tn["PrizePlayer"].InnerText != "") justNode.PrizePlayer = PrizeManager.P[tn["PrizePlayer"].InnerText]; if (tn["PrizePlayerRemove"].InnerText != "") justNode.PrizePlayerRemove = PrizeManager.P[tn["PrizePlayerRemove"].InnerText]; if (tn["Activator"].InnerText != "" && tn["Activator"].InnerText != null) justNode.Activatorr = tn["Activator"].InnerText; else justNode.Activatorr = ""; justNode.PrzypiszMetode(); justNode.DialogID = item["DialogID"].InnerText; justDialog.Nodes.Add(tn["TalkNodeID"].InnerText, justNode); } XmlNodeList TalkEdges = item["Edges"].ChildNodes; foreach (XmlNode te in TalkEdges) { TalkEdge justEdge = new TalkEdge(justDialog.Nodes[te["ToWhere"].InnerText]); justEdge.ID = te["TalkEdgeID"].InnerText; XmlNodeList ConditionsInEdge = te["Conditions"].ChildNodes; List<Condition> listaWarunkow = new List<Condition>(); foreach (XmlNode cin in ConditionsInEdge) { listaWarunkow.Add((Condition)int.Parse(cin["ConditionType"].InnerText)); } justEdge.AddConditions(listaWarunkow); while (justDialog.EdgesToNodes.ContainsKey(te["TalkEdgeID"].InnerText)) { justDialog.Nodes[justDialog.EdgesToNodes[te["TalkEdgeID"].InnerText]].Edges.Add(justEdge); justDialog.EdgesToNodes.Remove(te["TalkEdgeID"].InnerText); } justEdge.Quest = te["ConditionQuestID"].InnerText; justEdge.AmountGold = int.Parse(te["GoldRequired"].InnerText); justDialog.Edges.Add(te["TalkEdgeID"].InnerText, justEdge); justDialog.Reactions[te["FromWhere"].InnerText].Edges.Add(justDialog.Edges[te["TalkEdgeID"].InnerText]); } justDialog.ID = item["DialogID"].InnerText; D.Add(item["DialogID"].InnerText, justDialog); } } }