Exemple #1
0
        public void SkillInit(NodeParent node)
        {
            DrawSkill(node);
            RPGPlayer  rPGPlayer = Main.player[Main.myPlayer].GetModPlayer <RPGPlayer>();
            NodeParent neightboor;

            for (int j = 0; j < node.GetNeightboor.Count; j++)
            {
                neightboor = node.GetNeightboor[j];
                if (node.GetNeightboor.Exists(x => x.ID == neightboor.ID) && !(node.connectedNeighboor.Exists(x => x.ID == neightboor.ID)))
                {
                    if (!(neightboor.GetNodeType == NodeType.LimitBreak && rPGPlayer.GetLevel() < 1000 || neightboor.GetNode.GetAscended && !skillTree.IsLimitBreak()))
                    {
                        DrawConnection((neightboor.GetActivate || node.GetActivate) ? Color.GreenYellow : Color.Gray, node.menuPos, neightboor.menuPos, node, neightboor);
                        node.connectedNeighboor.Add(neightboor);
                        neightboor.connectedNeighboor.Add(node);
                    }
                }
            }

            int listSize = allConnection.Count;

            for (int i = 0; i < listSize; i++)
            {
                backGround.Append(allConnection[i]);
            }
            listSize = allBasePanel.Count;
            for (int i = 0; i < listSize; i++)
            {
                backGround.Append(allBasePanel[i]);
            }
        }
Exemple #2
0
        private void OnClickNode(UIMouseEvent evt, UIElement listeningElement, NodeParent node)
        {
            if (node.GetActivate)
            {
                if (node.GetNodeType == NodeType.Class)
                {
                    node.ToggleEnable();

                    UpdateValue();
                    if (node.GetEnable == false)
                    {
                        Main.PlaySound(SoundID.MenuClose);
                    }
                    else
                    {
                        Main.PlaySound(SoundID.MenuOpen);
                    }
                    return;
                }
            }

            RPGPlayer rPGPlayer = Main.player[Main.myPlayer].GetModPlayer <RPGPlayer>();

            switch (node.CanUpgrade(rPGPlayer.GetSkillPoints, rPGPlayer.GetLevel()))
            {
            case Reason.CanUpgrade:
                rPGPlayer.SpentSkillPoints(node.GetCostPerLevel);
                node.Upgrade();
                UpdateToolTip(node);
                UpdateValue();
                Main.PlaySound(SoundID.MenuOpen);
                break;

            default:
                Main.PlaySound(SoundID.MenuClose);
                break;
            }
        }
        static public void HandlePacket(BinaryReader reader, int whoAmI)
        {
            Message msg = (Message)reader.ReadByte();
            Dictionary <DataTag, object> tags = new Dictionary <DataTag, object>();

            foreach (DataTag tag in dataTags[msg])
            {
                tags.Add(tag, tag.read(reader));
            }
            switch (msg)
            {
            case Message.SyncLevel:
                RPGPlayer p = Main.player[(int)tags[DataTag.playerId]].GetModPlayer <RPGPlayer>();
                if (p.baseName == "")
                {
                    p.baseName = Main.player[(int)tags[DataTag.playerId]].name;
                }


                if ((int)tags[DataTag.playerId] != Main.myPlayer)
                {
                    if (Main.netMode != NetmodeID.SinglePlayer)
                    {
                        p.SyncLevel((int)tags[DataTag.amount]);
                    }
                    Main.player[(int)tags[DataTag.playerId]].name = p.baseName + " The Lvl." + p.GetLevel() + " " + (string)tags[DataTag.buffer];
                }

                break;

            case Message.AddXP:
                Main.LocalPlayer.GetModPlayer <RPGPlayer>().AddXp((int)tags[DataTag.amount], (int)tags[DataTag.level]);
                break;

            case Message.SyncNPCSpawn:
                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    NPC npc = Main.npc[(int)tags[DataTag.npcId]];

                    if (npc.GetGlobalNPC <ARPGGlobalNPC>() == null)
                    {
                        AnotherRpgMod.Instance.Logger.Info(npc.GivenName);
                    }

                    //npc.SetDefaults(npc.type);
                    if (npc.GetGlobalNPC <ARPGGlobalNPC>().StatsCreated == true)
                    {
                        return;
                    }
                    int     tier  = (int)tags[DataTag.tier];
                    int     level = (int)tags[DataTag.level];
                    NPCRank rank  = (NPCRank)tags[DataTag.rank];

                    NPCModifier modifiers = (NPCModifier)tags[DataTag.modifiers];
                    if (npc == null || npc.GetGlobalNPC <ARPGGlobalNPC>() == null)
                    {
                        return;
                    }
                    AnotherRpgMod.Instance.Logger.Info(npc.GivenOrTypeName + "\nTier : " + tier + "   Level : " + level + "   rank : " + rank + "   Modifier  : " + modifiers + " \n Buffer : " + (string)tags[DataTag.buffer]);

                    Dictionary <string, string> bufferStack = Unparse((string)tags[DataTag.buffer]);

                    WorldManager.BossDefeated = (int)tags[DataTag.WorldTier];

                    npc.GetGlobalNPC <ARPGGlobalNPC>().StatsCreated = true;
                    npc.GetGlobalNPC <ARPGGlobalNPC>().modifier     = modifiers;
                    npc.GetGlobalNPC <ARPGGlobalNPC>().SetLevelTier(level, tier, (byte)rank);
                    npc.GetGlobalNPC <ARPGGlobalNPC>().specialBuffer = bufferStack;

                    npc.GetGlobalNPC <ARPGGlobalNPC>().SetStats(npc);

                    npc.GivenName = NPCUtils.GetNpcNameChange(npc, tier, level, rank);



                    //AnotherRpgMod.Instance.Logger.Info("NPC created with id : " + npc.whoAmI);
                    //AnotherRpgMod.Instance.Logger.Info( "Client Side : \n" + npc.GetGivenOrTypeNetName() + "\nLvl." + (npc.GetGlobalNPC<ARPGGlobalNPC>().getLevel + npc.GetGlobalNPC<ARPGGlobalNPC>().getTier) + "\nHealth : " + npc.life + " / " + npc.lifeMax + "\nDamage : " + npc.damage + "\nDef : " + npc.defense + "\nTier : " + npc.GetGlobalNPC<ARPGGlobalNPC>().getRank + "\n\n");
                }
                break;

            case Message.SyncNPCUpdate:
                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    NPC npcu = Main.npc[(int)tags[DataTag.npcId]];

                    if (npcu.lifeMax != (int)tags[DataTag.maxLife] || npcu.life != (int)tags[DataTag.life])
                    {
                        AnotherRpgMod.Instance.Logger.Warn("DESYNC ERROR SPOTTED FOR : ");
                        AnotherRpgMod.Instance.Logger.Warn(npcu.GivenOrTypeName + "\n" + (int)tags[DataTag.life] + " / " + (int)tags[DataTag.maxLife] + "\n" + npcu.life + " / " + npcu.lifeMax);
                    }
                    Main.npc[(int)tags[DataTag.npcId]].lifeMax = (int)tags[DataTag.maxLife];
                    Main.npc[(int)tags[DataTag.npcId]].life    = (int)tags[DataTag.life];
                }
                break;

            case Message.Log:
                if (Main.netMode == NetmodeID.MultiplayerClient)
                {
                    //ErrorLogger.Log("LOG FROM SERVER");
                    AnotherRpgMod.Instance.Logger.Info((string)tags[DataTag.buffer]);
                }

                break;

            case Message.AskNpc:
                if (Main.netMode == NetmodeID.Server)
                {
                    NPC npc = Main.npc[(int)tags[DataTag.npcId]];
                    if (npc.GetGlobalNPC <ARPGGlobalNPC>() == null)
                    {
                        return;
                    }
                    int tier  = npc.GetGlobalNPC <ARPGGlobalNPC>().getTier;
                    int level = npc.GetGlobalNPC <ARPGGlobalNPC>().getLevel;
                    int rank  = npc.GetGlobalNPC <ARPGGlobalNPC>().getRank;
                    Mod mod   = AnotherRpgMod.Instance;
                    //MPDebug.Log(mod, "Server Side : \n" + npc.GetGivenOrTypeNetName() + " ID : " + npc.whoAmI + "\nLvl." + (npc.GetGlobalNPC<ARPGGlobalNPC>().getLevel + npc.GetGlobalNPC<ARPGGlobalNPC>().getTier) + "\nHealth : " + npc.life + " / " + npc.lifeMax + "\nDamage : " + npc.damage + "\nDef : " + npc.defense + "\nTier : " + npc.GetGlobalNPC<ARPGGlobalNPC>().getRank + "\n");

                    SendNpcSpawn(mod, npc, tier, level, npc.GetGlobalNPC <ARPGGlobalNPC>());
                }
                break;
            }
        }
Exemple #4
0
        public override void Update(GameTime gameTime)
        {
            int listSize = allConnection.Count;

            for (int i = 0; i < listSize; i++)
            {
                allConnection[i].Left.Set((allConnection[i].basePos.X + offSet.X) * sizeMultplier, 0);
                allConnection[i].Top.Set((allConnection[i].basePos.Y + offSet.Y) * sizeMultplier, 0);
            }
            listSize = allBasePanel.Count;
            for (int i = 0; i < listSize; i++)
            {
                allBasePanel[i].Left.Set((allBasePanel[i].basePos.X + offSet.X) * sizeMultplier, 0);
                allBasePanel[i].Top.Set((allBasePanel[i].basePos.Y + offSet.Y) * sizeMultplier, 0);
            }

            RPGPlayer rPGPlayer = Main.player[Main.myPlayer].GetModPlayer <RPGPlayer>();

            skillPointsLeft.SetText("Skill Points : " + rPGPlayer.GetSkillPoints + " / " + (rPGPlayer.GetLevel() - 1));

            Recalculate();
        }
Exemple #5
0
        public void Init()
        {
            //Erase all previous value
            Erase();
            sizeMultplier = Zoom * UIScale * ScreenMult;
            skillTree.ResetConnection();
            allConnection = new List <Connection>();
            allBasePanel  = new List <SkillPanel>();
            allText       = new List <SkillText>();



            backGround = new UIPanel();
            backGround.SetPadding(0);
            backGround.Left.Set(0, 0f);
            backGround.Top.Set(0, 0f);
            backGround.Width.Set(Main.screenWidth, 0f);
            backGround.Height.Set(Main.screenHeight, 0f);
            backGround.BackgroundColor = new Color(73, 94, 171, 150);
            Append(backGround);

            RPGPlayer rPGPlayer = Main.player[Main.myPlayer].GetModPlayer <RPGPlayer>();

            skillPointsLeft = new UIText("Skill Points : " + rPGPlayer.GetSkillPoints + " / " + (rPGPlayer.GetLevel() - 1));
            skillPointsLeft.Left.Set(150, 0f);
            skillPointsLeft.Top.Set(150, 0f);
            backGround.Append(skillPointsLeft);

            ResetText = new UIText("RESET", 1 * ScreenMult, true)
            {
                TextColor = Color.Gray
            };
            ResetText.Left.Set(150 * ScreenMult, 0f);
            ResetText.Top.Set(250 * ScreenMult, 0f);
            ResetText.Width.Set(0, 0f);
            ResetText.Height.Set(0, 0f);
            ResetText.OnClick     += new MouseEvent(ResetStats);
            ResetText.OnMouseOver += new MouseEvent(ResetTextHover);
            ResetText.OnMouseOut  += new MouseEvent(ResetTextOut);
            backGround.Append(ResetText);

            backGround.OnMouseDown   += new UIElement.MouseEvent(DragStart);
            backGround.OnMouseUp     += new UIElement.MouseEvent(DragEnd);
            backGround.OnScrollWheel += new ScrollWheelEvent(ScrollUpDown);

            Instance = this;
            for (int i = 0; i < skillTree.nodeList.nodeList.Count; i++)
            {
                SkillInit(skillTree.nodeList.nodeList[i]);
            }



            //
        }