public override Item Clone () { Consumable item = new Consumable(); base.CloneBase(item); //copy all vars before return return item; }
public int CompareTo(Consumable other) { if(other == null) { return 1; } //SORTS BY ID NUMBER return id - other.id; }
/// <summary> /// Initializes a new instance of the <see cref="com.soomla.unity.MarketItem"/> class. /// </summary> public MarketItem(JSONObject jsonObject) { ProductId = jsonObject[JSONConsts.MARKETITEM_PRODUCT_ID].str; Price = jsonObject[JSONConsts.MARKETITEM_PRICE].n; int cOrdinal = System.Convert.ToInt32(((JSONObject)jsonObject[JSONConsts.MARKETITEM_CONSUMABLE]).n); if (cOrdinal == 0) { this.consumable = Consumable.NONCONSUMABLE; } else if (cOrdinal == 1){ this.consumable = Consumable.CONSUMABLE; } else { this.consumable = Consumable.SUBSCRIPTION; } }
public MarketItem(AndroidJavaObject jniMarketItem) { ProductId = jniMarketItem.Call<string>("getProductId"); Price = jniMarketItem.Call<double>("getPrice"); int managedOrdinal = jniMarketItem.Call<AndroidJavaObject>("getManaged").Call<int>("ordinal"); switch(managedOrdinal){ case 0: this.consumable = Consumable.NONCONSUMABLE; break; case 1: this.consumable = Consumable.CONSUMABLE; break; case 2: this.consumable = Consumable.SUBSCRIPTION; break; default: this.consumable = Consumable.CONSUMABLE; break; } }
public Consumable Generate(string consumableTemplateKey) { // TODO: do this for realz var template = (ConsumableTemplate)ConsumableTemplate.cache[consumableTemplateKey]; var consumable = new Consumable(); consumable.key = template.key; consumable.name = template.name; consumable.usedName = template.usedName; consumable.statEffects = new Dictionary<string, float>(); foreach (KeyValuePair<string, RangeAttribute> statEffect in template.statEffects) { var statKey = statEffect.Key; var range = statEffect.Value; consumable.statEffects[statKey] = Random.Range(range.min, range.max); } return consumable; }
/// <summary> /// Constructor. /// Generates an instance of <c>MarketItem</c> from a <c>JSONObject<c>. /// </summary> /// <param name="jsonObject">A <c>JSONObject</c> representation of the wanted /// <c>MarketItem</c>.</param> public MarketItem(JSONObject jsonObject) { string keyToLook = ""; #if UNITY_IOS && !UNITY_EDITOR keyToLook = JSONConsts.MARKETITEM_IOS_ID; #elif UNITY_ANDROID && !UNITY_EDITOR keyToLook = JSONConsts.MARKETITEM_ANDROID_ID; #endif if (!string.IsNullOrEmpty(keyToLook) && jsonObject.HasField(keyToLook)) { ProductId = jsonObject[keyToLook].str; } else { ProductId = jsonObject[JSONConsts.MARKETITEM_PRODUCT_ID].str; } Price = jsonObject[JSONConsts.MARKETITEM_PRICE].n; int cOrdinal = System.Convert.ToInt32(((JSONObject)jsonObject[JSONConsts.MARKETITEM_CONSUMABLE]).n); if (cOrdinal == 0) { this.consumable = Consumable.NONCONSUMABLE; } else if (cOrdinal == 1){ this.consumable = Consumable.CONSUMABLE; } else { this.consumable = Consumable.SUBSCRIPTION; } if (jsonObject[JSONConsts.MARKETITEM_MARKETPRICE]) { this.MarketPrice = jsonObject[JSONConsts.MARKETITEM_MARKETPRICE].str; } else { this.MarketPrice = ""; } if (jsonObject[JSONConsts.MARKETITEM_MARKETTITLE]) { this.MarketTitle = jsonObject[JSONConsts.MARKETITEM_MARKETTITLE].str; } else { this.MarketTitle = ""; } if (jsonObject[JSONConsts.MARKETITEM_MARKETDESC]) { this.MarketDescription = jsonObject[JSONConsts.MARKETITEM_MARKETDESC].str; } else { this.MarketDescription = ""; } }
public bool IsUseable(Consumable Consumable, Character Char) { foreach (string check in Consumable.UseableChecks) { switch (check) { case "IsAlive": if (!Char.IsAlive) return false; break; case "NotFullMP": if (Char.MP == Char.MaxMP) return false; break; case "NotFullHP": if (Char.HP == Char.MaxHP) return false; break; } } return true; }
public override bool Initialize(GameObject gameObject) { this.consumable = gameObject.GetComponent <Consumable>(); return(consumable != null && base.Initialize(gameObject)); }
public void OnConsume(MobileEntity entity, Consumable item) { entity.SendLocalizedMessage(6300345); entity.ApplyDamage(entity, 10); }
public void OnConsume(MobileEntity entity, Consumable item) { entity.Poison(item.Owner, new Poison(TimeSpan.Zero, _potency)); }
private void LoadGame() { GameData data = SaveSystem.Load(); if (data != null) { PlayerController.IS_FIRST_GAME = data.is_firstGame; loaded = data; PlayerController.Player.currentStats[(int)StatType.Health] = data.health; PlayerController.Player.currentStats[(int)StatType.Hunger] = data.hunger; PlayerController.Player.currentStats[(int)StatType.Thirst] = data.thirst; PlayerController.Player.currentStats[(int)StatType.Energy] = data.energy; UpdateGameClock(data.gameClock); foreach (string s in data.consumables) { Consumable c = Instantiate(Resources.Load("Items/Consumables/" + s) as Consumable); if (c != null) { InventoryManager.Inventory.AddItem(c); } } for (int i = 0; i < data.equipment.Count; i++) { Gear g = Instantiate(Resources.Load("Items/Gear/" + data.equipment[i]) as Gear); g.liveGear = data.equipementLife[i]; if (g != null) { InventoryManager.Inventory.AddItem(g); } } foreach (string s in data.junks) { Junk j = Instantiate(Resources.Load("Items/Junks/" + s) as Junk); if (j != null) { InventoryManager.Inventory.AddItem(j); } } foreach (string s in data.resources) { Resource r = Instantiate(Resources.Load("Items/Resources/" + s) as Resource); if (r != null) { InventoryManager.Inventory.AddItem(r); } } for (int i = 0; i < data.equippedGear.Count; i++) { Gear equipped = Resources.Load("Items/Gear/" + data.equippedGear[i]) as Gear; if (equipped != null) { Debug.Log(equipped + " is equipped"); foreach (Gear g in InventoryManager.Inventory.GetItems(typeof(Gear))) { if (g.IsSameAs(equipped) && g.liveGear == data.equippedGearLife[i]) { Debug.Log(g + " is equivalent to " + equipped); PlayerController.Player.EquipGear(g); } } } } Debug.Log("Save loaded!"); NewGame = false; if (data.isSleeping) { BackgroundTasks.Tasks.IsSleeping = true; BackgroundTasks.Tasks.StartSleeping = GameData.ConvertStringToDateTime(data.sleepingStartTime); BackgroundTasks.Tasks.EndSleeping = GameData.ConvertStringToDateTime(data.sleepingEndTime); } /*===== SCAVENGING =======*/ if (data.isScavenging) { BackgroundTasks.Tasks.actualScavengingStep = data.scavengingActualStep; BackgroundTasks.Tasks.totalScavengingSteps = data.scavengingTotalSteps; Scavenging scavenging = new Scavenging(); //load itemsfound List <(Item item, Item.ItemClass itemClass)> itemsFound = new List <(Item item, Item.ItemClass itemClass)>(); for (int i = 0; i < data.scavengingItemsFound_itemName.Count; i++) { Item.ItemClass itemC = Item.ConvertStringToItemCLass(data.scavengingItemsFound_itemClass[i]); itemsFound.Add((Item.LoadItem(data.scavengingItemsFound_itemName[i], itemC), itemC)); } scavenging.itemsFound = itemsFound; scavenging.scavengeLog = data.ScavengeLog; scavenging.oldStatusBar = (data.scavengingOldStatusBar[0], data.scavengingOldStatusBar[1], data.scavengingOldStatusBar[2], data.scavengingOldStatusBar[3]); BackgroundTasks.Tasks.lastScavenging = scavenging; List <DateTime> scavengepalier = new List <DateTime>(); foreach (var palier in data.scavengingPalier) { scavengepalier.Add(GameData.ConvertStringToDateTime(palier)); } if (data.scavengingStartTime != null && data.scavengingEndTime != null) { BackgroundTasks.Tasks.StartScavenging = GameData.ConvertStringToDateTime(data.scavengingStartTime); BackgroundTasks.Tasks.EndScavenging = GameData.ConvertStringToDateTime(data.scavengingEndTime); Debug.Log("After loading : " + BackgroundTasks.Tasks.StartScavenging + " - " + BackgroundTasks.Tasks.EndScavenging); } BackgroundTasks.Tasks.scavengingPalier = scavengepalier; BackgroundTasks.Tasks.IsScavenging = true; } else { BackgroundTasks.Tasks.IsScavenging = false; } Debug.Log("New State Of IsScavenging because loaddata" + BackgroundTasks.Tasks.IsScavenging); /*======== END SCAVENGING ========*/ } else { NewGame = true; } }
public ConsumablePartySelectScreen(Consumable Consumable) { this.Consumable = Consumable; selected = 0; Entries = Session.currentSession.Party; }
private static Consumable GenerateConsumable() { StatsType whatStat = ChoosePotStat(); int magnitude = rnd.Next( 10, ((Maze.GetInstance().MazeLevel + 1) * 10) + 1 ) + rnd.Next( -_plusOrMinusToPool, _plusOrMinusToPool ); int duration; if (whatStat == StatsType.CurHp || whatStat == StatsType.CurResources) { whatStat = StatsType.CurHp; // <------- THIS DISABLES MANA POTIONS duration = 0; } else duration = rnd.Next(30, 70); List<EffectInformation> potionEffects = new List<EffectInformation>(); //potionEffects.Add( new EffectInformation( (StatsType) whatStat, magnitude, 0, duration ) ); for (int x = 0; x < ((int)StatsType.Max); x++) { if (x != (int)whatStat) potionEffects.Add(new EffectInformation((StatsType)x, 0)); else potionEffects.Add(new EffectInformation((StatsType)whatStat, magnitude, 0, duration)); } Consumable thePotion = new Consumable(key++, potionEffects, GetPotName(whatStat)); return thePotion; }
private void AddConsumable(Consumable item) { consumables.Add(item); GameSingleton.Instance.uiManager.inventoryUi.UpdateUiConsumable(item); }
// Método que gera um item do tipo Consumível na Lista de Itens public void SetUpConsumable(Consumable menuConsumable) { consumable = menuConsumable; image.sprite = consumable.image; text.text = consumable.itemName; }
private static Consumable MakeConsumable(string section) { Consumable c = new Consumable(); if (section == "IMMUNIZATIONS") { ManufacturedProduct mp = new ManufacturedProduct(); mp.ClassCode = new CS<RoleClassManufacturedProduct>(RoleClassManufacturedProduct.ManufacturedProduct); mp.TemplateId = new LIST<II>(); mp.TemplateId.Add(new II("2.16.840.1.113883.10.20.22.4.54")); mp.ManufacturedDrugOrOtherMaterial = new Material(); Material m = new Material(); m.Code = new CE<string>( "140", "2.16.840.1.113883.12.292", "Vaccines administered (CVX)", null, "Influenza, seasonal, injectable, preservative free", null); m.Code.OriginalText = new ED(); m.Code.OriginalText.MediaType = "text/x-hl7-text+xml"; m.Code.OriginalText.Representation = EncapsulatedDataRepresentation.XML; m.Code.OriginalText.Reference = new TEL(); m.Code.OriginalText.Reference.Value = "#immunization1"; mp.ManufacturedDrugOrOtherMaterial = m; ON on = new ON(); on.Part.Add(new ENXP("Influenza Vaccine Company")); mp.ManufacturerOrganization = new Organization(); mp.ManufacturerOrganization.Name = new SET<ON>(); mp.ManufacturerOrganization.Name.Add(on); c.ManufacturedProduct = new ManufacturedProduct(); c.ManufacturedProduct = mp; } if (section == "MEDICATIONS") { ManufacturedProduct mp = new ManufacturedProduct(); mp.ClassCode = new CS<RoleClassManufacturedProduct>(RoleClassManufacturedProduct.ManufacturedProduct); mp.TemplateId = new LIST<II>(); mp.TemplateId.Add(new II("2.16.840.1.113883.10.20.22.4.23")); mp.ManufacturedDrugOrOtherMaterial = new Material(); Material m = new Material(); m.Code = new CE<string>( "314077", "2.16.840.1.113883.6.88", "RxNorm", null, "Lisinopril 20 MG Oral Tablet", null); m.Code.OriginalText = new ED(); m.Code.OriginalText.MediaType = "text/x-hl7-text+xml"; m.Code.OriginalText.Representation = EncapsulatedDataRepresentation.XML; m.Code.OriginalText.Reference = new TEL(); m.Code.OriginalText.Reference.Value = "#medication1"; mp.ManufacturedDrugOrOtherMaterial = m; c.ManufacturedProduct = new ManufacturedProduct(); c.ManufacturedProduct = mp; } return c; }
public MenuEntryConsumable(Consumable Item, int Count) : base((Item)Item, Count) { }
public Consumable(Consumable consumable) : base(consumable) { this.e = consumable.e; this.consumablePrefab = consumable.consumablePrefab; }
public WebshopItem(Consumable consumable, WebshopViewModel webshopViewModel) { Consumable = consumable; WebshopViewModel = webshopViewModel; ResetAmount(); }
public void RemoveConsumable(Consumable item) { consumables.Remove(item); GameSingleton.Instance.uiManager.inventoryUi.RemoveConsumable(item); }
// Use this for initialization void Start() { invItem = new Item(); invItem.name = gameObject.name; invItem.picture = invPic; invItem.description = description; invItem.isWeapon = isWeapon; invItem.isEquipement = isEquipment; invItem.isConsumable = isConsumable; //invMesh = (GameObject)Resources.Load (gameObject.name); //invItem.itemGameObject = invMesh; if (isWeapon) { WeaponStats wscript = GetComponent <WeaponStats>(); invWep = new Weapon(); if (wscript.isMeleeW) { invWep.wtype = Weapon.type.Melee; } if (wscript.isRangedW) { invWep.wtype = Weapon.type.Ranged; } if (wscript.isMagicW) { invWep.wtype = Weapon.type.Magic; } invWep.wepItem = invItem; invWep.wepAttack = wscript.wAttack; invWep.wepRange = wscript.wRanged; invWep.wepMagic = wscript.wMagic; invMesh = (GameObject)Resources.Load("Weapons/" + gameObject.name); invItem.itemGameObject = invMesh; invItem.description += "\n "; invItem.description += "\n Attack: " + invWep.wepAttack.ToString(); invItem.description += " Ranged: " + invWep.wepRange.ToString(); invItem.description += "\n Magic: " + invWep.wepMagic.ToString(); invItem.description += " Type: " + invWep.wtype.ToString(); } if (isEquipment) { EquipmentStats escript = GetComponent <EquipmentStats>(); invEquip = new Equipment(); invEquip.eItem = invItem; invEquip.eDefense = escript.eDefense; invEquip.eSpeed = escript.eSpeed; invEquip.eHealth = escript.eHealth; invEquip.eMana = escript.eMana; invEquip.slot = escript.slot; invMesh = (GameObject)Resources.Load("Equipment/" + gameObject.name); invItem.itemGameObject = invMesh; //string slotString = "Equipment"; //if(escript.slot == 0) // slotString = "Boots"; //if(escript.slot == 1) // slotString = "Gloves"; //if(escript.slot == 2) // slotString = "Helmet";// invItem.description += "\n "; invItem.description += "\n Defense: " + invEquip.eDefense.ToString(); invItem.description += " Speed: " + invEquip.eSpeed.ToString(); invItem.description += "\n Health: " + invEquip.eHealth.ToString(); invItem.description += " Mana: " + invEquip.eMana.ToString(); } if (isConsumable) { ConsumableStats cscript = GetComponent <ConsumableStats>(); invCons = new Consumable(); invCons.consItem = invItem; invCons.effect = cscript.effectiveness; if (cscript.isCure) { invCons.ctype = Consumable.type.Cure; } if (cscript.isPotion) { invCons.ctype = Consumable.type.Potion; if (cscript.isHpotion) { invCons.cpotion = Consumable.potion.HPotion; invCons.consItem.description = "A potion that restores health"; invCons.consItem.description += "\n Effectiveness: " + invCons.effect + "%"; } if (cscript.isMpotion) { invCons.cpotion = Consumable.potion.MPotion; invCons.consItem.description = "A potion that restores mana"; invCons.consItem.description += "\n Effectiveness: " + invCons.effect + "%"; } } invMesh = (GameObject)Resources.Load("Consumable/" + gameObject.name); invItem.itemGameObject = invMesh; } }
/// <summary> /// Pickup Consumable /// </summary> /// <param name="consumable">consumable</param> public virtual void AddConsumableItem(Consumable consumable) { consumables.Add(consumable); health += consumable.healthIncrease; }
public void AddToConsumable(Consumable consumable) { base.AddObject("Consumable", consumable); }
public ConsumableStack(Consumable consumable, object consumableStats, int count = 1) { this.Consumable = consumable; this.consumableStats = consumableStats; this.count = count; }
/// <summary> /// Constructor. /// </summary> /// <param name="productId">The id of the current item in the market.</param> /// <param name="consumable">The type of the current item in the market.</param> /// <param name="price">The actual $$ cost of the current item in the market.</param> public MarketItem(string productId, Consumable consumable, double price) { this.ProductId = productId; this.consumable = consumable; this.Price = price; }
public void AddConsumable(Consumable consumable) { consumables.Add(consumable); // Adiciona o consumível coletado à lista de consumíveis no inventário }
public ConsumableChangedEventArgs(int slotIndex, Consumable oldValue, Consumable newValue) : base(oldValue, newValue) { this.SlotIndex = slotIndex; }
IEnumerator CookAfter(float time, GameObject Obj, Consumable consu, int index) { FirePlace _fp = this.GetComponentInChildren <FirePlace>(); float iterator = time; //Debug.Log(iterator); bool isRoutine = false; bool stop = false; while (iterator > 0) { Debug.Log("DOWHILE: " + iterator.ToString()); if (isRoutine == false) { if (_fp.isLit == false) { Obj.layer = 8; // COULD MAKE SO IT CARRIES ON IF LIT INSTEAD OF THROWING IT OFF. _CookingSlots[index].used = false; _CookingSlots[index].obj = null; for (int i = 0; i < Obj.GetComponent <ID>().Colliders.Length; i++) { Obj.GetComponent <ID>().Colliders[i].enabled = true; } Obj.GetComponent <Rigidbody>().isKinematic = false; Obj.GetComponent <Rigidbody>().useGravity = true; stop = true; yield return(null); StopCoroutine("CookAfter"); break; } isRoutine = true; yield return(new WaitForSeconds(1)); iterator--; consu.timeToCook--; // remove line if want to start from start isRoutine = false; } } // every second -= 1 // check if fireplace still lit if (stop == false) { Debug.Log("enterpass"); consu.enabled = true; consu.Cook(); Obj.layer = 8; _CookingSlots[index].used = false; _CookingSlots[index].obj = null; for (int i = 0; i < Obj.GetComponent <ID>().Colliders.Length; i++) { Obj.GetComponent <ID>().Colliders[i].enabled = true; } } }
public void OnConsume(MobileEntity entity, Consumable item) { entity.BalmTimer = new BalmTimer(entity); }
private void RecalculateAvailability() { m_button.interactable = GameManager.instance.MoneyManager.GetCurrentMoney() >= Consumable.GetPrice(); }
public void OnConsume(MobileEntity entity, Consumable item) { entity.Health += _amount; }
/// <summary> /// 解析物品信息 /// </summary> void ParseItemJson() { itemList = new List <Item> (); //文本在Unity里面是TextAsset类型 TextAsset itemText = Resources.Load <TextAsset>("Items"); string itemsJson = itemText.text; JSONObject j = new JSONObject(itemsJson); foreach (JSONObject temp in j.list) { string typeStr = temp ["type"].str; Item.ItemType type = (Item.ItemType)System.Enum.Parse(typeof(Item.ItemType), typeStr); //下面是解析这个对象里面的公有属性 int id = (int)temp ["id"].n; string name = temp ["name"].str; Item.ItemQuality quality = (Item.ItemQuality)System.Enum.Parse(typeof(Item.ItemQuality), temp["quality"].str); string description = temp["description"].str; int capacity = (int)temp["capacity"].n; int buyPrice = (int)temp["buyPrice"].n; int sellPrice = (int)temp["sellPrice"].n; string sprite = temp["sprite"].str; Item item = null; switch (type) { case Item.ItemType.Consumable: int hp = (int)temp ["hp"].n; int mp = (int)temp ["mp"].n; item = new Consumable(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, hp, mp); break; case Item.ItemType.Equipment: int strength = (int)temp["strength"].n; int intellect = (int)temp["intellect"].n; int agility = (int)temp["agility"].n; int stamina = (int)temp["stamina"].n; Equipment.EquipmentType equipType = (Equipment.EquipmentType)System.Enum.Parse(typeof(Equipment.EquipmentType), temp["equipType"].str); item = new Equipment(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, strength, intellect, agility, stamina, equipType); break; case Item.ItemType.Weapon: int damage = (int)temp["damage"].n; Weapon.WeaponType wpType = (Weapon.WeaponType)System.Enum.Parse(typeof(Weapon.WeaponType), temp["weaponType"].str); item = new Weapon(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite, damage, wpType); break; case Item.ItemType.Material: item = new Material(id, name, type, quality, description, capacity, buyPrice, sellPrice, sprite); break; } itemList.Add(item); Debug.Log(item.Sprite); } }
public async IAsyncEnumerable <DemandResource <Consumable> > QueryDemandsAsync(Consumable con) { NullCheck.ThrowIfNull <Consumable>(con); var consumable = new ConsumableDemandEntity().Build(con); var maxDistance = con.kilometer; AddressEntity locationOfDemandedConsumable = null; if (con.address.ContainsInformation()) { var consumableAddress = con.address; locationOfDemandedConsumable = new AddressEntity().build(consumableAddress); _addressMaker.SetCoordinates(locationOfDemandedConsumable); } var query = from demand in _context.demand as IQueryable <DemandEntity> join c in _context.demand_consumable on demand.id equals c.demand_id join ad in _context.address on demand.address_id equals ad.Id into tmp from ad in tmp.DefaultIfEmpty() where consumable.category == c.category && !c.is_deleted select new { demand, c, ad }; if (!string.IsNullOrEmpty(consumable.name)) { query = query.Where(collection => consumable.name == collection.c.name); } if (!string.IsNullOrEmpty(consumable.manufacturer)) { query = query.Where(collection => consumable.manufacturer == collection.c.manufacturer); } if (consumable.amount > 0) { query = query.Where(collection => consumable.amount <= collection.c.amount); } var results = await query.ToListAsync(); foreach (var data in results) { var resource = new Consumable().build(data.c); // If the query specifies a location but the demand does not, the demand should not be considered. if (locationOfDemandedConsumable != null && data.ad == null) { continue; } if (locationOfDemandedConsumable != null) { var yLatitude = data.ad.Latitude; var yLongitude = data.ad.Longitude; var distance = DistanceCalculator.computeDistance( locationOfDemandedConsumable.Latitude, locationOfDemandedConsumable.Longitude, yLatitude, yLongitude); if (distance > maxDistance && maxDistance != 0) { continue; } resource.kilometer = (int)Math.Round(distance); } var demand = new DemandResource <Consumable>() { resource = resource }; yield return(demand); } }
// PartyMemberAI public void UpdateNew() { if (this.m_mover != null && this.m_mover.AIController == null) { this.m_mover.AIController = this; } if (GameState.s_playerCharacter != null && base.gameObject == GameState.s_playerCharacter.gameObject && PartyMemberAI.DebugParty) { UIDebug.Instance.SetText("Party Debug", PartyMemberAI.GetPartyDebugOutput(), Color.cyan); UIDebug.Instance.SetTextPosition("Party Debug", 0.95f, 0.95f, UIWidget.Pivot.TopRight); } if (this.m_destinationCircleState != null) { if (base.StateManager.IsStateInStack(this.m_destinationCircleState)) { this.ShowDestination(this.m_destinationCirclePosition); } else { this.m_destinationCircleState = null; this.HideDestination(); } } if (GameState.s_playerCharacter != null && GameState.s_playerCharacter.RotatingFormation && this.Selected) { this.ShowDestinationTarget(this.m_desiredFormationPosition); } else { this.HideDestinationTarget(); } if (this.m_revealer != null) { this.m_revealer.WorldPos = base.gameObject.transform.position; this.m_revealer.RequiresRefresh = false; } else { this.CreateFogRevealer(); } if (GameState.Paused) { base.CheckForNullEngagements(); if (this.m_ai != null) { this.m_ai.Update(); } base.DrawDebugText(); return; } if (this.m_ai == null) { return; } if (GameState.Option.AutoPause.IsEventSet(AutoPauseOptions.PauseEvent.EnemySpotted)) { this.UpdateEnemySpotted(); } if (this.QueuedAbility != null && this.QueuedAbility.Ready) { AIState currentState = this.m_ai.CurrentState; Consumable component = this.QueuedAbility.GetComponent <Consumable>(); if (component != null && component.Type == Consumable.ConsumableType.Ingestible) { ConsumePotion consumePotion = this.m_ai.QueuedState as ConsumePotion; if (!(currentState is ConsumePotion) && (consumePotion == null || currentState.Priority < 1)) { ConsumePotion consumePotion2 = AIStateManager.StatePool.Allocate <ConsumePotion>(); base.StateManager.PushState(consumePotion2); consumePotion2.Ability = this.QueuedAbility; AttackBase primaryAttack = this.GetPrimaryAttack(); if (!(primaryAttack is AttackMelee) || !(primaryAttack as AttackMelee).Unarmed) { consumePotion2.HiddenObjects = primaryAttack.GetComponentsInChildren <Renderer>(); } } } else { Attack attack = currentState as Attack; if (this.QueuedAbility.Passive || attack == null) { this.QueuedAbility.Activate(currentState.Owner); } else { Ability ability = AIStateManager.StatePool.Allocate <Ability>(); ability.QueuedAbility = this.QueuedAbility; if (attack != null) { if (attack.CanCancel) { attack.OnCancel(); base.StateManager.PopCurrentState(); base.StateManager.PushState(ability); } else { base.StateManager.QueueStateAtTop(ability); } } else { base.StateManager.PushState(ability); } } } this.QueuedAbility = null; } BaseUpdate(); // modified if (GameState.IsLoading || GameState.s_playerCharacter == null) { return; } if (this.m_alphaControl != null && this.m_alphaControl.Alpha < 1.401298E-45f) { this.m_alphaControl.Alpha = 1f; } if (this.m_mover != null && !GameState.InCombat) { var walk = false; // modified if (GameState.InStealthMode) { // If FastSneak is not enabled we walk if (!IEModOptions.FastSneak) { walk = true; } else { // if the fastSneak mod is active, then check if any enemies are spotted // if so...we walk for (int i = 0; i < PartyMemberAI.PartyMembers.Length; ++i) { var p = PartyMemberAI.PartyMembers[i]; if (p != null && p.m_enemySpotted) { walk = true; break; } } } } // walk mode overrides fast sneak mode if (Mod_NoEngagement_Player.WalkMode) { walk = true; } float num = (!walk) ? this.m_mover.GetRunSpeed() : this.m_mover.GetWalkSpeed(); // modified GameObject[] selectedPartyMembers = PartyMemberAI.SelectedPartyMembers; for (int i = 0; i < selectedPartyMembers.Length; i++) { GameObject gameObject = selectedPartyMembers[i]; if (!(gameObject == null) && !(gameObject == base.gameObject)) { Mover component2 = gameObject.GetComponent <Mover>(); float num2 = (!walk) ? component2.GetRunSpeed() : component2.GetWalkSpeed(); // modified if (num2 < num) { num = component2.DesiredSpeed; } } } if (num < this.m_mover.GetWalkSpeed() * 0.75f) { num = this.m_mover.GetWalkSpeed(); } this.m_mover.UseCustomSpeed(num); } if (this.m_suspicionDecayTimer > 0f) { this.m_suspicionDecayTimer -= Time.deltaTime; } if (this.m_suspicionDecayTimer <= 0f) { for (int j = this.m_detectingMe.Count - 1; j >= 0; j--) { this.m_detectingMe[j].m_time -= (float)AttackData.Instance.StealthDecayRate * Time.deltaTime; if (this.m_detectingMe[j].m_time <= 0f) { this.m_detectingMe.RemoveAt(j); } } } }
/// <summary> /// Initializes a new instance of the <see cref="com.soomla.unity.MarketItem"/> class. /// </summary> /// <param name='productId'> /// The Id of the current item in Google Play or App Store. /// </param> /// <param name='consumable'> /// the Consumable type of the current item in Google Play or App Store. /// </param> /// <param name='price'> /// The actual $$ cost of the current item in Google Play or App Store. /// </param> public MarketItem(string productId, Consumable consumable, double price) { this.ProductId = productId; this.consumable = consumable; this.Price = price; }
public UseItemCombatCommand(Entity issuer, Consumable item) : base(issuer) { this.item = item; }
public virtual void DropItem(ItemSlot p_targetSlot) { if (DragDropManager.Instance.DraggedItem is ItemDragObject) { ItemDragObject itemDragObject = (ItemDragObject)DragDropManager.Instance.DraggedItem; if (itemDragObject.ItemSlot != null) { if (!SwitchItems(p_targetSlot, itemDragObject.ItemSlot, itemDragObject.Item)) { DragDropManager.Instance.CancelDragAction(); } DragDropManager.Instance.EndDragAction(); } } else if (DragDropManager.Instance.DraggedItem is ShopDragObject) { ShopDragObject shopDragObject = (ShopDragObject)DragDropManager.Instance.DraggedItem; Int32 p_targetSlot2 = p_targetSlot.Index; if (p_targetSlot is EquipmentSlot) { Party party = LegacyLogic.Instance.WorldManager.Party; EquipmentSlot equipmentSlot = (EquipmentSlot)p_targetSlot; Equipment equipment = shopDragObject.Item as Equipment; Equipment equipment2 = equipmentSlot.Item as Equipment; Int32 num = 0; if (equipmentSlot.Item != null) { num++; } if (equipment != null && equipment.ItemSlot == EItemSlot.ITEM_SLOT_2_HAND && equipment2 != null && equipment2.ItemSlot != EItemSlot.ITEM_SLOT_2_HAND) { if (equipmentSlot.Index == 0 && equipmentSlot.Parent.ItemSlots[1].Item != null) { num++; } else if (equipmentSlot.Index == 1 && equipmentSlot.Parent.ItemSlots[0].Item != null) { num++; } } Int32 num2 = party.Inventory.GetMaximumItemCount() - party.Inventory.GetCurrentItemCount(); Boolean flag = party.HirelingHandler.HasEffect(ETargetCondition.HIRE_MULE); if (flag) { num2 += party.MuleInventory.GetMaximumItemCount() - party.MuleInventory.GetCurrentItemCount(); } if (!equipmentSlot.Parent.Inventory.IsItemPlaceableAt(shopDragObject.Item, equipmentSlot.Index) || num > num2) { DragDropManager.Instance.CancelDragAction(); DragDropManager.Instance.EndDragAction(); return; } } else if (p_targetSlot.Item != null && !Consumable.AreSameConsumables(shopDragObject.Item, p_targetSlot.Item)) { p_targetSlot2 = -1; } shopDragObject.ItemSlot.Parent.DropCallback(m_inventory, p_targetSlot2); DragDropManager.Instance.EndDragAction(); } else if (DragDropManager.Instance.DraggedItem is LootDragObject) { LootDragObject lootDragObject = (LootDragObject)DragDropManager.Instance.DraggedItem; Int32 p_targetSlot3 = p_targetSlot.Index; if (p_targetSlot.Item != null && !Consumable.AreSameConsumables(lootDragObject.Item, p_targetSlot.Item)) { p_targetSlot3 = -1; } lootDragObject.ItemSlot.Parent.DropCallback(m_inventory, p_targetSlot3); DragDropManager.Instance.EndDragAction(); } else { DragDropManager.Instance.CancelDragAction(); } }
public static Consumable CreateConsumable(int consumableID) { Consumable consumable = new Consumable(); consumable.ConsumableID = consumableID; return consumable; }
public void Put(int id, [FromBody] Consumable consumable) { //Update db.Consumable.Update(consumable); db.SaveChanges(); }
public void removeConsumableItem(int index) { Consumable empty = new Consumable(); itemsList [index] = empty; slots [index] = empty; }
public void Consume(Consumable consumable) { ressources.AddRessource(consumable.ressource.type, consumable.ressource.amount); }
public string Delete([FromBody] Consumable consumable) { db.Consumable.Remove(consumable); db.SaveChanges(); return(JsonConvert.SerializeObject("Ok")); }
public static PlayerEvent Consumable(Consumable consumable) { PlayerEvent ev = new PlayerEvent(consumable.name); ev.type = Type.Consumable; ev.data[consumableKey] = consumable; return ev; }
/// <summary> /// Returns an item from either the gear, consumables, or candles table /// </summary> /// <param name="name"> Name of the item </param> /// <param name="type"> Type of the item (consumable, gear, or candle) </param> /// <param name="dbConnection"> IDbConnectino to get attack with </param> /// <returns> Returns an Attack with the information initialized </returns> public Item GetItemByNameID(string nameID, string type, IDbConnection dbConnection) { using (IDbCommand dbcmd = dbConnection.CreateCommand()) { dbcmd.CommandText = "SELECT * FROM " + type + " WHERE NameID = '" + nameID + "'"; using (IDataReader reader = dbcmd.ExecuteReader()) { Item newItem = null; string subType = ""; string className = ""; string[] effects = new string[3]; int[] values = new int[3]; if (reader.Read()) { if (type == "Consumables") { subType = reader.GetString(2); effects[0] = reader.GetString(3); effects[1] = reader.GetString(5); effects[2] = reader.GetString(7); values[0] = reader.GetInt32(4); values[1] = reader.GetInt32(6); values[2] = reader.GetInt32(8); newItem = new Consumable(nameID, ItemConstants.CONSUMABLE, subType, effects, values); } else if (type == "Gear") { subType = reader.GetString(2); className = reader.GetString(3); effects[0] = reader.GetString(4); effects[1] = reader.GetString(6); effects[2] = reader.GetString(8); values[0] = reader.GetInt32(5); values[1] = reader.GetInt32(7); values[2] = reader.GetInt32(9); newItem = new Gear(nameID, ItemConstants.GEAR, subType, className, effects, values); } else if (type == "Candles") { Attack a = GetAttack(nameID, false, dbConnection); subType = reader.GetString(2); className = reader.GetString(3); effects[0] = reader.GetString(4); effects[1] = reader.GetString(6); effects[2] = reader.GetString(8); values[0] = reader.GetInt32(5); values[1] = reader.GetInt32(7); values[2] = reader.GetInt32(9); newItem = new Candle(nameID, ItemConstants.CANDLE, subType, className, a, effects, values); } else if (type == "Specials") { subType = reader.GetString(2); newItem = new Special(nameID, ItemConstants.SPECIAL, subType); } } if (newItem == null) { Debug.LogError("Item " + nameID + " does not exist in the DB"); } return(newItem); } } }
public void fromJSONObject(JSONObject json) { JSONObject marketItem = json.GetField("marketItem"); JSONObject jsonProductId = marketItem.GetField("productId"); if (jsonProductId != null) { this.productId = marketItem.GetField("productId").str; } else { this.productId = ""; } JSONObject jsonIosId = marketItem.GetField ("iosId"); this.useIos = (jsonIosId != null); if (this.useIos) { this.iosId = jsonIosId.str; } JSONObject jsonAndroidId = marketItem.GetField ("androidId"); this.useAndroid = (jsonAndroidId != null); if (this.useAndroid) { this.androidId = jsonAndroidId.str; } this.price = marketItem.GetField ("price").f; this.consumable = (Consumable)int.Parse(marketItem.GetField("consumable").ToString()); }
protected override Composite CreateBehavior() { return(_root ?? (_root = new PrioritySelector( new Action(c => { if (Me.HealthPercent < 2) { return RunStatus.Failure; } if (Me.HealthPercent < 60 && !Me.IsActuallyInCombat) { WoWItem food = Consumable.GetBestFood(true); CharacterSettings.Instance.FoodName = food != null ? food.Name : string.Empty; Rest.Feed(); return RunStatus.Running; } if (IsInVehicle) { _isBehaviorDone = true; return RunStatus.Success; } WoWUnit Horse = ObjectManager.GetObjectsOfType <WoWUnit>().Where(u => u.Entry == 28782).OrderBy(u => u.Distance).FirstOrDefault(); if (Horse != null) { if (!Me.IsActuallyInCombat) { if (Horse.Distance > 4) { Navigator.MoveTo(Horse.Location); } else { Horse.Interact(); } } if (Me.IsActuallyInCombat) { if (Me.CurrentTarget != null) { if (Me.CurrentTarget.Dead) { Me.ClearTarget(); } else if (Me.CurrentTarget.Entry == 28768) { if (!Me.IsSafelyFacing(Horse)) { Horse.Face(); } } else if (!Me.IsSafelyFacing(Me.CurrentTarget)) { Me.CurrentTarget.Face(); } if (Me.IsMoving) { WoWMovement.MoveStop(); } if (!Me.IsSafelyFacing(Me.CurrentTarget)) { Me.CurrentTarget.Face(); } if (SpellManager.CanCast("Icy Touch")) { SpellManager.Cast("Icy Touch"); } if (SpellManager.CanCast("Plague Strike")) { SpellManager.Cast("Plague Strike"); } if (SpellManager.CanCast("Blood Strike")) { SpellManager.Cast("Blood Strike"); } if (SpellManager.CanCast("Death Coil")) { SpellManager.Cast("Death Coil"); } } } } else { Navigator.MoveTo(Location); } return RunStatus.Running; } )))); }
public static uint Used(Consumable consumable) { if (used.ContainsKey(consumable.ID)) return used[consumable.ID]; return 0; }
private Consumable(Consumable source) : this(source.Name) { }
public override void OnInspectorGUI() { ItemManager im = target as ItemManager; List <Weapon> weapons = new List <Weapon>(); List <Armor> armors = new List <Armor>(); List <Container> containers = new List <Container>(); List <Consumable> consumables = new List <Consumable>(); List <Shield> shields = new List <Shield>(); List <Jewelry> jewelries = new List <Jewelry>(); #region Fill Created Lists for (int i = 0; i < im.itemList.Count; i++) { if (im.itemList[i].GetType() == typeof(Weapon)) { weapons.Add((Weapon)im.itemList[i]); } if (im.itemList[i].GetType() == typeof(Armor)) { armors.Add((Armor)im.itemList[i]); } if (im.itemList[i].GetType() == typeof(Container)) { containers.Add((Container)im.itemList[i]); } if (im.itemList[i].GetType() == typeof(Consumable)) { consumables.Add((Consumable)im.itemList[i]); } if (im.itemList[i].GetType() == typeof(Shield)) { shields.Add((Shield)im.itemList[i]); } if (im.itemList[i].GetType() == typeof(Jewelry)) { jewelries.Add((Jewelry)im.itemList[i]); } } #endregion #region Initialize Button if (GUILayout.Button("Initialize List")) { Weapon newWeapon = (Weapon)ScriptableObject.CreateInstance <Weapon>(); newWeapon.name = "No Item"; newWeapon.description = ""; newWeapon.cost = 0; newWeapon.maxDurability = 0; newWeapon.curDurability = newWeapon.maxDurability; newWeapon.damage = 0; newWeapon.equipType = EquipTag.OneHanded; newWeapon.icon = Resources.Load("icon_emptyItem") as Texture2D; newWeapon.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newWeapon); Armor newArmor1 = (Armor)ScriptableObject.CreateInstance <Armor>(); newArmor1.name = "Shirt"; newArmor1.description = "Keeps the nips nice and fresh."; newArmor1.cost = 10; newArmor1.maxDurability = 100; newArmor1.curDurability = newArmor1.maxDurability; newArmor1.icon = Resources.Load("icon_shirt1") as Texture2D; newArmor1.defense = 1; newArmor1.equipType = EquipTag.Chest; newArmor1.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newArmor1); Armor newArmor2 = (Armor)ScriptableObject.CreateInstance <Armor>(); newArmor2.name = "Gloves"; newArmor2.description = "Helps prevent blisters."; newArmor2.cost = 10; newArmor2.maxDurability = 100; newArmor2.icon = Resources.Load("icon_gloves1") as Texture2D; newArmor2.defense = 1; newArmor2.equipType = EquipTag.Hands; newArmor2.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newArmor2); Armor newArmor3 = (Armor)ScriptableObject.CreateInstance <Armor>(); newArmor3.name = "Pants"; newArmor3.description = "Cold breezes on the privates can be both a blessing and a curse."; newArmor3.cost = 10; newArmor3.maxDurability = 100; newArmor3.curDurability = newArmor3.maxDurability; newArmor3.icon = Resources.Load("icon_pants1") as Texture2D; newArmor3.defense = 1; newArmor3.equipType = EquipTag.Legs; newArmor3.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newArmor3); Armor newArmor4 = (Armor)ScriptableObject.CreateInstance <Armor>(); newArmor4.name = "Sandals"; newArmor4.description = "Only slightly better than going barefoot."; newArmor4.cost = 10; newArmor4.maxDurability = 100; newArmor4.curDurability = newArmor4.maxDurability; newArmor4.icon = Resources.Load("icon_shoes1") as Texture2D; newArmor4.defense = 1; newArmor4.equipType = EquipTag.Feet; newArmor4.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newArmor4); Container newContainer1 = (Container)ScriptableObject.CreateInstance <Container>(); newContainer1.name = "Small Pouch"; newContainer1.description = "Useful for quick access and visibility to small items."; newContainer1.cost = 20; newContainer1.icon = Resources.Load("icon_container1") as Texture2D; newContainer1.holdVolume = 20; newContainer1.equipType = EquipTag.Pouch; newContainer1.id = im.idCount; im.idCount++; im.itemList.Add(newContainer1); Container newContainer2 = (Container)ScriptableObject.CreateInstance <Container>(); newContainer2.name = "Small Bag"; newContainer2.description = "If it fits, it can go in!"; newContainer2.cost = 40; newContainer2.icon = Resources.Load("icon_container1") as Texture2D; newContainer2.holdVolume = 40; newContainer2.equipType = EquipTag.Bag; newContainer2.id = im.idCount; im.idCount++; im.itemList.Add(newContainer2); Jewelry newJewelry = (Jewelry)ScriptableObject.CreateInstance <Jewelry>(); newJewelry.name = "Engagement Ring"; newJewelry.description = "A thing like this would definitely increase a persons moral with it in their possession."; newJewelry.cost = 5000; newJewelry.maxDurability = 100; newJewelry.curDurability = newJewelry.maxDurability; newJewelry.icon = Resources.Load("icon_ring1") as Texture2D; newJewelry.equipType = EquipTag.Jewelry; newJewelry.id = im.idCount; im.idCount++; im.itemList.Add(newJewelry); Weapon newWeapon1 = (Weapon)ScriptableObject.CreateInstance <Weapon>(); newWeapon1.name = "Iron Hatchet"; newWeapon1.description = "Useful for cutting down trees and chopping them into logs."; newWeapon1.cost = 30; newWeapon1.maxDurability = 50; newWeapon1.curDurability = newWeapon1.maxDurability; newWeapon1.damage = 3; newWeapon1.equipType = EquipTag.TwoHanded; newWeapon1.icon = Resources.Load("icon_axe3") as Texture2D; newWeapon1.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newWeapon1); Weapon newWeapon2 = (Weapon)ScriptableObject.CreateInstance <Weapon>(); newWeapon2.name = "Iron Pickaxe"; newWeapon2.description = "Used to mine ore from stone."; newWeapon2.cost = 30; newWeapon2.maxDurability = 50; newWeapon2.curDurability = newWeapon2.maxDurability; newWeapon2.damage = 3; newWeapon2.equipType = EquipTag.TwoHanded; newWeapon2.icon = Resources.Load("icon_pickaxe2") as Texture2D; newWeapon2.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newWeapon2); Weapon newWeapon3 = (Weapon)ScriptableObject.CreateInstance <Weapon>(); newWeapon3.name = "Iron Knife"; newWeapon3.description = "An all purpose cutting knife."; newWeapon3.cost = 30; newWeapon3.maxDurability = 50; newWeapon3.curDurability = newWeapon3.maxDurability; newWeapon3.damage = 3; newWeapon3.equipType = EquipTag.OneHanded; newWeapon3.icon = Resources.Load("icon_dagger2") as Texture2D; newWeapon3.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newWeapon3); } #endregion if (GUILayout.Button("Save/Load")) { saveItemDatabase(); if (im.fm.checkFile("Database/Items.xml") == true) //if file exists, use it { //XmlDocument xmlDoc = im.fm.useXmlFile("Database","Items","xml",false); loadItemDatabase(); } else { Debug.Log("file did not save properly to load"); } } im.idCount = EditorGUILayout.IntField("ID Count: ", im.idCount); //idCount saved in im for variable persistence #region Weapon Dropdown showingWeapons = EditorGUILayout.Foldout(showingWeapons, "Weapons"); //showingWeapons = changes bool by dropdown arrow if (showingWeapons == true) //if true, make the list visible { EditorGUI.indentLevel = 2; //number of times to tab the following guitext for (int i = 0; i < weapons.Count; i++) //display all of the weapons in our database { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(weapons[i].name); if (GUILayout.Button("-")) { im.itemList.Remove(weapons[i]); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; //changes the variable by user input weapons[i].id = int.Parse(EditorGUILayout.TextField("ID: ", weapons[i].id.ToString())); weapons[i].name = EditorGUILayout.TextField("Name: ", weapons[i].name); weapons[i].description = EditorGUILayout.TextField("Description: ", weapons[i].description); weapons[i].cost = EditorGUILayout.IntField("Cost: ", weapons[i].cost); weapons[i].volume = EditorGUILayout.IntField("Volume: ", weapons[i].volume); weapons[i].weight = EditorGUILayout.IntField("Weight: ", weapons[i].weight); weapons[i].equipType = (EquipTag)EditorGUILayout.EnumPopup("Weapon Type: ", weapons[i].equipType); switch (weapons[i].equipType) { case EquipTag.OneHanded: weapons[i].equipType = EquipTag.OneHanded; break; case EquipTag.TwoHanded: weapons[i].equipType = EquipTag.TwoHanded; break; } weapons[i].maxDurability = EditorGUILayout.IntField("Durability: ", weapons[i].maxDurability); weapons[i].curDurability = weapons[i].maxDurability; weapons[i].damage = EditorGUILayout.IntField("Damage: ", weapons[i].damage); weapons[i].icon = (Texture2D)EditorGUILayout.ObjectField(weapons[i].icon, typeof(Texture2D), false); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); //adds space between objects } if (GUILayout.Button("Add New Weapon")) { Weapon newWeapon = (Weapon)ScriptableObject.CreateInstance <Weapon>(); newWeapon.name = "NEW WEAPON"; newWeapon.description = ""; newWeapon.cost = 0; newWeapon.maxDurability = 0; newWeapon.curDurability = newWeapon.maxDurability; newWeapon.damage = 0; newWeapon.equipType = EquipTag.OneHanded; newWeapon.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newWeapon); } EditorGUI.indentLevel = 0; //makes sure only this dropdown is indented } #endregion #region Armor Dropdown showingArmor = EditorGUILayout.Foldout(showingArmor, "Armor"); if (showingArmor == true) { EditorGUI.indentLevel = 2; for (int i = 0; i < armors.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(armors[i].name); if (GUILayout.Button("-")) { im.itemList.Remove(armors[i]); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; armors[i].id = int.Parse(EditorGUILayout.TextField("ID: ", armors[i].id.ToString())); armors[i].name = EditorGUILayout.TextField("Name: ", armors[i].name); armors[i].description = EditorGUILayout.TextField("Description: ", armors[i].description); armors[i].cost = EditorGUILayout.IntField("Cost: ", armors[i].cost); armors[i].volume = EditorGUILayout.IntField("Volume: ", armors[i].volume); armors[i].weight = EditorGUILayout.IntField("Weight: ", armors[i].weight); armors[i].equipType = (EquipTag)EditorGUILayout.EnumPopup("Armor Type: ", armors[i].equipType); switch (armors[i].equipType) { case EquipTag.Head: armors[i].equipType = EquipTag.Head; break; case EquipTag.Chest: armors[i].equipType = EquipTag.Chest; break; case EquipTag.Hands: armors[i].equipType = EquipTag.Hands; break; case EquipTag.Legs: armors[i].equipType = EquipTag.Legs; break; case EquipTag.Feet: armors[i].equipType = EquipTag.Feet; break; } armors[i].maxDurability = EditorGUILayout.IntField("Durability: ", armors[i].maxDurability); armors[i].curDurability = armors[i].maxDurability; armors[i].defense = EditorGUILayout.IntField("Defense: ", armors[i].defense); armors[i].icon = (Texture2D)EditorGUILayout.ObjectField(armors[i].icon, typeof(Texture2D), false); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); //adds space between objects } if (GUILayout.Button("Add New Armor")) { Armor newArmor = (Armor)ScriptableObject.CreateInstance <Armor>(); newArmor.name = "NEW ARMOR"; newArmor.description = ""; newArmor.cost = 0; newArmor.maxDurability = 0; newArmor.curDurability = newArmor.maxDurability; newArmor.defense = 0; newArmor.equipType = EquipTag.Head; newArmor.id = im.idCount; im.idCount++; //don't forget to add the other variable numbers im.itemList.Add(newArmor); } EditorGUI.indentLevel = 0; //makes sure only this dropdown is indented } #endregion #region Container Dropdown showingContainers = EditorGUILayout.Foldout(showingContainers, "Containers"); if (showingContainers == true) { EditorGUI.indentLevel = 2; for (int i = 0; i < containers.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(containers[i].name); if (GUILayout.Button("-")) { im.itemList.Remove(containers[i]); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; containers[i].id = int.Parse(EditorGUILayout.TextField("ID: ", containers[i].id.ToString())); containers[i].name = EditorGUILayout.TextField("Name: ", containers[i].name); containers[i].description = EditorGUILayout.TextField("Description: ", containers[i].description); containers[i].cost = EditorGUILayout.IntField("Cost: ", containers[i].cost); containers[i].volume = EditorGUILayout.IntField("Volume: ", containers[i].volume); containers[i].weight = EditorGUILayout.IntField("Weight: ", containers[i].weight); containers[i].equipType = (EquipTag)EditorGUILayout.EnumPopup("Container Type: ", containers[i].equipType); switch (containers[i].equipType) { case EquipTag.Bag: containers[i].equipType = EquipTag.Bag; break; case EquipTag.Pouch: containers[i].equipType = EquipTag.Pouch; break; } containers[i].holdVolume = EditorGUILayout.IntField("Hold Volume: ", containers[i].holdVolume); containers[i].icon = (Texture2D)EditorGUILayout.ObjectField(containers[i].icon, typeof(Texture2D), false); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); //adds space between objects } if (GUILayout.Button("Add New Container")) { Container newContainer = (Container)ScriptableObject.CreateInstance <Container>(); newContainer.name = "NEW CONTAINER"; newContainer.description = ""; newContainer.cost = 0; newContainer.holdVolume = 0; newContainer.equipType = EquipTag.Bag; newContainer.id = im.idCount; im.idCount++; im.itemList.Add(newContainer); } EditorGUI.indentLevel = 0; //makes sure only this dropdown is indented } #endregion #region Consumable Dropdown showingConsumables = EditorGUILayout.Foldout(showingConsumables, "Consumables"); if (showingConsumables == true) { EditorGUI.indentLevel = 2; for (int i = 0; i < consumables.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(consumables[i].name); if (GUILayout.Button("-")) { im.itemList.Remove(consumables[i]); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; consumables[i].id = int.Parse(EditorGUILayout.TextField("ID: ", consumables[i].id.ToString())); consumables[i].name = EditorGUILayout.TextField("Name: ", consumables[i].name); consumables[i].description = EditorGUILayout.TextField("Description: ", consumables[i].description); consumables[i].cost = EditorGUILayout.IntField("Cost: ", consumables[i].cost); consumables[i].volume = EditorGUILayout.IntField("Volume: ", consumables[i].volume); consumables[i].weight = EditorGUILayout.IntField("Weight: ", consumables[i].weight); consumables[i].icon = (Texture2D)EditorGUILayout.ObjectField(consumables[i].icon, typeof(Texture2D), false); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); //adds space between objects } if (GUILayout.Button("Add New Consumable")) { Consumable newConsumable = (Consumable)ScriptableObject.CreateInstance <Consumable>(); newConsumable.name = "NEW CONSUMABLE"; newConsumable.description = ""; newConsumable.cost = 0; newConsumable.stack = 1; newConsumable.equipType = EquipTag.Other; newConsumable.id = im.idCount; im.idCount++; im.itemList.Add(newConsumable); } EditorGUI.indentLevel = 0; //makes sure only this dropdown is indented } #endregion #region Shield Dropdown showingShields = EditorGUILayout.Foldout(showingShields, "Shields"); if (showingShields == true) { EditorGUI.indentLevel = 2; for (int i = 0; i < shields.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(shields[i].name); if (GUILayout.Button("-")) { im.itemList.Remove(shields[i]); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; shields[i].id = int.Parse(EditorGUILayout.TextField("ID: ", shields[i].id.ToString())); shields[i].name = EditorGUILayout.TextField("Name: ", shields[i].name); shields[i].description = EditorGUILayout.TextField("Description: ", shields[i].description); shields[i].cost = EditorGUILayout.IntField("Cost: ", shields[i].cost); shields[i].volume = EditorGUILayout.IntField("Volume: ", shields[i].volume); shields[i].weight = EditorGUILayout.IntField("Weight: ", shields[i].weight); shields[i].maxDurability = EditorGUILayout.IntField("Durability: ", shields[i].maxDurability); shields[i].curDurability = shields[i].maxDurability; shields[i].guard = EditorGUILayout.IntField("Guard: ", shields[i].guard); shields[i].icon = (Texture2D)EditorGUILayout.ObjectField(shields[i].icon, typeof(Texture2D), false); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); //adds space between objects } if (GUILayout.Button("Add New Shield")) { Shield newShield = (Shield)ScriptableObject.CreateInstance <Shield>(); newShield.name = "NEW SHIELD"; newShield.description = ""; newShield.cost = 0; newShield.maxDurability = 0; newShield.curDurability = newShield.maxDurability; newShield.guard = 0; newShield.equipType = EquipTag.OneHanded; newShield.id = im.idCount; im.idCount++; im.itemList.Add(newShield); } EditorGUI.indentLevel = 0; //makes sure only this dropdown is indented } #endregion #region Jewelry Dropdown showingJewelry = EditorGUILayout.Foldout(showingJewelry, "Jewelries"); if (showingJewelry == true) { EditorGUI.indentLevel = 2; for (int i = 0; i < jewelries.Count; i++) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField(jewelries[i].name); if (GUILayout.Button("-")) { im.itemList.Remove(jewelries[i]); } EditorGUILayout.EndHorizontal(); EditorGUI.indentLevel += 1; jewelries[i].id = int.Parse(EditorGUILayout.TextField("ID: ", jewelries[i].id.ToString())); jewelries[i].name = EditorGUILayout.TextField("Name: ", jewelries[i].name); jewelries[i].description = EditorGUILayout.TextField("Description: ", jewelries[i].description); jewelries[i].cost = EditorGUILayout.IntField("Cost: ", jewelries[i].cost); jewelries[i].volume = EditorGUILayout.IntField("Volume: ", jewelries[i].volume); jewelries[i].weight = EditorGUILayout.IntField("Weight: ", jewelries[i].weight); jewelries[i].maxDurability = EditorGUILayout.IntField("Durability: ", jewelries[i].maxDurability); jewelries[i].curDurability = jewelries[i].maxDurability; jewelries[i].icon = (Texture2D)EditorGUILayout.ObjectField(jewelries[i].icon, typeof(Texture2D), false); EditorGUI.indentLevel -= 1; EditorGUILayout.Space(); //adds space between objects } if (GUILayout.Button("Add New Jewelry")) { Jewelry newJewelry = (Jewelry)ScriptableObject.CreateInstance <Jewelry>(); newJewelry.name = "NEW JEWELRY"; newJewelry.description = ""; newJewelry.cost = 0; newJewelry.maxDurability = 0; newJewelry.curDurability = newJewelry.maxDurability; newJewelry.equipType = EquipTag.Jewelry; newJewelry.id = im.idCount; im.idCount++; im.itemList.Add(newJewelry); } EditorGUI.indentLevel = 0; //makes sure only this dropdown is indented } #endregion }
static void Main(string[] args) { int currentRoom = 0; int currentFloor = 0; //Floor Generation Floor floor1 = new Floor(7); //Room Generation floor1.AddEdge(0, 0, Constants.D_TYPES.UP); floor1.AddEdge(0, 1, Constants.D_TYPES.S); floor1.AddEdge(1, 0, Constants.D_TYPES.N); floor1.AddEdge(1, 2, Constants.D_TYPES.E); floor1.AddEdge(1, 3, Constants.D_TYPES.S); floor1.AddEdge(1, 4, Constants.D_TYPES.W); floor1.AddEdge(2, 1, Constants.D_TYPES.W); floor1.AddEdge(2, 3, Constants.D_TYPES.SW); floor1.AddEdge(3, 1, Constants.D_TYPES.N); floor1.AddEdge(3, 2, Constants.D_TYPES.NE); floor1.AddEdge(4, 1, Constants.D_TYPES.E); floor1.AddEdge(4, 5, Constants.D_TYPES.S); floor1.AddEdge(5, 4, Constants.D_TYPES.N); floor1.AddEdge(5, 6, Constants.D_TYPES.S); floor1.AddEdge(6, 5, Constants.D_TYPES.N); floor1.AddEdge(6, 6, Constants.D_TYPES.DOWN); //Labirinth Generation Labirinth lab = new Labirinth(new Dictionary <int, Floor> { { 0, floor1 } }); //Item Generation lab.floors[0].roomList[3].AddItem(new IronHelm()); lab.floors[0].roomList[2].AddItem(new IronGloves()); lab.floors[0].roomList[0].AddItem(new IronBreast()); lab.floors[0].roomList[4].AddItem(new IronLegs()); lab.floors[0].roomList[6].AddItem(new IronBoots()); lab.floors[0].roomList[5].AddItem(new Bread()); lab.floors[0].roomList[1].AddNpc(new Wolf()); //Monster Generation Console.Write("Enter the name of your hero: "); MainCharacter mc = new MainCharacter(Console.ReadLine()); Console.WriteLine("As you are taking your regular walk, you stumble upon a dungeon."); Console.WriteLine("You decide to take a look, seeing as you have nothing better to do..."); Console.WriteLine("As you walk down the first flight of stairs, you find an Iron Dagger and an Iron Shield."); Console.WriteLine("'Of course you take them with you. (who wouldnt?)"); Console.WriteLine(); mc.Get(new IronDagger()); mc.Get(new IronShield()); Console.WriteLine(); Console.WriteLine("Looks like an adventure is starting..."); Console.WriteLine("(To see all available commands type help)"); String line; String[] commands; while (true) { Console.WriteLine("\n*****************************************************************************************************************\n"); line = Console.ReadLine(); commands = line.Split(null); try { switch (commands[0].ToLower()) { case "help": { Console.WriteLine("Possible Commands:"); Console.Write("n s e w "); Console.Write("ne nw se sw "); Console.Write("up down "); Console.Write("inv drop get "); Console.Write("look hero equip "); Console.Write("unequip item monster "); Console.Write("attack eat summon "); Console.WriteLine("exit"); break; } case "n": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.N) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "s": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.S) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "e": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.E) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "w": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.W) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "ne": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.NE) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "nw": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.NW) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "se": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.SE) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "sw": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; int room = currentRoom; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.SW) { canAdvance = true; room = d.n; } } if (canAdvance) { Console.WriteLine("You advance to room {0}", room); currentRoom = room; } else { Console.WriteLine("No room in that direction"); } break; } case "up": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.UP) { canAdvance = true; } } if (canAdvance) { if (currentFloor == 0) { Console.WriteLine("Seeing as you don't want to die, you leave through the entrance you came."); Console.WriteLine("Thanks for playing."); Console.WriteLine("Press any key to leave the game."); Console.Read(); Environment.Exit(0); } else { currentRoom = lab.floors[--currentFloor].Size - 1; } } else { Console.WriteLine("No stairs in this room..."); } break; } case "down": { List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); bool canAdvance = false; foreach (Direction d in ld) { if (d.d == Constants.D_TYPES.DOWN) { canAdvance = true; } } if (canAdvance) { if (currentFloor == lab.Number - 1) { Console.WriteLine("Congratulations, you reached the last room of the last floor."); Console.WriteLine("Thanks for playing."); Console.WriteLine("Press any key to leave the game."); Console.Read(); Environment.Exit(0); } else { currentFloor++; currentRoom = 0; } } else { Console.WriteLine("No stairs in this room..."); } break; } case "inv": { mc.PrintInv(); break; } case "drop": { if (commands.Length > 1) { String itemName = ""; for (int i = 1; i < commands.Length; i++) { itemName += commands[i]; itemName += " "; } itemName = itemName.Substring(0, itemName.Length - 1); if (mc.IsInInv(itemName.ToLower())) { Item item = mc.GetItem(itemName.ToLower()); mc.Drop(item); lab.floors[currentFloor].roomList[currentRoom].AddItem(item); } else { Console.WriteLine("Can't drop what isn't there"); } } else { Console.WriteLine("Usage: drop <item name>"); } break; } case "get": { if (commands.Length > 1) { String itemName = ""; for (int i = 1; i < commands.Length; i++) { itemName += commands[i]; itemName += " "; } itemName = itemName.Substring(0, itemName.Length - 1); Item item = lab.GetItem(currentFloor, currentRoom, itemName.ToLower()); if (item != null) { mc.Get(item); lab.floors[currentFloor].roomList[currentRoom].RemoveItem(item.name.ToLower()); } else { Console.WriteLine("No such item on the current room"); } } else { Console.WriteLine("Usage: get <item name>"); } break; } case "look": { bool stairsUp = false; bool stairsDown = false; Console.WriteLine("You take a look around...\n"); Dictionary <String, Item> fi = lab.floors[currentFloor].roomList[currentRoom].itemList; if (fi.Count != 0) { TextInfo tf = new CultureInfo("en-US", false).TextInfo; foreach (String s in fi.Keys) { Console.WriteLine("You spot an {0}", tf.ToTitleCase(s)); } } Dictionary <String, Npc> fn = lab.floors[currentFloor].roomList[currentRoom].npcList; if (fn.Count != 0) { TextInfo tf = new CultureInfo("en-US", false).TextInfo; foreach (String s in fn.Keys) { Npc npc = lab.floors[currentFloor].roomList[currentRoom].npcList[s]; if (npc.hp > 0) { Console.WriteLine("You spot a {0} ", tf.ToTitleCase(s)); } else { Console.WriteLine("You spot the corpse of a {0} ", tf.ToTitleCase(s)); } } } Console.WriteLine(); List <Direction> ld = lab.floors[currentFloor].GetSuccessors(currentRoom); foreach (Direction d in ld) { switch (d.d) { case Constants.D_TYPES.UP: { stairsUp = true; break; } case Constants.D_TYPES.DOWN: { stairsDown = true; break; } case Constants.D_TYPES.N: { Console.WriteLine("You spot a door to the North"); break; } case Constants.D_TYPES.S: { Console.WriteLine("You spot a door to the South"); break; } case Constants.D_TYPES.E: { Console.WriteLine("You spot a door to the East"); break; } case Constants.D_TYPES.W: { Console.WriteLine("You spot a door to the West"); break; } case Constants.D_TYPES.NE: { Console.WriteLine("You spot a door to the NorthEast"); break; } case Constants.D_TYPES.NW: { Console.WriteLine("You spot a door to the NorthWest"); break; } case Constants.D_TYPES.SE: { Console.WriteLine("You spot a door to the SouthEast"); break; } case Constants.D_TYPES.SW: { Console.WriteLine("You spot a door to the SouthWest"); break; } } } if (stairsUp) { Console.WriteLine("You spot some stairs Up"); } if (stairsDown) { Console.WriteLine("You spot some stairs Down"); } break; } case "equip": { if (commands.Length > 1) { String itemName = ""; for (int i = 1; i < commands.Length; i++) { itemName += commands[i]; itemName += " "; } itemName = itemName.Substring(0, itemName.Length - 1); if (mc.IsInInv(itemName.ToLower())) { Item item = mc.GetItem(itemName.ToLower()); mc.Equip(item); } else { Console.WriteLine("That is not in your inventory"); } } else { Console.WriteLine("Usage: equip <item name>"); } break; } case "item": { if (commands.Length > 1) { String itemName = ""; for (int i = 1; i < commands.Length; i++) { itemName += commands[i]; itemName += " "; } itemName = itemName.Substring(0, itemName.Length - 1); Item item; int status; // 0, 1, 2 - 0 if it is in inv, 1 if it is in equipped and 2 if it is on the ground if (mc.inv.ContainsKey(itemName)) { item = mc.inv[itemName]; status = 0; } else if (mc.equipment.ContainsKey(itemName)) { item = mc.equipment[itemName]; status = 1; } else { item = lab.floors[currentFloor].roomList[currentRoom]?.itemList[itemName.ToLower()]; status = 2; } if (item != null) { if (item is Weapon) { Weapon w = (Weapon)item; TextInfo tf = new CultureInfo("en-US", false).TextInfo; if (status == 0) { Console.WriteLine("Item Status: Equipped."); } else if (status == 1) { Console.WriteLine("Item Status: In inventory."); } else { Console.WriteLine("Item Status: On the ground."); } Console.WriteLine("Attack: {0}", w.attack); Console.WriteLine("Block: {0}", w.block); Console.WriteLine("Durability: {0}", w.durability); } else if (item is Armor) { Armor a = (Armor)item; TextInfo tf = new CultureInfo("en-US", false).TextInfo; if (status == 0) { Console.WriteLine("Item Status: Equipped."); } else if (status == 1) { Console.WriteLine("Item Status: In inventory."); } else { Console.WriteLine("Item Status: On the ground."); } Console.WriteLine("Item {0} information:", tf.ToTitleCase(a.name)); Console.WriteLine("Block: {0}", a.armor); Console.WriteLine("Durability: {0}", a.durability); } else { // No other items implemented yet } } else { Console.WriteLine("No such item equipped, in inventory or on the ground..."); } } else { Console.WriteLine("Usage: item <item name>"); } break; } case "monster": { if (commands.Length > 1) { String monsterName = ""; for (int i = 1; i < commands.Length; i++) { monsterName += commands[i]; monsterName += " "; } monsterName = monsterName.Substring(0, monsterName.Length - 1); Npc monster; if (lab.floors[currentFloor].roomList[currentRoom].npcList.ContainsKey(monsterName.ToLower())) { monster = lab.floors[currentFloor].roomList[currentRoom].npcList[monsterName.ToLower()]; } else { monster = null; } if (monster != null) { TextInfo tf = new CultureInfo("en-US", false).TextInfo; if (monster.hp > 0) { Console.WriteLine("You spot a monster, upon closer inspection you can see it's stats"); Console.WriteLine("The monster is a {0} and has {1} HP, {2} Attack and {3} armor", tf.ToTitleCase(monster.name), monster.hp, monster.attack, monster.armor); } else { Console.WriteLine("The {0} is already dead...", tf.ToTitleCase(monster.name)); } } else { Console.WriteLine("No such monster in this room..."); } } else { Console.WriteLine("Usage: monster <monster name>"); } break; } case "hero": { Console.WriteLine("Our Hero {0} currently has {1} HP and {2} Armor", mc.Name, mc.Hp, mc.Armor); mc.PrintEquiped(); break; } case "attack": { if (commands.Length > 1) { String monsterName = ""; for (int i = 1; i < commands.Length; i++) { monsterName += commands[i]; monsterName += " "; } Npc monster; monsterName = monsterName.Substring(0, monsterName.Length - 1); if (lab.floors[currentFloor].roomList[currentRoom].npcList.ContainsKey(monsterName.ToLower())) { monster = lab.floors[currentFloor].roomList[currentRoom]?.npcList[monsterName.ToLower()]; } else { monster = null; } if (monster != null) { if (monster.hp > 0) { int attack = mc.Attack(); int damage = attack - monster.armor; int monsterDamage = monster.attack - mc.Armor; TextInfo tf = new CultureInfo("en-US", false).TextInfo; if (damage <= 0) { Console.WriteLine("You attempt to attack the {0} but you deal 0 damage...", tf.ToTitleCase(monster.name)); if (monsterDamage > 0) { if ((mc.Hp - monsterDamage) <= 0) { Console.WriteLine("The {0} deals a fatal blow!", tf.ToTitleCase(monster.name)); Console.WriteLine("An adventure ends..."); Console.WriteLine("Thanks for playing."); Console.WriteLine("Press any key to leave the game."); Console.Read(); Environment.Exit(0); } else { mc.Hp -= monsterDamage; Console.WriteLine("The {0} attacks you back and deals {1} damage!", tf.ToTitleCase(monster.name), monsterDamage); } } else { Console.WriteLine("The {0} attempts to attack you back but your armor prevails", tf.ToTitleCase(monster.name)); } } else { Console.WriteLine("You attack the {0} for {1} points of damage!", tf.ToTitleCase(monster.name), damage); if ((monster.hp - damage) <= 0) { monster.hp = 0; Console.WriteLine("You kill the monster and live to fight another day!"); lab.floors[currentFloor].roomList[currentRoom].npcList[monsterName].hp = 0; } else { monster.hp -= damage; lab.floors[currentFloor].roomList[currentRoom].npcList[monsterName].hp = monster.hp; if (monsterDamage <= 0) { Console.WriteLine("The {0} attacks you back but your armor prevails and he deals 0 damage.", tf.ToTitleCase(monster.name)); } else { if ((mc.Hp - monsterDamage) <= 0) { Console.WriteLine("The {0} deals a fatal blow!", tf.ToTitleCase(monster.name)); Console.WriteLine("An adventure ends..."); Console.WriteLine("Thanks for playing."); Console.WriteLine("Press any key to leave the game."); Console.Read(); Environment.Exit(0); } else { mc.Hp -= monsterDamage; Console.WriteLine("The {0} attacks you back and deals {1} damage!", tf.ToTitleCase(monster.name), monsterDamage); } } } } } else { Console.WriteLine("Calm down... He's already dead..."); } } else { Console.WriteLine("No such monster in this room..."); } } else { Console.WriteLine("Usage: attack <monster name>"); } break; } case "eat": { if (commands.Length > 1) { String itemName = ""; for (int i = 1; i < commands.Length; i++) { itemName += commands[i]; itemName += " "; } itemName = itemName.Substring(0, itemName.Length - 1); if (mc.Hp == 10) { Console.WriteLine("Health is full!"); } else { if (mc.IsInInv(itemName)) { Item item = mc.inv[itemName]; if (item is Consumable) { Consumable c = (Consumable)item; if (mc.Hp + c.amount > 10) { mc.Hp = 10; Console.WriteLine("You're fully healed!"); mc.inv.Remove(c.name); } else { mc.Hp += c.amount; Console.WriteLine("You restore {0} points of health", c.amount); mc.inv.Remove(c.name); } } else { Console.WriteLine("Can't eat that..."); } } else { Console.WriteLine("No such item in yout inventory"); } } } else { Console.WriteLine("Usage: eat <item name>"); } break; } case "summon": { if (commands.Length > 1) { // Not yet implemented } else { Console.WriteLine("Usage: summon <item name>"); } break; } case "exit": { Console.WriteLine(); Console.WriteLine("An adventure ends..."); Console.WriteLine("Thanks for playing."); Console.WriteLine("Press any key to leave the game."); Console.Read(); Environment.Exit(0); break; } default: { Console.WriteLine("Command not recognized..."); break; } } } catch (Exception ex) { Console.WriteLine("Something broke... Here's the message: " + ex.Message); Console.WriteLine("Here's the trace: " + ex.StackTrace); Console.Read(); Environment.Exit(1); } } }
void DrawConsumableList(ItemDataBase control) { ItemIndex = EditorGUILayout.IntSlider("Item Index", ItemIndex, 0, control.ConsumableList.Count - 1); EditorGUILayout.BeginHorizontal(); if(GUILayout.Button("Add Item")) { var newConsume = new Consumable(); newConsume.Type = ItemType.Consumable; control.ConsumableList.Add(newConsume); ItemIndex = control.ConsumableList.Count - 1; } if(GUILayout.Button("Remove Item")) { control.ConsumableList.RemoveAt(ItemIndex); ItemIndex = control.ConsumableList.Count - 1; } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); CommonItemProps(control.ConsumableList[ItemIndex]); }
protected Consumable(Consumable other) : base(other){}