示例#1
0
 public void Import(ItemConfig config)
 {
     if (config != null)
     {
         ItemVO item = new ItemVO()
         {
             ID        = config.name,
             Type      = config.Type,
             Price     = config.Price,
             State     = new Dictionary <string, string>(),
             AssetID   = config.Asset == null ? null : config.Asset.name,
             Permanent = config.Permanent,
             Market    = config.Market
         };
         if (config.State != null)
         {
             Array.ForEach(config.State, s => item.State[s.Key] = s.Value);
         }
         Items[config.name] = item;
         if (!string.IsNullOrEmpty(item.AssetID))
         {
             _assets[item.AssetID] = config.Asset;
         }
     }
 }
示例#2
0
 public string GetItemName(ItemVO item)
 {
     return(item == null ? ""
         : string.IsNullOrEmpty(item.Name)
         ? AmbitionApp.Localize(item.ID + ItemConsts.ITEM_LOC_NAME)
         : item.Name);
 }
示例#3
0
        void HandleItemDisplay(ItemVO item)
        {
            _item = item;
            OutfitVO outfitTest = _item as OutfitVO; //This is to test if the item is an Outfit

            if (outfitTest != null)
            {
                OutfitVO outfit = (OutfitVO)_item;
                int      displayPrice;

                if (_inventorymodel.Market.Contains(_item)) //If the item is in Fatima's shop
                {
                    ItemCostText.text      = CostString;
                    BuyOrSellItemText.text = BuyOutfitString;
                    displayPrice           = outfit.Price;
                }
                else   //If the item is not in Fatima's shop
                {
                    ItemCostText.text      = ValueString;
                    BuyOrSellItemText.text = SellOutfitString;
                    displayPrice           = (int)(outfit.Price * _inventorymodel.SellbackMultiplier);
                }
                ItemPriceText.text = "£" + displayPrice.ToString("### ###");
            }
        }
示例#4
0
 private void HandleEquip(ItemVO item)
 {
     if (item != null)
     {
         Activate();
     }
 }
示例#5
0
        private void HandleOutfit(ItemVO item)
        {
            OutfitVO outfit = item as OutfitVO;
            int      val    = outfit?.Novelty ?? 0;

            _animator.SetFloat("OutfitNovelty", .01f * (float)val);
        }
示例#6
0
        public void Execute(CommodityVO reward)
        {
            InventoryModel inventory = AmbitionApp.GetModel <InventoryModel>();
            ItemVO         item      = inventory.Instantiate(reward.ID);

            if (item == null)
            {
                ItemConfig config = Resources.Load <ItemConfig>(Filepath.Items + reward.ID);
                inventory.Import(config);
                item = inventory.Instantiate(reward.ID);
            }
            if (item != null)
            {
                if (reward.Value > 0)
                {
                    item.Price = reward.Value;
                }
                item.Created = AmbitionApp.GetModel <CalendarModel>().Today;
                inventory.Inventory.Add(item);
                inventory.Broadcast();
            }
#if DEBUG
            else
            {
                Debug.LogWarningFormat("No inventory template matches reward ID '{0}'; synthesizing one", reward.ID);
            }
#endif
        }
示例#7
0
        public int GetFactionBonus(ItemVO item, FactionType faction)
        {
            OutfitVO outfit = item as OutfitVO;

            if (outfit == null)
            {
                return(0);
            }
            FactionVO fvo = AmbitionApp.GetModel <FactionModel>()[faction];

            if (fvo == null)
            {
                return(0);
            }

            if (outfit.State == null)
            {
                outfit.State = new Dictionary <string, string>();
            }
            int modesty = outfit.Modesty;
            int luxury  = outfit.Luxury;
            int novelty = outfit.Novelty;

            // -200 to +200
            int sum = 200 - (Math.Abs(fvo.Modesty - modesty) + Math.Abs(fvo.Luxury - luxury));

            // max range +/- 20 cred for outfit
            const int credibility_shift_scale = 20;     // TODO expose this tuning variable

            return((int)(sum * novelty * credibility_shift_scale * 0.00005f));
        }
示例#8
0
        public void Execute(DateTime day)
        {
            InventoryModel model = AmbitionApp.GetModel <InventoryModel>();
            int            count = model.ItemDefinitions.Length;
            ItemVO         item;
            string         style = null;

            model.Market.Clear();
            while (model.Market.Count < model.NumMarketSlots)
            {
                item = new ItemVO(model.ItemDefinitions[Util.RNG.Generate(0, count)]);
                item.State[ItemConsts.STYLE] = style = model.Styles[Util.RNG.Generate(0, model.Styles.Length)];
                item.Name = style + " " + item.Name;
                model.Market.Add(item);
            }

            OutfitVO outfit = OutfitVO.Create();

            outfit.Style = style;
            outfit.GenerateName();

            List <ItemVO> outfits = new List <ItemVO>()
            {
                outfit, OutfitVO.Create(), OutfitVO.Create()
            };

            if (AmbitionApp.GetModel <FactionModel>()["Bourgeoisie"].Level >= 3)
            {
                outfits.Add(OutfitVO.Create());
            }
            model.Market.RemoveAll(i => i.Type == ItemConsts.OUTFIT);
            model.Market.AddRange(outfits);
        }
示例#9
0
 private void HandleBrowse(ItemVO item)
 {
     _outfit = item?.Type == ItemType.Outfit ? item : null;
     BuyButton.interactable = (_outfit != null) &&
                              ((IsMerchant && _outfit.Price <= AmbitionApp.Game.Livre) ||
                               (!IsMerchant && !_outfit.Permanent));
     BuyButtonCostText.text = _outfit == null ? "" : "£" + _outfit.Price;
 }
示例#10
0
        private int sortByStyleComparer(ItemVO a, ItemVO b)
        {
            object styleA, styleB;
            string cmpA = (a.State != null && a.State.TryGetValue(ItemConsts.STYLE, out styleA)) ? (string)styleA : null;
            string cmpB = (b.State != null && b.State.TryGetValue(ItemConsts.STYLE, out styleB)) ? (string)styleB : null;

            return(ascendingOrder ? cmpA.CompareTo(cmpB) : cmpB.CompareTo(cmpA));
        }
示例#11
0
 public void ClickBuyButton()
 {
     if (_outfit != null)
     {
         AmbitionApp.SendMessage(IsMerchant ? InventoryMessages.BUY_ITEM : InventoryMessages.SELL_ITEM, _outfit);
     }
     _outfit = null;
     BuyButton.interactable = false;
 }
示例#12
0
 public Sprite GetAsset(ItemVO item)
 {
     if (string.IsNullOrEmpty(item?.AssetID))
     {
         return(null);
     }
     _assets.TryGetValue(item.AssetID, out Sprite asset);
     return(asset);
 }
示例#13
0
 public ItemVO(ItemVO item)
 {
     ID          = item.ID;
     Name        = item.Name;
     Description = item.Description;
     Type        = item.Type;
     Tags        = item.Tags;
     State       = new Dictionary <string, object>(item.State);
     Price       = item.Price;
     Asset       = item.Asset;
     Quantity    = item.Quantity;
 }
示例#14
0
 public OutfitVO(ItemVO item) : base(item, item.State)
 {
     Type = ItemType.Outfit;
     if (GetStat(ItemConsts.TIMES_WORN) == null)
     {
         TimesWorn = 0;
     }
     if (GetStat(ItemConsts.NOVELTY) == null)
     {
         Novelty = 100;
     }
 }
示例#15
0
 private ItemVO Instantiate(ItemVO item)
 {
     if (item == null)
     {
         return(null);
     }
     switch (item.Type) // Add to this if new item types are introduced
     {
     case ItemType.Outfit:
         return(new OutfitVO(item));
     }
     return(new ItemVO(item));
 }
示例#16
0
        private ItemVO Copy(ItemVO item)
        {
            if (item == null)
            {
                return(null);
            }
            ItemVO result = Instantiate(item);

            result.Price   = item.Price;
            result.State   = new Dictionary <string, string>(item.State);
            result.Created = item.Created;
            return(result);
        }
示例#17
0
        public void Execute(CommodityVO reward)
        {
            InventoryModel inventory = AmbitionApp.GetModel <InventoryModel>();

            if (inventory.Inventory.Count < inventory.NumSlots)
            {
                ItemVO[] itemz = Array.FindAll(inventory.ItemDefinitions, i => i.Type == reward.ID);
                ItemVO   item  = new ItemVO(itemz[Util.RNG.Generate(0, itemz.Length)])
                {
                    Quantity = reward.Value
                };
                inventory.Inventory.Add(item);
            }
        }
示例#18
0
 private void HandleOutfit(OutfitVO outfit)
 {
     if (outfit != null)
     {
         ItemVO item = (ItemVO)outfit;
         object value;
         _meter.value = item.State.TryGetValue(Stat, out value)
                                 ? Convert.ToInt32(value)
                                 : 0;
     }
     else
     {
         _meter.value = 0;
     }
 }
示例#19
0
        private void HandleEquip(ItemVO item)
        {
            OutfitVO outfit = item as OutfitVO;

            if (outfit != null)
            {
                int value = outfit.GetIntStat(Stat);
                if (Stat != ItemConsts.NOVELTY)
                {
                    value = (int)((100 + value) >> 1);
                }
                StopAllCoroutines();
                ValueText.text = value.ToString();
                StartCoroutine(Fill(value));
            }
        }
        //TO DO: Make this work with Accessories (when they're full implemented)
        void HandleItemDisplay(ItemVO item)
        {
            OutfitVO outfitTest = item as OutfitVO; //This is to test if the item is an Outfit

            if (outfitTest != null)
            {
                OutfitVO outfit = (OutfitVO)item;
                ItemNameText.text        = outfit.Name;
                ItemDescriptionText.text = outfit.Description;
                //To Do: Make the modesty and luxury sliders always work in the right direction
                LuxurySlider.value   = outfit.Luxury;
                LuxuryStatText.text  = outfit.Luxury + " (" + outfit.GenerateLuxuryString() + ")";
                ModestySlider.value  = outfit.Modesty;
                ModestyStatText.text = outfit.Modesty + " (" + outfit.GenerateModestyString() + ")";
                NoveltySlider.value  = outfit.Novelty;
                NoveltyStatText.text = outfit.Novelty + "/100";
                PaperDoll.sprite     = DressCollection.GetSprite(outfit.Style);
            }
        }
示例#21
0
 public void CalculatePrice()
 {
     Price = (int)((Math.Abs(Modesty) + Math.Abs(Luxury)) * (float)Novelty * 0.01f);
     if (Style != AmbitionApp.GetModel <InventoryModel>().CurrentStyle)   //Check to see if this Outfit matches what's in Style
     {
         Price = (int)(Price * Ambition.AmbitionApp.GetModel <InventoryModel>().OutOfStyleMultiplier);
     }
     if (Price < 10)
     {
         Price = 10;                         // If the Price is less than 10 make it 10. Will Sell for 5 at most (Sell price is 50% of Buy Price)
     }
     else
     {
         InventoryModel inventory = AmbitionApp.GetModel <InventoryModel>();
         ItemVO         item      = inventory.Inventory.Find(i => i.State.ContainsKey("outfit_cost"));
         if (item != null)
         {
             Price = (int)(Price * Convert.ToDouble(item.State["outfit_cost"]));
         }
     }
 }
示例#22
0
        private void HandleOutfit(ItemVO item)
        {
            OutfitVO outfit = item as OutfitVO;

            if (outfit != null)
            {
                InventoryModel inventory = AmbitionApp.Inventory;
                int            credShift;
                if (FactionEffectsBtn != null)
                {
                    FactionEffectsBtn.interactable = true;
                }
                if (OutfitDescriptionText != null)
                {
                    OutfitDescriptionText.text = GetOutfitDescription(outfit);
                }
                OutfitNameText.text = AmbitionApp.Localization.GetItemName(outfit);
                foreach (FactionTextEffect effect in FactionEffects)
                {
                    credShift         = inventory.GetFactionBonus(outfit, effect.Faction);
                    effect.Text.text  = (credShift > 0 ? "+" : "") + credShift.ToString();
                    effect.Text.color = credShift > 0
                        ? PositiveEffectTxtColor
                        : credShift < 0
                        ? NegativeEffectTxtColor
                        : NeutralEffectTxtColor;
                    effect.Text.fontStyle = (credShift == 0) ? FontStyle.Normal : FontStyle.Bold;
                }
            }
            else
            {
                foreach (FactionTextEffect effect in FactionEffects)
                {
                    effect.Text.text      = "0";
                    effect.Text.color     = NeutralEffectTxtColor;
                    effect.Text.fontStyle = FontStyle.Normal;
                }
            }
        }
示例#23
0
        public static bool Check(RequirementVO req)
        {
            var party = AmbitionApp.GetModel <PartyModel>().Party;

            // outfit reaction credibility shift
            ItemVO        outfit = AmbitionApp.Inventory.GetEquippedItem(ItemType.Outfit);
            CalendarEvent e      = AmbitionApp.GetEvent();
            FactionType   faction;

            if (e is PartyVO)
            {
                faction = ((PartyVO)e).Faction;
            }
            else
            {
                CharacterVO character = AmbitionApp.GetModel <CharacterModel>().GetCharacter(((RendezVO)e).Character);
                faction = character?.Faction ?? FactionType.Military;
            }
            int value = AmbitionApp.Inventory.GetFactionBonus(outfit, faction);

            return(RequirementsSvc.Check(req, value));
        }
示例#24
0
        public void SetItem(ItemVO item)
        {
            bool drawerEnabled = ((_item = item) != null);

            _button.enabled  = drawerEnabled;
            ItemName.enabled = drawerEnabled;
            Ribbon.enabled   = drawerEnabled;
            Note.SetActive(drawerEnabled);
            if (drawerEnabled)
            {
                ItemName.text = item.Name;
                if (item.State.ContainsKey(ItemConsts.STYLE))
                {
                    RibbonMapping mapping = Array.Find(Styles, s => s.style == (string)(item.State[ItemConsts.STYLE]));
                    Ribbon.sprite = mapping.sprite;
                }
                else
                {
                    Ribbon.sprite = null;
                }
                Ribbon.enabled = (Ribbon.sprite != null);
                Note.SetActive(item.State.ContainsKey(ItemConsts.GIFT));
            }
        }
示例#25
0
 public OutfitVO(ItemVO outfit) : base(outfit)
 {
 }
示例#26
0
        public bool CheckRequirements(CommodityVO[] requirments)
        {
            GameModel model = AmbitionApp.GetModel <GameModel>();

            foreach (CommodityVO req in requirments)
            {
                switch (req.Type)
                {
                case CommodityType.Item:
                    InventoryModel inventory = AmbitionApp.GetModel <InventoryModel>();
                    ItemVO         item      = inventory.Inventory.Find(i => i.Name == req.ID);
                    if (item == null || item.Quantity < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Livre:
                    if (model.Livre < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Location:
                    ParisModel paris = AmbitionApp.GetModel <ParisModel>();
                    if (!paris.Locations.Contains(req.ID))
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Reputation:
                    FactionModel factions = AmbitionApp.GetModel <FactionModel>();
                    return((req.ID != null && factions.Factions.ContainsKey(req.ID))
                            ? factions[req.ID].Reputation >= req.Value
                            : model.Reputation >= req.Value);

                case CommodityType.Servant:
                    ServantModel servants = AmbitionApp.GetModel <ServantModel>();
                    if (!servants.Servants.ContainsKey(req.ID))
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Date:
                    CalendarModel calendar = AmbitionApp.GetModel <CalendarModel>();
                    if (calendar.Today.Ticks < req.Value)
                    {
                        return(false);
                    }
                    break;

                case CommodityType.Mark:
                    MapModel map = AmbitionApp.GetModel <MapModel>();
                    return(Array.Exists(map.Map.Rooms, r => r.HostHere && r.Cleared));
                }
            }
            return(true);
        }
示例#27
0
 private void HandleBrowse(ItemVO item)
 {
     LoadOutButton.interactable = item is OutfitVO;
     AmbitionApp.SendMessage(InventoryMessages.EQUIP, item);
 }
示例#28
0
 void HandleOutfit(ItemVO outfit)
 {
     Doll.sprite = AmbitionApp.Inventory.GetAsset(outfit);
 }
示例#29
0
 void BlankStats()
 {
     ItemPriceText.text = "£0";
     ItemCostText.text  = ValueString;
     _item = null;
 }
示例#30
0
 public void HandleEquip(ItemVO item) => Activate();