コード例 #1
0
ファイル: Hero.cs プロジェクト: Alphadrake86/ProjectNeon
 public Hero(HeroCharacter character, RuntimeDeck deck)
 {
     this.character = character;
     this.deck      = deck;
     missingHp      = 0;
     equipment      = new HeroEquipment(character.Class);
 }
コード例 #2
0
        public async Task Trash(int id)
        {
            Hero hero = await this.heroService.GetHero();

            HeroEquipment itemToRemove   = hero.Inventory.Items.Find(i => i.Id == id);
            HeroAmulet    amuletToRemove = hero.Inventory.Amulets.Find(a => a.Id == id);

            if (itemToRemove != null)
            {
                this.context.HeroEquipments.Remove(itemToRemove);
            }
            else if (amuletToRemove != null)
            {
                this.context.HeroAmulets.Remove(amuletToRemove);

                typeof(AmuletBag)
                .GetProperties()
                .Where(x => x.Name.StartsWith("On") && (int)x.GetValue(hero.AmuletBag) == id)
                .ToList()
                .ForEach(x => x.SetValue(hero.AmuletBag, 0));
            }
            else
            {
                throw new FarmHeroesException(
                          InventoryExceptionMessages.ItemNotOwnedMessage,
                          InventoryExceptionMessages.ItemNotOwnedInstruction,
                          Redirects.InventoryRedirect);
            }

            await this.context.SaveChangesAsync();

            this.tempDataDictionaryFactory
            .GetTempData(this.httpContext.HttpContext)
            .Add("Alert", $"You trashed the desired item successfully.");
        }
コード例 #3
0
        public async Task <string> Sell(int id)
        {
            ShopEquipment shopEquipment = await this.context.ShopEquipments.FindAsync(id);

            int heroLevel = await this.levelService.GetCurrentHeroLevel();

            this.CheckIfRequiredLevelIsMet(shopEquipment, heroLevel);

            await this.resourcePouchService.DecreaseResource(ResourceNames.Gold, shopEquipment.Price);

            HeroEquipment heroEquipment = new HeroEquipment
            {
                Name          = shopEquipment.Name,
                Type          = shopEquipment.Type,
                RequiredLevel = shopEquipment.RequiredLevel,
                ImageUrl      = shopEquipment.ImageUrl,
                Attack        = shopEquipment.Attack,
                Defense       = shopEquipment.Defense,
                Mastery       = shopEquipment.Mastery,
            };

            await this.inventoryService.InsertEquipment(heroEquipment);

            this.tempDataDictionaryFactory
            .GetTempData(this.httpContext.HttpContext)
            .Add("Alert", $"You bought {heroEquipment.Name}.");

            return(heroEquipment.Type.ToString());
        }
コード例 #4
0
    ///////////////
    public void EquipItem(EquipmentItem item)
    {
        if (item == null)
        {
            return;
        }

        EquipmentItem equippedItem;

        // если на персонаже нет предмета в этом слоте, тогда надеваем предмет
        if (!HeroEquipment.TryGetValue(item.Slot, out equippedItem))
        {
            HeroEquipment.Add(item.Slot, item);
            InventoryContent.Instance.RemoveItem(item);

            if (OnEquipmentChanged != null)
            {
                OnEquipmentChanged();
            }

            return;
        }

        InventoryContent.Instance.AddEquipmentItem(equippedItem);
        InventoryContent.Instance.RemoveItem(item);
        HeroEquipment[item.Slot] = item;

        if (OnEquipmentChanged != null)
        {
            OnEquipmentChanged();
        }
    }
コード例 #5
0
ファイル: HeroAttack.cs プロジェクト: uraffululz/HeroSupport
 void OnEnable()
 {
     arenaManager = GameObject.FindGameObjectWithTag("SceneManager").GetComponent <ArenaSceneManagement>();
     anim         = GetComponent <Animator>();
     anim.SetBool("inCombat", true);
     //charStats = GetComponent<StatsPlayer>();
     myEquipment = GetComponent <HeroEquipment>();
 }
コード例 #6
0
    public void HeroEquipment_CanEquipForNonMatchingClass_IsFalse()
    {
        var heroEquipment = new HeroEquipment(TestClasses.Soldier);

        var sword = new InMemoryEquipment().Initialized(TestClasses.Paladin);

        Assert.IsFalse(heroEquipment.CanEquip(sword));
    }
コード例 #7
0
    public void HeroEquipment_CanEquipForMatchingClass_IsTrue()
    {
        var heroEquipment = new HeroEquipment(TestClasses.Soldier);

        var gun = new InMemoryEquipment().Initialized(TestClasses.Soldier);

        Assert.IsTrue(heroEquipment.CanEquip(gun));
    }
コード例 #8
0
    private void InitAugmentSlots(Hero h, HeroEquipment equipment)
    {
        var augments = equipment.Augments;

        InitAugmentSlot1(h, augments);
        InitAugmentSlot2(h, augments);
        InitAugmentSlot3(h, augments);
    }
コード例 #9
0
    public void HeroEquipment_EquipWeapon_IsEquipped()
    {
        var heroEquipment = new HeroEquipment(TestClasses.Soldier);
        var gun           = new InMemoryEquipment().Initialized(TestClasses.Soldier);

        heroEquipment.Equip(gun);

        Assert.AreEqual(1, heroEquipment.All.Length);
    }
コード例 #10
0
 private void CheckIfInventoryHasFreeSpace(Inventory inventory, HeroEquipment heroEquipment)
 {
     if (inventory.Items.Count == inventory.MaximumCapacity)
     {
         throw new FarmHeroesException(
                   InventoryExceptionMessages.NotEnoughSpaceMessage,
                   InventoryExceptionMessages.NotEnoughSpaceInstruction,
                   string.Format(Redirects.ShopRedirect, heroEquipment.Type));
     }
 }
コード例 #11
0
 private void CheckIfEquipmentBelongsToHero(Hero hero, HeroEquipment heroEquipment)
 {
     if (hero.InventoryId != heroEquipment.InventoryId)
     {
         throw new FarmHeroesException(
                   EquipmentExceptionMessages.DoesNotBelongToHeroMessage,
                   EquipmentExceptionMessages.DoesNotBelongToHeroInstruction,
                   Redirects.InventoryRedirect);
     }
 }
コード例 #12
0
        public async Task InsertEquipment(HeroEquipment heroEquipment)
        {
            Inventory inventory = await this.GetCurrentHeroInventory();

            this.CheckIfInventoryHasFreeSpace(inventory, heroEquipment);

            inventory.Items.Add(heroEquipment);

            await this.context.SaveChangesAsync();
        }
コード例 #13
0
    ///////////////
    public void UnequipItem(EquipmentItem item)
    {
        if (item == null)
        {
            return;
        }

        HeroEquipment.Remove(item.Slot);
        InventoryContent.Instance.AddEquipmentItem(item);

        if (OnEquipmentChanged != null)
        {
            OnEquipmentChanged();
        }
    }
コード例 #14
0
    /// <summary>
    /// Builds a hero, including any value used for battle calculations. Persists between battles.
    /// </summary>
    /// <param name="type">as HeroType</param>
    /// <param name="stats">as BattleStats</param>
    /// <param name="equipment">inventory of equipped equipment</param>
    /// <param name="name">fullname</param>
    public BattleHero(HeroType type, BattleStats stats, HeroEquipment equipment = null, string name = "Hero1")
    {
        heroType = type;
        sprites  = HeroSpriteData.MakeNewHeroSprites(heroType);

        fullName = name;

        // Load BStats
        BStats = stats;
        BStats.UpdateMax();
        HealAll();
        if (equipment != null)
        {
            Equipment = equipment;
        }
    }
コード例 #15
0
        public async Task Upgrade(int id)
        {
            Inventory inventory = await this.inventoryService.GetCurrentHeroInventory();

            HeroEquipment heroEquipment = inventory.Items.Find(i => i.Id == id);

            this.CheckIfItemIsOwnedByHero(heroEquipment);
            this.CheckIfItemIsFullyUpgraded(heroEquipment, HeroEquipmentMaximumLevel);

            int cost = SmithFormulas.CalculateEquipmentUpgradeCost(heroEquipment);

            await this.resourcePouchService.DecreaseResource(ResourceNames.Crystals, cost);

            heroEquipment.Level += 5;

            await this.context.SaveChangesAsync();

            this.tempDataDictionaryFactory
            .GetTempData(this.httpContext.HttpContext)
            .Add("Alert", $"You upgraded {heroEquipment.Name}.");
        }
コード例 #16
0
    //Utils//

    ///////////////
    public void LoadProfile(JsonObject json)
    {
        InitBaseStats(GameDataStorage.Instance.NewProfileData);

        // экипировка героя
        JsonArray heroEquipments = json.Get <JsonArray>("hero_equipment");

        foreach (JsonObject obj in heroEquipments)
        {
            EquipmentItem item = GameDataStorage.Instance.GetEquipmentByName(obj.GetString("Name", string.Empty));

            HeroEquipment.Add((EquipmentSlot)obj.GetInt("Slot"), item);
        }

        // содержимое карманов
        JsonArray pocketItems = json.Get <JsonArray>("pocket_items");

        for (int i = 0; i < pocketItems.Count; i++)
        {
            if (pocketItems[i] == null)
            {
                continue;
            }

            MaterialData itemData = GameDataStorage.Instance.GetMaterialByName((string)pocketItems[i]);

            PocketItems[i] = new MaterialInfo(itemData, 1);
        }

        // прогресс по миссиям

        NormalWorldMissionNumber   = json.GetInt("Normal");
        WaterWorldMissionNumber    = json.GetInt("Water");
        FireWorldMissionNumber     = json.GetInt("Fire");
        EarthWorldMissionNumber    = json.GetInt("Earth");
        DarknessWorldMissionNumber = json.GetInt("Darkness");
        AirWorldMissionNumber      = json.GetInt("Air");
    }
コード例 #17
0
        public async Task Equip(int id)
        {
            Hero hero = await this.heroService.GetHero();

            HeroEquipment heroEquipment = await this.GetHeroEquipmentById(id);

            EquippedSet equippedSet = await this.GetEquippedSet();

            this.CheckIfEquipmentBelongsToHero(hero, heroEquipment);

            if (equippedSet.Equipped.Any(x => x.Type == heroEquipment.Type))
            {
                equippedSet.Equipped.Remove(equippedSet.Equipped.Find(x => x.Type == heroEquipment.Type));
            }

            equippedSet.Equipped.Add(heroEquipment);

            await this.context.SaveChangesAsync();

            this.tempDataDictionaryFactory
            .GetTempData(this.httpContext.HttpContext)
            .Add("Alert", $"You equipped {heroEquipment.Name}.");
        }
コード例 #18
0
    // After HeroStatsMenu instantiates the EquipMenu, it passes relevant values for set up
    public void SetHero(int index, EquipSlots slot, GameObject parentGameObject)
    {
        // Sets HeroStatsMenuMonitor's gameObject as a parent, and displays it so the new menu displays
        this.parentGameObject = parentGameObject;
        parentGameObject.SetActive(false);

        // Index of current hero
        heroIndex = index;
        hero      = BattleLoader.Party.Hero[heroIndex];

        // Type of weapon or armor being selected
        this.slot = slot;
        heroStash = BattleLoader.Party.Hero[heroIndex].Equipment;

        // Make sure equip button is inactive at start
        equipButton.GetComponent <Button>().interactable = false;


        messageText.text = "";
        partyStash       = BattleLoader.Party.Inventory;

        // Fill the grid
        PopulateGrid();
    }
コード例 #19
0
    public void HeroEquipment_New_NoEquipment()
    {
        var heroEquipment = new HeroEquipment(TestClasses.Soldier);

        Assert.AreEqual(0, heroEquipment.All.Length);
    }
コード例 #20
0
    // Refresh each of the 6 slots of equipment
    public void RefreshEquipped()
    {
        // Retrieve hero's personal inventory of equipped items
        equipment = BattleLoader.Party.Hero[ID].Equipment;

        // If the slot property returns null, nothing is equipped and the
        // display should be left blank, as it is at instantiation

        // If a slot property returns a non-null InvNames field, retrieve the
        // InvEqItem stored in the hero's inventory and set the display
        if (equipment.Weapon != null)
        {
            InvEqItem weapon = (InvEqItem)(equipment.GetItem((InvNames)equipment.Weapon));
            weaponText.text      = weapon.FullName;
            weaponStatsText.text = CreateSummary(weapon.BStats);
            weaponImage.sprite   = weapon.Sprite;
            weaponImage.enabled  = true;
        }
        if (equipment.Helm != null)
        {
            InvEqItem helm = (InvEqItem)equipment.GetItem((InvNames)equipment.Helm);
            helmText.text      = helm.FullName;
            helmStatsText.text = CreateSummary(helm.BStats);
            helmImage.sprite   = helm.Sprite;
            helmImage.enabled  = true;
        }
        if (equipment.Armor != null)
        {
            InvEqItem armor = (InvEqItem)equipment.GetItem((InvNames)equipment.Armor);
            armorText.text      = armor.FullName;
            armorStatsText.text = CreateSummary(armor.BStats);
            armorImage.sprite   = armor.Sprite;
            armorImage.enabled  = true;
        }
        if (equipment.Gloves != null)
        {
            InvEqItem gloves = (InvEqItem)equipment.GetItem((InvNames)equipment.Gloves);
            glovesText.text      = gloves.FullName;
            glovesStatsText.text = CreateSummary(gloves.BStats);
            glovesImage.sprite   = gloves.Sprite;
            glovesImage.enabled  = true;
        }
        if (equipment.Belt != null)
        {
            InvEqItem belt = (InvEqItem)equipment.GetItem((InvNames)equipment.Belt);
            beltText.text      = belt.FullName;
            beltStatsText.text = CreateSummary(belt.BStats);
            beltImage.sprite   = belt.Sprite;
            beltImage.enabled  = true;
        }
        if (equipment.Boots != null)
        {
            InvEqItem boots = (InvEqItem)equipment.GetItem((InvNames)equipment.Boots);
            bootsText.text      = boots.FullName;
            bootsStatsText.text = CreateSummary(boots.BStats);
            bootsImage.sprite   = boots.Sprite;
            bootsImage.enabled  = true;
        }

        // Refresh HP/MP, from PartyMenuPanel
        RefreshPanel();
    }
コード例 #21
0
 public override void UnLoadWeapon(HeroEquipment hero)
 {
     throw new NotImplementedException();
 }
コード例 #22
0
        private async Task <HeroEquipment> GetHeroEquipmentById(int id)
        {
            HeroEquipment heroEquipment = await this.context.HeroEquipments.FindAsync(id);

            return(heroEquipment);
        }
コード例 #23
0
ファイル: Weapon.cs プロジェクト: lozzmki/ZProject
 public abstract void LoadWeapon(HeroEquipment hero);
コード例 #24
0
 /// <summary>
 /// Calculates the upgrade cost of an <see cref="FarmHeroes.Data.Models.HeroModels.HeroEquipment"/>.
 /// </summary>
 /// <param name="equipment">
 /// A <see cref="FarmHeroes.Data.Models.HeroModels.HeroEquipment"/>, upon which to be calculated the price.
 /// </param>
 /// <returns>
 /// An <see cref="int"/>, the upgrade cost of the <see cref="FarmHeroes.Data.Models.HeroModels.HeroEquipment"/>.
 /// </returns>
 public static int CalculateEquipmentUpgradeCost(HeroEquipment equipment) =>
 equipment.RequiredLevel * (equipment.Level + 5);