Пример #1
0
        public override bool FireEvent(Event E)
        {
            if (E.ID == "AIBored")
            {
                if (ParentObject.GetPart <Inventory>() != null)
                {
                    if (XRLCore.Core.Game.TimeTicks - lastPlayed > 100)
                    {
                        lastPlayed = XRLCore.Core.Game.TimeTicks;

                        foreach (GameObject GO in ParentObject.GetPart <Inventory>().GetObjects())
                        {
                            if (GO.GetPart <acegiak_Musical>() != null)
                            {
                                GO.FireEvent(XRL.World.Event.New("InvCommandPlayTune", "Owner", ParentObject, "Object", GO));
                            }
                        }
                    }
                }
            }



            if (E.ID == "ShowConversationChoices" && !ParentObject.IsPlayer())
            {
                if (XRLCore.Core.Game.Player.Body.GetPart <acegiak_SongBook>() != null && XRLCore.Core.Game.Player.Body.HasSkill("acegiak_Customs_Music"))
                {
                    //IPart.AddPlayerMessage("My tags are:" + String.Join(", ", FactionTags(ParentObject.pBrain.GetPrimaryFaction()).ToArray()));

                    if (this.Songs.Count > 0 && !this.learnedFrom)
                    {
                        if (E.GetParameter <ConversationNode>("CurrentNode") != null && E.GetParameter <ConversationNode>("CurrentNode") is WaterRitualNode)
                        {
                            WaterRitualNode           wrnode  = E.GetParameter <ConversationNode>("CurrentNode") as WaterRitualNode;
                            List <ConversationChoice> Choices = E.GetParameter <List <ConversationChoice> >("Choices") as List <ConversationChoice>;

                            if (Choices.Where(b => b.ID == "LearnSong").Count() <= 0)
                            {
                                bool canlearn = XRLCore.Core.Game.PlayerReputation.get(ParentObject.pBrain.GetPrimaryFaction()) >= 50;

                                ConversationChoice conversationChoice = new ConversationChoice();
                                conversationChoice.Text       = (canlearn?"&G":"&K") + "Teach me to play &W" + this.Songs[0].Name + (canlearn?"&g":"&K") + " [" + (canlearn?"&C":"&r") + "-50" + (canlearn?"&g":"&K") + " reputation]";
                                conversationChoice.GotoID     = "End";
                                conversationChoice.ParentNode = wrnode;
                                conversationChoice.ID         = "LearnSong";
                                conversationChoice.onAction   = delegate()
                                {
                                    if (!canlearn)
                                    {
                                        Popup.Show("You do not have enough reputation.");
                                        return(false);
                                    }
                                    XRLCore.Core.Game.Player.Body.GetPart <acegiak_SongBook>().Songs.Add(this.Songs[0]);
                                    this.learnedFrom = true;
                                    Popup.Show("You learned to play " + this.Songs[0].Name);

                                    JournalAPI.AddAccomplishment("You learned to play " + this.Songs[0].Name);
                                    JournalAPI.AddObservation(Faction.getFormattedName(ParentObject.pBrain.GetPrimaryFaction()) + " play a song called \"" + this.Songs[0].Name + "\"", this.Songs[0].Name, "Songs", null, null, true);
                                    XRLCore.Core.Game.PlayerReputation.modify(Factions.get(ParentObject.pBrain.GetPrimaryFaction()).Name, -50, false);

                                    return(true);
                                };
                                Choices.Add(conversationChoice);
                                Choices.Sort(new ConversationChoice.Sorter());
                                // wrnode.Choices.Add(conversationChoice);
                                // wrnode.SortEndChoicesToEnd();
                                E.SetParameter("CurrentNode", wrnode);
                            }
                        }
                    }
                }
            }
            return(base.FireEvent(E));
        }