Exemplo n.º 1
0
 public NormalNonoptionGainbuffEvent(string eventName, string eventDescription, int counter, GameEventType eventType, int whichEvent,
                                     string effectDescription, BuffEntry buff)
     : base(eventName, eventDescription, counter, eventType, whichEvent)
 {
     this.buff = buff;
     this.effectDescription = effectDescription;
 }
Exemplo n.º 2
0
        private void lstEnchants_SelectedIndexChanged(object sender, EventArgs e)
        {
            // Update values and temporarily disable update events from firing
            enable = false;
            var i = lstEnchants.SelectedIndex;

            txtName.Text = lstEnchants.Text;

            var curBuff = new BuffEntry();

            foreach (var be in mBuffs)
            {
                if (be.Name == "ENCHANT_" + lstEnchants.Text)
                {
                    curBuff = be;
                }
            }

            numSpellLevel.Value = curBuff.Power;
            numDuration.Value   = curBuff.Duration;
            numShieldHP.Value   = curBuff.ShieldHealth;

            UpdateNumerics();
            enable = true;
        }
 public void Clear()
 {
     nonoptionPart.gameObject.SetActive(false);
     optionPart.gameObject.SetActive(false);
     resultPanel.gameObject.SetActive(false);
     currentMemory      = -1;
     currentBuff        = null;
     currentItems       = null;
     currentOptions     = null;
     currentMonsterType = MonsterType.NUM;
     effectString       = "";
 }
Exemplo n.º 4
0
        public object getVal(string key, bool evenIfExpired)
        {
            if (!vals.ContainsKey(key))
            {
                return(null);
            }
            BuffEntry ret = vals[key];

            if (!evenIfExpired && ret.Expired)
            {
                return(null);
            }
            return(ret.Value);
        }
    public void OnUseBtn()
    {
        Item      useditem    = itemReader.GetItemData(currentType);
        BuffEntry currentBuff = useditem.buff;
        Monster   monster     = gameManager.gameInteraction.menu.currentMonster;

        if (currentBuff == null)
        {
            return;
        }
        if (currentBuff.counter >= 0)
        {
            monster.addBuff(currentBuff.attributeType, currentBuff.value, currentBuff.counter);
        }
        else
        {
            monster.modifyAttribute(currentBuff.attributeType, currentBuff.value);
        }
        monster.UpdateCurrentValue();
        inventory.itemManager.ConsumeItem(currentType, 1);
        UpdateInventory();
    }
Exemplo n.º 6
0
        public static MonsterXfer FromStream(Stream mstream, ThingDb.Thing tt, short ParsingRule)
        {
            MonsterXfer result = new MonsterXfer();

            NoxBinaryReader br = new NoxBinaryReader(mstream);
            result.Direction = (DirectionEncoded) br.ReadUInt64();
            result.ScriptEvents = new string[10];
            // Читаем имена обработчиков скриптовых событий
            for (int i = 0; i < 10; i++)
            {
                if (i == 2)
                    result.DetectEventTimeout = br.ReadUInt16();

                result.ScriptEvents[i] = br.ReadScriptEventString();
            }
            // Пропуск (0)
            if (ParsingRule >= 11)
                br.ReadInt32();
            if (ParsingRule >= 31)
            {
                result.ActionRoamPathFlag = br.ReadByte();
                if (ParsingRule < 51)
                    result.StatusFlags = (NoxEnums.MonsterStatus) br.ReadUInt16();
                else
                    result.StatusFlags = (NoxEnums.MonsterStatus) br.ReadUInt32();

                result.HealthMultiplier = br.ReadSingle();
                result.RetreatRatio = br.ReadSingle();
                result.ResumeRatio = br.ReadSingle();
                result.SightRange = br.ReadSingle();
                if (ParsingRule < 33)
                    br.BaseStream.Seek(2, SeekOrigin.Current);
                result.Aggressiveness = br.ReadSingle();
                if (ParsingRule < 34)
                    result.DefaultAction = br.ReadInt32();
                result.EscortObjName = br.ReadString();
                if (ParsingRule >= 34)
                {
                    int spells = br.ReadInt32();
                    result.KnownSpells = new List<SpellEntry>();
                    string spellName = null;
                    uint spellFlags = 0;

                    for (int i = 0; i < spells; i++)
                    {
                        spellName = br.ReadString();
                        spellFlags = br.ReadUInt32();
                        if (ThingDb.thingdb.Spells.Keys.Contains(spellName))
                            result.KnownSpells.Add(new SpellEntry(spellName, spellFlags));
                    }
                }
                else
                    br.BaseStream.Seek(0x224, SeekOrigin.Current);
                // Задержки между заклинаниями
                if (ParsingRule < 46)
                {
                    result.ReactionCastingDelayMin = (ushort) br.ReadByte();
                    result.ReactionCastingDelayMax = (ushort) br.ReadByte();
                    if (ParsingRule <= 32) br.ReadInt32();
                    result.BuffCastingDelayMin = (ushort) br.ReadByte();
                    result.BuffCastingDelayMax = (ushort) br.ReadByte();
                    if (ParsingRule <= 32) br.ReadInt32();
                    result.DebuffCastingDelayMin = (ushort) br.ReadByte();
                    result.DebuffCastingDelayMax = (ushort) br.ReadByte();
                    if (ParsingRule <= 32) br.ReadInt32();
                    result.OffensiveCastingDelayMin = (ushort) br.ReadByte();
                    result.OffensiveCastingDelayMax = (ushort) br.ReadByte();
                    if (ParsingRule <= 32) br.ReadInt32();
                    result.BlinkCastingDelayMin = (ushort) br.ReadByte();
                    result.BlinkCastingDelayMax = (ushort) br.ReadByte();
                    if (ParsingRule <= 32) br.ReadInt32();
                }
                else
                {
                    result.ReactionCastingDelayMin = br.ReadUInt16();
                    result.ReactionCastingDelayMax = br.ReadUInt16();
                    result.BuffCastingDelayMin = br.ReadUInt16();
                    result.BuffCastingDelayMax = br.ReadUInt16();
                    result.DebuffCastingDelayMin = br.ReadUInt16();
                    result.DebuffCastingDelayMax = br.ReadUInt16();
                    result.OffensiveCastingDelayMin = br.ReadUInt16();
                    result.OffensiveCastingDelayMax = br.ReadUInt16();
                    result.BlinkCastingDelayMin = br.ReadUInt16();
                    result.BlinkCastingDelayMax = br.ReadUInt16();
                }
                if (ParsingRule > 32)
                    result.LockPathDistance = br.ReadSingle();

                if (ParsingRule >= 33)
                {
                    result.SpellPowerLevel = br.ReadInt32();
                    result.AimSkillLevel = br.ReadSingle();
                    if (ParsingRule < 42)
                    {
                        if (br.ReadInt16() == 0)
                            result.Immortal = true;
                    }
                    if (ParsingRule < 53)
                    {
                        int spellIndex = br.ReadInt32();
                        result.TrapSpell1 = ThingDb.thingdb.Spells.Values[spellIndex].Name;
                        spellIndex = br.ReadInt32();
                        result.TrapSpell2 = ThingDb.thingdb.Spells.Values[spellIndex].Name;
                        spellIndex = br.ReadInt32();
                        result.TrapSpell3 = ThingDb.thingdb.Spells.Values[spellIndex].Name;
                    }
                    else
                    {
                        result.TrapSpell1 = br.ReadString();
                        result.TrapSpell2 = br.ReadString();
                        result.TrapSpell3 = br.ReadString();
                    }
                }
                if (ParsingRule >= 34)
                {
                    string action = br.ReadString();
                    result.DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action);
                }
                if (ParsingRule >= 41)
                {
                    // здесь придётся читать просто огромное кол-во инфы
                    // однако она используется очень редко, обычно entryType = 4; forced = 0
                    short entryType = br.ReadInt16();
                    if (entryType <= 4)
                    {
                        byte forced = 1;
                        if (entryType >= 2)
                            forced = br.ReadByte();
                        if (forced == 1 || entryType < 2)
                        {
                            return result;
                            // TODO для ПОЛНОЙ совместимости, придётся
                        }
                    }
                }
                if (ParsingRule >= 42)
                {
                    result.Immortal = br.ReadBoolean();
                }
                if (ParsingRule >= 43 && tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.SHOPKEEPER])
                {
                    // Информация о содержании магазина
                    ShopkeeperInfoStruct si = new ShopkeeperInfoStruct();
                    if (ParsingRule >= 50)
                        si.BuyValueMultiplier = br.ReadSingle();
                    if (ParsingRule >= 61)
                        si.SellValueMultiplier = br.ReadSingle();
                    if (ParsingRule >= 48)
                        si.ShopkeeperGreetingText = br.ReadString();
                    byte items = br.ReadByte();
                    si.ShopItems = new ShopItemInfo[items];
                    for (int i = 0; i < items; i++)
                    {
                        ShopItemInfo item = new ShopItemInfo();
                        if (ParsingRule < 50) br.ReadInt32();
                        item.Count = br.ReadByte();
                        item.Name = br.ReadString();
                        if (ParsingRule >= 47)
                        {
                            item.SpellID = br.ReadString();
                            item.Ench1 = br.ReadString();
                            item.Ench2 = br.ReadString();
                            item.Ench3 = br.ReadString();
                            item.Ench4 = br.ReadString();
                        }
                        si.ShopItems[i] = item;
                    }
                    result.ShopkeeperInfo = si;
                }
                if (ParsingRule >= 44)
                    result.MagicNumber = br.ReadUInt32();
                if (ParsingRule >= 45)
                    result.AddedSubclass = br.ReadUInt32();
                if (ParsingRule >= 49)
                    result.Health = br.ReadInt16();
                if (ParsingRule >= 51)
                {
                    result.SetDefaultResumeRatio = br.ReadBoolean();
                    result.SetDefaultRetreatRatio = br.ReadBoolean();
                    result.SetDefaultMonsterStatus = br.ReadBoolean();
                    result.LearnDefaultSpells = br.ReadBoolean();
                }
                if (ParsingRule >= 54 && tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.FEMALE_NPC])
                {
                    result.MaidenBodyColors = new Color[6];
                    byte R, G, B;
                    for (int i = 0; i < 6; i++)
                    {
                        R = br.ReadByte();
                        G = br.ReadByte();
                        B = br.ReadByte();
                        result.MaidenBodyColors[i] = Color.FromArgb(R, G, B);
                    }
                    if (ParsingRule >= 55)
                        result.MaidenVoiceSet = br.ReadString();
                }
                if (ParsingRule >= 62)
                {
                    short entryType = br.ReadInt16();
                    if (entryType > 2 || entryType <= 0) return result;

                    byte count = br.ReadByte();
                    result.BuffList = new BuffEntry[count];
                    while (count > 0)
                    {
                        BuffEntry be = new BuffEntry();
                        be.Name = br.ReadString();
                        be.Power = br.ReadByte();
                        be.Duration = br.ReadInt32();
                        if (be.Name == ENCHANT_SHIELD && entryType >= 2)
                            be.ShieldHealth = br.ReadInt32();

                        result.BuffList[count] = be;
                        count--;
                    }
                    Array.Reverse(result.BuffList);
                }
                if (ParsingRule >= 63 && tt.Subclass[(int) ThingDb.Thing.SubclassBitIndex.WOUNDED_NPC])
                    result.WoundedNPCVoiceSet = br.ReadString();
                if (ParsingRule >= 64)
                    result.PoisonLevel = br.ReadByte();
            }
            return result;
        }
    public void UpdateGameEventPanel(GameEvent gameEvent)
    {
        Clear();
        mainPanel.gameObject.SetActive(true);
        this.gameEvent = gameEvent;
        switch (gameEvent.eventType)
        {
        case GameEventType.NormalNonoptionGainbuffEvent:
            try
            {
                NormalNonoptionGainbuffEvent convertedEvent = (NormalNonoptionGainbuffEvent)gameEvent;
                EnableNonoptionPart();
                currentBuff  = convertedEvent.GetBuff();
                effectString = convertedEvent.GetEffectDescription();
                effect.text  = effectString;
            } catch (InvalidCastException ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.NormalNonoptionGainitemsEvent:
            try
            {
                NormalNonoptionGainitemsEvent convertedEvent = (NormalNonoptionGainitemsEvent)gameEvent;
                EnableNonoptionPart();
                currentItems = convertedEvent.GetItems();
                effectString = convertedEvent.GetEffectDescription();
                effect.text  = effectString;
            } catch (InvalidCastException ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.NormalNonoptionMemoryEvent:
            try
            {
                NormalNonoptionMemoryEvent convertedEvent = (NormalNonoptionMemoryEvent)gameEvent;
                EnableNonoptionPart();
                currentMemory = convertedEvent.GetMemoryId();
                effectString  = convertedEvent.GetEffectDescription();
                effect.text   = effectString;
            } catch (InvalidCastException ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.NormalOptionEvent:
            try
            {
                NormalOptionEvent convertedEvent = (NormalOptionEvent)gameEvent;
                EnableOptionPart();
                currentOptions = convertedEvent.GetOptions();
                for (int i = 0; i < optionsButton.Count; i++)
                {
                    if (i < currentOptions.Count)
                    {
                        optionsButton[i].gameObject.SetActive(true);
                        optionsButton[i].GetComponent <Text>().text = currentOptions[i].name;
                    }
                    else
                    {
                        optionsButton[i].gameObject.SetActive(false);
                    }
                }
            } catch (InvalidCastException ex)
            {
                Debug.Log(ex.StackTrace);
            }

            break;

        case GameEventType.MysterypersonGainitemsEvent:
            try
            {
                MysterypersonGainitemsEvent convertedEvent = (MysterypersonGainitemsEvent)gameEvent;
                EnableOptionPart();
                currentOptions = convertedEvent.GetOptions();
                for (int i = 0; i < optionsButton.Count; i++)
                {
                    if (i < currentOptions.Count)
                    {
                        optionsButton[i].gameObject.SetActive(true);
                        optionsButton[i].GetComponent <Text>().text = currentOptions[i].name;
                    }
                    else
                    {
                        optionsButton[i].gameObject.SetActive(false);
                    }
                }
            } catch (InvalidCastException ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.MysterypersonGaincharacterEvent:
            try
            {
                MysterypersonGaincharacterEvent convertedEvent = (MysterypersonGaincharacterEvent)gameEvent;
                EnableOptionPart();
                currentMonsterType  = convertedEvent.GetMonsterType();
                currentMonsterLevel = convertedEvent.GetLevel();
                currentOptions      = convertedEvent.GetOptions();
                for (int i = 0; i < optionsButton.Count; i++)
                {
                    if (i < currentOptions.Count)
                    {
                        optionsButton[i].gameObject.SetActive(true);
                        optionsButton[i].GetComponent <Text>().text = currentOptions[i].name;
                    }
                    else
                    {
                        optionsButton[i].gameObject.SetActive(false);
                    }
                }
            } catch (InvalidCastException ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        default:
            break;
        }
        name.text        = gameEvent.eventName;
        description.text = gameEvent.eventDescription;
        eventReader      = new GameEventReader();
        Sprite sprite;

        if ((sprite = Resources.Load(imagePath + eventReader.GetGameEventIndex(gameEvent), typeof(Sprite)) as Sprite) != null)
        {
            cg.sprite = sprite;
        }
    }
Exemplo n.º 8
0
        public override bool FromStream(Stream mstream, short ParsingRule, ThingDb.Thing thing)
        {
            NoxBinaryReader br = new NoxBinaryReader(mstream);

            DirectionId  = (byte)Array.IndexOf(NOX_DIRECT_LONG, br.ReadUInt64());
            ScriptEvents = new string[10];
            // Read script event handler names
            for (int i = 0; i < 10; i++)
            {
                if (i == 2)
                {
                    DetectEventTimeout = br.ReadUInt16();
                }

                ScriptEvents[i] = br.ReadScriptEventString();
            }
            // Skip (0)
            if (ParsingRule >= 11)
            {
                br.ReadInt32();
            }
            if (ParsingRule >= 31)
            {
                ActionRoamPathFlag = br.ReadByte();
                if (ParsingRule < 51)
                {
                    StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt16();
                }
                else
                {
                    StatusFlags = (NoxEnums.MonsterStatus)br.ReadUInt32();
                }

                HealthMultiplier = br.ReadSingle();
                RetreatRatio     = br.ReadSingle();
                ResumeRatio      = br.ReadSingle();
                SightRange       = br.ReadSingle();
                if (ParsingRule < 33)
                {
                    br.BaseStream.Seek(2, SeekOrigin.Current);
                }
                Aggressiveness = br.ReadSingle();
                if (ParsingRule < 34)
                {
                    DefaultAction = br.ReadInt32();
                }
                EscortObjName = br.ReadString();
                if (ParsingRule >= 34)
                {
                    int spells = br.ReadInt32();
                    KnownSpells = new List <SpellEntry>();
                    string spellName  = null;
                    uint   spellFlags = 0;

                    for (int i = 0; i < spells; i++)
                    {
                        spellName  = br.ReadString();
                        spellFlags = br.ReadUInt32();
                        if (ThingDb.Spells.Keys.Contains(spellName))
                        {
                            KnownSpells.Add(new SpellEntry(spellName, spellFlags));
                        }
                    }
                }
                else
                {
                    br.BaseStream.Seek(0x224, SeekOrigin.Current);
                }
                // Spell usage delay values
                if (ParsingRule < 46)
                {
                    ReactionCastingDelayMin = (ushort)br.ReadByte();
                    ReactionCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    BuffCastingDelayMin = (ushort)br.ReadByte();
                    BuffCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    DebuffCastingDelayMin = (ushort)br.ReadByte();
                    DebuffCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    OffensiveCastingDelayMin = (ushort)br.ReadByte();
                    OffensiveCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                    BlinkCastingDelayMin = (ushort)br.ReadByte();
                    BlinkCastingDelayMax = (ushort)br.ReadByte();
                    if (ParsingRule <= 32)
                    {
                        br.ReadInt32();
                    }
                }
                else
                {
                    ReactionCastingDelayMin  = br.ReadUInt16();
                    ReactionCastingDelayMax  = br.ReadUInt16();
                    BuffCastingDelayMin      = br.ReadUInt16();
                    BuffCastingDelayMax      = br.ReadUInt16();
                    DebuffCastingDelayMin    = br.ReadUInt16();
                    DebuffCastingDelayMax    = br.ReadUInt16();
                    OffensiveCastingDelayMin = br.ReadUInt16();
                    OffensiveCastingDelayMax = br.ReadUInt16();
                    BlinkCastingDelayMin     = br.ReadUInt16();
                    BlinkCastingDelayMax     = br.ReadUInt16();
                }
                if (ParsingRule > 32)
                {
                    LockPathDistance = br.ReadSingle();
                }

                if (ParsingRule >= 33)
                {
                    SpellPowerLevel = br.ReadInt32();
                    AimSkillLevel   = br.ReadSingle();
                    if (ParsingRule < 42)
                    {
                        if (br.ReadInt16() == 0)
                        {
                            Immortal = true;
                        }
                    }
                    if (ParsingRule < 53)
                    {
                        int spellIndex = br.ReadInt32();
                        TrapSpell1 = ThingDb.Spells.Values[spellIndex].Name;
                        spellIndex = br.ReadInt32();
                        TrapSpell2 = ThingDb.Spells.Values[spellIndex].Name;
                        spellIndex = br.ReadInt32();
                        TrapSpell3 = ThingDb.Spells.Values[spellIndex].Name;
                    }
                    else
                    {
                        TrapSpell1 = br.ReadString();
                        TrapSpell2 = br.ReadString();
                        TrapSpell3 = br.ReadString();
                    }
                }
                if (ParsingRule >= 34)
                {
                    string action = br.ReadString();
                    DefaultAction = Array.IndexOf(NoxEnums.AIActionStrings, action);
                }
                if (ParsingRule >= 41)
                {
                    // large, complex structure dealing with AI-specific data
                    // it is only used on saved games, normally entryType = 4; forced = 0
                    short entryType = br.ReadInt16();
                    if (entryType <= 4)
                    {
                        byte forced = 1;
                        if (entryType >= 2)
                        {
                            forced = br.ReadByte();
                        }
                        if (forced == 1 || entryType < 2)
                        {
                            return(false);
                            // TODO implement for full compatibility
                        }
                    }
                }
                if (ParsingRule >= 42)
                {
                    Immortal = br.ReadBoolean();
                }
                if (ParsingRule >= 43 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.SHOPKEEPER])
                {
                    // Shop contents
                    ShopkeeperInfoStruct si = new ShopkeeperInfoStruct();
                    if (ParsingRule >= 50)
                    {
                        si.BuyValueMultiplier = br.ReadSingle();
                    }
                    if (ParsingRule >= 61)
                    {
                        si.SellValueMultiplier = br.ReadSingle();
                    }
                    if (ParsingRule >= 48)
                    {
                        si.ShopkeeperGreetingText = br.ReadString();
                    }
                    byte items = br.ReadByte();
                    si.ShopItems = new ShopItemInfo[items];
                    for (int i = 0; i < items; i++)
                    {
                        ShopItemInfo item = new ShopItemInfo();
                        if (ParsingRule < 50)
                        {
                            br.ReadInt32();
                        }
                        item.Count = br.ReadByte();
                        item.Name  = br.ReadString();
                        if (ParsingRule >= 47)
                        {
                            item.SpellID = br.ReadString();
                            item.Ench1   = br.ReadString();
                            item.Ench2   = br.ReadString();
                            item.Ench3   = br.ReadString();
                            item.Ench4   = br.ReadString();
                        }
                        si.ShopItems[i] = item;
                    }
                    ShopkeeperInfo = si;
                }
                if (ParsingRule >= 44)
                {
                    MagicNumber = br.ReadUInt32();
                }
                if (ParsingRule >= 45)
                {
                    AddedSubclass = br.ReadUInt32();
                }
                if (ParsingRule >= 49)
                {
                    Health = br.ReadInt16();
                }
                if (ParsingRule >= 51)
                {
                    SetDefaultResumeRatio   = br.ReadBoolean();
                    SetDefaultRetreatRatio  = br.ReadBoolean();
                    SetDefaultMonsterStatus = br.ReadBoolean();
                    LearnDefaultSpells      = br.ReadBoolean();
                }
                if (ParsingRule >= 54 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.FEMALE_NPC])
                {
                    MaidenBodyColors = new Color[6];
                    byte R, G, B;
                    for (int i = 0; i < 6; i++)
                    {
                        R = br.ReadByte();
                        G = br.ReadByte();
                        B = br.ReadByte();
                        MaidenBodyColors[i] = Color.FromArgb(R, G, B);
                    }
                    if (ParsingRule >= 55)
                    {
                        MaidenVoiceSet = br.ReadString();
                    }
                }
                if (ParsingRule >= 62)
                {
                    short entryType = br.ReadInt16();
                    if (entryType > 2 || entryType <= 0)
                    {
                        return(false);
                    }

                    byte count = br.ReadByte();
                    BuffList = new BuffEntry[count];
                    while (count > 0)
                    {
                        BuffEntry be = new BuffEntry();
                        be.Name     = br.ReadString();
                        be.Power    = br.ReadByte();
                        be.Duration = br.ReadInt32();
                        if (be.Name == ENCHANT_SHIELD && entryType >= 2)
                        {
                            be.ShieldHealth = br.ReadInt32();
                        }

                        BuffList[count] = be;
                        count--;
                    }
                    Array.Reverse(BuffList);
                }
                if (ParsingRule >= 63 && thing.Subclass[(int)ThingDb.Thing.SubclassBitIndex.WOUNDED_NPC])
                {
                    WoundedNPCVoiceSet = br.ReadString();
                }
                if (ParsingRule >= 64)
                {
                    PoisonLevel = br.ReadByte();
                }
            }
            return(true);
        }
    public GameEvent getNewGameEvent(GameEventType type, int which)
    {
        if (which < 0 || which >= eventNums[(int)type])
        {
            return(null);
        }

        GameEvent gameEvent        = null;
        string    eventName        = "";
        string    eventDescription = "";
        int       eventCounter     = 0;

        //int eventid=0;

        if (xmlDoc != null)
        {
            string     xpath = eventxpath[(int)type];
            XmlElement node  = (XmlElement)xmlDoc.SelectNodes(xpath)[which];
            eventName        = node["name"].InnerXml;
            eventDescription = node["description"].InnerXml;
            eventCounter     = int.Parse(node["counter"].InnerXml);
        }
        else
        {
            Debug.Log("EventReader not load correctly");
            return(null);
        }

        switch (type)
        {
        case GameEventType.NormalNonoptionGainbuffEvent:
            try
            {
                XmlElement node = (XmlElement)xmlDoc.SelectNodes(eventxpath[(int)type])[which];

                XmlElement buffnode = (XmlElement)node.SelectSingleNode("buff");
                int        counter  = int.Parse(buffnode["counter"].InnerXml);
                int        value    = int.Parse(buffnode["value"].InnerXml);

                string attributeType = buffnode["attribute"].InnerXml;


                string    effectDescription = node["effectDescription"].InnerXml;
                BuffEntry entry             = new BuffEntry(GameEventHelper.getAttributeTypeFromString(attributeType),
                                                            counter, value);
                gameEvent = new NormalNonoptionGainbuffEvent(eventName, eventDescription, eventCounter, type, which,
                                                             effectDescription,
                                                             entry);
                //Debug.Log(gameEvent.ToString());
            }
            catch (Exception ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.NormalNonoptionGainitemsEvent:
            try
            {
                XmlElement  node = (XmlElement)xmlDoc.SelectNodes(eventxpath[(int)type])[which];
                string      effectDescription = node["effectDescription"].InnerXml;
                XmlNodeList itemnodes         = node.SelectNodes("item");
                //Debug.Log("itemnodes: " + itemnodes.Count);
                List <ItemEntry> items = new List <ItemEntry>();
                for (int i = 0; i < itemnodes.Count; i++)
                {
                    ItemEntry  itemEntry = new ItemEntry();
                    XmlElement itemnode  = (XmlElement)itemnodes[i];
                    itemEntry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(itemnode["type"].InnerXml);
                    itemEntry.itemType    = GameEventHelper.getItemTypeFromString(itemEntry.primaryType, itemnode["typeEnum"].InnerXml);
                    itemEntry.number      = int.Parse(itemnode["number"].InnerXml);
                    itemEntry.posibility  = int.Parse(itemnode["posibility"].InnerXml);
                    items.Add(itemEntry);
                }
                gameEvent = new NormalNonoptionGainitemsEvent(eventName, eventDescription, eventCounter, type, which, effectDescription,
                                                              items);
                //Debug.Log(gameEvent.ToString());
            }
            catch (Exception ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.NormalNonoptionMemoryEvent:
            try
            {
                XmlElement node = (XmlElement)xmlDoc.SelectNodes(eventxpath[(int)type])[which];
                string     effectDescription = node["effectDescription"].InnerXml;

                int memoryid = int.Parse(node["memory"].InnerXml);

                gameEvent = new NormalNonoptionMemoryEvent(eventName, eventDescription, eventCounter, type, which, effectDescription,
                                                           memoryid);
            }
            catch (Exception ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.NormalOptionEvent:
            try
            {
                XmlNodeList optionnodes = xmlDoc.SelectNodes(eventxpath[(int)type])[which].SelectNodes("options/option");
                //Debug.Log(optionnodes.Count);
                List <GameEventOption> options = new List <GameEventOption>();
                for (int i = 0; i < optionnodes.Count; i++)
                {
                    XmlElement  node      = (XmlElement)optionnodes[i];
                    string      name      = node["name"].InnerXml;
                    XmlNodeList itemnodes = node.SelectNodes("item");
                    XmlNodeList buffnodes = node.SelectNodes("buff");

                    List <ItemEntry> items = itemnodes.Count > 0?new List <ItemEntry>():null;
                    List <BuffEntry> buffs = buffnodes.Count > 0?new List <BuffEntry>():null;

                    //Debug.Log("Items: " + itemnodes.Count + "\t\tBuffs: " + buffnodes.Count);

                    for (int j = 0; j < itemnodes.Count; j++)
                    {
                        XmlElement item      = (XmlElement)itemnodes[j];
                        ItemEntry  itementry = new ItemEntry();
                        itementry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(item["type"].InnerXml);
                        itementry.itemType    = GameEventHelper.getItemTypeFromString(itementry.primaryType, item["typeEnum"].InnerXml);
                        itementry.number      = int.Parse(item["number"].InnerXml);
                        itementry.posibility  = int.Parse(item["posibility"].InnerXml);

                        items.Add(itementry);
                    }

                    for (int j = 0; j < buffnodes.Count; j++)
                    {
                        XmlElement buff      = (XmlElement)buffnodes[j];
                        BuffEntry  buffentry = new BuffEntry(GameEventHelper.getAttributeTypeFromString(buff["attribute"].InnerXml),
                                                             int.Parse(buff["counter"].InnerXml), int.Parse(buff["value"].InnerXml));
                        buffs.Add(buffentry);
                    }

                    GameEventOption option = new GameEventOption(name, items, buffs, null, null);
                    options.Add(option);
                }
                gameEvent = new NormalOptionEvent(eventName, eventDescription, eventCounter, type, which,
                                                  options);
                //Debug.Log(gameEvent.ToString());
            }
            catch (Exception ex)
            {
                Debug.Log(ex.StackTrace);
            }

            break;

        case GameEventType.MysterypersonGainitemsEvent:
            try
            {
                XmlNodeList optionnodes = xmlDoc.SelectNodes(eventxpath[(int)type])[which].SelectNodes("options/option");
                //Debug.Log(optionnodes.Count);
                List <GameEventOption> options = new List <GameEventOption>();
                for (int i = 0; i < optionnodes.Count; i++)
                {
                    XmlElement node   = (XmlElement)optionnodes[i];
                    string     name   = node["name"].InnerXml;
                    string     result = node["result"].InnerXml ?? null;
                    //Debug.Log("event " + which + " " + name + result);
                    XmlNodeList itemnodes = node.SelectNodes("item");
                    XmlNodeList buffnodes = node.SelectNodes("buff");
                    XmlNodeList costnodes = node.SelectNodes("cost/item");

                    List <ItemEntry> items = itemnodes.Count > 0 ? new List <ItemEntry>() : null;
                    List <BuffEntry> buffs = buffnodes.Count > 0 ? new List <BuffEntry>() : null;
                    List <ItemEntry> costs = costnodes.Count > 0?new List <ItemEntry>():null;

                    //Debug.Log("Items: " + itemnodes.Count + "\t\tBuffs: " + buffnodes.Count);

                    for (int j = 0; j < itemnodes.Count; j++)
                    {
                        XmlElement item      = (XmlElement)itemnodes[j];
                        ItemEntry  itementry = new ItemEntry();
                        itementry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(item["type"].InnerXml);
                        itementry.itemType    = GameEventHelper.getItemTypeFromString(itementry.primaryType, item["typeEnum"].InnerXml);
                        itementry.number      = int.Parse(item["number"].InnerXml);
                        itementry.posibility  = int.Parse(item["posibility"].InnerXml);

                        items.Add(itementry);
                    }

                    for (int j = 0; j < buffnodes.Count; j++)
                    {
                        XmlElement buff      = (XmlElement)buffnodes[j];
                        BuffEntry  buffentry = new BuffEntry(GameEventHelper.getAttributeTypeFromString(buff["attribute"].InnerXml),
                                                             int.Parse(buff["counter"].InnerXml), int.Parse(buff["value"].InnerXml));
                        buffs.Add(buffentry);
                    }

                    for (int j = 0; j < costnodes.Count; j++)
                    {
                        XmlElement cost      = (XmlElement)costnodes[j];
                        ItemEntry  costentry = new ItemEntry();
                        costentry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(cost["type"].InnerXml);
                        costentry.itemType    = GameEventHelper.getItemTypeFromString(costentry.primaryType, cost["typeEnum"].InnerXml);
                        costentry.number      = int.Parse(cost["number"].InnerXml);
                        costentry.posibility  = 100;

                        costs.Add(costentry);
                    }

                    GameEventOption option = new GameEventOption(name, items, buffs, costs, result);
                    options.Add(option);
                }
                gameEvent = new MysterypersonGainitemsEvent(eventName, eventDescription, eventCounter, type, which, options);
                //Debug.Log(gameEvent.ToString());
            }
            catch (Exception ex)
            {
                Debug.Log(ex.StackTrace);
            }
            break;

        case GameEventType.MysterypersonGaincharacterEvent:
            try
            {
                XmlNode     eventnode   = xmlDoc.SelectNodes(eventxpath[(int)type])[which];
                XmlNodeList optionnodes = eventnode.SelectNodes("options/option");

                MonsterType monsterType = GameEventHelper.getMonsterTypeFromString(eventnode["character"].InnerXml);
                int         level       = int.Parse(eventnode["level"].InnerXml);

                List <GameEventOption> options = new List <GameEventOption>();

                for (int i = 0; i < optionnodes.Count; i++)
                {
                    XmlElement node   = (XmlElement)optionnodes[i];
                    string     name   = node["name"].InnerXml;
                    string     result = node["result"].InnerXml ?? null;
                    //Debug.Log("event " + which + " " + name + result);
                    XmlNodeList itemnodes = node.SelectNodes("item");
                    XmlNodeList buffnodes = node.SelectNodes("buff");
                    XmlNodeList costnodes = node.SelectNodes("cost/item");

                    List <ItemEntry> items = itemnodes.Count > 0 ? new List <ItemEntry>() : null;
                    List <BuffEntry> buffs = buffnodes.Count > 0 ? new List <BuffEntry>() : null;
                    List <ItemEntry> costs = costnodes.Count > 0 ? new List <ItemEntry>() : null;

                    //Debug.Log("Items: " + itemnodes.Count + "\t\tBuffs: " + buffnodes.Count);

                    for (int j = 0; j < itemnodes.Count; j++)
                    {
                        XmlElement item      = (XmlElement)itemnodes[j];
                        ItemEntry  itementry = new ItemEntry();
                        itementry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(item["type"].InnerXml);
                        itementry.itemType    = GameEventHelper.getItemTypeFromString(itementry.primaryType, item["typeEnum"].InnerXml);
                        itementry.number      = int.Parse(item["number"].InnerXml);
                        itementry.posibility  = int.Parse(item["posibility"].InnerXml);

                        items.Add(itementry);
                    }

                    for (int j = 0; j < buffnodes.Count; j++)
                    {
                        XmlElement buff      = (XmlElement)buffnodes[j];
                        BuffEntry  buffentry = new BuffEntry(GameEventHelper.getAttributeTypeFromString(buff["attribute"].InnerXml),
                                                             int.Parse(buff["counter"].InnerXml), int.Parse(buff["value"].InnerXml));
                        buffs.Add(buffentry);
                    }

                    for (int j = 0; j < costnodes.Count; j++)
                    {
                        XmlElement cost      = (XmlElement)costnodes[j];
                        ItemEntry  costentry = new ItemEntry();
                        costentry.primaryType = GameEventHelper.getItemPrimaryTypeFromString(cost["type"].InnerXml);
                        costentry.itemType    = GameEventHelper.getItemTypeFromString(costentry.primaryType, cost["typeEnum"].InnerXml);
                        costentry.number      = int.Parse(cost["number"].InnerXml);
                        costentry.posibility  = 100;

                        costs.Add(costentry);
                    }

                    GameEventOption option = new GameEventOption(name, items, buffs, costs, result);
                    options.Add(option);
                }

                gameEvent = new MysterypersonGaincharacterEvent(eventName, eventDescription, eventCounter, type, which,
                                                                monsterType, level, options);
                //Debug.Log(gameEvent.ToString());
            }
            catch (Exception ex)
            {
                Debug.Log(ex.StackTrace);
            }

            break;

        default:
            break;
        }

        return(gameEvent);
    }