Пример #1
0
        public void CastEggs_Level2Spells([Range(0, 2)] int level2EggIndex)
        {
            Tuple <MagicType, string> eggCombo = _level2Eggs[level2EggIndex];

            string    spellName = eggCombo.Item2;
            MagicType spellType = eggCombo.Item1;

            Spell spell  = SpellFactory.GetSpell(spellName);
            int   damage = spell.Power + _chicken.MagicStrength;

            _hero.SetMove(_doNothingMove, 4);
            _hero.SetMove(_runawayMove);
            _hero.SetMoveTarget(_hero);

            _sidekick.SetHealth(damage + 1);
            _sidekick.SetMove(_doNothingMove);
            _sidekick.SetMoveTarget(_sidekick);

            int typeIndex = Globals.EggMagicTypes.ToList().IndexOf(spellType);

            _chanceService.PushWhichEventsOccur(typeIndex, typeIndex, (typeIndex + 1) % 3, 1); //the 3 egg types and targetting the sidekick

            _battleManager.SuppressBattleIntroAndOutroMessages();
            _battleManager.Battle(_humanTeam, _enemyTeam);

            var outputs = _output.GetOutputs();

            Assert.AreEqual(5, outputs.Length); // 1 for each egg lay, 1 for actual attack, 1 to output how much damage the fighter took

            Assert.AreEqual(_castPrefix + spellName + "!\n", outputs[3].Message);

            Assert.AreEqual(1, _sidekick.CurrentHealth);
        }
Пример #2
0
        /// <summary>
        /// 获得相应的magic值
        /// </summary>
        /// <param name="magic">数据库中magic值</param>
        /// <param name="magicType">magic类型</param>
        /// <returns></returns>
        public static int GetMagicValue(int magic, MagicType magicType)
        {
            if (magic == 0)
            {
                return(0);
            }

            string m = magic.ToString();

            switch (magicType)
            {
            case MagicType.HtmlTitle:
                if (m.Length >= 2)
                {
                    return(TypeConverter.ObjectToInt(m.Substring(1, 1)));
                }
                break;

            case MagicType.MagicTopic:
                if (m.Length >= 5)
                {
                    return(TypeConverter.ObjectToInt(m.Substring(2, 3)));
                }
                break;

            case MagicType.TopicTag:
                if (m.Length >= 6)
                {
                    return(TypeConverter.ObjectToInt(m.Substring(5, 1)));
                }
                break;
            }
            return(0);
        }
Пример #3
0
        private SpellData(byte[] data)
        {
            byte b2 = data[2];
            byte b11 = data[11];
            byte b12 = data[12];

            data.Decode();

            data[2] = b2;
            data[11] = b11;
            data[12] = b12;

            this.index = data[0] | data[1] << 8;
            this.magictype = (MagicType)(data[2] | data[3] << 8);
            this.element = (Element)(sbyte)data[4];
            this.validtargets = (ValidTargets)(data[6] | data[7] << 8);
            this.skill = (Skill)(data[8] | data[9] << 8);
            this.mpcost = (data[10] | data[11] << 8);
            this.casttime = data[12];
            this.recast = data[13];
            this.id = data[38] | data[39] << 8;
            this.iconid = data[40];

            this.valid = this.iconid != 0;
            // Check if spell is usable by any job.
            for (int i = 0; i < 24; i++)
            {
                this.valid |= data[14 + i] != 0xFF;
            }
        }
Пример #4
0
 /// <summary>
 /// Calc cost magic
 /// </summary>
 /// <param name="parMagicType">Type of magic</param>
 /// <returns>Cost mana points</returns>
 public override int CostMagic(MagicType parMagicType)
 {
     int ret = base.CostMagic(parMagicType);
     if (ret > 0)
         --ret;
     return ret;
 }
Пример #5
0
        /// <summary>
        /// A method that fires the <see cref="OnMagicalDamageTaken" /> event and potentially the <seealso cref="OnShieldDestroyed"/> event
        /// Taking into acocunt elemental weaknesses. THe base version does not actually use the <paramref name="attackingType"/> to somehow inform the damage taken
        /// </summary>
        /// <param name="damage"></param>
        /// <param name="attackingType"></param>
        /// <returns></returns>
        public virtual int DecrementHealth(int damage, MagicType attackingType)
        {
            if (damage < 0)
            {
                throw new ArgumentException("DecrementHealth cannot be given a negative amount of damage!", nameof(damage));
            }

            int previousHealth = CurrentHealth;

            CurrentHealth -= damage;

            if (CurrentHealth < 0)
            {
                CurrentHealth = 0;
            }

            MagicalDamageTakenEventArgs e = new MagicalDamageTakenEventArgs(damage, attackingType);

            OnMagicalDamageTaken(e);

            if (CurrentHealth == 0)
            {
                OnShieldDestroyed(new ShieldDestroyedEventArgs());
            }

            return(previousHealth - CurrentHealth);
        }
 public MagicBonusAppliedEventArgs(MagicStatType magicStatType, MagicType magicType, int bonusAmount, bool isSecretStatBonus)
 {
     MagicStatType     = magicStatType;
     MagicType         = magicType;
     BonusAmount       = bonusAmount;
     IsSecretStatBonus = isSecretStatBonus;
 }
Пример #7
0
    //准备释放魔法
    public void PrepareMagic(Hero _hero, Magic _magic)
    {
        //判定魔法学派,根据英雄的相应学派等级释放不同效果
        int magicLevel = _magic.GetMagicLevel(_hero);

        MagicType type = _magic.type;

        if (type == MagicType.Battle)
        {
        }

        currentMagic = _magic;

        //隐藏节点
        NodeSelector.HideActionNodes();

        //目标类型:无目标直接释放
        int targetType = Mathf.Min(_magic.targetType.Length - 1, magicLevel);

        //int effect = Mathf.Min(_magic.effects.Length - 1, magicLevel);
        if (_magic.targetType[targetType] == MagicTargetType.Null)
        {
            CastMagic();
        }
        else
        {
            //是需要选择目标的技能
            MagicTargetFliter fliter = _magic.targetFliter[Mathf.Min(_magic.targetFliter.Length - 1, magicLevel)];

            NodeSelector.GetSpellableNodes(fliter);
        }
    }
Пример #8
0
        public void CastSpell_CorrectlyDoesNotReflectsSpells_ReflectStatus_DoesNotMatchAttackingType(
            [Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType,
            [Values(MagicType.Wind, MagicType.Earth, MagicType.Water)] MagicType reflectType)
        {
            const int spellCost  = 5;
            const int spellPower = 5;
            const int expectedRemainingHealth = 100 - spellPower;

            Spell         spell       = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower);
            BattleMove    runawayMove = MoveFactory.Get(BattleMoveType.Runaway);
            ReflectStatus status      = new ReflectStatus(1, reflectType);

            _human.SetHealth(100);
            _human.SetMana(spellCost);
            _human.SetMagicStrength(0);
            _human.SetMagicBonus(spellType, 0);
            _human.SetMagicResistance(0);
            _human.SetResistanceBonus(spellType, 0);
            _human.AddSpell(spell);
            _human.SetMove(spell, 1);
            _human.SetMove(runawayMove);
            _human.SetMoveTarget(_enemy);

            _enemy.AddStatus(status);
            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "human should still have full health, the spell should not have been reflected!");
            Assert.AreEqual(expectedRemainingHealth, _enemy.CurrentHealth, "the enemy should have lost 5 health from being hit by the spell!");
        }
 public ElementalBattleShield(int health, int defense, int magicResistance, MagicType elementalType, int shieldBusterDefense = 0, string displayArticle = null, string displayName = null)
     : base(health, defense, magicResistance, shieldBusterDefense,
            displayArticle ?? (elementalType == MagicType.Ice || elementalType == MagicType.Earth ? "an" : "a"),
            displayName ?? $"{elementalType.ToString().ToLower()} elemental battle shield")
 {
     ElementalType = elementalType;
 }
Пример #10
0
        public MagicRecord(List <byte> fileData, NameTable nameTable) : base(fileData, false)
        {
            this.nameTable   = nameTable;
            ID               = rbc.ReadShort(fileData, Size);
            OwnerID          = rbc.ReadShort(fileData, Size);
            TargetingType    = rbc.GetNullTerminatedString(fileData, Size);
            type             = (MagicType)rbc.ReadByte(fileData, Size);
            ActionIntent     = (ActionIntentType)rbc.ReadByte(fileData, Size);
            Element          = (ElementType)rbc.ReadByte(fileData, Size);
            forAltAttackMode = rbc.ReadByte(fileData, Size);
            SelectionType    = (TargetSelectionType)rbc.ReadByte(fileData, Size);
            MaxRangeRadius   = rbc.ReadFloat(fileData, Size);
            SelectionRadius  = rbc.ReadByte(fileData, Size);
            unusedField2     = rbc.ReadInt(fileData, Size);
            signatureType    = (SignatureType)rbc.ReadLong(fileData, Size);
            ParseFieldEffects(fileData);
            CastTime      = rbc.ReadByte(fileData, Size);
            Delay         = rbc.ReadByte(fileData, Size);
            Cost          = rbc.ReadShort(fileData, Size);
            Unbalance     = rbc.ReadByte(fileData, Size);
            BreakDamage   = (BreakGrade)rbc.ReadShort(fileData, Size);
            LevelUnlocked = rbc.ReadByte(fileData, Size);
            MenuSortOrder = rbc.ReadShort(fileData, Size);
            AnimationName = rbc.GetNullTerminatedString(fileData, Size);
            Name          = rbc.GetNullTerminatedString(fileData, Size);
            string description = rbc.GetNullTerminatedString(fileData, Size);

            Description1stLine = description.Substring(0, Math.Max(description.IndexOf('\n'), 0));
            Description2ndLine = description.Substring(Math.Max(description.IndexOf('\n'), 0));
            Description2ndLine = Description2ndLine.Replace("\n  ", "");
        }
Пример #11
0
        public void CastSpell_CorrectlyReflectsSpells_WithCorrectMultiplier([Values(MagicType.Water, MagicType.Earth, MagicType.Wind)] MagicType spellType,
                                                                            [Values(true, false)] bool reflectAll)
        {
            const int spellCost  = 5;
            const int spellPower = 5;
            const int expectedRemainingHealth = 100 - (spellPower * 2);

            Spell      spell       = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower);
            BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway);

            MagicType     reflectType = reflectAll ? MagicType.All : spellType;
            ReflectStatus status      = new ReflectStatus(1, reflectType, 2);

            _human.SetHealth(100);
            _human.SetMana(spellCost);
            _human.AddSpell(spell);
            _human.SetMove(spell, 1);
            _human.SetMove(runawayMove);
            _human.SetMoveTarget(_enemy);

            _enemy.AddStatus(status);
            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth, "enemy should still have full health, the spell should have been reflected!");
            Assert.AreEqual(expectedRemainingHealth, _human.CurrentHealth, $"the human should have lost {spellPower * 2} health from being hit by their own spell reflected at double the power!");
        }
Пример #12
0
        public static Int32 GetMagicValue(Int32 magic, MagicType magicType)
        {
            if (magic == 0)
            {
                return(0);
            }
            string text = magic.ToString();

            switch (magicType)
            {
            case MagicType.HtmlTitle:
                if (text.Length >= 2)
                {
                    return(text.Substring(1, 1).ToInt());
                }
                break;

            case MagicType.MagicTopic:
                if (text.Length >= 5)
                {
                    return(text.Substring(2, 3).ToInt());
                }
                break;

            case MagicType.TopicTag:
                if (text.Length >= 6)
                {
                    return(text.Substring(5, 1).ToInt());
                }
                break;
            }
            return(0);
        }
Пример #13
0
        public void CastSpell_SpellsVanishIfReflectedTwice([Values(MagicType.Fire, MagicType.Ice, MagicType.Lightning)] MagicType spellType,
                                                           [Values(true, false)] bool reflectAll)
        {
            const int spellCost  = 5;
            const int spellPower = 5;

            Spell      spell       = new Spell("foo", spellType, SpellType.Attack, TargetType.SingleEnemy, spellCost, spellPower);
            BattleMove runawayMove = MoveFactory.Get(BattleMoveType.Runaway);

            MagicType     reflectType = reflectAll ? MagicType.All : spellType;
            ReflectStatus status      = new ReflectStatus(1, reflectType);

            _human.SetHealth(100);
            _human.SetMana(spellCost);
            _human.AddStatus(status);
            _human.AddSpell(spell);
            _human.SetMove(spell, 1);
            _human.SetMove(runawayMove);
            _human.SetMoveTarget(_enemy);

            _enemy.AddStatus(status);
            _enemy.SetHealth(100);

            _battleManager.Battle(_humanTeam, _enemyTeam);

            Assert.AreEqual(_enemy.MaxHealth, _enemy.CurrentHealth, "enemy should still have full health, the spell should have disappeared without hurting anyone!");
            Assert.AreEqual(_human.MaxHealth, _human.CurrentHealth, "the human should still have full health, the spell should have disappeared without hurting anyone");
        }
Пример #14
0
    protected ArmourItemData(SerializationInfo info, StreamingContext context) : base(info, context)
    {
        _armourSlotType = (SlotType)info.GetInt32("slotType");
        _armourType     = (Type)info.GetInt32("armourType");
        _value          = info.GetInt32("value");
        _magicalType    = (MagicType)info.GetInt32("magicType");

        switch (_armourSlotType)
        {
        case SlotType.eHEAD:
            _previewSprite = Resources.Load <Sprite>("Sprites/Items/armour/helmet/" + info.GetString("spriteName"));
            break;

        case SlotType.eCHEST:
            _previewSprite = Resources.Load <Sprite>("Sprites/Items/armour/chest/" + info.GetString("spriteName"));
            break;

        case SlotType.eLEGS:
            _previewSprite = Resources.Load <Sprite>("Sprites/Items/armour/boots/" + info.GetString("spriteName"));
            break;

        default:
            break;
        }
    }
Пример #15
0
        protected override MethodInfo DetermineMethod(Type type)
        {
            var property = MagicType
                           .GetCachedType(type)
                           .ResolveProperty(_propertyName, _eventAdapterService.DefaultPropertyResolutionStyle);

            if (property == null)
            {
                return(null);
            }

            if (property.EventPropertyType == EventPropertyType.SIMPLE)
            {
                if (property.GetMethod.ReturnType.IsGenericStringDictionary())
                {
                    return(property.GetMethod);
                }
            }
            else if (property.EventPropertyType == EventPropertyType.MAPPED)
            {
                return(property.GetMethod);
            }

            return(null);
        }
Пример #16
0
        /// <summary>
        /// Used to add bonuses specific to a fighter (e.g. influenced by a decision during gameplay).
        /// This will increase either one of MagicStrengthBonus's fields or MagicResistanceBonus's fields (if magic type is a simple element),
        /// or the basic MagicStrength/MagicResistance value if magicType "none" or "all" is specified
        /// </summary>
        /// <param name="magicStatType">Determines whther it's magic attack or magic resistance being boosted</param>
        /// <param name="magicType"></param>
        /// <param name="bonus"></param>
        /// <param name="isSecretStatBoost"></param>
        public void AddMagicBonus(MagicStatType magicStatType, MagicType magicType, int bonus, bool isSecretStatBoost = false)
        {
            if (magicType == MagicType.All || magicType == MagicType.None)
            {
                if (magicStatType == MagicStatType.Power)
                {
                    MagicStrength += bonus;
                }
                else
                {
                    MagicResistance += bonus;
                }
            }
            else
            {
                MagicSet <int> bonusesSet = magicStatType == MagicStatType.Power
                    ? MagicStrengthBonuses
                    : MagicResistanceBonuses;

                bonusesSet[magicType] += bonus;
            }

            MagicBonusAppliedEventArgs e = new MagicBonusAppliedEventArgs(magicStatType, magicType, bonus, isSecretStatBoost);

            OnMagicBonusApplied(e);
        }
Пример #17
0
        /// <summary>Загружаем атрибуты магии</summary>
        private void LoadAttributes(XmlNode node)
        {
            Name       = node.SelectSingleNode("Name").InnerText;
            _Animation = new PlayerAnimation(node.SelectSingleNode("MovementAnimation"));
            _Width     = int.Parse(node.SelectSingleNode("width").InnerText);
            _Speed     = int.Parse(node.SelectSingleNode("MovementAnimation/speed").InnerText);
            _Height    = int.Parse(node.SelectSingleNode("height").InnerText);
            double res = Convert.ToDouble(node.SelectSingleNode("Animation").InnerText);

            _Reload   = Convert.ToInt32(node.SelectSingleNode("Reload").InnerText) * 100;
            Animation = (int)((double)res * 100);
            res       = Convert.ToDouble(node.SelectSingleNode("Delay").InnerText);
            Delay     = (int)((double)res * 100);
            Cost      = Convert.ToInt32(node.SelectSingleNode("Cost").InnerText);
            Effect    = Convert.ToInt32(node.SelectSingleNode("Effect").InnerText);
            var type = node.SelectSingleNode("Direction").InnerText;

            Direction      = (DirectionType)Enum.Parse(typeof(DirectionType), type);
            type           = node.SelectSingleNode("Type").InnerText;
            Type           = (MagicType)Enum.Parse(typeof(MagicType), type);
            Radius         = Convert.ToInt32(node.SelectSingleNode("Radius").InnerText);
            EffectRadius   = Convert.ToInt32(node.SelectSingleNode("EffectRadius").InnerText);
            type           = node.SelectSingleNode("PostEffect").InnerText;
            PostEffect     = (PostEffectType)Enum.Parse(typeof(PostEffectType), type);
            PostEffectTime = Convert.ToInt32(node.SelectSingleNode("PostEffectTime").InnerText);
            Targets        = new List <TargetType>();
            var lst = node.SelectNodes("Targets/Target");

            foreach (XmlNode current in lst)
            {
                Targets.Add((TargetType)Enum.Parse(typeof(TargetType), current.InnerText));
            }
        }
Пример #18
0
        public static void MeasureMagic()
        {
            Console.WriteLine("Lambda(Magic)");

            var bidData       = new BidData("IBM", 0L, 0.50);
            var bidDataObject = (Object)bidData;

            var propInfo   = typeof(BidData).GetProperty("BidPrice");
            var methodInfo = propInfo.GetGetMethod();

            var lambda = MagicType.GetLambdaAccessor(methodInfo);

            for (int nn = 0; nn < 10; nn++)
            {
                var timeItem = PerformanceObserver.TimeMicro(
                    delegate
                {
                    for (int ii = 1000000; ii >= 0; ii--)
                    {
                        lambda.Invoke(bidDataObject);
                    }
                });

                Console.WriteLine("Lambda(Magic):  {0,8} {1,8:N3} {2,8:N3}", timeItem, timeItem / 1000000.0m, 1000000.0m / timeItem);
            }
        }
Пример #19
0
        // Get function addresses
        private static Boolean GetFunctionAddreses(ref IntPtr VirtualAllocAddr, ref IntPtr CreateThreadAddr, ref IntPtr WaitForSingleObjectAddr)
        {
            // Get 'Kernel32.dll' image base address
            IntPtr                 Kernel32BaseAddr = FindKernel32();
            IMAGE_DOS_HEADER       ImageDosHeader   = (IMAGE_DOS_HEADER)Marshal.PtrToStructure(Kernel32BaseAddr, typeof(IMAGE_DOS_HEADER));
            MagicType              Architecture     = (MagicType)Marshal.ReadInt32((IntPtr)(Kernel32BaseAddr.ToInt64() + ImageDosHeader.e_lfanew + 4 + 20));
            IMAGE_EXPORT_DIRECTORY ImageExportDirectory;

            switch (Architecture)
            {
            case MagicType.IMAGE_NT_OPTIONAL_HDR32_MAGIC:
                IMAGE_OPTIONAL_HEADER32 PEHeader32 = (IMAGE_OPTIONAL_HEADER32)Marshal.PtrToStructure((IntPtr)(Kernel32BaseAddr.ToInt64() + ImageDosHeader.e_lfanew + 4 + 20), typeof(IMAGE_OPTIONAL_HEADER32));
                ImageExportDirectory = (IMAGE_EXPORT_DIRECTORY)Marshal.PtrToStructure((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)PEHeader32.ExportTable.VirtualAddress), typeof(IMAGE_EXPORT_DIRECTORY));
                break;

            case MagicType.IMAGE_NT_OPTIONAL_HDR64_MAGIC:
                IMAGE_OPTIONAL_HEADER64 PEHeader64 = (IMAGE_OPTIONAL_HEADER64)Marshal.PtrToStructure((IntPtr)(Kernel32BaseAddr.ToInt64() + ImageDosHeader.e_lfanew + 4 + 20), typeof(IMAGE_OPTIONAL_HEADER64));
                ImageExportDirectory = (IMAGE_EXPORT_DIRECTORY)Marshal.PtrToStructure((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)PEHeader64.ExportTable.VirtualAddress), typeof(IMAGE_EXPORT_DIRECTORY));
                break;

            default:
                Console.WriteLine("Failed to identify 'kernel32.dll' architecture");
                return(false);
            }
            ;

            // Setup variables for iterating over export table
            int    CurrentFunctionNameAddr;
            String CurrentFunctionName;

            // Iterate over export table
            for (int i = 0; i < ImageExportDirectory.NumberOfNames; i++)
            {
                // Get current function's address (pointer) and name (pointer)
                CurrentFunctionNameAddr = Marshal.ReadInt32((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)ImageExportDirectory.AddressOfNames + (i * 4)));
                CurrentFunctionName     = Marshal.PtrToStringAnsi((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)CurrentFunctionNameAddr));

                // Check to see if it is the required function
                if (CurrentFunctionName.Equals("VirtualAlloc"))
                {
                    VirtualAllocAddr = (IntPtr)(Kernel32BaseAddr.ToInt64() + Marshal.ReadInt32((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)ImageExportDirectory.AddressOfFunctions + (i * 4))));
                }
                else if (CurrentFunctionName.Equals("CreateThread"))
                {
                    CreateThreadAddr = (IntPtr)(Kernel32BaseAddr.ToInt64() + Marshal.ReadInt32((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)ImageExportDirectory.AddressOfFunctions + (i * 4))));
                }
                else if (CurrentFunctionName.Equals("WaitForSingleObject"))
                {
                    WaitForSingleObjectAddr = (IntPtr)(Kernel32BaseAddr.ToInt64() + Marshal.ReadInt32((IntPtr)(Kernel32BaseAddr.ToInt64() + (int)ImageExportDirectory.AddressOfFunctions + (i * 4))));
                }

                // Return if all functions have been found
                if ((VirtualAllocAddr != IntPtr.Zero) && (CreateThreadAddr != IntPtr.Zero) && (WaitForSingleObjectAddr != IntPtr.Zero))
                {
                    return(true);
                }
            }
            return(false);
        }
Пример #20
0
 public MagicType MagicType()
 {
     if (magicType == null)
     {
         magicType = new MagicType();
     }
     return(magicType);
 }
Пример #21
0
        public void AddResidentMagic(MyHexPosition position, MagicType magic)
        {
            Assert.IsFalse(_residentMagicMap.ContainsKey(position), $"There is arleady magic at ${position}");
            Assert.IsTrue(HasTileAt(position));

            _residentMagicMap[position] = magic;
            GetTileAt(position).ApplyWindMagic();  //todo TL1
        }
Пример #22
0
 public Spell(string description, MagicType elementalType, SpellType spellType, TargetType targetType, int cost, int power)
     : base(description, BattleMoveType.Spell, targetType)
 {
     ElementalType = elementalType;
     SpellType     = spellType;
     Cost          = cost;
     Power         = power;
 }
Пример #23
0
        /// <summary>
        /// Returns a value representing the attack power of a particular fighter wielding a particular magic type
        /// with a base spell power
        /// </summary>
        /// <param name="caster">The <see cref="IFighter"/> casting the magic attack</param>
        /// <param name="magicType">The type of the spell, which may affecting the bonuses available to the caster</param>
        /// <param name="spellPower">The base power of the spell</param>
        /// <returns></returns>
        protected int CalculateMagicalStrength(IFighter caster, MagicType magicType, int spellPower)
        {
            int ret = spellPower + caster.MagicStrength + caster.MagicStrengthBonuses[magicType];

            ret = (int)(ret * CalculateMagicMultiplier(caster, magicType));

            return(ret);
        }
Пример #24
0
        protected int CalculateMagicDamageDealt(IFighter target, MagicType magicType, int magicPower)
        {
            var totalResist = target.MagicResistance + target.MagicResistanceBonuses[magicType];
            //damage done before affinities or resistance taken into account
            var ret = magicPower - totalResist;

            return(ret);
        }
Пример #25
0
 public Feature()
 {
     mark        = new Mark();
     dataView    = new DataView();
     magicType   = new MagicType();
     restore     = new Restore();
     saveAsImage = new SaveAsImage();
 }
 public MagicMultiplierStatus(
     int numberOfTurns,
     MagicType magicType,
     double multiplier)
     : base(numberOfTurns, multiplier)
 {
     MagicType = magicType;
 }
Пример #27
0
        public void CorrectlyExecutesCutscene_SubRegionCompleted()
        {
            const MagicType firstBossEggType  = MagicType.Fire;
            const MagicType secondBossEggType = MagicType.Ice;

            ColorString[] firstSceneLines  = { new ColorString("foo"), new ColorString("bar") };
            SingleScene   firstSingleScene = new SingleScene(firstSceneLines);

            ColorString[] secondSceneLines  = { new ColorString("baz"), new ColorString("fwee") };
            SingleScene   secondSingleScene = new SingleScene(secondSceneLines);

            SingleScene[] scenes          = { firstSingleScene, secondSingleScene };
            Cutscene      regionACutscene = new Cutscene(scenes);

            TeamConfiguration firstBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, firstBossEggType));
            SubRegion         subRegionA             = new SubRegion(WorldSubRegion.Fields, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(firstBossConfiguration), regionCompletedCutscene: regionACutscene);

            TeamConfiguration secondBossConfiguration = new TeamConfiguration(new EnemyConfiguration(FighterType.Egg, 1, secondBossEggType));
            SubRegion         subRegionB = new SubRegion(WorldSubRegion.DesertCrypt, 0, new ChanceEvent <int> [0], new FighterType[0], new BattlefieldConfiguration(secondBossConfiguration));

            SubRegion[] subRegions = { subRegionA, subRegionB };

            Region fakeFieldsRegion = new Region(WorldRegion.Fields, new BattleMove[0], subRegions);

            _regionFactory.SetRegion(WorldRegion.Fields, fakeFieldsRegion);

            AreaMap <Region, WorldRegion> regionMap = new AreaMap <Region, WorldRegion>(fakeFieldsRegion, new MapPath <Region, WorldRegion>(fakeFieldsRegion));

            AreaMap <SubRegion, WorldSubRegion> subRegionMap = new AreaMap <SubRegion, WorldSubRegion>(subRegionA, new MapPath <SubRegion, WorldSubRegion>(subRegionA, subRegionB));

            _mapManager.SetRegionalMap(regionMap);
            _mapManager.SetSubRegionalMap(WorldRegion.Fields, subRegionMap);

            _regionManager = GetRegionManager();

            TestEnemyFighter target = (TestEnemyFighter)TestFighterFactory.GetFighter(TestFighterType.TestEnemy, 1);

            target.SetHealth(1, 0);

            _humanFighter1.SetMove(_basicAttackMove, 1);
            _humanFighter1.SetMove(_runawayMove, 1);
            _humanFighter1.SetMoveTarget(target);

            _humanFighter2.SetMove(_doNothingMove);

            _chanceService.PushAttackHitsNotCrit();

            _regionManager.Battle(_battleManager, _humanTeam);

            List <MockOutputMessage> outputs = _output.GetOutputs().ToList();

            List <ColorString> allCutsceneLines = firstSceneLines.Concat(secondSceneLines).ToList();

            foreach (ColorString cutsceneLine in allCutsceneLines)
            {
                Assert.NotNull(outputs.FirstOrDefault(output => output.Message == cutsceneLine.Value + "\n" && output.Color == cutsceneLine.Color));
            }
        }
Пример #28
0
        public void FighterTakesCorrectDamage_ElementalImmunity([Values(MagicType.Fire, MagicType.Water, MagicType.Ice)] MagicType type)
        {
            _enemy.SetHealth(100);
            _enemy.SetElementalImmunity(type);
            _enemy.MagicalDamage(10, type);

            //will have 90 health left if immunity not taken into account
            Assert.AreEqual(100, _enemy.CurrentHealth);
        }
Пример #29
0
 public void Copy(Magic magic)
 {
     this.nombre     = magic.nombre;
     this.id         = magic.id;
     this.manaCost   = magic.manaCost;
     this.type       = magic.type;
     this.damage     = magic.damage;
     this.spellModel = magic.spellModel;
 }
Пример #30
0
        public void FighterTakesCorrectDamage_ElementalResistance_ToAllMagicTypes([Values(MagicType.Water, MagicType.Wind, MagicType.Lightning)] MagicType type)
        {
            _enemy.SetHealth(100);
            _enemy.SetElementalResistance(MagicType.All);
            _enemy.MagicalDamage(10, type);

            //The current health will be 90 if the resistance has no impact on damage done
            Assert.AreEqual(95, _enemy.CurrentHealth);
        }
Пример #31
0
 //TODO: set up way to have reflect status stay indefinitely
 public ReflectFieldEffect(
     TargetType targetType,
     string moveName,
     MagicType magicType,
     int?effectDuration = null)
     : base(targetType, moveName, effectDuration, false)
 {
     MagicType = magicType;
 }
Пример #32
0
        public void FighterTakesCorrectDamage_ElementalWeakness_ToAllMagicTypes([Values(MagicType.Fire, MagicType.Ice, MagicType.Earth)] MagicType type)
        {
            _enemy.SetHealth(100);
            _enemy.SetElementalWeakness(MagicType.All);
            _enemy.MagicalDamage(10, type);

            //The current health will be 90 if the resistance has no impact on damage done
            Assert.AreEqual(80, _enemy.CurrentHealth);
        }
Пример #33
0
    private static MagicType[] CreateKillTable()
    {
        MagicType[] killTable = new MagicType[4];
        killTable[(int)MagicType.None] = (MagicType)(-1);
        killTable[(int)MagicType.Rock] = MagicType.Scissors;
        killTable[(int)MagicType.Paper] = MagicType.Rock;
        killTable[(int)MagicType.Scissors] = MagicType.Paper;

        return killTable;
    }
Пример #34
0
        public MagicData(string name, MagicType type, MagicCore[] cores, string desc,
            AttackType element, string se, string anime)
        {
            Debug.Assert(AttackTypes.Magic.Contains(element),
                "属性({0})は「火水風土光闇」の中から選んでください。");

            Name = name;
            Type = type;
            Cores = cores;
            Description = desc;
            Element = element;
            SEFileName = se;
            AnimationFileName = anime;
        }
Пример #35
0
 public Magic(MagicType type)
 {
     Type = type;
 }
Пример #36
0
    private void Update()
    {
        if (this.isLocalPlayer)
        {
            this.magic = TestPlayer.MagicType.None;

            if (Input.GetKey(this.rockKey))
            {
                this.magic = MagicType.Rock;
            }
            else if (Input.GetKey(this.paperKey))
            {
                this.magic = MagicType.Paper;
            }
            else if (Input.GetKey(this.scissorsKey))
            {
                this.magic = MagicType.Scissors;
            }

            CmdUpdateMagic(this.magic);
        }
        else
        {
            // Interpolate position
            while (this.synchedPositions.Count > 0 && this.synchedPositions.Peek().t <= this.targetLerpTime)
            {
                this.interpolateFromSynchedPosition = this.synchedPositions.Dequeue();
            }

            if (this.synchedPositions.Count > 0)
            {
                float t = Mathf.InverseLerp(this.interpolateFromSynchedPosition.t, this.synchedPositions.Peek().t, this.targetLerpTime);
                this.transform.position = Vector3.Lerp(this.interpolateFromSynchedPosition.position, this.synchedPositions.Peek().position, t);
            }
            else
            {
                this.transform.position = this.interpolateFromSynchedPosition.position;
            }

            this.targetLerpTime += Time.deltaTime;

            // Magic
            this.magic = this.synchedMagic;
        }

        switch (this.magic)
        {
            case MagicType.None:
                this.material.color = Color.white;
                break;

            case MagicType.Paper:
                this.material.color = this.paperColour;
                break;

            case MagicType.Rock:
                this.material.color = this.rockColour;
                break;

            case MagicType.Scissors:
                this.material.color = this.scissorsColour;
                break;
        }
    }
Пример #37
0
        /// <summary>
        /// Apply magic
        /// </summary>
        /// <param name="parMagicType">Type magic</param>
        /// <param name="X">X on game</param>
        /// <param name="Y">Y on game</param>
        /// <returns></returns>
        public bool ApplyMagic(MagicType parMagicType, int X, int Y)
        {
            switch (parMagicType)
            {
                #region case MagicType.Converter:
                case MagicType.Converter:
                    if (X == -1 && Y == -1)
                        return false;
                    if (X == Constants.COUNT_HERO_SLOTS_FOR_WIZARD)
                        return false;
                    if (map.hero.Magics[X] != MagicType.Empty)
                        map.hero.ConvertMagic(map.hero.Magics[X]);
                    break;
                #endregion
                #region case MagicType.TeleMonster:
                case MagicType.TeleMonster:
                    if (X == -1 && Y == -1)
                        return false;
                    foreach (Monster monster in map.monsterList)
                    {
                        if (monster.Rectangle.Contains(X, Y))
                        {
                            if (!map.ClickHeroMoveToMonster(X / Constants.TEXTURE_SIZE,
                                Y / Constants.TEXTURE_SIZE))
                                return false;

                            map.hero.ApplyMagic(parMagicType);
                            map.map[monster.Rectangle.X / Constants.TEXTURE_SIZE,
                                monster.Rectangle.Y / Constants.TEXTURE_SIZE]
                                = (int) MapItem.None;
                            Random rand = new Random();
                            int Xnew, Ynew;
                            do
                            {
                                Xnew = rand.Next(Constants.MAP_SIZE);
                                Ynew = rand.Next(Constants.MAP_SIZE);
                            } while (map.map[Xnew, Ynew] != (int)MapItem.None);
                            map.map[Xnew, Ynew] = (int)MapItem.Monster;
                            monster.Move(Xnew * Constants.TEXTURE_SIZE, Ynew * Constants.TEXTURE_SIZE);
                            return true;
                        }
                    }
                    break;
                #endregion
                #region case MagicType.Heal:
                case MagicType.Heal:
                    map.hero.ApplyMagic(parMagicType);
                    map.hero.Poisoned = false;
                    map.hero.HealthCurrent += Constants.COUNT_HEAL_HEALTH_POINT * map.hero.Level;
                    return true;
                #endregion
                #region case MagicType.Endwall:
                case MagicType.Endwall:
                    if (X == -1 && Y == -1)
                        return false;
                    if (map.map[X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE] == (int)MapItem.Wall)
                    {
                        if (!map.ClickHeroMoveToMonster(X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE))
                            return false;
                        map.hero.ApplyMagic(parMagicType);
                        map.map[X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE] = (int)MapItem.None;
                    }
                    return true;
                #endregion
                #region case MagicType.Might:
                case MagicType.Might:
                    map.hero.ApplyMagic(parMagicType);
                    map.hero.Might = true;
                    break;
                #endregion
                #region case MagicType.Reveal:
                case MagicType.Reveal:
                    map.hero.ApplyMagic(parMagicType);
                    map.SearchRandom(Constants.COUNT_REVEAL_MAGIC_BLOCKS);
                    break;
                #endregion
                #region case MagicType.Fireball:
                case MagicType.Fireball:
                    if (X == -1 && Y == -1)
                        return false;
                    if (map.map[X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE] != (int)MapItem.Monster)
                        return false;
                    if (!map.ClickHeroMoveToMonster(X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE))
                        return false;

                    for (int i = 0; i < map.monsterList.Count; ++i)
                    {
                        if (map.monsterList[i].Rectangle.Contains(X, Y))
                        {
                            map.hero.ApplyMagic(parMagicType);
                            map.monsterList[i].SetDamage(Constants.DAMAGE_FIREBALL_PER_LEVEL * map.hero.Level, true);
                            if (map.monsterList[i].HealthCurrent <= 0)
                            {
                                if (map.hero.ClassHero == Class.Paladin && map.monsterList[i].Undead)
                                    map.hero.HealthCurrent += map.hero.HealthMax / 2;
                                map.hero.AddExperience(map.monsterList[i].Level, true, 0);
                                map.DeathMonster(map.monsterList[i]);
                                --i;
                            }
                            return true;
                        }
                    }
                    return false;
                #endregion
                #region case MagicType.Petrify:
                case MagicType.Petrify:
                    if (X == -1 && Y == -1)
                        return false;
                    if (map.map[X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE] != (int)MapItem.Monster)
                        return false;
                    Monster monsterPetrify = null;
                    foreach (Monster monster in map.monsterList)
                    {
                        if (monster.Rectangle.Contains(X, Y))
                        {
                            if (monster.Level == Constants.MONSTER_BOSS_LEVEL)
                                return false;
                            monsterPetrify = monster;
                            break;
                        }
                    }
                    if (!map.ClickHeroMoveToMonster(X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE))
                        return false;

                    map.hero.ApplyMagic(parMagicType);
                    map.monsterList.Remove(monsterPetrify);
                    map.map[X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE] = (int)MapItem.Wall;
                    return true;
                #endregion
                #region case MagicType.Poison:
                case MagicType.Poison:
                    if (X == -1 && Y == -1)
                        return false;
                    if (map.map[X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE] != (int)MapItem.Monster)
                        return false;
                    if (!map.ClickHeroMoveToMonster(X / Constants.TEXTURE_SIZE, Y / Constants.TEXTURE_SIZE))
                        return false;

                    foreach (Monster monster in map.monsterList)
                    {
                        if (monster.Rectangle.Contains(X, Y))
                        {
                            map.hero.ApplyMagic(parMagicType);
                            if (!monster.Undead)
                                monster.Poisoned = true;
                            return true;
                        }
                    }
                    break;
                #endregion
                #region case MagicType.FirstStrike:
                case MagicType.FirstStrike:
                    map.hero.ApplyMagic(parMagicType);
                    map.hero.FirstStrike = true;
                    break;
                #endregion
                #region case MagicType.KillProtect:
                case MagicType.KillProtect:
                    map.hero.ApplyMagic(parMagicType);
                    map.hero.KillProtect = true;
                    break;
                #endregion
                #region case MagicType.Summon:
                case MagicType.Summon:
                    map.hero.ApplyMagic(parMagicType);

                    int minDist = int.MaxValue;
                    Monster summonMonster = null;

                    foreach (Monster monster in map.monsterList)
                    {
                        if (monster.Level == map.hero.Level)
                        {
                            int dX = (map.hero.Rectangle.X - monster.Rectangle.X) / Constants.TEXTURE_SIZE;
                            dX *= dX < 0 ? -1 : 1;
                            int dY = (map.hero.Rectangle.Y - monster.Rectangle.Y) / Constants.TEXTURE_SIZE;
                            dY *= dY < 0 ? -1 : 1;

                            int tempDist = (dX * dX + dY * dY);
                            if (minDist > tempDist)
                            {
                                minDist = tempDist;
                                summonMonster = monster;
                            }
                        }
                    }

                    if (summonMonster == null)
                        return true;

                    // int = (X * 100) + Y
                    List<int> position = new List<int>();
                    int X0 = map.hero.Rectangle.X / Constants.TEXTURE_SIZE;
                    int Y0 = map.hero.Rectangle.Y / Constants.TEXTURE_SIZE;

                    if (X0 > 0)
                    {
                        if (Y0 > 0)
                            if (map.map[X0 - 1, Y0 - 1] == (int)MapItem.None)
                                position.Add((X0 - 1) * 100 + Y0 - 1);
                        if (map.map[X0 - 1, Y0] == (int)MapItem.None)
                            position.Add((X0 - 1) * 100 + Y0);
                        if (Y0 < Constants.MAP_SIZE - 1)
                            if (map.map[X0 - 1, Y0 + 1] == (int)MapItem.None)
                                position.Add((X0 - 1) * 100 + Y0 + 1);
                    }

                    if (Y0 > 0)
                        if (map.map[X0, Y0 - 1] == (int)MapItem.None)
                            position.Add(X0 * 100 + Y0 - 1);
                    if (map.map[X0, Y0] == (int)MapItem.None)
                        position.Add(X0 * 100 + Y0);
                    if (Y0 < Constants.MAP_SIZE - 1)
                        if (map.map[X0, Y0 + 1] == (int)MapItem.None)
                            position.Add(X0 * 100 + Y0 + 1);

                    if (X0 < Constants.MAP_SIZE - 1)
                    {
                        if (Y0 > 0)
                            if (map.map[X0 + 1, Y0 - 1] == (int)MapItem.None)
                                position.Add((X0 + 1) * 100 + Y0 - 1);
                        if (map.map[X0 + 1, Y0] == (int)MapItem.None)
                            position.Add((X0 + 1) * 100 + Y0);
                        if (Y0 < Constants.MAP_SIZE - 1)
                            if (map.map[X0 + 1, Y0 + 1] == (int)MapItem.None)
                                position.Add((X0 + 1) * 100 + Y0 + 1);
                    }

                    if (position.Count == 0)
                        return true;

                    Random randSummon = new Random();
                    int indexRand = randSummon.Next(position.Count);

                    int aroundX = position[indexRand] / 100;
                    int aroundY = position[indexRand] % 100;

                    map.map[summonMonster.Rectangle.X / Constants.TEXTURE_SIZE,
                        summonMonster.Rectangle.Y / Constants.TEXTURE_SIZE] = (int)MapItem.None;
                    summonMonster.Move(aroundX * Constants.TEXTURE_SIZE, aroundY * Constants.TEXTURE_SIZE);
                    map.map[aroundX, aroundY] = (int)MapItem.Monster;

                    return true;
                #endregion
                #region case MagicType.Blood:
                case MagicType.Blood:
                    map.hero.ApplyMagic(parMagicType);
                    map.hero.Blood = true;
                    break;
                #endregion
                #region case MagicType.TeleSelf:
                case MagicType.TeleSelf:
                    map.hero.ApplyMagic(parMagicType);

                    Random randTele = new Random();
                    int XTele, YTele;
                    do
                    {
                        XTele = randTele.Next(Constants.MAP_SIZE);
                        YTele = randTele.Next(Constants.MAP_SIZE);
                    } while (map.map[XTele, YTele] != (int)MapItem.None);

                    map.HeroReplace(XTele, YTele);
                    return true;
                #endregion
            }
            return true;
        }
Пример #38
0
 protected override object this[string index]
 {
     get
     {
         #region
         switch (index)
         {
             case "UserID": return UserID;
             case "MagicID": return MagicID;
             case "MagicType": return MagicType;
             case "MagicLv": return MagicLv;
             case "IsEnabled": return IsEnabled;
             default: throw new ArgumentException(string.Format("UserMagic index[{0}] isn't exist.", index));
         }
         #endregion
     }
     set
     {
         #region
         switch (index)
         {
             case "UserID":
                 _UserID = value.ToNotNullString();
                 break;
             case "MagicID":
                 _MagicID = value.ToInt();
                 break;
             case "MagicType":
                 _MagicType = value.ToEnum<MagicType>();
                 break;
             case "MagicLv":
                 _MagicLv = value.ToShort();
                 break;
             case "IsEnabled":
                 _IsEnabled = value.ToBool();
                 break;
             default: throw new ArgumentException(string.Format("UserMagic index[{0}] isn't exist.", index));
         }
         #endregion
     }
 }
Пример #39
0
 GameObject CreateObject(MagicType type)
 {
     return CreateObject (type, lastSize);
 }
Пример #40
0
    GameObject CreateObject(MagicType type, Size size)
    {
        Vector3 vector = mainHand.PalmPosition.ToUnityScaled ();
        Quaternion rotation = Camera.main.transform.rotation;

        //if same obj in last frame, then just move it
        if (objInLastFrame != null && type == lastCall && size == lastSize) {
            objInLastFrame.transform.position = transform.TransformPoint (mainHand.PalmPosition.ToUnityScaled ());
            objInLastFrame.transform.rotation = transform.rotation;

            return objInLastFrame;
            } else {
            string magicType = null;

            //should happen when it's switching sizes of fireball or shooting fireball
            if (lastCall == MagicType.FireCharge) {
                ClearFirecharges();
            }

                    switch (type) {
                case MagicType.FireCharge:
                    switch (size) {
                      case Size.Small:
                          magicType = MagicConstant.FIRECHARGE_SMALL_NAME;
                          break;
                      case Size.Medium:
                          magicType = MagicConstant.FIRECHARGE_MEDIUM_NAME;
                          break;
                      case Size.Large:
                          magicType = MagicConstant.FIRECHARGE_LARGE_NAME;
                          break;
                    }
                    vector = transform.TransformPoint(vector);
                    break;
                case MagicType.Fireball:
                    // TODO: Need to get the fireball to be shot where the user is facing
                    magicType = MagicConstant.FIREBALL_RELEASE_NAME;
                    vector = vector + (Vector3.up * 0.3f);
                    vector = transform.TransformPoint(vector);
                    break;
                case MagicType.IceWall:
                    magicType = MagicConstant.ICEWALL_NAME;
                    vector = vector + (Vector3.up * 0.4f);
                    vector = transform.TransformPoint(vector);
                    vector.y = 0f;
                    Instantiate(Resources.Load (MagicConstant.ICEWALL_SUMMON), vector, rotation);
                    break;
                default:
                    break;
                        }

            objInCurrFrame = (GameObject)Instantiate(Resources.Load (magicType), vector, rotation);

            switch (type) {
                case MagicType.Fireball:
                    objInCurrFrame.name = lastSize.ToString();
                    Destroy(objInCurrFrame, 5);
                    break;
                case MagicType.IceWall:
                    Vector3 rotate = new Vector3(-90, 0, 0);
                    objInCurrFrame.transform.Rotate(rotate);
                    break;
                default:
                    break;
            }

            lastCall = type;
            lastSize = size;

            return objInCurrFrame;
        }
    }
Пример #41
0
        /// <summary>
        /// Convert magic to race bonus
        /// </summary>
        /// <param name="parMagicType">Type of magic</param>
        public void ConvertMagic(MagicType parMagicType)
        {
            for (int i = 0; i < 5; ++i)
            {
                if (i == 5)
                    return;
                if (Magics[i] == parMagicType)
                {
                    Magics[i] = MagicType.Empty;
                    break;
                }
            }

            switch (RaceHero)
            {
                case Race.Human:
                    DamageBonus += 10;
                    break;
                case Race.Elf:
                    SetBonus(TileType.MPBoost);
                    SetBonus(TileType.MPBoost);
                    break;
                case Race.Dwarf:
                    SetBonus(TileType.HPBoost);
                    break;
                case Race.Halfling:
                    ++HealthPotion;
                    break;
                case Race.Gnome:
                    ++ManaPotion;
                    break;
                case Race.Goblin:
                    AddExperience(0, false, 5);
                    break;
                case Race.Orc:
                    DamageBase += 2;
                    break;
            }
        }
Пример #42
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="X">X on map</param>
 /// <param name="Y">Y on map</param>
 /// <param name="parTexture">Texture</param>
 /// <param name="parMagicType">Type of magic</param>
 public MagicTile(int X, int Y, Texture2D parTexture, MagicType parMagicType)
     : base(X, Y, parTexture)
 {
     Magic = parMagicType;
 }
Пример #43
0
        /// <summary>
        /// 获得相应的magic值
        /// </summary>
        /// <param name="magic">数据库中magic值</param>
        /// <param name="magicType">magic类型</param>
        /// <returns></returns>
        public static int GetMagicValue(int magic, MagicType magicType)
        {
            if (magic == 0)
                return 0;

            string m = magic.ToString();
            switch (magicType)
            {
                case MagicType.HtmlTitle:
                    if (m.Length >= 2)
                        return TypeConverter.ObjectToInt(m.Substring(1, 1));
                    break;
                case MagicType.MagicTopic:
                    if (m.Length >= 5)
                        return TypeConverter.ObjectToInt(m.Substring(2, 3));
                    break;
                case MagicType.TopicTag:
                    if (m.Length >= 6)
                        return TypeConverter.ObjectToInt(m.Substring(5, 1));
                    break;
            }
            return 0;

        }
Пример #44
0
 /// <summary>
 /// 设置相应的magic值
 /// </summary>
 /// <param name="magic">原始magic值</param>
 /// <param name="magicType"></param>
 /// <param name="bonusstat"></param>
 /// <returns></returns>
 public static int SetMagicValue(int magic, MagicType magicType, int newmagicvalue)
 {
     string[] m = Utils.SplitString(magic.ToString(), "");
     switch (magicType)
     {
         case MagicType.HtmlTitle:
             if (m.Length >= 2)
             {
                 m[1] = newmagicvalue.ToString().Substring(0, 1);
                 return TypeConverter.StrToInt(string.Join("", m), magic);
             }
             else
             {
                 return TypeConverter.StrToInt(string.Format("1{0}", newmagicvalue.ToString().Substring(0, 1)), magic);
             }
         case MagicType.MagicTopic:
             if (m.Length >= 5)
             {
                 string[] t = Utils.SplitString(newmagicvalue.ToString().PadLeft(3, '0'), "");
                 m[2] = t[0];
                 m[3] = t[1];
                 m[4] = t[2];
                 return TypeConverter.StrToInt(string.Join("", m), magic);
             }
             else
             {
                 return TypeConverter.StrToInt(string.Format("1{0}{1}", GetMagicValue(magic, MagicType.HtmlTitle), newmagicvalue.ToString().PadLeft(3, '0').Substring(0, 3)), magic);
             }
         case MagicType.TopicTag:
             if (m.Length >= 6)
             {
                 m[5] = newmagicvalue.ToString().Substring(0, 1);
                 return TypeConverter.StrToInt(string.Join("", m), magic);
             }
             else
             {
                 return TypeConverter.StrToInt(string.Format("1{0}{1}{2}", GetMagicValue(magic, MagicType.HtmlTitle), GetMagicValue(magic, MagicType.MagicTopic).ToString("000"), newmagicvalue.ToString().Substring(0, 1)), magic);
             }
     }
     return magic;
 }
Пример #45
0
        /// <summary>Загружаем атрибуты магии</summary>
        private void LoadAttributes(XmlNode node)
        {
            Name = node.SelectSingleNode("Name").InnerText;
              _Animation = new PlayerAnimation(node.SelectSingleNode("MovementAnimation"));
              _Width = int.Parse(node.SelectSingleNode("width").InnerText);
              _Speed = int.Parse(node.SelectSingleNode("MovementAnimation/speed").InnerText);
              _Height = int.Parse(node.SelectSingleNode("height").InnerText);
              double res = Convert.ToDouble(node.SelectSingleNode("Animation").InnerText);
              _Reload = Convert.ToInt32(node.SelectSingleNode("Reload").InnerText) * 100;
              Animation = (int)((double)res * 100);
              res = Convert.ToDouble(node.SelectSingleNode("Delay").InnerText);
              Delay = (int)((double)res * 100);
              Cost = Convert.ToInt32(node.SelectSingleNode("Cost").InnerText);
              Effect = Convert.ToInt32(node.SelectSingleNode("Effect").InnerText);
              var type = node.SelectSingleNode("Direction").InnerText;
              Direction = (DirectionType)Enum.Parse(typeof(DirectionType), type);
              type = node.SelectSingleNode("Type").InnerText;
              Type = (MagicType)Enum.Parse(typeof(MagicType), type);
              Radius = Convert.ToInt32(node.SelectSingleNode("Radius").InnerText);
              EffectRadius = Convert.ToInt32(node.SelectSingleNode("EffectRadius").InnerText);
              type = node.SelectSingleNode("PostEffect").InnerText;
              PostEffect = (PostEffectType)Enum.Parse(typeof(PostEffectType), type);
              PostEffectTime = Convert.ToInt32(node.SelectSingleNode("PostEffectTime").InnerText);
              Targets = new List<TargetType>();
              var lst = node.SelectNodes("Targets/Target");

              foreach (XmlNode current in lst)
            Targets.Add((TargetType)Enum.Parse(typeof(TargetType), current.InnerText));
        }
Пример #46
0
 /// <summary>
 /// Apply magic
 /// </summary>
 /// <param name="parMagicType">Type of magic</param>
 public virtual void ApplyMagic(MagicType parMagicType)
 {
     ManaCurrent -= CostMagic(parMagicType);
 }
Пример #47
0
 private void CmdUpdateMagic(MagicType magic)
 {
     this.synchedMagic = magic;
 }
Пример #48
0
        protected override object this[string index]
		{
			get
			{
                #region
				switch (index)
				{
                    case "MagicID": return MagicID;
                    case "MagicName": return MagicName;
                    case "MagicType": return MagicType;
                    case "HeadID": return HeadID;
                    case "MagicLv": return MagicLv;
                    case "MagicDesc": return MagicDesc;
                    case "DemandLv": return DemandLv;
                    case "Version": return Version;
					default: throw new ArgumentException(string.Format("MagicInfo index[{0}] isn't exist.", index));
				}
                #endregion
			}
			set
			{
                #region
				switch (index)
				{
                    case "MagicID": 
                        _MagicID = value.ToInt(); 
                        break; 
                    case "MagicName": 
                        _MagicName = value.ToNotNullString(); 
                        break; 
                    case "MagicType":
                        _MagicType = value.ToEnum<MagicType>(); 
                        break; 
                    case "HeadID": 
                        _HeadID = value.ToNotNullString(); 
                        break; 
                    case "MagicLv": 
                        _MagicLv = value.ToShort(); 
                        break; 
                    case "MagicDesc": 
                        _MagicDesc = value.ToNotNullString(); 
                        break; 
                    case "DemandLv": 
                        _DemandLv = value.ToShort(); 
                        break; 
                    case "Version": 
                        _Version = value.ToInt(); 
                        break; 
					default: throw new ArgumentException(string.Format("MagicInfo index[{0}] isn't exist.", index));
				}
                #endregion
			}
		}
Пример #49
0
 /// <summary>
 /// Calc cost magic
 /// </summary>
 /// <param name="parMagicType">Type of magic</param>
 /// <returns>Cost mana points</returns>
 public virtual int CostMagic(MagicType parMagicType)
 {
     switch (parMagicType)
     {
         case MagicType.TeleMonster:
             return 10;
         case MagicType.Heal:
             return 3;
         case MagicType.Endwall:
             return 8;
         case MagicType.Might:
             return 2;
         case MagicType.Reveal:
             return 3;
         case MagicType.Fireball:
             return 6;
         case MagicType.Petrify:
             return 5;
         case MagicType.Poison:
             return 5;
         case MagicType.FirstStrike:
             return 3;
         case MagicType.KillProtect:
             return 10;
         case MagicType.Summon:
             return 6;
         case MagicType.Blood:
             return 0;
         case MagicType.TeleSelf:
             return 6;
     }
     return 0;
 }
Пример #50
0
 /// <summary>
 /// Calc cost magic
 /// </summary>
 /// <param name="parMagicType">Type of magic</param>
 /// <returns>Cost mana points</returns>
 public override int CostMagic(MagicType parMagicType)
 {
     if (parMagicType == MagicType.Endwall)
         return 1;
     return base.CostMagic(parMagicType);
 }
Пример #51
0
 /// <summary>
 /// Apply magic
 /// </summary>
 /// <param name="parMagicType">Type of magic</param>
 public override void ApplyMagic(MagicType parMagicType)
 {
     base.ApplyMagic(parMagicType);
     HealthCurrent += CostMagic(parMagicType) * 2;
 }