Exemple #1
0
        public static Vector2 GetDistanceToPlayer(NPC npc, int npcType)
        {
            int npcOwner = PartyMemberLogic.IsPartyMember(npcType);

            if (npcOwner >= 0)
            {
                return(npc.Center - Main.player[npcOwner].Center);
            }
            return(npc.Center - Main.player[Main.myPlayer].Center);
        }
Exemple #2
0
        public static void GuidePartyMemberAI(NPC npc, Vector2 prevPos, int projType, ref int[] npcStats)
        {
            int npcOwner = PartyMemberLogic.IsPartyMember(npcStats[6]);

            if (npcOwner >= 0)
            {
                Vector2 desiredpos = Main.player[npcOwner].Center;

                npc.ai[2]++;

                for (int i = 1; i < Main.maxNPCs; i++)
                {
                    if (Main.npc[i].active && !Main.npc[i].friendly && MathHelp.Magnitude(GetDistanceToPlayer(Main.npc[i], npcOwner)) < 400)
                    {
                        npcStats[3] = (npcStats[3] == 0 ||
                                       MathHelp.Magnitude(GetDistanceToPlayer(Main.npc[i], npcOwner)) < MathHelp.Magnitude(GetDistanceToPlayer(Main.npc[npcStats[3]], npcOwner)))
                            ? i : npcStats[3];
                    }
                }

                if (npcStats[3] != 0 && Main.npc[npcStats[3]].active)
                {
                    desiredpos = (Vector2.Distance(Main.npc[npcStats[3]].Center, Main.player[Main.myPlayer].Center) > 300) ? desiredpos : Main.npc[npcStats[3]].Center;

                    if (npc.ai[2] > 25)
                    {
                        ProjectileSource_NPC s = new ProjectileSource_NPC(npc);
                        Attack(ref npcStats[5], projType, MathHelp.Normalize(Main.npc[npcStats[3]].Center - npc.Center) * 15, npc.Center, s);
                        npcStats[4] = 5;
                        npc.ai[2]   = 0;
                    }
                }

                desiredpos = desiredpos - npc.Center;

                if (Math.Abs(desiredpos.X) > 125 + PartyMemberLogic.GetPartySlotOcupied(npc.type) * 30)
                {
                    npc.velocity = new Vector2(MathHelp.Sign(desiredpos.X) * 3, (prevPos == npc.Center) ? -10 : npc.velocity.Y);
                }
                else
                {
                    npc.velocity.X -= (Math.Abs(npc.velocity.X) < 1) ? -npc.velocity.X : MathHelp.Sign(npc.velocity.X);
                }
            }
        }
Exemple #3
0
        public void GetPartyMember(int npcNum)
        {
            if (npcNum < Main.maxNPCs && Main.npc[npcNum].active && Main.npc[npcNum].townNPC)
            {
                NPC npc = Main.npc[npcNum];
                if (PartyMemberLogic.IsPartyMember(Main.npc[npcNum].type) >= 0)
                {
                    Conversation conv = new Conversation(GetMemberDialog(npc.type), Color.White, DialogSystem.NPC_DIALOGTIME, npc.GivenOrTypeName);
                    DialogSystem.AddConversation(conv);

                    PartyMemberLogic.RemovePartyMember(npc.type);
                    npc.color = Color.White;
                    npc.Teleport(new Vector2(npc.homeTileX * 16, npc.homeTileY * 16 - npc.height) - npc.velocity);
                    npc.velocity = new Vector2();
                }
                else
                {
                    Conversation conv = new Conversation(GetMemberDialog(npc.type, true), Color.White, DialogSystem.NPC_DIALOGTIME, npc.GivenOrTypeName);
                    DialogSystem.AddConversation(conv);
                    PartyMemberLogic.AddPartyMember(npc.type, Player.name);
                }
            }
        }
Exemple #4
0
        public override void Update(GameTime gameTime)
        {
            Player p = Main.player[Main.myPlayer];

            sora = p.GetModPlayer <SoraPlayer>();

            if (!Main.playerInventory)
            {
                KingdomTerrahearts.instance.SetPartyUI(false);
                return;
            }

            slotsDisplay.SetText("Slots left: " + PartyMemberLogic.GetPartySlotsLeft(p.name));

            //0:Guide
            if (NPC.AnyNPCs(NPCID.Guide))
            {
                if (buttons[0] == null)
                {
                    buttons[0] = new UIPanel();
                    buttons[0].Width.Set(50, 0);
                    buttons[0].Height.Set(50, 0);
                    buttons[0].HAlign = 0f;
                    buttons[0].Top.Set(25, 0);
                    buttons[0].OnClick += OnGuideClick;
                    panel.Append(buttons[0]);

                    UIText text = new UIText("Guide");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[0].Append(text);
                }
                else if (buttons[0] != new UIPanel())
                {
                    buttons[0].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Guide) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[0] != null)
                {
                    buttons[0].Remove();
                    buttons[0] = null;
                }
            }

            //1:Merchant
            if (NPC.AnyNPCs(NPCID.Merchant))
            {
                if (buttons[1] == null)
                {
                    buttons[1] = new UIPanel();
                    buttons[1].Width.Set(50, 0);
                    buttons[1].Height.Set(50, 0);
                    buttons[1].HAlign = 0.25f;
                    buttons[1].Top.Set(25, 0);
                    buttons[1].OnClick += OnMerchantClick;
                    panel.Append(buttons[1]);

                    UIText text = new UIText("Merch");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[1].Append(text);
                }
                else if (buttons[1] != new UIPanel())
                {
                    buttons[1].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Merchant) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[1] != null)
                {
                    buttons[1].Remove();
                    buttons[1] = null;
                }
            }

            //2:Nurse
            if (NPC.AnyNPCs(NPCID.Nurse))
            {
                if (buttons[2] == null)
                {
                    buttons[2] = new UIPanel();
                    buttons[2].Width.Set(50, 0);
                    buttons[2].Height.Set(50, 0);
                    buttons[2].HAlign = 0.5f;
                    buttons[2].Top.Set(25, 0);
                    buttons[2].OnClick += OnNurseClick;
                    panel.Append(buttons[2]);

                    UIText text = new UIText("Nurse");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[2].Append(text);
                }
                else if (buttons[2] != new UIPanel())
                {
                    buttons[2].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Nurse) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[2] != null)
                {
                    buttons[2].Remove();
                    buttons[2] = null;
                }
            }

            //3:Demolitionist
            if (NPC.AnyNPCs(NPCID.Demolitionist))
            {
                if (buttons[3] == null)
                {
                    buttons[3] = new UIPanel();
                    buttons[3].Width.Set(50, 0);
                    buttons[3].Height.Set(50, 0);
                    buttons[3].HAlign = 0.75f;
                    buttons[3].Top.Set(25, 0);
                    buttons[3].OnClick += OnBomberClick;
                    panel.Append(buttons[3]);

                    UIText text = new UIText("Bomb");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[3].Append(text);
                }
                else if (buttons[3] != new UIPanel())
                {
                    buttons[3].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Demolitionist) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[3] != null)
                {
                    buttons[3].Remove();
                    buttons[3] = null;
                }
            }

            //4:Dye trader
            if (NPC.AnyNPCs(NPCID.DyeTrader))
            {
                if (buttons[4] == null)
                {
                    buttons[4] = new UIPanel();
                    buttons[4].Width.Set(50, 0);
                    buttons[4].Height.Set(50, 0);
                    buttons[4].HAlign = 0f;
                    buttons[4].VAlign = 0.25f;
                    buttons[4].Top.Set(25, 0);
                    buttons[4].OnClick += OnDyeClick;
                    panel.Append(buttons[4]);

                    UIText text = new UIText("Dye");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[4].Append(text);
                }
                else if (buttons[4] != new UIPanel())
                {
                    buttons[4].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.DyeTrader) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[4] != null)
                {
                    buttons[4].Remove();
                    buttons[4] = null;
                }
            }

            //5:Angler
            if (NPC.AnyNPCs(NPCID.Angler))
            {
                if (buttons[5] == null)
                {
                    buttons[5] = new UIPanel();
                    buttons[5].Width.Set(50, 0);
                    buttons[5].Height.Set(50, 0);
                    buttons[5].HAlign = 0.25f;
                    buttons[5].VAlign = 0.25f;
                    buttons[5].Top.Set(25, 0);
                    buttons[5].OnClick += OnAnglerClick;
                    panel.Append(buttons[5]);

                    UIText text = new UIText("Fish");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[5].Append(text);
                }
                else if (buttons[5] != new UIPanel())
                {
                    buttons[5].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Angler) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[5] != null)
                {
                    buttons[5].Remove();
                    buttons[5] = null;
                }
            }

            //6:Dryad
            if (NPC.AnyNPCs(NPCID.Dryad))
            {
                if (buttons[6] == null)
                {
                    buttons[6] = new UIPanel();
                    buttons[6].Width.Set(50, 0);
                    buttons[6].Height.Set(50, 0);
                    buttons[6].HAlign = 0.5f;
                    buttons[6].VAlign = 0.25f;
                    buttons[6].Top.Set(25, 0);
                    buttons[6].OnClick += OnDryadClick;
                    panel.Append(buttons[6]);

                    UIText text = new UIText("Dryad");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[6].Append(text);
                }
                else if (buttons[6] != new UIPanel())
                {
                    buttons[6].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Dryad) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[6] != null)
                {
                    buttons[6].Remove();
                    buttons[6] = null;
                }
            }

            //7:Painter
            if (NPC.AnyNPCs(NPCID.Painter))
            {
                if (buttons[7] == null)
                {
                    buttons[7] = new UIPanel();
                    buttons[7].Width.Set(50, 0);
                    buttons[7].Height.Set(50, 0);
                    buttons[7].HAlign = 0.75f;
                    buttons[7].VAlign = 0.25f;
                    buttons[7].Top.Set(25, 0);
                    buttons[7].OnClick += OnPainterClick;
                    panel.Append(buttons[7]);

                    UIText text = new UIText("Paint");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[7].Append(text);
                }
                else if (buttons[7] != new UIPanel())
                {
                    buttons[7].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Painter) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[7] != null)
                {
                    buttons[7].Remove();
                    buttons[7] = null;
                }
            }

            //8:Arms Dealer
            if (NPC.AnyNPCs(NPCID.ArmsDealer))
            {
                if (buttons[8] == null)
                {
                    buttons[8] = new UIPanel();
                    buttons[8].Width.Set(50, 0);
                    buttons[8].Height.Set(50, 0);
                    buttons[8].HAlign = 0f;
                    buttons[8].VAlign = 0.5f;
                    buttons[8].Top.Set(25, 0);
                    buttons[8].OnClick += OnGunnerClick;
                    panel.Append(buttons[8]);

                    UIText text = new UIText("Guns");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[8].Append(text);
                }
                else if (buttons[8] != new UIPanel())
                {
                    buttons[8].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.ArmsDealer) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[8] != null)
                {
                    buttons[8].Remove();
                    buttons[8] = null;
                }
            }

            //9:Taberkeeper (DD2Bartender)
            if (NPC.AnyNPCs(NPCID.DD2Bartender))
            {
                if (buttons[9] == null)
                {
                    buttons[9] = new UIPanel();
                    buttons[9].Width.Set(50, 0);
                    buttons[9].Height.Set(50, 0);
                    buttons[9].HAlign = 0.25f;
                    buttons[9].VAlign = 0.5f;
                    buttons[9].Top.Set(25, 0);
                    buttons[9].OnClick += OnTabernClick;
                    panel.Append(buttons[9]);

                    UIText text = new UIText("Tabern");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[9].Append(text);
                }
                else if (buttons[9] != new UIPanel())
                {
                    buttons[9].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.DD2Bartender) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[9] != null)
                {
                    buttons[9].Remove();
                    buttons[9] = null;
                }
            }

            //10:Stylist
            if (NPC.AnyNPCs(NPCID.Stylist))
            {
                if (buttons[10] == null)
                {
                    buttons[10] = new UIPanel();
                    buttons[10].Width.Set(50, 0);
                    buttons[10].Height.Set(50, 0);
                    buttons[10].HAlign = 0.5f;
                    buttons[10].VAlign = 0.5f;
                    buttons[10].Top.Set(25, 0);
                    buttons[10].OnClick += OnStylistClick;
                    panel.Append(buttons[10]);

                    UIText text = new UIText("Style");
                    text.HAlign = text.VAlign = 0.5f;
                    buttons[10].Append(text);
                }
                else if (buttons[10] != new UIPanel())
                {
                    buttons[10].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Stylist) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[10] != null)
                {
                    buttons[10].Remove();
                    buttons[10] = null;
                }
            }

            //11:Goblin tinkerer
            if (NPC.AnyNPCs(NPCID.GoblinTinkerer))
            {
                if (buttons[11] == null)
                {
                    buttons[11] = new UIPanel();
                    buttons[11].Width.Set(50, 0);
                    buttons[11].Height.Set(50, 0);
                    buttons[11].HAlign = 0.75f;
                    buttons[11].VAlign = 0.5f;
                    buttons[11].Top.Set(25, 0);
                    buttons[11].OnClick += OnGoblinClick;
                    panel.Append(buttons[11]);

                    UIText text = new UIText("Goblin");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[11].Append(text);
                }
                else if (buttons[11] != new UIPanel())
                {
                    buttons[11].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.GoblinTinkerer) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[11] != null)
                {
                    buttons[11].Remove();
                    buttons[11] = null;
                }
            }

            //12:Witch doctor
            if (NPC.AnyNPCs(NPCID.WitchDoctor))
            {
                if (buttons[12] == null)
                {
                    buttons[12] = new UIPanel();
                    buttons[12].Width.Set(50, 0);
                    buttons[12].Height.Set(50, 0);
                    buttons[12].HAlign = 0f;
                    buttons[12].VAlign = 0.75f;
                    buttons[12].Top.Set(25, 0);
                    buttons[12].OnClick += OnWitchClick;
                    panel.Append(buttons[12]);

                    UIText text = new UIText("Witch");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[12].Append(text);
                }
                else if (buttons[12] != new UIPanel())
                {
                    buttons[12].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.WitchDoctor) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[12] != null)
                {
                    buttons[12].Remove();
                    buttons[12] = null;
                }
            }

            //13:Clothier
            if (NPC.AnyNPCs(NPCID.Clothier))
            {
                if (buttons[13] == null)
                {
                    buttons[13] = new UIPanel();
                    buttons[13].Width.Set(50, 0);
                    buttons[13].Height.Set(50, 0);
                    buttons[13].HAlign = 0.25f;
                    buttons[13].VAlign = 0.75f;
                    buttons[13].Top.Set(25, 0);
                    buttons[13].OnClick += OnClothierClick;
                    panel.Append(buttons[13]);

                    UIText text = new UIText("Clothier");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[13].Append(text);
                }
                else if (buttons[13] != new UIPanel())
                {
                    buttons[13].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Clothier) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[13] != null)
                {
                    buttons[13].Remove();
                    buttons[13] = null;
                }
            }

            //14:Mechanic
            if (NPC.AnyNPCs(NPCID.Mechanic))
            {
                if (buttons[14] == null)
                {
                    buttons[14] = new UIPanel();
                    buttons[14].Width.Set(50, 0);
                    buttons[14].Height.Set(50, 0);
                    buttons[14].HAlign = 0.5f;
                    buttons[14].VAlign = 0.75f;
                    buttons[14].Top.Set(25, 0);
                    buttons[14].OnClick += OnMechanicClick;
                    panel.Append(buttons[14]);

                    UIText text = new UIText("Mech");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[14].Append(text);
                }
                else if (buttons[14] != new UIPanel())
                {
                    buttons[14].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.Mechanic) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[14] != null)
                {
                    buttons[14].Remove();
                    buttons[14] = null;
                }
            }

            //15:Party Girl
            if (NPC.AnyNPCs(NPCID.PartyGirl))
            {
                if (buttons[15] == null)
                {
                    buttons[15] = new UIPanel();
                    buttons[15].Width.Set(50, 0);
                    buttons[15].Height.Set(50, 0);
                    buttons[15].HAlign = 0.75f;
                    buttons[15].VAlign = 0.75f;
                    buttons[15].Top.Set(25, 0);
                    buttons[15].OnClick += OnPartyClick;
                    panel.Append(buttons[15]);

                    UIText text = new UIText("Party");
                    text.HAlign = 0.5f;
                    text.VAlign = 0.5f;
                    buttons[15].Append(text);
                }
                else if (buttons[15] != new UIPanel())
                {
                    buttons[15].BackgroundColor = (PartyMemberLogic.IsPartyMember(NPCID.PartyGirl) >= 0) ? Color.LightBlue : Color.Transparent;
                }
            }
            else
            {
                if (buttons[15] != null)
                {
                    buttons[15].Remove();
                    buttons[15] = null;
                }
            }
        }