public static void Read(SerializationReader Reader, acegiak_Romancable romancable) { string classname = Reader.ReadString(); Type type = Type.GetType(classname); acegiak_RomanceBoon boon = (acegiak_RomanceBoon)Activator.CreateInstance(type, romancable); boon.setRomancable(romancable); romancable.boons.Add(boon); }
public acegiak_RomanceChatNode BuildNode(acegiak_RomanceChatNode node) { havePreference(); this.lockout = false; node.Choices.Clear(); //IPart.AddPlayerMessage("They are:"+ParentObject.pBrain.GetOpinion(XRLCore.Core.Game.Player.Body)+": "+ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body).ToString()+" patience:"+patience.ToString()); if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) < 1 && patience > 0) { ParentObject.pBrain.SetFeeling(XRLCore.Core.Game.Player.Body, 1); } if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) < 1 || patience <= 0) { List <string> Stories = new List <string>(new string[] { "Sorry, I have other things to do.", "Anyway, I'm very busy.", "Maybe we could talk some more another time?" }); node.Text = node.Text + "\n\n" + Stories[Stat.Rnd2.Next(0, Stories.Count - 1)]; ConversationChoice returntostart = new ConversationChoice(); returntostart.Ordinal = 800; returntostart.Text = "Ok."; returntostart.GotoID = node.ParentConversation.StartNodes[0].ID; returntostart.ParentNode = node; node.Choices.Add(returntostart); } else if (boons.Where(b => b.BoonReady(XRLCore.Core.Game.Player.Body)).Count() > 0) { acegiak_RomanceBoon boon = boons.Where(b => b.BoonReady(XRLCore.Core.Game.Player.Body)).OrderBy(o => Stat.Rnd2.NextDouble()).FirstOrDefault(); try { node = boon.BuildNode(node); node.InsertMyReaction(ParentObject, XRLCore.Core.Game.Player.Body); node.ExpandText(GetSelfEntity()); } catch (Exception e) { node.Text = e.ToString() + "\n\n" + node.Text; } } else { int c = 0; int whichquestion = 0; do { whichquestion = Stat.Rnd2.Next(0, preferences.Count); c++; }while(whichquestion == lastQuestion && c < 5); lastQuestion = whichquestion; try { node = preferences[whichquestion].BuildNode(node); node.InsertMyReaction(ParentObject, XRLCore.Core.Game.Player.Body); node.ExpandText(GetSelfEntity()); } catch (Exception e) { node.Text = e.ToString() + "\n\n" + node.Text; } if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) > 5) { acegiak_RomanceChatChoice giftoption = new acegiak_RomanceChatChoice(); giftoption.Ordinal = 900; giftoption.Text = "[Offer A Gift]"; giftoption.action = "*Gift"; giftoption.ParentNode = node; giftoption.GotoID = "End"; node.Choices.Add(giftoption); } if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) >= 25) { acegiak_RomanceChatChoice kissoption = new acegiak_RomanceChatChoice(); kissoption.Ordinal = 910; kissoption.Text = "[Propose a Date]"; kissoption.action = "*Date"; kissoption.ParentNode = node; kissoption.GotoID = "End"; node.Choices.Add(kissoption); } if (ParentObject.GetPart <acegiak_Kissable>() != null && ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) >= 55) { acegiak_RomanceChatChoice kissoption = new acegiak_RomanceChatChoice(); kissoption.Ordinal = 910; kissoption.Text = "[Attempt to Kiss]"; kissoption.action = "*Kiss"; kissoption.ParentNode = node; kissoption.GotoID = "End"; node.Choices.Add(kissoption); } } if (ParentObject.pBrain.GetFeeling(XRLCore.Core.Game.Player.Body) < 1) { ParentObject.pBrain.SetFeeling(XRLCore.Core.Game.Player.Body, 1); } patience--; ConversationChoice liveanddrink = new ConversationChoice(); liveanddrink.Ordinal = 99999; liveanddrink.Text = "Live and drink."; liveanddrink.GotoID = "End"; liveanddrink.ParentNode = node; node.Choices.Add(liveanddrink); return(node); }
public void havePreference() { if (ParentObject.IsPlayer()) { this.preferences = new List <acegiak_RomancePreference>(); this.boons = new List <acegiak_RomanceBoon>(); return; } bool loading = false; if (this.preferences == null || this.boons == null) { Loading.SetLoadingStatus("Compiling preferences..."); loading = true; } if (this.preferences == null) { //IPart.AddPlayerMessage("Populating Preference for "+ParentObject.DisplayNameOnly); this.preferences = new List <acegiak_RomancePreference>(); List <acegiak_RomancePreference> possible = new List <acegiak_RomancePreference>(); if (GameObjectFactory.Factory == null || GameObjectFactory.Factory.BlueprintList == null) { return; } GameObjectBlueprint[] blueprints = GameObjectFactory.Factory.BlueprintList.ToArray(); for (int i = blueprints.Length - 1; i >= 0; i--) { GameObjectBlueprint blueprint = blueprints[i]; if (!blueprint.IsBaseBlueprint() && blueprint.DescendsFrom("RomancePreference")) { //IPart.AddPlayerMessage("possible preference type:"+blueprint.Name); GameObject sample = GameObjectFactory.Factory.CreateSampleObject(blueprint.Name); if (sample.HasTag("classname") && sample.GetTag("classname") != null && sample.GetTag("classname") != "") { try{ acegiak_RomancePreference preference = Activator.CreateInstance(Type.GetType(sample.GetTag("classname")), this) as acegiak_RomancePreference; possible.Add(preference); }catch (Exception e) { LogWarning(e.ToString()); } } } } //IPart.AddPlayerMessage("possible prefs checked."); int count = Stat.Rnd2.Next(3) + 3; //IPart.AddPlayerMessage("choosing "+count.ToString()+" out of "+possible.Count().ToString()+" prefs"); for (int i = 0; i < count; i++) { int w = Stat.Rnd2.Next(possible.Count()); preferences.Add(possible[w]); } } if (this.boons == null) { // IPart.AddPlayerMessage("Populating Preference"); this.boons = new List <acegiak_RomanceBoon>(); List <acegiak_RomanceBoon> possible = new List <acegiak_RomanceBoon>(); if (GameObjectFactory.Factory == null || GameObjectFactory.Factory.BlueprintList == null) { return; } foreach (GameObjectBlueprint blueprint in GameObjectFactory.Factory.BlueprintList) { if (!blueprint.IsBaseBlueprint() && blueprint.DescendsFrom("RomanceBoon")) { //IPart.AddPlayerMessage(blueprint.Name); GameObject sample = GameObjectFactory.Factory.CreateSampleObject(blueprint.Name); if (sample.HasTag("classname") && sample.GetTag("classname") != null && sample.GetTag("classname") != "") { acegiak_RomanceBoon preference = Activator.CreateInstance(Type.GetType(sample.GetTag("classname")), this) as acegiak_RomanceBoon; possible.Add(preference); } } } int count = Stat.Rnd2.Next(2); for (int i = 0; i < count; i++) { int w = Stat.Rnd2.Next(possible.Count()); boons.Add(possible[w]); } // IPart.AddPlayerMessage(this.preferences.ToString()); } if (loading) { Loading.SetLoadingStatus(null); } touch(); }