Exemplo n.º 1
0
        public void DrawTooltip(GameTime gameTime, RenderEnv env, StringLinker stringLinker)
        {
            if (tooltipTarget == null)
            {
                return;
            }

            StringResult     sr;
            List <TextBlock> blocks = new List <TextBlock>();
            Vector2          size   = Vector2.Zero;

            switch (tooltipTarget.ObjectType)
            {
            case RenderObjectType.Mob:
            {
                LifePatch p = tooltipTarget as LifePatch;
                stringLinker.StringMob.TryGetValue(p.LifeID, out sr);
                Vector2 current = Vector2.Zero;

                PrepareTextBlock(blocks, env.Fonts.TooltipTitleFont, sr == null ? "(null)" : sr.Name, ref current, Color.White);
                current += new Vector2(4, 4);
                PrepareTextBlock(blocks, env.Fonts.TooltipContentFont, "id:" + p.LifeID.ToString("d7"), ref current, Color.White);
                size.X  = Math.Max(size.X, current.X);
                current = new Vector2(0, current.Y + 16);

                LifeInfo info = p.LifeInfo;

                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "Level: " + info.level + (info.boss ? " (Boss)" : null), ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "HP/MP: " + info.maxHP + " / " + info.maxMP, ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "PAD/MAD: " + info.PADamage + " / " + info.MADamage, ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "PDr/MDr: " + info.PDRate + "% / " + info.MDRate + "%", ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "Acc/Eva: " + info.acc + " / " + info.eva, ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "KB: " + info.pushed, ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "Exp: " + info.exp, ref current, Color.White, ref size.X);
                if (info.undead)
                {
                    PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "undead: 1", ref current, Color.White, ref size.X);
                }
                StringBuilder sb;
                if ((sb = GetLifeElemAttrString(ref info.elemAttr)).Length > 0)
                {
                    PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "elem: " + sb.ToString(), ref current, Color.White, ref size.X);
                }
                size.Y = current.Y;
            }
            break;

            case RenderObjectType.Npc:
            {
                LifePatch p = tooltipTarget as LifePatch;
                stringLinker.StringNpc.TryGetValue(p.LifeID, out sr);
                Vector2 current = Vector2.Zero;

                PrepareTextBlock(blocks, env.Fonts.TooltipTitleFont, sr == null ? "(null)" : sr.Name, ref current, Color.White);
                current += new Vector2(4, 4);
                PrepareTextBlock(blocks, env.Fonts.TooltipContentFont, "id:" + p.LifeID.ToString("d7"), ref current, Color.White);
                size.X  = Math.Max(size.X, current.X);
                current = new Vector2(0, current.Y + 16);

                foreach (var kv in p.Actions)
                {
                    if (kv.Value == p.Frames)
                    {
                        PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "action: " + kv.Key, ref current, Color.White, ref size.X);
                    }
                }
                size.Y = current.Y;
            }
            break;

            case RenderObjectType.Portal:
            {
                PortalPatch p       = tooltipTarget as PortalPatch;
                Vector2     current = Vector2.Zero;
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "pName: " + p.PortalName, ref current, Color.White, ref size.X);
                string pTypeName = GetPortalTypeString(p.PortalType);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "pType: " + p.PortalType + (pTypeName == null ? null : (" (" + pTypeName + ")")), ref current, Color.White, ref size.X);
                stringLinker.StringMap.TryGetValue(p.ToMap, out sr);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "toMap: " + (sr == null ? "(null)" : sr.Name) + "(" + p.ToMap + ")", ref current, Color.White, ref size.X);
                PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "toName: " + p.ToName, ref current, Color.White, ref size.X);
                if (!string.IsNullOrEmpty(p.Script))
                {
                    PrepareTextLine(blocks, env.Fonts.TooltipContentFont, "script: " + p.Script, ref current, Color.White, ref size.X);
                }
                size.Y = current.Y;
            }
            break;
            }

            if (blocks.Count > 0)
            {
                size += new Vector2(26, 26);
                Vector2 origin = new Vector2(env.Input.MousePosition.X, env.Input.MousePosition.Y);
                origin.X = MathHelper.Clamp(origin.X, 0, Math.Max(0, env.Camera.Width - size.X));
                origin.Y = MathHelper.Clamp(origin.Y, 0, Math.Max(0, env.Camera.Height - size.Y));
                this.DrawFrame(env, origin, size);

                origin += new Vector2(13, 13);
                foreach (TextBlock block in blocks)
                {
                    env.Sprite.DrawStringEx(block.Font, block.Text, block.Position, block.ForeColor, -origin);
                }
            }
        }
Exemplo n.º 2
0
        public void DrawTooltip(GameTime gameTime, RenderEnv env, StringLinker stringLinker)
        {
            if (tooltipTarget == null)
            {
                return;
            }

            StringResult     sr;
            List <TextBlock> blocks = new List <TextBlock>();
            Vector2          size   = Vector2.Zero;

            switch (tooltipTarget.ObjectType)
            {
            case RenderObjectType.Mob:
            {
                LifePatch p = tooltipTarget as LifePatch;
                stringLinker.StringMob.TryGetValue(p.LifeID, out sr);
                Vector2 current = Vector2.Zero;

                blocks.Add(PrepareTextBlock(env.Fonts.TooltipTitleFont, sr == null ? "(null)" : sr.Name, ref current, Color.White));
                current += new Vector2(4, 4);
                blocks.Add(PrepareTextBlock(env.Fonts.TooltipContentFont, "id:" + p.LifeID.ToString("d7"), ref current, Color.White));
                size.X  = Math.Max(size.X, current.X);
                current = new Vector2(0, current.Y + 16);

                LifeInfo info = p.LifeInfo;
                Vector2  size2;
                var      blocks2 = TooltipHelper.Prepare(info, env.Fonts, out size2);
                for (int i = 0; i < blocks2.Length; i++)
                {
                    blocks2[i].Position.Y += current.Y;
                    blocks.Add(blocks2[i]);
                }
                size.X = Math.Max(size.X, size2.X);
                size.Y = current.Y + size2.Y;
            }
            break;

            case RenderObjectType.Npc:
            {
                LifePatch p = tooltipTarget as LifePatch;
                stringLinker.StringNpc.TryGetValue(p.LifeID, out sr);
                Vector2 current = Vector2.Zero;

                blocks.Add(PrepareTextBlock(env.Fonts.TooltipTitleFont, sr == null ? "(null)" : sr.Name, ref current, Color.White));
                current += new Vector2(4, 4);
                blocks.Add(PrepareTextBlock(env.Fonts.TooltipContentFont, "id:" + p.LifeID.ToString("d7"), ref current, Color.White));
                size.X  = Math.Max(size.X, current.X);
                current = new Vector2(0, current.Y + 16);

                foreach (var kv in p.Actions)
                {
                    if (kv.Value == p.Frames)
                    {
                        blocks.Add(PrepareTextLine(env.Fonts.TooltipContentFont, "action: " + kv.Key, ref current, Color.White, ref size.X));
                    }
                }
                size.Y = current.Y;
            }
            break;

            case RenderObjectType.Portal:
            {
                PortalPatch p       = tooltipTarget as PortalPatch;
                Vector2     current = Vector2.Zero;
                blocks.Add(PrepareTextLine(env.Fonts.TooltipContentFont, "pName: " + p.PortalName, ref current, Color.White, ref size.X));
                string pTypeName = GetPortalTypeString(p.PortalType);
                blocks.Add(PrepareTextLine(env.Fonts.TooltipContentFont, "pType: " + p.PortalType + (pTypeName == null ? null : (" (" + pTypeName + ")")), ref current, Color.White, ref size.X));
                stringLinker.StringMap.TryGetValue(p.ToMap, out sr);
                blocks.Add(PrepareTextLine(env.Fonts.TooltipContentFont, "toMap: " + (sr == null ? "(null)" : sr.Name) + "(" + p.ToMap + ")", ref current, Color.White, ref size.X));
                blocks.Add(PrepareTextLine(env.Fonts.TooltipContentFont, "toName: " + p.ToName, ref current, Color.White, ref size.X));
                if (!string.IsNullOrEmpty(p.Script))
                {
                    blocks.Add(PrepareTextLine(env.Fonts.TooltipContentFont, "script: " + p.Script, ref current, Color.White, ref size.X));
                }
                size.Y = current.Y;
            }
            break;
            }

            if (blocks.Count > 0)
            {
                size += new Vector2(26, 26);
                Vector2 origin = new Vector2(env.Input.MousePosition.X, env.Input.MousePosition.Y);
                origin.X = MathHelper.Clamp(origin.X, 0, Math.Max(0, env.Camera.Width - size.X));
                origin.Y = MathHelper.Clamp(origin.Y, 0, Math.Max(0, env.Camera.Height - size.Y));
                this.DrawFrame(env, origin, size);

                origin += new Vector2(13, 13);
                foreach (TextBlock block in blocks)
                {
                    env.Sprite.DrawStringEx(block.Font, block.Text, block.Position, block.ForeColor, -origin);
                }
            }
        }
Exemplo n.º 3
0
 public LifePatch()
 {
     actions  = new Dictionary <string, RenderAnimate>();
     lifeInfo = new LifeInfo();
 }
Exemplo n.º 4
0
    public static void AddAllCards()
    {
        Reset();
        SortedDictionary <string, string> cardNameKeyDict = new SortedDictionary <string, string>();

        foreach (int v in Enum.GetValues(typeof(LanguageShorts)))
        {
            string strName = Enum.GetName(typeof(LanguageShorts), v);
            cardNameKeyDict[strName] = "cardName_" + strName;
        }

        string text;

        using (StreamReader sr = new StreamReader(CardsXMLFile))
        {
            text = sr.ReadToEnd();
        }

        XmlDocument doc = new XmlDocument();

        doc.LoadXml(text);
        XmlElement node_AllCards = doc.DocumentElement;

        for (int i = 0; i < node_AllCards.ChildNodes.Count; i++)
        {
            XmlNode node_Card = node_AllCards.ChildNodes.Item(i);
            int     cardID    = int.Parse(node_Card.Attributes["id"].Value);
            CardDict.Add(cardID, new CardInfo_Base());
        }

        for (int i = 0; i < node_AllCards.ChildNodes.Count; i++)
        {
            XmlNode node_Card = node_AllCards.ChildNodes.Item(i);

            int cardID = int.Parse(node_Card.Attributes["id"].Value);

            BaseInfo    baseInfo    = new BaseInfo();
            UpgradeInfo upgradeInfo = new UpgradeInfo();
            LifeInfo    lifeInfo    = new LifeInfo();
            BattleInfo  battleInfo  = new BattleInfo();
            MechInfo    mechInfo    = new MechInfo();
            EquipInfo   equipInfo   = new EquipInfo();
            WeaponInfo  weaponInfo  = new WeaponInfo();
            ShieldInfo  shieldInfo  = new ShieldInfo();
            PackInfo    packInfo    = new PackInfo();
            MAInfo      maInfo      = new MAInfo();

            SideEffectBundle sideEffectBundle = new SideEffectBundle();
            SideEffectBundle sideEffectBundle_BattleGroundAura = new SideEffectBundle();

            for (int j = 0; j < node_Card.ChildNodes.Count; j++)
            {
                XmlNode node_CardInfo = node_Card.ChildNodes[j];
                switch (node_CardInfo.Attributes["name"].Value)
                {
                case "baseInfo":
                    SortedDictionary <string, string> cardNameDict = new SortedDictionary <string, string>();
                    foreach (KeyValuePair <string, string> kv in cardNameKeyDict)
                    {
                        string cardName = node_CardInfo.Attributes[kv.Value].Value;
                        cardNameDict[kv.Key] = cardName;
                    }

                    baseInfo = new BaseInfo(
                        pictureID: int.Parse(node_CardInfo.Attributes["pictureID"].Value),
                        cardNames: cardNameDict,
                        isTemp: node_CardInfo.Attributes["isTemp"].Value == "True",
                        isHide: node_CardInfo.Attributes["isHide"].Value == "True",
                        metal: int.Parse(node_CardInfo.Attributes["metal"].Value),
                        energy: int.Parse(node_CardInfo.Attributes["energy"].Value),
                        coin: int.Parse(node_CardInfo.Attributes["coin"].Value),
                        effectFactor: 1,
                        limitNum: int.Parse(node_CardInfo.Attributes["limitNum"].Value),
                        cardRareLevel: int.Parse(node_CardInfo.Attributes["cardRareLevel"].Value),
                        shopPrice: int.Parse(node_CardInfo.Attributes["shopPrice"].Value),
                        cardType: (CardTypes)Enum.Parse(typeof(CardTypes), node_CardInfo.Attributes["cardType"].Value));
                    break;

                case "upgradeInfo":
                    int u_id = int.Parse(node_CardInfo.Attributes["upgradeCardID"].Value);
                    int d_id = int.Parse(node_CardInfo.Attributes["degradeCardID"].Value);
                    upgradeInfo = new UpgradeInfo(
                        upgradeCardID: u_id,
                        degradeCardID: d_id,
                        cardLevel: 1,
                        cardLevelMax: 1);
                    break;

                case "lifeInfo":
                    lifeInfo = new LifeInfo(
                        life: int.Parse(node_CardInfo.Attributes["life"].Value),
                        totalLife: int.Parse(node_CardInfo.Attributes["totalLife"].Value));
                    break;

                case "battleInfo":
                    battleInfo = new BattleInfo(
                        basicAttack: int.Parse(node_CardInfo.Attributes["basicAttack"].Value),
                        basicArmor: int.Parse(node_CardInfo.Attributes["basicArmor"].Value),
                        basicShield: int.Parse(node_CardInfo.Attributes["basicShield"].Value));
                    break;

                case "mechInfo":
                    mechInfo = new MechInfo(
                        isSoldier: node_CardInfo.Attributes["isSoldier"].Value == "True",
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True",
                        isSniper: node_CardInfo.Attributes["isSniper"].Value == "True",
                        isCharger: node_CardInfo.Attributes["isCharger"].Value == "True",
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True",
                        isSentry: node_CardInfo.Attributes["isSentry"].Value == "True",
                        slot1: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot1"].Value),
                        slot2: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot2"].Value),
                        slot3: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot3"].Value),
                        slot4: (SlotTypes)Enum.Parse(typeof(SlotTypes), node_CardInfo.Attributes["slot4"].Value));
                    break;

                case "weaponInfo":
                    weaponInfo = new WeaponInfo(
                        energy: int.Parse(node_CardInfo.Attributes["energy"].Value),
                        energyMax: int.Parse(node_CardInfo.Attributes["energyMax"].Value),
                        attack: int.Parse(node_CardInfo.Attributes["attack"].Value),
                        weaponType: (WeaponTypes)Enum.Parse(typeof(WeaponTypes), node_CardInfo.Attributes["weaponType"].Value),
                        isSentry: node_CardInfo.Attributes["isSentry"].Value == "True",
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True");
                    equipInfo = new EquipInfo(SlotTypes.Weapon);
                    break;

                case "shieldInfo":
                    shieldInfo = new ShieldInfo(
                        armor: int.Parse(node_CardInfo.Attributes["armor"].Value),
                        shield: int.Parse(node_CardInfo.Attributes["shield"].Value),
                        shieldType: (ShieldTypes)Enum.Parse(typeof(ShieldTypes), node_CardInfo.Attributes["shieldType"].Value),
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True");
                    equipInfo = new EquipInfo(SlotTypes.Shield);
                    break;

                case "packInfo":
                    packInfo = new PackInfo(
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True",
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True",
                        isSniper: node_CardInfo.Attributes["isSniper"].Value == "True"
                        );
                    equipInfo = new EquipInfo(SlotTypes.Pack);
                    break;

                case "maInfo":
                    maInfo = new MAInfo(
                        isFrenzy: node_CardInfo.Attributes["isFrenzy"].Value == "True",
                        isDefense: node_CardInfo.Attributes["isDefense"].Value == "True",
                        isSniper: node_CardInfo.Attributes["isSniper"].Value == "True"
                        );
                    equipInfo = new EquipInfo(SlotTypes.MA);
                    break;

                case "sideEffectsBundle":
                {
                    ExtractSideEffectBundle(baseInfo.CardType, node_CardInfo, sideEffectBundle);
                    break;
                }

                case "sideEffectsBundle_Aura":
                {
                    ExtractSideEffectBundle(baseInfo.CardType, node_CardInfo, sideEffectBundle_BattleGroundAura);
                    break;
                }
                }
            }

            switch (baseInfo.CardType)
            {
            case CardTypes.Mech:
                addCard(new CardInfo_Mech(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            lifeInfo: lifeInfo,
                            battleInfo: battleInfo,
                            mechInfo: mechInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;

            case CardTypes.Equip:
                addCard(new CardInfo_Equip(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            equipInfo: equipInfo,
                            weaponInfo: weaponInfo,
                            shieldInfo: shieldInfo,
                            packInfo: packInfo,
                            maInfo: maInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;

            case CardTypes.Spell:
                addCard(new CardInfo_Spell(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;

            case CardTypes.Energy:
                addCard(new CardInfo_Spell(
                            cardID: cardID,
                            baseInfo: baseInfo,
                            upgradeInfo: upgradeInfo,
                            sideEffectBundle: sideEffectBundle,
                            sideEffectBundle_BattleGroundAura: sideEffectBundle_BattleGroundAura));
                break;
            }
        }

        // Check all upgradeID and degradeID valid in library
        foreach (KeyValuePair <int, CardInfo_Base> kv in CardDict)
        {
            int uid = kv.Value.UpgradeInfo.UpgradeCardID;
            int did = kv.Value.UpgradeInfo.DegradeCardID;

            if (uid != -1)
            {
                if (!CardDict.ContainsKey(uid))
                {
                    kv.Value.UpgradeInfo.UpgradeCardID = -1;
                    NeedReload = true;
                }
            }

            if (did != -1)
            {
                if (!CardDict.ContainsKey(did))
                {
                    kv.Value.UpgradeInfo.DegradeCardID = -1;
                    NeedReload = true;
                }
            }
        }

        //TODO  Check all id in SE

        // Make all upgradeID and degradeID linked
        foreach (KeyValuePair <int, CardInfo_Base> kv in CardDict)
        {
            int uid = kv.Value.UpgradeInfo.UpgradeCardID;
            int did = kv.Value.UpgradeInfo.DegradeCardID;

            if (uid != -1)
            {
                CardInfo_Base uCard = CardDict[uid];
                if (uCard.UpgradeInfo.DegradeCardID != kv.Key)
                {
                    if (uCard.UpgradeInfo.DegradeCardID == -1)
                    {
                        uCard.UpgradeInfo.DegradeCardID = kv.Key;
                    }
                    else
                    {
                        CardInfo_Base uCard_ori_dCard = CardDict[uCard.UpgradeInfo.DegradeCardID];
                        if (uCard_ori_dCard.UpgradeInfo.UpgradeCardID == uCard.CardID)
                        {
                            kv.Value.UpgradeInfo.UpgradeCardID = -1;
                        }
                        else
                        {
                            uCard.UpgradeInfo.DegradeCardID = kv.Key;
                        }
                    }

                    NeedReload = true;
                }
            }

            if (did != -1)
            {
                CardInfo_Base dCard = CardDict[did];
                if (dCard.UpgradeInfo.UpgradeCardID != kv.Key)
                {
                    if (dCard.UpgradeInfo.UpgradeCardID == -1)
                    {
                        dCard.UpgradeInfo.UpgradeCardID = kv.Key;
                    }
                    else
                    {
                        CardInfo_Base dCard_ori_uCard = CardDict[dCard.UpgradeInfo.UpgradeCardID];
                        if (dCard_ori_uCard.UpgradeInfo.DegradeCardID == dCard.CardID)
                        {
                            kv.Value.UpgradeInfo.DegradeCardID = -1;
                        }
                        else
                        {
                            dCard.UpgradeInfo.UpgradeCardID = kv.Key;
                        }
                    }

                    NeedReload = true;
                }
            }
        }

        // Check Series valid, no cycle
        foreach (KeyValuePair <int, CardInfo_Base> kv in CardDict)
        {
            List <int> cardSeries   = GetCardSeries(kv.Key);
            int        cardLevelMax = cardSeries.Count;
            kv.Value.UpgradeInfo.CardLevelMax = cardLevelMax;
            int cardLevel = 0;
            foreach (int cardID in cardSeries)
            {
                cardLevel++;
                if (cardID == kv.Key)
                {
                    break;
                }
            }

            kv.Value.UpgradeInfo.CardLevel = cardLevel;
        }

        //If any problem, refresh XML and reload
        if (NeedReload)
        {
            NeedReload = false;
            RefreshAllCardXML();
            ReloadCardXML();
        }
    }
Exemplo n.º 5
0
 public static void UpdateLife(int amount, LifeInfo lifeinfo)
 {
     UpdateCurrentLifeOrchestration(amount, lifeinfo);
 }
Exemplo n.º 6
0
 private static void UpdateCurrentLife(int amount, LifeInfo lifeinfo)
 {
     lifeinfo.CurrentLife += amount;
 }
Exemplo n.º 7
0
 private static void UpdateCurrentLifeOrchestration(int amount, LifeInfo lifeinfo)
 {
     UpdateCurrentLife(amount, lifeinfo);
     VerificationDeath(lifeinfo);
 }
Exemplo n.º 8
0
 static void Main(string[] args)
 {
     LifeInfo.LunchBreak();
     LifeInfo.Holiday();
 }