Пример #1
0
    public void OnArmorInsert(ArmorSlot slot, Item item)
    {
        ((Armor)item).m_Limb = slot.m_Limb;
        item.ItemsManagerUnregister();
        item.transform.SetParent(slot.transform);
        Physics.IgnoreCollision(this.m_Player.m_Collider, item.GetComponent <Collider>());
        Renderer[] componentsDeepChild = General.GetComponentsDeepChild <Renderer>(item.gameObject);
        for (int i = 0; i < componentsDeepChild.Length; i++)
        {
            componentsDeepChild[i].enabled = false;
        }
        ArmorInfo armorInfo = (ArmorInfo)item.m_Info;
        ArmorData armorData = this.m_LimbMap[(int)slot.m_Limb];

        armorData.m_MeshMap[(int)armorInfo.m_ArmorType].SetActive(true);
        armorData.m_Mesh          = armorData.m_MeshMap[(int)armorInfo.m_ArmorType];
        armorData.m_AttachedArmor = item;
        armorData.m_AttachedArmorOrigCollCenter        = armorData.m_AttachedArmor.m_BoxCollider.center;
        armorData.m_AttachedArmorOrigCollSize          = armorData.m_AttachedArmor.m_BoxCollider.size;
        armorData.m_AttachedArmor.m_BoxCollider.center = armorData.m_AttachedArmorCollCenter;
        armorData.m_AttachedArmor.m_BoxCollider.size   = armorData.m_AttachedArmorCollSize;
        armorData.m_ArmorType  = armorInfo.m_ArmorType;
        armorData.m_Absorption = armorInfo.m_Absorption;
        armorData.m_Health     = armorInfo.m_Health;
        HUDBodyInspection.Get().m_ArmorEnabled = true;
        this.SetMeshesVisible(HUDBodyInspection.Get().m_ArmorEnabled);
        BodyInspectionController.Get().OnArmorAttached(slot.m_Limb);
    }
Пример #2
0
    public void UnequipArmor()
    {
        equippedArmor = new ArmorInfo();
        isUsingArmor  = false;

        armorUIParent.SetActive(false);
    }
Пример #3
0
 public bool Equals(ArmorInfo other)
 {
     if (other == null)
     {
         return(false);
     }
     return(this.ID.Equals(other.ID));
 }
Пример #4
0
 public static ArmorInfoViewModel ToViewModel(this ArmorInfo ai)
 {
     return(new ArmorInfoViewModel
     {
         ArmorInfoId = ai.Id,
         Armor = ai.Armor.ToViewModel(),
         FeaturesApplied = ai.FeaturesApplied.Select(fi => fi.ToViewModel()).ToList(),
         Notes = ai.Notes
     });
 }
Пример #5
0
        public static ArmorInfo FindArmorInfoFromId(int id)
        {
            ArmorInfo data = null;

            data = armorInfoList.Find(x => x.Id == id);
            if (data == null)
            {
                Debugger.Log("Error : Not Found In ArmorInfo. ID :" + id);
            }
            return(data);
        }
Пример #6
0
    public void OnDragItemToSlot(ArmorSlot slot, Item item)
    {
        ArmorData armorData = this.m_LimbMap[(int)slot.m_Limb];
        ArmorInfo armorInfo = (ArmorInfo)item.m_Info;

        armorData.m_MeshMap[(int)armorInfo.m_ArmorType].SetActive(true);
        Renderer[] componentsDeepChild = General.GetComponentsDeepChild <Renderer>(item.gameObject);
        for (int i = 0; i < componentsDeepChild.Length; i++)
        {
            componentsDeepChild[i].enabled = false;
        }
        BodyInspectionController.Get().OnArmorAttached(slot.m_Limb);
    }
Пример #7
0
    public override bool Equals(System.Object obj)
    {
        if (obj == null)
        {
            return(false);
        }
        ArmorInfo c = obj as ArmorInfo;

        if ((System.Object)c == null)
        {
            return(false);
        }
        return(ID == c.ID);
    }
Пример #8
0
    public void EquipArmor(ArmorInfo armorInfo)
    {
        equippedArmor = armorInfo;
        isUsingArmor  = true;

        maxArmorHealth = armorInfo.armorHealth;

        armorUIParent.SetActive(true);

        targetArmorFillAmount = 1f;
        armorBarImage.color   = Global.DamageTypeToColor(armorInfo.armorType);

        armorText.text = $"{armorInfo.armorHealth}/{maxArmorHealth}";
    }
Пример #9
0
    void ArmorMaker()
    {
        ArmorList = new  List <ArmorInfo>();
        Armorset  = new ArmorInfo();



//		Armorset.Damagereduc = 1;
//
//        Armorset.MatType = MatType.Find(x=>x.Name== "Wuud");
//		Armorset.Weight = 5;
//		Armorset.Name = "Wuuden Armor";
//		Armorset.Quality = "";
//		ArmorList.Add (Armorset);
    }
 public void EquipArmor(ArmorInfo NewArmor, string location)
 {
     if (location == "Chestpiece")
     {
         if (ChestArmor != null)
         {
             CurrentWeight = (CurrentWeight - ChestArmor.Weight) + NewArmor.Weight;
         }
         ChestArmor = NewArmor;
     }
     else if (location == "Shield")
     {
         if (ShieldArmor != null)
         {
             CurrentWeight = (CurrentWeight - ShieldArmor.Weight) + NewArmor.Weight;
         }
         ShieldArmor = NewArmor;
     }
     else if (location == "Helmet")
     {
         if (HeadArmor != null)
         {
             CurrentWeight = (CurrentWeight - HeadArmor.Weight) + NewArmor.Weight;
         }
         HeadArmor = NewArmor;
     }
     else if (location == "Legging")
     {
         if (LegArmor != null)
         {
             CurrentWeight = (CurrentWeight - LegArmor.Weight) + NewArmor.Weight;
         }
         LegArmor = NewArmor;
     }
     else if (location == "Boots")
     {
         if (FeetArmor != null)
         {
             CurrentWeight = (CurrentWeight - FeetArmor.Weight) + NewArmor.Weight;
         }
         FeetArmor = NewArmor;
     }
 }
Пример #11
0
    private void OnArmorDestroyed(ArmorData armor_data)
    {
        if (armor_data.m_AttachedArmor != null)
        {
            UnityEngine.Object.Destroy(armor_data.m_AttachedArmor.gameObject);
        }
        Item item = ItemsManager.Get().CreateItem(ItemID.broken_armor, false, armor_data.m_Slot.transform);

        item.transform.SetParent(armor_data.m_Slot.transform);
        Physics.IgnoreCollision(this.m_Player.m_Collider, item.GetComponent <Collider>());
        Renderer[] componentsDeepChild = General.GetComponentsDeepChild <Renderer>(item.gameObject);
        for (int i = 0; i < componentsDeepChild.Length; i++)
        {
            componentsDeepChild[i].enabled = false;
        }
        armor_data.m_Slot.m_Item = item;
        if (armor_data.m_Mesh)
        {
            armor_data.m_Mesh.SetActive(false);
        }
        if (armor_data.m_DestroyedMesh)
        {
            armor_data.m_DestroyedMesh.SetActive(true);
            if (armor_data.m_Cloth)
            {
                armor_data.m_Cloth.enabled = false;
                armor_data.m_Cloth.enabled = true;
            }
        }
        armor_data.m_Mesh          = armor_data.m_DestroyedMesh;
        armor_data.m_AttachedArmor = item;
        armor_data.m_AttachedArmorOrigCollCenter        = armor_data.m_AttachedArmor.m_BoxCollider.center;
        armor_data.m_AttachedArmorOrigCollSize          = armor_data.m_AttachedArmor.m_BoxCollider.size;
        armor_data.m_AttachedArmor.m_BoxCollider.center = armor_data.m_AttachedArmorCollCenter;
        armor_data.m_AttachedArmor.m_BoxCollider.size   = armor_data.m_AttachedArmorCollSize;
        armor_data.m_Destroyed = true;
        ((Armor)item).m_Limb   = armor_data.m_Slot.m_Limb;
        ArmorInfo armorInfo = (ArmorInfo)item.m_Info;

        armor_data.m_ArmorType       = armorInfo.m_ArmorType;
        item.transform.localPosition = Vector3.zero;
    }
Пример #12
0
    public static ArmorInfo CopyMe(ArmorInfo copy)
    {
        ArmorInfo temp = new ArmorInfo();

        temp.Beauty           = copy.Beauty;
        temp.Damagereduc      = copy.Damagereduc;
        temp.CurrentDurablity = copy.CurrentDurablity;
        temp.Enchants         = copy.Enchants;
        temp.BasePrice        = copy.BasePrice;
        temp.SellPrice        = copy.SellPrice;
        temp.MaxDurablity     = copy.MaxDurablity;
        temp.MyBaseinfo       = WeapArmorBaseInfo.Copyme(copy.MyBaseinfo);
        temp.Name             = copy.Name;
        temp.Quality          = copy.Quality;
        temp.Weight           = copy.Weight;
        temp.QualityNum       = copy.QualityNum;
        temp.Size             = copy.Size;
        temp.Location         = copy.Location;
        temp.ID = copy.ID;
        return(temp);
    }
Пример #13
0
        public override BaseItemInfo LoadItem(Module module, string id, ObjectData data)
        {
            var dataObj = data.Data;
            var type    = dataObj.OptionalString("Type");

            BaseItemInfo result;

            if (type == "Food")
            {
                var food = new FoodInfo
                {
                };

                result = food;
            }
            else if (type == "WaterContainer")
            {
                var waterContainer = new WaterContainerInfo
                {
                    Capacity = dataObj.EnsureInt("Capacity")
                };

                result = waterContainer;
            }
            else if (type == "Weapon")
            {
                var weapon = new WeaponInfo
                {
                    MinDamage  = dataObj.EnsureInt("MinDamage"),
                    MaxDamage  = dataObj.EnsureInt("MaxDamage"),
                    AttackType = dataObj.EnsureEnum <AttackType>("AttackType")
                };

                result = weapon;
            }
            else if (type == "Armor")
            {
                var armor = new ArmorInfo
                {
                    ArmorClass = dataObj.EnsureInt("ArmorClass"),
                    SubType    = dataObj.EnsureEnum <EquipType>("SubType")
                };

                result = armor;
            }
            else
            {
                // Misc
                result = new BaseItemInfo();
            }

            module.EnsureBaseMapObject(dataObj, result, "Item" + id);
            result.Name  = dataObj.EnsureString(Compiler.NameName);
            result.Price = dataObj.EnsureInt("Price");

            var tanningObj = dataObj.OptionalJObject("Tanning");

            if (tanningObj != null)
            {
                result.Tanning = new Inventory();
                foreach (var pair in tanningObj)
                {
                    var componentInfo = module.ItemInfos.Ensure(pair.Key);
                    var quantity      = pair.Value.ToInt();

                    result.Tanning.Add(new Item(componentInfo), quantity);
                }
            }

            var craftingObj = dataObj.OptionalJObject("Crafting");

            if (craftingObj != null)
            {
                result.Crafting = new Inventory();
                foreach (var pair in craftingObj)
                {
                    var componentInfo = module.ItemInfos.Ensure(pair.Key);
                    var quantity      = pair.Value.ToInt();

                    result.Crafting.Add(new Item(componentInfo), quantity);
                }
            }

            string typeName;

            if (data.Properties != null && data.Properties.TryGetValue("Type", out typeName))
            {
                result.Type = typeName.ToEnum <ItemType>();
            }

            return(result);
        }
Пример #14
0
        public async Task <int> SaveCreature([FromBody] CreatureEditInput input)
        {
            if (input.IsPlayerCharacter && input.CreatureId == 0)
            {
                if (await dbContext.Creatures.CountAsync(c => !c.Delisted && c.IsPlayerCharacter && c.Author.Id == userSession.Player.Id) >= 6)
                {
                    return(0); //they were warned client-side that the beta only allows six player characters
                }
            }

            Creature creature = null;

            if (input.CreatureId > 0)
            {
                creature = await this.CreatureQuery.Where(c => c.Author.Id == this.userSession.Player.Id)
                           .SingleOrDefaultAsync(c => c.Id == input.CreatureId);
            }
            else
            {
                creature                        = new Creature();
                creature.CreatedAtMS            = System.DateTimeOffset.UtcNow.ToUnixTimeMilliseconds();
                dbContext.Entry(creature).State = EntityState.Added;
                dbContext.Attach(this.userSession.Player);
                creature.Author = this.userSession.Player;
            }

            if (!string.IsNullOrWhiteSpace(input.DescriptionChangedTo))
            {
                creature.Description = input.DescriptionChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.HairChangedTo))
            {
                creature.Hair = input.HairChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.AgeChangedTo))
            {
                creature.Age = input.AgeChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.WeightChangedTo))
            {
                creature.Weight = input.WeightChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.HeightChangedTo))
            {
                creature.Height = input.HeightChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.SkinChangedTo))
            {
                creature.Skin = input.SkinChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.EyesChangedTo))
            {
                creature.Eyes = input.EyesChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.NameChangedTo))
            {
                creature.Name = input.NameChangedTo;
            }
            if (!string.IsNullOrWhiteSpace(input.GenderChangedTo))
            {
                creature.Gender = input.GenderChangedTo;
            }

            if (input.RaceIdChangedTo > 0)
            {
                creature.Race = await dbContext.Races.SingleOrDefaultAsync(r => r.Id == input.RaceIdChangedTo);
            }
            else if (input.RaceIdChangedTo < 0) //-1 means remove Race
            {
                creature.Race = null;
            }

            creature.CurrentEnergyLedger = input.CurrentEnergyLedgerIs;
            creature.Level             = input.LevelIs;
            creature.IsPlayerCharacter = input.IsPlayerCharacter;

            foreach (var oathInfoVM in input.NewOathInformation)
            {
                OathInfo oathInfo = new OathInfo
                {
                    Broken = oathInfoVM.Broken,
                    OathId = oathInfoVM.Oath.OathId,
                    Notes  = oathInfoVM.Notes
                };
                creature.OathInformation.Add(oathInfo);
            }

            foreach (var featureInfoVM in input.NewFeatureInformation)
            {
                FeatureInfo featureInfo = new FeatureInfo
                {
                    FeatureId                 = featureInfoVM.Feature.FeatureId,
                    CostWhenTaken             = featureInfoVM.CostWhenTaken,
                    EnergySacrificedWhenTaken = featureInfoVM.EnergySacrificedWhenTaken,
                    TakenAtLevel              = featureInfoVM.TakenAtLevel,
                    Notes = featureInfoVM.Notes
                };
                if (featureInfoVM.FeatureInfoId > 0)
                {
                    var existingFeatureInfo = creature.FeatureInformation.FirstOrDefault(fi => fi.Id == featureInfoVM.FeatureInfoId);
                    if (existingFeatureInfo != null)
                    {
                        dbContext.Entry(existingFeatureInfo).State = EntityState.Detached;
                        featureInfo.Id = featureInfoVM.FeatureInfoId;
                        dbContext.Attach(featureInfo);
                        dbContext.Entry(featureInfo).State = EntityState.Modified;
                    }
                }
                else
                {
                    creature.FeatureInformation.Add(featureInfo);
                }
            }

            foreach (var itemInfoVM in input.NewItemInformation)
            {
                ItemInfo itemInfo = new ItemInfo
                {
                    ItemId = itemInfoVM.Item.EquipmentId,
                    Notes  = itemInfoVM.Notes
                };
                if (itemInfoVM.ItemInfoId > 0)
                {
                    // make sure this actually belongs to this here creature
                    var existingItemInfo = creature.ItemInformation.FirstOrDefault(ii => ii.Id == itemInfoVM.ItemInfoId);
                    if (existingItemInfo != null)
                    {
                        dbContext.Entry(existingItemInfo).State = EntityState.Detached;
                        itemInfo.Id = itemInfoVM.ItemInfoId;
                        dbContext.Attach(itemInfo);
                        dbContext.Entry(itemInfo).State = EntityState.Modified;
                    }
                }
                else
                {
                    creature.ItemInformation.Add(itemInfo);
                }
            }

            foreach (var weaponInfoFeatureChange in input.WeaponFeatureChanges)
            {
                var weaponInfo = creature.WeaponInformation.FirstOrDefault(si => si.Id == weaponInfoFeatureChange.WeaponInfoId);
                if (weaponInfo == null)
                {
                    continue;
                }

                foreach (var featureInfoVM in weaponInfoFeatureChange.NewFeatures)
                {
                    var featureInfo = featureInfoVM.ToDomainModel();
                    featureInfo.Feature = null;
                    weaponInfo.FeaturesApplied.Add(featureInfo);
                }
                weaponInfo.FeaturesApplied.RemoveAll(fi => weaponInfoFeatureChange.DeletedFeatureInfoIds.Contains(fi.Id));
            }

            foreach (var weaponInfoVM in input.NewWeaponInformation)
            {
                WeaponInfo weaponInfo = new WeaponInfo
                {
                    WeaponId = weaponInfoVM.Weapon.EquipmentId,
                    Notes    = weaponInfoVM.Notes
                };
                if (weaponInfoVM.WeaponInfoId > 0)
                {
                    // make sure this actually belongs to this here creature
                    var existingWeaponInfo = creature.ItemInformation.FirstOrDefault(ii => ii.Id == weaponInfoVM.WeaponInfoId);
                    if (existingWeaponInfo != null)
                    {
                        dbContext.Entry(existingWeaponInfo).State = EntityState.Detached;
                        weaponInfo.Id = weaponInfoVM.WeaponInfoId;
                        dbContext.Attach(weaponInfo);
                        dbContext.Entry(weaponInfo).State = EntityState.Modified;
                    }
                }
                else
                {
                    foreach (var featureInfoVM in weaponInfoVM.FeaturesApplied)
                    {
                        var featureInfo = featureInfoVM.ToDomainModel();
                        featureInfo.Feature = null;
                        weaponInfo.FeaturesApplied.Add(featureInfo);
                    }
                    creature.WeaponInformation.Add(weaponInfo);
                }
            }

            foreach (var armorInfoVM in input.NewArmorInformation)
            {
                ArmorInfo armorInfo = new ArmorInfo
                {
                    ArmorId = armorInfoVM.Armor.EquipmentId,
                    Notes   = armorInfoVM.Notes
                };
                if (armorInfoVM.ArmorInfoId > 0)
                {
                    // make sure this actually belongs to this here creature
                    var existingWeaponInfo = creature.ArmorInformation.FirstOrDefault(ii => ii.Id == armorInfoVM.ArmorInfoId);
                    if (existingWeaponInfo != null)
                    {
                        dbContext.Entry(existingWeaponInfo).State = EntityState.Detached;
                        armorInfo.Id = armorInfoVM.ArmorInfoId;
                        dbContext.Attach(armorInfo);
                        dbContext.Entry(armorInfo).State = EntityState.Modified;
                    }
                }
                else
                {
                    creature.ArmorInformation.Add(armorInfo);
                }
            }


            foreach (var flawInfoVM in input.NewFlawInformation)
            {
                FlawInfo flawInfo = new FlawInfo
                {
                    FlawId = flawInfoVM.Flaw.FlawId,
                    Notes  = flawInfoVM.Notes
                };
                if (flawInfoVM.FlawInfoId > 0)
                {
                    // make sure this actually belongs to this here creature
                    var existingFlawInfo = creature.FlawInformation.FirstOrDefault(fi => fi.Id == flawInfoVM.FlawInfoId);
                    if (existingFlawInfo != null)
                    {
                        dbContext.Entry(existingFlawInfo).State = EntityState.Detached;
                        flawInfo.Id = flawInfoVM.FlawInfoId;
                        dbContext.Attach(flawInfo);
                        dbContext.Entry(flawInfo).State = EntityState.Modified;
                    }
                }
                else
                {
                    creature.FlawInformation.Add(flawInfo);
                }
            }

            foreach (var spellInfoFeatureChange in input.SpellFeatureChanges)
            {
                var spellInfo = creature.SpellInformation.FirstOrDefault(si => si.Id == spellInfoFeatureChange.SpellInfoId);
                if (spellInfo == null)
                {
                    continue;
                }

                foreach (var featureInfoVM in spellInfoFeatureChange.NewFeatures)
                {
                    var featureInfo = featureInfoVM.ToDomainModel();
                    featureInfo.Feature = null;
                    spellInfo.FeaturesApplied.Add(featureInfo);
                }
                spellInfo.FeaturesApplied.RemoveAll(fi => spellInfoFeatureChange.DeletedFeatureInfoIds.Contains(fi.Id));
            }

            foreach (var spellInfoVM in input.NewSpellInformation)
            {
                SpellInfo spellInfo = new SpellInfo
                {
                    SpellId         = spellInfoVM.Spell.SpellId,
                    Notes           = spellInfoVM.Notes,
                    FeaturesApplied = new List <FeatureInfo>()
                };


                if (spellInfoVM.SpellInfoId > 0)
                {
                    var existingSpellInfo = creature.SpellInformation.FirstOrDefault(si => si.Id == spellInfoVM.SpellInfoId);
                    dbContext.Entry(existingSpellInfo).State = EntityState.Detached;
                    spellInfo.Id = existingSpellInfo.Id;
                    dbContext.Attach(spellInfo);

                    dbContext.Entry(spellInfo).State = EntityState.Modified;
                }
                else
                {
                    foreach (var featureInfoVM in spellInfoVM.FeaturesApplied)
                    {
                        var featureInfo = featureInfoVM.ToDomainModel();
                        featureInfo.Feature = null;
                        spellInfo.FeaturesApplied.Add(featureInfo);
                    }
                    creature.SpellInformation.Add(spellInfo);
                }
            }

            foreach (var statModVM in input.NewStatMods)
            {
                var statMod = statModVM.ToDomainModel();
                if (statModVM.StatModId > 0)
                {
                    var existingStatMod = creature.BaseStats.SingleOrDefault(sm => sm.Id == statModVM.StatModId);
                    if (existingStatMod != null) // make sure this stat belongs to this creature
                    {
                        dbContext.Entry(existingStatMod).State = EntityState.Detached;

                        statMod.Id = statModVM.StatModId;
                        dbContext.Attach(statMod);
                        dbContext.Entry(statMod).State = EntityState.Modified;
                    }
                }
                else
                {
                    statMod.Id = 0;
                    creature.BaseStats.Add(statMod);
                }
            }

            foreach (var skillVM in input.NewSkills)
            {
                var skill = new Skill
                {
                    Name       = skillVM.Name,
                    Ranks      = skillVM.Ranks,
                    BelongsTo  = skillVM.BelongsTo,
                    HasDefense = skillVM.HasDefense
                };

                if (skillVM.SkillId > 0)
                {
                    var existingSkill = creature.Skills.SingleOrDefault(s => s.Id == skillVM.SkillId);
                    if (existingSkill != null) //make sure this skill belongs to this creature
                    {
                        dbContext.Entry(existingSkill).State = EntityState.Detached;
                        skill.Id = skillVM.SkillId;
                        dbContext.Attach(skill);
                        dbContext.Entry(skill).State = EntityState.Modified;
                    }
                }
                else
                {
                    creature.Skills.Add(skill);
                }
            }

            creature.FlawInformation.RemoveAll(fi => input.DeletedFlawInformationIds.Contains(fi.Id));
            creature.OathInformation.RemoveAll(oi => input.DeletedOathInformationIds.Contains(oi.Id));
            creature.FeatureInformation.RemoveAll(fi => input.DeletedFeatureInformationIds.Contains(fi.Id));

            creature.WeaponInformation.RemoveAll(wi => input.DeletedWeaponInformationIds.Contains(wi.Id));
            creature.ArmorInformation.RemoveAll(ai => input.DeletedArmorInformationIds.Contains(ai.Id));
            creature.ItemInformation.RemoveAll(ii => input.DeletedArmorInformationIds.Contains(ii.Id));

            creature.SpellInformation.RemoveAll(si => input.DeletedSpellInfoIds.Contains(si.Id));
            creature.Skills.RemoveAll(s => input.DeletedSkillIds.Contains(s.Id));
            creature.BaseStats.RemoveAll(sm => input.DeletedStatModIds.Contains(sm.Id));

            await dbContext.SaveChangesAsync();

            return(creature.Id);
        }