Inheritance: MonoBehaviour, IGameItemView
Ejemplo n.º 1
0
    internal static bool DrawAddGameFeaturesMenu(GameItem _inDevGame)
    {
        GUI.Box(getRect(SMLBOXBUFFERWIDTH, SMLBOXBUFFERWIDTH), "Features!");
            GUILayout.BeginArea(getRect(SMLBOXBUFFERWIDTH, SMLBOXBUFFERWIDTH));
            int i = 0, x = 0;
            foreach (GameFeature f in GameValues.Features) {
                if (x == 0) {
                    GUILayout.BeginHorizontal();
                }
                if (x == 3) {
                    GUILayout.EndHorizontal();
                    x = -1;// lol
                }
                _engFeatures[i] = GUILayout.Toggle(_engFeatures[i], f.Title);
                i++; x++;
            }
            if (x != 0)
                GUILayout.EndHorizontal();
            bool close = false;
            if (GUILayout.Button("Done")) {
                close = true;
            }

            GUILayout.EndArea();
            if (close) {
                return false;
            }
            return true;
    }
Ejemplo n.º 2
0
 public Boss(string name, int level, GameItem itemDrop, WeaponEffect effect, int maxHealth,
     int health, int attackDamage, int magic, int defense, int resist, int expDropped,
     int goldDropped, int baseHealth, int baseAttack, int baseMagic, int baseDefense, 
     int baseResist, int expDropBase, int goldDropBase, float healthModifier, 
     float attackModifier, float magicModifier, float defenseModifier, float resistModifier,
     float expModifier, float goldModifier)
     : base(0, 0)
 {
     this.name = name;
     this.level = level;
     this.itemDrop = itemDrop;
     this.effect = effect;
     this.maxHealth = maxHealth;
     this.health = health;
     this.attackDamage = attackDamage;
     this.magic = magic;
     this.defense = defense;
     this.resist = resist;
     this.expDropped = expDropped;
     this.goldDropped = goldDropped;
     this.baseHealth = baseHealth;
     this.baseAttack = baseAttack;
     this.baseMagic = baseMagic;
     this.baseDefense = baseDefense;
     this.baseResist = baseResist;
     this.expDropBase = expDropBase;
     this.goldDropBase = goldDropBase;
     this.healthModifier = healthModifier;
     this.attackModifier = attackModifier;
     this.magicModifier = magicModifier;
     this.defenseModifier = defenseModifier;
     this.resistModifier = resistModifier;
     this.expDropBase = expDropBase;
     this.goldDropBase = goldDropBase;
 }
Ejemplo n.º 3
0
    public void addToSlot(GameItem slot)
    {
        _item = slot;

        _hasItem = true;
        _iconNum = slot.sprite;
    }
Ejemplo n.º 4
0
 public void addItem(GameItem item, int pos)
 {
     ItemSlotController slot = itens[pos].GetComponent<ItemSlotController>();
     if (!slot.hasItem)
     {
         slot.addToSlot(item);
     }
 }
Ejemplo n.º 5
0
 public bool CreateNewGame(GameItem game)
 {
     if (_inDevGame != null)
         return false;
         _inDevGame = game;
     _sc.StartWork();
     GUIHelpers.resetGameFeatures();
     return true;
 }
Ejemplo n.º 6
0
 public void addItem(GameItem item)
 {
     if (_numItens == _slots.Count)
     {
         addRowSlots();
     }
     (_slots[_numItens] as GameObject).GetComponent<ItemSlotSlider>().addToSlot(item);
     _numItens++;
 }
Ejemplo n.º 7
0
 /**
  * item is the GameItem to create upon rendering this event
  * parentForItem is the parent to (later) attach it to, during rendering if event triggers.
  */
 public ItemCreateSoundEvent(GameItem itemToAppear, GameItem parentForItem)
     : base()
 {
     if (itemToAppear is Ball)
         _duration = (itemToAppear as Ball).GetTrajectoryDuration();
     else
         _duration = 0;
     this.gameItem = itemToAppear;
     this.parentForItem = parentForItem;
 }
Ejemplo n.º 8
0
    public static GameItem generateAlchemy(AlchemyType type)
    {
        GameItem _itm = new GameItem();
        _itm.type = ItemType.Alchemy;
        _itm.alchemyType = type;
        _itm.setAttributes("alchemy", "description", 7, 100);
        _itm.setAlchemyAttributes(20, TargetTypes.Self, TargetAttribute.Life);

        return _itm;
    }
Ejemplo n.º 9
0
 /// <summary>
 /// Gets the percent progress per day for the current game
 /// Formula of employees(stats) + game size/ features etc
 /// </summary>0-1 range returned for now.
 /// <param name="game"></param>
 /// <returns></returns>
 internal float GetDaysWorkPercent(GameItem game)
 {
     int val = 0;
     foreach (StaffComponent s in Staff) {
         if (s != null)
         val += (s.Programming + s.Art) / 100;
     }
     //val /= game.Scope;
     return val / (game.Scope+1); // 0=small 1=medium
 }
Ejemplo n.º 10
0
    public static GameItem generateEquipment(EquipmentType equip)
    {
        GameItem _itm = new GameItem();
        _itm.type = ItemType.Equipment;
        _itm.equipmentType = equip;
        _itm.setAttributes("equipment", "description", 9, 100);
        _itm.attributes.SetAttributes(4, 4, 4, 4, 4, 44, 0);

        _itm.special = new GameSkill();
        _itm.special.SetAttributes("special skill", "description", 15, TargetTypes.Enemy, TargetAttribute.Life);

        return _itm;
    }
Ejemplo n.º 11
0
        public ViewModel()
        {
            NextItems = new ObservableCollection<GameItem>();

            _items = new GridGameItems(7, 7);
            for (int i = 0; i < _items.Rows; i++)
            {
                for (int j = 0; j < _items.Columns; j++)
                {
                    _items[i, j] = new GameItem(i,j, "");
                }
            }
            Result = string.Format("Score: {0}", 0);
        }
Ejemplo n.º 12
0
    public void addItem(GameItem itm)
    {
        Object obj = Instantiate(buttonAction);

        (obj as GameObject).transform.parent = this.transform;

        (obj as GameObject).GetComponent<GUIText>().pixelOffset = new Vector2(210, 80 + 40 * _count);
        (obj as GameObject).GetComponent<GUIText>().text = itm.name;

        (obj as GameObject).GetComponent<ButtonUseSkill>().action = OptionType.Item;
        (obj as GameObject).GetComponent<ButtonUseSkill>().item = itm;

        _buttons.SetValue(obj, _count);
        _itens.SetValue(itm, _count);

        _count++;
    }
Ejemplo n.º 13
0
    ///<summary>
    /// Attempts to put GameItem 'item' as an equipped item on the player
    ///</summary>
    public void Equip(GameItem item)
    {
        if (item is HeadItem)
        {
            inventory.Remove(item);
            if (GetHelmet() != null)
            {
                inventory.Add(GetHelmet());
            }
            SetHelmet((HeadItem)item);
        }
        else if (item is ChestItem)
        {
            inventory.Remove(item);
            if (GetChest() != null)
            {
                inventory.Add(GetChest());
            }
            SetChest((ChestItem)item);
        }
        else if (item is LegItem)
        {
            inventory.Remove(item);
            if (GetLegs() != null)
            {
                inventory.Add(GetLegs());
            }
            SetLegs((LegItem)item);
        }
        else if (item is WeaponItem)
        {
            inventory.Remove(item);
            if (GetWeapon() != null)
            {
                inventory.Add(GetWeapon());
            }
            SetWeapon((WeaponItem)item);
        }
        else
        {
            throw new Exception("Don't know how to equip " + item.GetType() + " " + item.GetItemName() +" Yet!");
        }

        CheckLevelReq();
    }
Ejemplo n.º 14
0
    /* add all the properties from a game object to the Game Item model */
    public static GameItem GameObjectToGameItem(GameObject gameObject)
    {
        #if UNITY_EDITOR
        /* we found a gameobject that doesn't have a prefab */
        if (EditorUtility.GetPrefabParent (gameObject) == null)
            return null;

        GameItem gameItem = new GameItem ();
        gameItem.name = EditorUtility.GetPrefabParent(gameObject).name;
        gameItem.position = gameObject.transform.position;
        gameItem.rotation = gameObject.transform.eulerAngles;
        gameItem.scale = gameObject.transform.localScale;

        return gameItem;
        #endif

        return null;
    }
Ejemplo n.º 15
0
    public void addEquipment(GameItem equipment)
    {
        GameObject itm = null;
        switch (equipment.equipmentType)
        {
            case EquipmentType.LeftArm:
                itm = _LeftArm;
                break;
            case EquipmentType.LeftLeg:
                itm = _LeftLeg;
                break;
            case EquipmentType.RightArm:
                itm = _RightArm;
                break;
            case EquipmentType.RightLeg:
                itm = _RightLeg;
                break;
        }

        ItemSlotController gamItm = itm.GetComponent<ItemSlotController>();
        gamItm.addToSlot(equipment);
    }
Ejemplo n.º 16
0
        private void CompleteQuestsAtLocation()
        {
            foreach (Quest quest in CurrentLocation.QuestsAvailableHere)
            {
                QuestStatus questToComplete =
                    CurrentPlayer.Quests.FirstOrDefault(q => q.PlayerQuest.ID == quest.ID &&
                                                        !q.IsCompleted);

                if (questToComplete != null)
                {
                    if (CurrentPlayer.HasAllTheseItems(quest.ItemsToComplete))
                    {
                        // Remove the quest completion items from the player's inventory
                        CurrentPlayer.RemoveItemsFromInventory(quest.ItemsToComplete);

                        _messageBroker.RaiseMessage("");
                        _messageBroker.RaiseMessage($"You completed the '{quest.Name}' quest");

                        // Give the player the quest rewards
                        _messageBroker.RaiseMessage($"You receive {quest.RewardExperiencePoints} experience points");
                        CurrentPlayer.AddExperience(quest.RewardExperiencePoints);

                        _messageBroker.RaiseMessage($"You receive {quest.RewardGold} gold");
                        CurrentPlayer.ReceiveGold(quest.RewardGold);

                        foreach (ItemQuantity itemQuantity in quest.RewardItems)
                        {
                            GameItem rewardItem = ItemFactory.CreateGameItem(itemQuantity.ItemID);
                            _messageBroker.RaiseMessage($"You receive a {rewardItem.Name}");
                            CurrentPlayer.AddItemToInventory(rewardItem);
                        }

                        // Mark the Quest as completed
                        questToComplete.IsCompleted = true;
                    }
                }
            }
        }
Ejemplo n.º 17
0
    public static Dictionary <GameItem, int> GetItemDicFromString(string data, ItemDatabase itemDB)
    {
        Dictionary <GameItem, int> items = new Dictionary <GameItem, int>();

        string[] dataLines = data.Split('/');
        int      pos       = 0;

        foreach (string line in dataLines)
        {
            if (line.Length > 0)
            {
                string[] i      = line.Split('-');
                int      id     = int.Parse(i[0]);
                int      amount = int.Parse(i[1]);
                int      locked = 0;
                if (i.Length > 2)
                {
                    locked = int.Parse(i[2]);
                }
                GameItem item = itemDB.GetItemByID(id);
                if (item == null)
                {
                    Console.WriteLine("Failed to find item." + line);
                }
                else
                {
                    if (locked == 1)
                    {
                        item.IsLocked = true;
                    }
                    item.itemPos = pos;
                    items[item]  = amount;
                    pos++;
                }
            }
        }
        return(items);
    }
Ejemplo n.º 18
0
    public void RemoveEquippedEquipment(EquipmentType pos)
    {
        switch (pos)
        {
        case EquipmentType.LeftArm:

            GlobalItens.AddToInventory(_leftArm);
            _leftArm     = null;
            _specials[0] = null;

            break;

        case EquipmentType.RightArm:

            GlobalItens.AddToInventory(_rightArm);
            _rightArm    = null;
            _specials[1] = null;

            break;

        case EquipmentType.LeftLeg:

            GlobalItens.AddToInventory(_leftLeg);
            _leftLeg     = null;
            _specials[2] = null;

            break;

        case EquipmentType.RightLeg:

            GlobalItens.AddToInventory(_rightLeg);
            _rightLeg    = null;
            _specials[3] = null;

            break;
        }
        UpdateAttributesEquipment();
    }
Ejemplo n.º 19
0
        public void CraftItemUsing(Recipe recipe)
        {
            if (CurrentPlayer.HasAllTheseItems(recipe.Ingredients))
            {
                CurrentPlayer.RemoveRecipeIngredientsFromInventory(recipe.Ingredients);

                foreach (ItemQuantity itemQuantity in recipe.OutputItems)
                {
                    if (itemQuantity.isWeapon)
                    {
                        Weapon outputWeapon = WeaponFactory.CreateWeapon(itemQuantity.ItemID);
                        CurrentPlayer.AddWeaponToWeapons(outputWeapon);
                        _messageBroker.RaiseMessage($"You craft a {outputWeapon.Name}");
                    }
                    else
                    {
                        GameItem outputItem = ItemFactory.CreateGameItem(itemQuantity.ItemID);
                        CurrentPlayer.AddItemToInventory(outputItem, itemQuantity.Quantity);
                        _messageBroker.RaiseMessage($"You craft {itemQuantity.Quantity} {outputItem.Name}");
                    }
                }
            }
            else
            {
                _messageBroker.RaiseMessage("You do not have the required ingredients:");
                foreach (ItemQuantity itemQuantity in recipe.Ingredients)
                {
                    if (itemQuantity.isWeapon)
                    {
                        _messageBroker.RaiseMessage($"{itemQuantity.Quantity} {WeaponFactory.WeaponName(itemQuantity.ItemID)}");
                    }
                    else
                    {
                        _messageBroker.RaiseMessage($"{itemQuantity.Quantity} {ItemFactory.ItemName(itemQuantity.ItemID)}");
                    }
                }
            }
        }
Ejemplo n.º 20
0
    public bool AddItemStackable(GameItem item, int amount)
    {
        if (totalItems == maxSize && (item.IsStackable == false || HasItem(item) == false))
        {
            return(false);
        }
        if (amount < 0)
        {
            amount = 0;
        }


        if (items.TryGetValue(item, out int current))
        {
            if (item.IsStackable)
            {
                items[item] = current + amount;
            }
            else
            {
                return(false);
            }
        }
        else
        {
            if (item.IsStackable)
            {
                item.itemPos = inventorySlotPos;
                items[item]  = amount;
            }
            else
            {
                return(false);
            }
        }
        UpdateItemCount();
        return(true);
    }
Ejemplo n.º 21
0
        protected async Task InstantiateAndShowPrefab(bool isStart = true)
        {
            GameObject newPrefabInstance;

            _cachedPrefabInstances.TryGetValue(GameItem.GiId + "_" + PrefabType + "_" + Name, out newPrefabInstance);
            if (newPrefabInstance == null)
            {
                newPrefabInstance = await GameItem.InstantiatePrefab(PrefabType, Name,
                                                                     Parent == null?transform : Parent.transform, WorldPositionStays);

                if (newPrefabInstance != null)
                {
                    var modifier = newPrefabInstance.GetComponent <PositionModifier>();
                    if (modifier != null)
                    {
                        newPrefabInstance.transform.position -= modifier.Offset;
                    }
                    newPrefabInstance.SetActive(false); // start inactive so we don't run transitions immediately
                    _cachedPrefabInstances.Add(GameItem.GiId + "_" + PrefabType + "_" + Name, newPrefabInstance);
                }
            }

            Assert.IsNotNull(newPrefabInstance,
                             string.Format(
                                 "The Prefab you are trying to instantiate is not setup. Please ensure the add it to the target GameItem {0}_{1}.",
                                 GameItem.IdentifierBase, GameItem.GiId));

            if (isStart)
            {
                GameObjectToGameObjectAnimation.SwapImmediately(_selectedPrefabInstance, newPrefabInstance);
            }
            else
            {
                GameObjectToGameObjectAnimation.AnimatedSwap(this, _selectedPrefabInstance, newPrefabInstance);
            }

            _selectedPrefabInstance = newPrefabInstance;
        }
Ejemplo n.º 22
0
        private void CompleteQuestsAtLocation()
        {
            foreach (Quest quest in CurrentLocation.QuestsAvailableHere)
            {
                QuestStatus questToComplete =
                    CurrentPlayer.Quests.FirstOrDefault(q => q.PlayerQuest.ID == quest.ID &&
                                                        !q.IsCompleted);

                if (questToComplete != null)
                {
                    if (CurrentPlayer.HasAllTheseItems(quest.ItemsToComplete))
                    {
                        CurrentPlayer.RemoveItemsFromInventory(quest.ItemsToComplete);

                        RaiseMessage("");
                        RaiseMessage($"You completed the '{quest.Name}' quest.");

                        //give player the rewards
                        RaiseMessage($"You receive {quest.RewardExperiencePoints} experience points.");
                        CurrentPlayer.AddExperience(quest.RewardExperiencePoints);

                        RaiseMessage($"You receive {quest.RewardTokens} tokens.");
                        CurrentPlayer.ReceiveTokens(quest.RewardTokens);

                        foreach (ItemQuantity itemQuantity in quest.RewardItems)
                        {
                            GameItem rewardItem = ItemFactory.CreateGameItem(itemQuantity.ItemID);

                            RaiseMessage($"You receive a {rewardItem.Name}");
                            CurrentPlayer.AddItemToInventory(rewardItem);
                        }

                        //mark as complete
                        questToComplete.IsCompleted = true;
                    }
                }
            }
        }
Ejemplo n.º 23
0
    public void GetForgeItemFromSlot(GameItem item, Sprite outer, Sprite inner, Color color)
    {
        forgeItem = item;

        // Check affordable
        var isAffordable = CurrencyManager.instance.CheckGoldAffordable(item.GetForgeCostByForgeLevel());

        b_ForgeIt.interactable = isAffordable;

        i_Outer.sprite      = outer;
        i_Inner.sprite      = inner;
        i_ItemSprite.sprite = item.sprite;
        t_Name.text         = item.GetNameByForgeLevel();
        t_Name.color        = color;
        t_CurrentPrice.text = item.GetCurrentPriceByForgeLevel().ToString();
        t_NextPrice.text    = item.GetNextPriceByForgeLevel().ToString();

        // Set forge cost
        var forgePriceStb = new StringBuilder("-");

        forgePriceStb.Append(item.GetForgeCostByForgeLevel());
        t_ForgePrice.text = forgePriceStb.ToString();



        // Set interval price
        var intervalPriceStb = new StringBuilder("(+");

        intervalPriceStb.Append((item.GetNextPriceByForgeLevel() - item.GetCurrentPriceByForgeLevel()));
        intervalPriceStb.Append(")");
        t_IntervalPrice.text = intervalPriceStb.ToString();

        // Set probabality
        var forgeProbStb = new StringBuilder(ForgeCalculator.GetProbability(item.forgeLevel).ToString());

        forgeProbStb.Append("%");
        t_ForgeProbability.text = forgeProbStb.ToString();
    }
Ejemplo n.º 24
0
 public void BuildUp(GameItem plank)
 {
     HouseSize.Experience += System.Math.Max(plank.Value / 20, 1);
     if (HouseSize.Experience >= Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted()))
     {
         LevelUp(HouseSize);
     }
     else if (((double)HouseSize.Experience - Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted() - 1)) / (Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted()) - Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted() - 1)) > .25 && notice25 == false)
     {
         messageManager.AddMessage("Your house is now 25% of the way to a size increase.");
         notice25 = true;
     }
     else if (((double)HouseSize.Experience - Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted() - 1)) / (Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted()) - Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted() - 1)) > .50 && notice50 == false)
     {
         messageManager.AddMessage("Your house is now 50% of the way to a size increase.");
         notice50 = true;
     }
     else if (((double)HouseSize.Experience - Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted() - 1)) / (Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted()) - Extensions.GetExperienceRequired(HouseSize.GetSkillLevelUnboosted() - 1)) > .75 && notice75 == false)
     {
         messageManager.AddMessage("Your house is now 75% of the way to a size increase.");
         notice75 = true;
     }
 }
Ejemplo n.º 25
0
    public double GetGearMultiplier(GameItem item)
    {
        if (item.Requirements == null || item.Requirements.Count == 0)
        {
            return(1);
        }
        string skill = item.Requirements.FirstOrDefault(x => x.Skill != "None")?.Skill ?? "None";

        if (skill == "None")
        {
            return(1);
        }
        double multi = 1;

        foreach (GameItem i in equippedItems)
        {
            if (i.EnabledActions.Contains(skill))
            {
                multi -= i.GatherSpeedBonus;
            }
        }
        return(Math.Max(multi, 0.01));
    }
Ejemplo n.º 26
0
    public virtual bool Equals(GameItem other)
    {
        bool sameGraphics = this.graphics.Equals(other.graphics);

        bool sameCategoryLength = this.categories.Length == other.categories.Length;
        bool sameCategories     = true;

        if (sameCategoryLength)
        {
            for (int i = 0; i < categories.Length; i++)
            {
                if (!this.categories[i].Equals(other.categories[i]))
                {
                    sameCategories = false;
                    break;
                }
            }
        }

        bool sameUseLimit = this.infiniteUses == other.infiniteUses;

        return(sameGraphics && sameCategories && sameUseLimit);
    }
Ejemplo n.º 27
0
 public bool AddItem(GameItem item)
 {
     //If the added item is null, the inventory is full and the item is not stackable,
     //or the inventory is full and the item is stackable, but not already in the inventory
     if (item == null ||
         (totalItems == maxSize && item.IsStackable == false) ||
         (totalItems == maxSize && item.IsStackable == true && HasItem(item) == false))
     {
         UpdateItemCount();
         return(false);
     }
     if (items.TryGetValue(item, out int amount))
     {
         items[item] = Math.Min(amount + 1, maxValue);
     }
     else
     {
         item.itemPos = inventorySlotPos;
         items[item]  = 1;
     }
     UpdateItemCount();
     return(true);
 }
Ejemplo n.º 28
0
        public AttackWithSpell(GameItem itemInUse, int minimumDamage, int maximumDamage, int manaCost)
            : base(itemInUse)
        {
            if (itemInUse.Category != GameItem.ItemCategory.Spell)
            {
                throw new ArgumentException($"{itemInUse.Name} není kouzlo");
            }

            if (_minimumDamage < 0)
            {
                throw new ArgumentException("minimumDamage musí být 0 nebo větší");
            }

            if (_maximumDamage < _minimumDamage)
            {
                throw new ArgumentException("maximumDamage musí být větší než minDmg");
            }

            _minimumDamage = minimumDamage;
            _maximumDamage = maximumDamage;
            _manaCost      = manaCost;
            _spellInUse    = itemInUse;
        }
Ejemplo n.º 29
0
 public static void OnClickGoldMoneyShopOpenTips(int nItemID, ItemSlotLogic.SLOT_TYPE eItemType, string strSlotName)
 {
     if (eItemType == SLOT_TYPE.TYPE_ITEM)
     {
         GameItem item = new GameItem();
         item.DataID = nItemID;
         if (item != null && item.IsValid())
         {
             if (item.IsEquipMent())
             {
                 //EquipTooltipsLogic.SetDelegateBuyClick(myde1, myde2);
                 //EquipTooltipsLogic.ShowEquipTooltip(item, EquipTooltipsLogic.ShowType.ShopBuyBatch);
                 EquipTooltipsLogic.ShowEquipTooltip(item, EquipTooltipsLogic.ShowType.Info);
             }
             else
             {
                 //ItemTooltipsLogic.SetDelegateBuyClick(myde1, myde2);
                 //ItemTooltipsLogic.ShowItemTooltip(item, ItemTooltipsLogic.ShowType.ShopBuyBatch);
                 ItemTooltipsLogic.ShowItemTooltip(item, ItemTooltipsLogic.ShowType.Info);
             }
         }
     }
 }
Ejemplo n.º 30
0
    /// <summary>
    /// A function designed to determine wether or not a monster should drop an item.
    /// </summary>
    /// <param name="seed">Seed for generating the bool. Should be set to system time during live gameplay.</param>
    /// <param name="rewardFactor">A single integer representing the likelyhood this particular enemy should drop a reward. Ideally based both on floor level and monster power. Higher number = Larger Chance</param>
    /// <returns>True if the monster should drop a potion, False otherwise.</returns>

    /*public static bool DropPotion(int seed, int rewardFactor, bool useSeed = true)
     * {
     *  Random random = GetRandom(seed, useSeed);
     *  if (random.Next(100) <= 1 + rewardFactor)
     *      return true;
     *
     *  return false;
     * }*/

    /// <summary>
    /// Generates the value for a given item.
    /// </summary>
    /// <param name="item">Item data in question, will usually be passed weapons or equipment; should have private helper functions for those.</param>
    /// <returns>The value the item should logically have. Note it is not random.</returns>
    public static double GenerateItemValue(GameItem item)
    {
        // Item value is based upon the item's rarity. TODO: Perhaps add more logic
        switch (item.Rarity)
        {
        case GameItem.ItemRarity.COMMON:
            return(50.0);

        case GameItem.ItemRarity.UNCOMMON:
            return(150.0);

        case GameItem.ItemRarity.RARE:
            return(350.0);

        case GameItem.ItemRarity.EPIC:
            return(650.0);

        case GameItem.ItemRarity.LEGENDARY:
            return(1500.0);
        }

        return(0.0);
    }
Ejemplo n.º 31
0
        private void OnClick_Buy(object sender, RoutedEventArgs e)
        {
            GameItem item = ((FrameworkElement)sender).DataContext as GameItem;

            if (item != null)
            {
                if (Session.CurrentPlayer.Gold >= item.Price)//player has enough money to buy item
                {
                    Session.CurrentPlayer.Gold -= item.Price;
                    Session.CurrentPlayer.AddItemToInventory(item);
                    Session.CurrentTrader.RemoveItemFromInventory(item);
                    MessagesTxbx.Text = "Thanks!";
                }
                else
                {
                    MessagesTxbx.Text = "You don't have enough money for that!";
                }
            }
            else
            {
                MessagesTxbx.Text = "It's as if you think empty air is an object...";
            }
        }
Ejemplo n.º 32
0
        public GameItem SelectOne(int id)
        {
            var           user      = new GameItem();
            var           sql       = "select * from [portal].[dbo].game where id = " + id;
            var           conn      = new SqlConnection(Constants.DBConnection);
            var           myCommand = new SqlCommand(sql, conn);
            SqlDataReader MyReader;

            conn.Open();
            MyReader = myCommand.ExecuteReader();
            while (MyReader.Read())
            {
                user.zoneID        = MyReader.GetInt32(MyReader.GetOrdinal("id"));
                user.name          = MyReader.GetString(MyReader.GetOrdinal("name"));
                user.displayStatus = MyReader.GetInt32(MyReader.GetOrdinal("displayStatus"));
                user.gameOrder     = MyReader.GetInt32(MyReader.GetOrdinal("gameOrder"));
            }
            //close reader cũ
            MyReader.Close();
            conn.Close();

            return(user);
        }
Ejemplo n.º 33
0
 public bool MeetsRequirements(GameItem item)
 {
     if (item == null)
     {
         return(false);
     }
     if (item.Requirements == null || item.Requirements.Count == 0)
     {
         return(true);
     }
     foreach (Requirement req in item.Requirements)
     {
         if (req.Skill != "None" && req.Skill != AutoCollectSkill)
         {
             return(false);
         }
         if (req.Skill == AutoCollectSkill && req.SkillLevel > AutoCollectLevel)
         {
             return(false);
         }
     }
     return(true);
 }
Ejemplo n.º 34
0
        public List <GameItem> GetGameItems()
        {
            var res = new List <GameItem>();

            foreach (var item in Images)
            {
                var gameItem = new GameItem();
                //gameItem.Image = item.Value;
                gameItem.AddAnswer(item.Key, true);

                foreach (var name in GetOtherAnswers(item.Key))
                {
                    gameItem.AddAnswer(name, false);
                }

                gameItem.Shuffle();

                res.Add(gameItem);
            }


            return(res);
        }
Ejemplo n.º 35
0
 public void UpdateSelectEquip()
 {
     if (AutoEquipGuid == GlobeVar.INVALID_GUID)
     {
         GameItemContainer EquipPack = GameManager.gameManager.PlayerDataPool.EquipPack;
         if (EquipPack != null)
         {
             for (int index = 0; index < EquipPack.ContainerSize; index++)
             {
                 GameItem equip = EquipPack.GetItem(index);
                 if (equip != null && equip.IsValid() && equip.IsBelt() == false)
                 {
                     AutoEquipGuid = equip.Guid;
                     SetAutoPickUpFlag((int)Games.GlobeDefine.GameDefine_Globe.AUTOCOMBAT_PICKUP_TYPE.PICKUP_EQUIP1, true);
                     SetAutoPickUpFlag((int)Games.GlobeDefine.GameDefine_Globe.AUTOCOMBAT_PICKUP_TYPE.PICKUP_EQUIP2, true);
                     ServerAutoInfo();
                     UpdateSellItem();
                     return;
                 }
             }
         }
     }
 }
Ejemplo n.º 36
0
 private void GatherItem()
 {
     if (Player.Instance.FollowerGatherItem(CurrentGatherItem) == false)
     {
         PlayerGatherItem();
     }
     if (CurrentGatherItem != null)
     {
         if (Player.Instance.CurrentFollower != null && Player.Instance.CurrentFollower.IsBanking)
         {
             TicksToNextAction = Player.Instance.CurrentFollower.TicksToNextAction;
         }
         else
         {
             if (PossibleGatherItems.Count > 1)
             {
                 int roll = Random.Next(0, PossibleGatherItems.Count);
                 CurrentGatherItem = PossibleGatherItems[roll];
             }
             TicksToNextAction = GetTicksToNextGather();
         }
     }
 }
Ejemplo n.º 37
0
    public void InactiveAllHolders()
    {
        thisItem          = null;
        thisImage.enabled = false;
        i_Coin.gameObject.SetActive(false);
        i_SpriteItem.gameObject.SetActive(false);
        i_SpriteOuter.gameObject.SetActive(false);
        i_SpriteInner.gameObject.SetActive(false);
        t_ItemName.gameObject.SetActive(false);
        t_Rarity.gameObject.SetActive(false);
        b_Forge.gameObject.SetActive(false);
        b_Drop.gameObject.SetActive(false);
        b_Sell.gameObject.SetActive(false);
        t_AMarketPrice.gameObject.SetActive(false);
        t_BMarketPrice.gameObject.SetActive(false);
        t_CMarketPrice.gameObject.SetActive(false);

        t_Damaged.gameObject.SetActive(false);
        t_Maintain.gameObject.SetActive(false);
        t_ATown.gameObject.SetActive(false);
        t_BTown.gameObject.SetActive(false);
        t_CTown.gameObject.SetActive(false);
    }
Ejemplo n.º 38
0
 void ProductSlotOnClick(int nItemID, ItemSlotLogic.SLOT_TYPE eItemType, string strSlotName)
 {
     if (nItemID == GlobeVar.INVALID_ID)
     {
         ShowFormula();
     }
     else
     {
         GameItem item = new GameItem();
         item.DataID = nItemID;
         if (item.IsValid())
         {
             if (item.IsEquipMent())
             {
                 EquipTooltipsLogic.ShowEquipTooltip(item, EquipTooltipsLogic.ShowType.UnEquiped);
             }
             else
             {
                 ItemTooltipsLogic.ShowItemTooltip(item, ItemTooltipsLogic.ShowType.Normal);
             }
         }
     }
 }
Ejemplo n.º 39
0
        private void CompleteQuestAtLocation()
        {
            foreach (Quests quests in CurrentLocation.QuestsAvailableHere)
            {
                QuestStatus questToComplete =
                    CurrentPlayer.Quests.FirstOrDefault(q => q.PlayerQuest.ID == quests.ID && !q.IsCompleted);

                if (questToComplete != null)
                {
                    if (CurrentPlayer.HasAllTheseItems(quests.ItemsToComplete))
                    {
                        //Fjerne de relevante quest ting så questen kan blive gennemført
                        CurrentPlayer.RemoveItemsFromInventory(quests.ItemsToComplete);

                        RaiseMessage("");
                        RaiseMessage($"You have competed the {quests.Name} quest!");

                        //Giver spilleren belønning

                        RaiseMessage($"You recieve {quests.RewardExperiencePoints} experience!");
                        CurrentPlayer.AddExperience(quests.RewardExperiencePoints);

                        RaiseMessage($"And you recieve {quests.RewardGold} gold!");
                        CurrentPlayer.ReceiveGold(quests.RewardGold);

                        foreach (ItemQuantity itemQuantity in quests.RewardItems)
                        {
                            GameItem rewardItem = ItemFactory.CreateGameItem(itemQuantity.ItemID);
                            CurrentPlayer.AddItemToInventory(rewardItem);
                            RaiseMessage($"And a {rewardItem.Name}!");
                        }
                        //Sætter Questen som gennemført
                        questToComplete.IsCompleted = true;
                    }
                }
            }
        }
Ejemplo n.º 40
0
    public void IdentifyGems()
    {
        List <KeyValuePair <GameItem, int> > items         = Player.Instance.Inventory.GetItems();
        List <KeyValuePair <GameItem, int> > itemsToRemove = new List <KeyValuePair <GameItem, int> >();
        int amt        = 0;
        int coinsToPay = 0;

        foreach (KeyValuePair <GameItem, int> pair in items)
        {
            if (pair.Key.Name == "Unidentified Gem")
            {
                if (Player.Instance.Inventory.GetNumberOfItem(ItemManager.Instance.GetItemByName("Coins")) - coinsToPay >= 300)
                {
                    coinsToPay += 300;
                    itemsToRemove.Add(new KeyValuePair <GameItem, int>(pair.Key, 1));
                }
            }
        }
        Player.Instance.Inventory.RemoveItems(ItemManager.Instance.GetItemByName("Coins"), coinsToPay);
        foreach (KeyValuePair <GameItem, int> pair in itemsToRemove)
        {
            if (Player.Instance.Inventory.RemoveItems(pair.Key, 1) == 1)
            {
                GameItem i = ItemManager.Instance.GetCopyOfItem(pair.Key.Parameter);
                Player.Instance.Inventory.AddItem(i);
                amt++;
            }
        }
        if (amt == 0)
        {
            MessageManager.AddMessage("You'll need both money and gems to have me identify them...");
        }
        else
        {
            MessageManager.AddMessage("Tochtei correctly identifies your gems.");
        }
    }
Ejemplo n.º 41
0
        private static void LoadItemsFromNodes(XmlNodeList nodes)
        {
            if (nodes == null)
            {
                return;
            }

            foreach (XmlNode node in nodes)
            {
                GameItem.ItemCategory itemCategory = DetermineItemCategory(node.Name);

                GameItem gameItem =
                    new GameItem(itemCategory,
                                 node.AttributeAsInt("ID"),
                                 node.AttributeAsString("Name"),
                                 node.AttributeAsInt("BuyPrice"),
                                 node.AttributeAsInt("SellPrice"),
                                 node.AttributeAsInt("Durability"),
                                 itemCategory == GameItem.ItemCategory.Weapon);

                if (itemCategory == GameItem.ItemCategory.Weapon)
                {
                    gameItem.Action =
                        new AttackWithWeapon(gameItem,
                                             node.AttributeAsInt("MinimumDamage"),
                                             node.AttributeAsInt("MaximumDamage"));
                }
                else if (itemCategory == GameItem.ItemCategory.Consumable)
                {
                    gameItem.Action =
                        new Heal(gameItem,
                                 node.AttributeAsInt("HitPointsToHeal"));
                }

                _standardGameItems.Add(gameItem);
            }
        }
        private void CreateSelectTopicButtons(IEnumerable <string> topics)
        {
            foreach (string topic in topics)
            {
                var viewbox = new Viewbox {
                    Child = new TextBlock {
                        Text = topic
                    }
                };

                var button = new Button
                {
                    Content = viewbox,
                    Tag     = topic,
                    Width   = 500,
                    Height  = 90,
                    Margin  = new Thickness(0, 0, 10, 10)
                };

                button.Click += (s, e) =>
                {
                    var b = s as Button;
                    if (b != null)
                    {
                        WhoAmIHomeVisibility = Visibility.Collapsed;
                        _gameItems           = EnglishGameHelper.RandomOrder(
                            FileManagement.GetListGameData().Where(
                                x => x.GameName == Constant.GameConstant.WhoAmI && x.Topic == b.Tag.ToString()).ToList());
                        SelectedGameItem = _gameItems[0];
                        _currentIndex    = 0;
                        _timer.IsEnabled = true;
                    }
                };

                LayoutRoot.Children.Add(button);
            }
        }
Ejemplo n.º 43
0
    /// <summary>
    /// 使用具体位置在当前房间生成游戏物体
    /// </summary>
    /// <param name="prefab"></param>
    /// <param name="position"></param>
    /// <returns></returns>
    public GameObject GenerateGameObjectInCurrentRoom(GameObject prefab, Vector2 position)
    {
        //物体生成后所归属的默认节点
        Transform container = currentRoom.defaultContainer;

        //尝试获取物体类别,不为空便设置到对应节点
        GameItem gameItem = prefab.GetComponent <GameItem>();

        if (gameItem != null)
        {
            switch (gameItem.gameItemType)
            {
            case GameItemType.Prop:
                container = currentRoom.propContainer;
                break;

            case GameItemType.Monster:
                container = currentRoom.monsterContainer;
                break;

            case GameItemType.Obstacles:
                container = currentRoom.obstaclesContainer;
                //配合延迟更新形成消息等待机制
                if (!isScanningGridGraph && this.gameObject.activeSelf)
                {
                    isScanningGridGraph = true;
                    StartCoroutine(DeleyScanGridGraph());
                }
                break;

            default:
                break;
            }
        }

        return(currentRoom.GenerateGameObjectWithPosition(prefab, position, container));
    }
Ejemplo n.º 44
0
    public void OnRewardItemClick(GameObject obj)
    {
        int nShowID = GlobeVar.INVALID_ID;

        if (obj.name.Equals("Jiangli1", StringComparison.OrdinalIgnoreCase))
        {
            nShowID = m_nRewardItemID[0];
        }
        else if (obj.name.Equals("Jiangli2", StringComparison.OrdinalIgnoreCase))
        {
            nShowID = m_nRewardItemID[1];
        }
        else if (obj.name.Equals("Jiangli3", StringComparison.OrdinalIgnoreCase))
        {
            nShowID = m_nRewardItemID[2];
        }
        else if (obj.name.Equals("Jiangli4", StringComparison.OrdinalIgnoreCase))
        {
            nShowID = m_nRewardItemID[3];
        }
        else
        {
            return;
        }

        GameItem item = new GameItem();

        item.DataID = nShowID;
        if (item.IsEquipMent())
        {
            EquipTooltipsLogic.ShowEquipTooltip(item, EquipTooltipsLogic.ShowType.Info);
        }
        else
        {
            ItemTooltipsLogic.ShowItemTooltip(item, ItemTooltipsLogic.ShowType.Info);
        }
    }
Ejemplo n.º 45
0
 public void GainExperienceFromWeapon(GameItem weapon, int damageDealt)
 {
     if (weapon.EnabledActions == null)
     {
         return;
     }
     if (weapon.EnabledActions.Contains("Knife"))
     {
         GainExperience("Deftness", (int)(damageDealt * 1.5));
         GainExperience("Knifesmanship", (int)(damageDealt));
     }
     else if (weapon.EnabledActions.Contains("Sword"))
     {
         GainExperience("Deftness", (int)(damageDealt * 0.5));
         GainExperience("Strength", damageDealt);
         GainExperience("Swordsmanship", (int)(damageDealt));
     }
     else if (weapon.EnabledActions.Contains("Axe"))
     {
         GainExperience("Deftness", (int)(damageDealt * 0.5));
         GainExperience("Strength", damageDealt);
         GainExperience("Axemanship", (int)(damageDealt));
     }
     else if (weapon.EnabledActions.Contains("Hammer"))
     {
         GainExperience("Strength", (int)(damageDealt * 1.5));
         GainExperience("Hammermanship", (int)(damageDealt));
     }
     else if (weapon.EnabledActions.Contains("Archery"))
     {
         GainExperience("Archery", (int)(damageDealt * 1.5));
     }
     else if (weapon.EnabledActions.Contains("Fishing"))
     {
         GainExperience("Fishing", (int)(damageDealt * 0.1));
     }
 }
Ejemplo n.º 46
0
    public void StoreItem(string code, string name, float weight, string description)
    {
        GameItem gameItem = new GameItem("", code, name, weight, description);
        _inventories.Add(gameItem);

        SyncItemAdd(gameItem);
    }
Ejemplo n.º 47
0
    internal static Boolean DrawGenreSelect(GameItem _currentGame)
    {
        if (_currentGame.Genre != 0xFFF)
                return false;

            GUI.Box(getRect(SMLBOXBUFFERWIDTH, SMLBOXBUFFERWIDTH), "");
            GUILayout.BeginArea(getRect(SMLBOXBUFFERWIDTH, SMLBOXBUFFERWIDTH));
            GUILayout.BeginHorizontal();
            _currentGame.Genre = GUILayout.SelectionGrid(_currentGame.Genre, GameValues.genreStrings, 5);
            GUILayout.EndHorizontal();
            GUILayout.EndArea();
            return true;
    }
Ejemplo n.º 48
0
    private static int getScore(GameItem _inDevGame,int num)
    {
        //TODO Make reviews non random.
            if (num == 0) {
                _scores = new int[6];
                for(int i = 0; i <= _scores.Count();i++) {
                _scores[i] = UnityEngine.Random.Range(0, 10);
                }
            }

            return _scores[num];
    }
Ejemplo n.º 49
0
 internal static bool DrawReviewScreen(GameItem _inDevGame)
 {
     GUI.Box(getRect(SMLBOXBUFFERWIDTH, SMLBOXBUFFERWIDTH), "Reviews are in!");
         GUILayout.BeginArea(getRect(SMLBOXBUFFERWIDTH, SMLBOXBUFFERWIDTH));
         GUILayout.BeginVertical();
         for(int i = 0;i < 6;i++){
             GUILayout.BeginHorizontal();
             GUILayout.Label(getScore(_inDevGame,i) + " / 10");
             GUILayout.EndHorizontal();
         }
         bool close = false;
         if (GUILayout.Button("Done")) {
             close = true;
         }
         GUILayout.EndVertical();
         GUILayout.EndArea();
         if (close)
             return false;
         return true;
 }
Ejemplo n.º 50
0
        protected override void OnRemoveItem(GameItem item)
        {
            if (OnRemoveItemCall != null)
                OnRemoveItemCall(this, item);

            Do(OnRemoveItemAction);
        }
Ejemplo n.º 51
0
 // delete grid item
 public void DeleteItem(GameItem item)
 {
     Destroy(item.gameObject);
     StartCoroutine( DelayReposition(0.1f) );
 }
Ejemplo n.º 52
0
	public int numItem(GameItem type)
	{
		return items[(int)type];
	}
Ejemplo n.º 53
0
    public bool RemoveItem(GameItem item)
    {
        _inventories.Remove(item);
        SyncItemRemove(item);

        return true;
    }
Ejemplo n.º 54
0
    public bool SyncItemRemove(GameItem item)
    {
        if (_mainGame == null)
        {
            return false;
        }

        _mainGame.Game.Avatar.SetInventoryRemove(item.Code, item.Id, item.Name, item.Weight, item.Description);

        return true;
    }
Ejemplo n.º 55
0
 /// <summary>
 /// Called when player hits Okay on create game.
 /// </summary>
 private void createGame()
 {
     GameObject.FindGameObjectWithTag("GameController").GetComponent<GameReleaseManager>().CreateNewGame(_currentGame);
     _currentGame = null;
 }
Ejemplo n.º 56
0
	public void setItemCount(GameItem type, int num)
	{
		if (num >= 0)
			items[(int)type] = num;
	}
Ejemplo n.º 57
0
	public void shiftItemCount(GameItem type, int num)
	{
		items[(int)type] += num;
		if (items[(int)type] < 0)
			items[(int)type] = 0;
	}
Ejemplo n.º 58
0
	public void addItem(GameItem type)
	{
		shiftItemCount(type, 1);
	}
Ejemplo n.º 59
0
 protected void OnInventoryRemove(GameItem item)
 {
     WindowManager.CreateDialog("dlgInventoryRemove", "Warning!", "Do you wish to delete item " + item.Code, new string[] { "Yes", "No" }, (dlg, choice) =>
     {
         if (choice == 0)
         {
             bool result = InventoryEngine.Instance.RemoveItem(item);
             if (PopBloopSettings.useLogs)
             {
                 Debug.Log("Remove Inventory Item: " + item.Code + " => Result: " + result.ToString());
             }
         }
         dlg.Hide();
     }).MakeCenter(300, 200);
 }
Ejemplo n.º 60
0
	public bool hasItem(GameItem type)
	{
		return numItem(type) > 0;
	}