Пример #1
0
 private void SetArmor(PlayerEntity player, int id)
 {
     if (armorDic.ContainsKey(id))
     {
         ArmorData data = armorDic[id];
         if (data.type == 1)
         {
             player.gamePlay.ArmorLv  = id;
             player.gamePlay.MaxArmor = data.max;
             player.gamePlay.CurArmor = data.max;
         }
         if (data.type == 2)
         {
             player.gamePlay.HelmetLv  = id;
             player.gamePlay.MaxHelmet = data.max;
             player.gamePlay.CurHelmet = data.max;
         }
     }
 }
Пример #2
0
        private void ReduceDamage(IEventArgs args, PlayerEntity player)
        {
            SimpleParable sp = (SimpleParable)args.GetUnit("damage");

            if (sp != null)
            {
                PlayerDamageInfo damage = (PlayerDamageInfo)sp.GetFieldObject(0);
                float            da     = damage.damage;
                if (damage.part == (int)EBodyPart.Head)
                {
                    int helId = player.gamePlay.HelmetLv;
                    if (armorDic.ContainsKey(helId))
                    {
                        ArmorData ad = armorDic[helId];

                        da = ReduceDamage(args, player, damage, ad.reduce, false);
                    }
                }
                else if (damage.part == (int)EBodyPart.Chest || damage.part == (int)EBodyPart.Stomach || damage.part == (int)EBodyPart.Pelvis)
                {
                    int armor = player.gamePlay.ArmorLv;
                    if (armorDic.ContainsKey(armor))
                    {
                        ArmorData ad = armorDic[armor];

                        da = ReduceDamage(args, player, damage, ad.reduce, true);
                    }
                }

                FloatPara d = (FloatPara)args.GetDefault().GetParameters().Get("damage");
                if (d != null)
                {
                    d.SetValue(da);
                }
            }
        }