Exemplo n.º 1
0
		private DiaQConversation GetData()
		{	// builds the data object to return. based on "current" node
			if (currNode == null) return null;

			if (currNode.type == DiaQNode.Type.Dialogue)
			{
				DiaQConversation d = new DiaQConversation();
				
				if (!string.IsNullOrEmpty(currNode.data[0])) 
				{
					// todo: parse the text for variable value replacement?
					d.conversationText = currNode.data[0];

					// append quest text?
					if (currNode.toggle[0] == true)
					{
						DiaQuest q = DiaQEngine.Instance.FindDefinedQuest(currNode.data[1]);
						if (q != null)
						{
							// add the whole quest object for later reference by whatever wants to look at it
							d.linkedQuest = q;

							// append quest text?
							if (currNode.toggle[1] == true)
							{
								// insert a line break if there is allready text present
								if (!string.IsNullOrEmpty(d.conversationText)) d.conversationText += "\n\n";

								// todo: parse the text for variable value replacement?
								d.conversationText += q.text;
							}
						}
					}
				}
				
				if (currNode.choices.Count > 0)
				{
					d.choices = new string[currNode.choices.Count];
					for (int i = 0; i < currNode.choices.Count; i++)
					{
						d.choices[i] = currNode.choices[i];
					}
				}

				return d;
			}

			return null;
		}
Exemplo n.º 2
0
		public void UpdateUniRPGDialogueRewards(DiaQConversation diaq, GUIDialogueData data)
		{
			// first make sure the rewards are cleared in case this is a data being reused
			data.showRewards = false;
			data.currencyReward = 0;
			data.itemRewards = null;
			data.attributeRewards = null; 

			if (diaq.linkedQuest != null)
			{
				if (diaq.linkedQuest.rewards.Count > 0)
				{
					data.showRewards = true;

					foreach (DiaQuest.Reward r in diaq.linkedQuest.rewards)
					{
						if (r.type == DiaQuest.Reward.Type.Currency)
						{
							data.currencyReward += r.value;
						}

						else if (r.type == DiaQuest.Reward.Type.Attribute)
						{
							if (!string.IsNullOrEmpty(r.ident))
							{
								RPGAttribute a = UniRPGGlobal.DB.GetAttribute(new GUID(r.ident));
								if (a != null)
								{
									data.attributeRewards = data.attributeRewards ?? new List<GUIDialogueData.AttribReward>(0);
									GUIDialogueData.AttribReward ar = data.attributeRewards.FirstOrDefault(x => x.attrib == a);
									if (ar == null) data.attributeRewards.Add(new GUIDialogueData.AttribReward() { attrib = a, valueAdd = r.value });
									else ar.valueAdd += r.value;
								}
						} } // else if (r.type == DiaQuest.Reward.Type.Attribute)

						else if (r.type == DiaQuest.Reward.Type.Item)
						{
							if (!string.IsNullOrEmpty(r.ident))
							{
								if (r.value > 0)
								{
									RPGItem it = UniRPGGlobal.DB.GetItem(new GUID(r.ident));
									if (it != null)
									{
										data.itemRewards = data.itemRewards ?? new List<GUIDialogueData.ItemReward>(0);
										GUIDialogueData.ItemReward ir = data.itemRewards.FirstOrDefault(x => x.item == it);
										if (ir == null) data.itemRewards.Add(new GUIDialogueData.ItemReward() { item = it, count = r.value });
										else ir.count += r.value;
									}
						} } } // else if (r.type == DiaQuest.Reward.Type.Item)
					}

				}
			}
		}