public bool ApplyItemEffect(ItemEffect effect) { int mpChangeIndicator = GetStatByName(effect.TargetStat); if(mpChangeIndicator == -1) return false; int mpChange = (int)(effect.FixedEffect * effect.ScalingEffect); string statName = effect.TargetStat.ToLower(); switch(statName) { case "mp": if(mpChange > 0) Gain(mpChange); else Lose(mpChange); break; case "max mp": MaxMP += mpChange; break; case "effective max mp": if(mpChange > 0) RaiseEffectiveMaxMP(mpChange); else LowerEffectiveMaxMP(mpChange); break; default: throw new Exception("Unexpected Health System stat name: " + statName); } return true; }
//TMs public ItemData(int tmNo, string name, ItemType itemType, BattleType battleType, string description, int price) { this.tmNo = tmNo; this.name = name; this.itemType = itemType; this.battleType = battleType; this.description = description; this.price = price; this.itemEffect = ItemEffect.TM; }
public ItemData(string name, ItemType itemType, BattleType battleType, string description, int price, ItemEffect itemEffect) { this.name = name; this.itemType = itemType; this.battleType = battleType; this.description = description; this.price = price; this.itemEffect = itemEffect; }
public void TestBuildItemEffect() { var ip = new ItemProvider(); var item = new Item(); var effects = new ItemEffect[] { new ItemEffect() { Quality = 100, Effects = new [] { new Effect() { Type = EFFECT_TYPE.ATTACK_ADD, Value = 10 }, new Effect() { Type = EFFECT_TYPE.ATTACK_ADD, Value = 1 } } }, new ItemEffect() { Quality = 80, Effects = new [] { new Effect() { Type = EFFECT_TYPE.ATTACK_ADD, Value = 8 }, new Effect() { Type = EFFECT_TYPE.ATTACK_ADD, Value = 2 } } }, new ItemEffect() { Quality = 0, Effects = new [] { new Effect() { Type = EFFECT_TYPE.ATTACK_ADD, Value = 7 }, new Effect() { Type = EFFECT_TYPE.ATTACK_ADD, Value = 3 } } } }; item = ip.BuildItem(80, item, effects); Assert.AreEqual(EFFECT_TYPE.ATTACK_ADD, item.Effects[0].Type); Assert.AreEqual(20, item.Effects[0].Value); }
//Last arguement ex: Ether adds'10f' pp, or pokeball effect is 'x1'(1f). public ItemData(string name, ItemType itemType, BattleType battleType, string description, int price, ItemEffect itemEffect, float floatParameter) { this.Name = name; this.Item_Type = itemType; this.Battle_Type = battleType; this.Description = description; this.Price = price; this.Item_Effect = itemEffect; this.FloatParameter = floatParameter; }
public Item(int id, string name, string description, float weight, int type) { this.id = id; this.name = name; this.description = description; this.weight = weight; this.type = type; effect = null; LoadIcon(); }
protected void StartEffect(ItemEffect effect) { Debug.LogError("startffect"); effect.effectInstance = Instantiate(effect.prefab); if (effect.parentPlayer && player != null) { effect.effectInstance.transform.parent = player.effectsParent; } effect.effectInstance.transform.localPosition = effect.relativePosition; }
// Clone public static ItemEffect Clone(ItemEffect original) { ItemEffect cloneEffect = new ItemEffect( effectType: original.effectType, boolParams: original.boolParams, floatParams: original.floatParams, stringParams: original.stringParams ); return(cloneEffect); }
private void ChangePlayerStatus(ItemEffect item) { Core.ResetPlayerParameter(); if (currentCoroutine != null) { _isItemEnabled.Value = false; StopCoroutine(currentCoroutine); } currentCoroutine = StartCoroutine(ItemCoroutine(item)); }
public static Item getPoison(AssetData assetData) { var iEffect = new ItemEffect(EffectType.DamageEnemy, 5, 5); var i = new Item("Poison", 1, 5, new List <ItemEffect> () { iEffect }); i.itemSprite = getItemSprite(assetData); return(i); }
public static Item getGrenade(AssetData assetData) { var iEffect = new ItemEffect(EffectType.DamageEnemy, 25, 1); var i = new Item("Grenade", 1, 5, new List <ItemEffect> () { iEffect }); i.itemSprite = getItemSprite(assetData); return(i); }
public static Item getRegenPotion(AssetData assetData) { var iEffect = new ItemEffect(EffectType.HealSelf, 5, 5); var i = new Item("Regen Potion", 1, 5, new List <ItemEffect> () { iEffect }); i.itemSprite = getItemSprite(assetData); return(i); }
public ItemData(string name, ItemType itemType, BattleType battleType, string description, int price, ItemEffect itemEffect, float floatParameter) { this.name = name; this.itemType = itemType; this.battleType = battleType; this.description = description; this.price = price; this.itemEffect = itemEffect; this.floatParameter = floatParameter; }
// Constructor public ItemData(string ID, string baseID = null, string itemName = null, ItemPocket pocket = ItemPocket.None, ItemBattlePocket battlePocket = ItemBattlePocket.None, bool useBaseAesthetic = false, string displayID = null, string bagDisplayID = null, bool combineBaseTags = false, IEnumerable <ItemTag> tags = null, ItemEffect[] effects = null, bool combineBaseEffects = false, EffectDatabase.ItemEff.ItemEffect[] effectsNew = null) { this.ID = ID; this.baseID = baseID; this.itemName = itemName; this.pocket = pocket; this.battlePocket = battlePocket; this.useBaseAesthetic = useBaseAesthetic; this.displayID = displayID; this.bagDisplayID = bagDisplayID; this.combineBaseTags = combineBaseTags; this.tags = new HashSet <ItemTag>(); if (tags != null) { this.tags.UnionWith(tags); } this.effects = (effects == null) ? new ItemEffect[0] : new ItemEffect[effects.Length]; if (effects != null) { for (int i = 0; i < effects.Length; i++) { this.effects[i] = ItemEffect.Clone(effects[i]); } } this.combineBaseEffects = combineBaseEffects; this.effectsNew = new List <EffectDatabase.ItemEff.ItemEffect>(); if (effectsNew != null) { List <EffectDatabase.ItemEff.ItemEffect> addableEffects = new List <EffectDatabase.ItemEff.ItemEffect>(); for (int i = 0; i < effectsNew.Length; i++) { addableEffects.Add(effectsNew[i].Clone()); } this.effectsNew = addableEffects; } }
private IEnumerator ItemCoroutine(ItemEffect item) { CurrentItem = item.ItemType; _isItemEnabled.Value = true; Core.SetPlayerParameter(item.PowerUpParameters); yield return(new WaitForSeconds(item.DurationTime)); _isItemEnabled.Value = false; Core.ResetPlayerParameter(); }
public void SetItemEffect(ItemEffect effect) { if (effect == ItemEffect.shield) { if (shield_time < 0.1f) { shield_time += 10; if (lvlController.score >= 5000) { shield_time += 10; } if (lvlController.score >= 7500) { shield_time += 5; } shield_c = StartCoroutine(Shield()); } else { StopCoroutine(shield_c); shield_time += 10; shield_c = StartCoroutine(Shield()); } } if (effect == ItemEffect.health_up) { life++; } if (effect == ItemEffect.speed_up) { speed++; if (speed >= 12) { fire_level = 12; } } if (effect == ItemEffect.fire_rate_up) { fire_rate -= 0.02f; if (fire_rate <= 0.2f) { fire_rate = 0.2f; } } if (effect == ItemEffect.fire_lvl_up) { fire_level++; if (fire_level >= 3) { fire_level = 3; } } }
//quando a gente encostar em algum dos itens, essa função vai ser responsavel por dizer qual o efeito public void SetItemEffect(ItemEffect effect) { if (effect == ItemEffect.levelUp) { int danoLevel = 0; danoLevel++; if (danoLevel >= 3) { danoLevel = 3; } } }
public int getProductId() { ItemEffect e = item.getEffect(); if (e.name != "Seed") { Debug.Log("ERROR : ITEM IS NOT SEED"); } int product = e.parameters[1]; return(product); }
public void DealDamage() { Debug.Log(PlayerItems.Count); for (int i = 0; i < PlayerItems.Count; i++) { ItemEffect effect = (ItemEffect)PlayerItems[i].GetComponent(typeof(ItemEffect)); effect.PassiveOnAttackEffect(); } StartCoroutine(GoForward()); GameObject.Find("CurrentEnemy").GetComponent <AudioSource>().Play(); GameObject.Find("CurrentEnemy").GetComponent <CurrentEnemyData>().enemyCurrentHealth -= intendedDamage; }
public void MapBlob() { var parsed = JSON.Parse(RawBlob); var items = parsed["Items"].AsArray; Items = new List <InventoryItem>(); foreach (var item in items.Childs) { InventoryItem newItem = new InventoryItem(); newItem.Name = item["Name"]; newItem.Description = item["Description"]; newItem.Value = item["Value"].AsInt; string itemType = item["ItemType"]; newItem.ItemType = (ItemType)Enum.Parse(typeof(ItemType), itemType); newItem.Quantity = 0; var equipEffects = item["EquipmentEffects"].AsArray; newItem.EquipmentEffects = new List <ItemEffect>(); foreach (var effect in equipEffects.Childs) { ItemEffect newEquipEffect = new ItemEffect(); newEquipEffect.TargetStat = effect["TargetStat"]; newEquipEffect.FixedEffect = effect["FixedEffect"].AsInt; newEquipEffect.ScalingEffect = effect["ScalingEffect"].AsFloat; newEquipEffect.EffectDuration = effect["EffectDuration"].AsFloat; newItem.EquipmentEffects.Add(newEquipEffect); } var consumeEffects = item["ConsumeEffects"].AsArray; newItem.ConsumeEffects = new List <ItemEffect>(); foreach (var effect in consumeEffects.Childs) { ItemEffect newUseEffect = new ItemEffect(); newUseEffect.TargetStat = effect["TargetStat"]; newUseEffect.FixedEffect = effect["FixedEffect"].AsInt; newUseEffect.ScalingEffect = effect["ScalingEffect"].AsFloat; newUseEffect.EffectDuration = effect["EffectDuration"].AsFloat; newItem.ConsumeEffects.Add(newUseEffect); } Items.Add(newItem); } }
public async Task <int> CreateItemEffect(ItemEffect use) { int output = (await dbConnection.QueryAsync <int>(@"INSERT INTO itemEffects(itemUseId, itemTypeId, effectType, effectParameters) VALUES(@itemUseId, @itemTypeId, @effectType, @json::json) RETURNING id", new { itemUseId = (int)use.ItemUseId, itemTypeId = use.ItemTypeId, effectType = (int)use.EffectType, json = JsonConvert.SerializeObject(use.EffectParameters, settings) })).First(); return(output); }
// get how many days are left public int getLeftDay(int day) { ItemEffect e = item.getEffect(); if (e.name != "Seed") { Debug.Log("ERROR : CULTIVATING ITEM IS NOT SEED"); } int requiredDay = e.parameters[0]; int passedDay = day - startDay; return(requiredDay - passedDay); }
public override void DrawCell(int index, int count = 0) { base.DrawCell(index, count); var dataList = itemPackage.GetItemEffectList(); if (index >= dataList.Count) { return; } ItemEffect effect = dataList[index]; nameLabel.text = effect.name + ":"; valueLabel.text = effect.value; }
public void SetItemEffect(ItemEffect effect) { if (effect == ItemEffect.shild) { } if (effect == ItemEffect.fire_lvl_up) { fire_level++; if (fire_level >= 3) { fire_level = 3; } } }
// for sequenceequal in itempack public override bool Equals(object obj) { if (obj.GetType() != typeof(ItemEffect)) { return(false); } ItemEffect o = (ItemEffect)obj; return(o.Type1 == Type1 && o.Type2 == Type2 && o.Value1 == Value1 && o.Value2 == Value2); }
private string generateProductText(ItemEffect effect) { string text = ""; List <int> param = effect.parameters; string product = ItemDatabase.findNameById(param[1]); int productCount = param[2]; string seed = ItemDatabase.findNameById(param[3]); int seedCount = param[4]; text += product + " x " + productCount.ToString() + '\n'; text += seed + " x " + seedCount.ToString(); return(text); }
private Sprite icon; // Item icon public Item(int id, string name, string description, float weight, int type, ItemEffect effect) { this.id = id; this.name = name; this.description = description; this.weight = weight; this.effect = effect; this.type = type; if (effect.name.Equals("Protection")) { this.armor = effect.parameters[0]; } LoadIcon(); }
public static void Use(ItemEffect effect, Item item) //maybe eventually pass unit component refs to effect specific gameobject? { if (effect == ItemEffect.Equip) { EquipToPlayer(item); } else if (effect == ItemEffect.HealthPotion) { HealthPotion(item); } else if (effect == ItemEffect.NA) { return; } }
public Item(string itemName, ItemType itemtype, ItemEffect itemEff, int itemAmount = 1, bool equiped = false, int AmountRestored = -1, int Damage = -1, int HP = -1, int MP = -1, int Defence = -1, int Str = -1, int Int = -1, int Dex = -1) { this.mItemEff = itemEff; this.mItemName = itemName; this.mItemAmount = itemAmount; this.mEquiped = equiped; this.mAmountRestored = AmountRestored; this.mDefense = Defence; this.mDam = Damage; this.mItemtype = itemtype; this.mStrength = Str; this.mHealth = HP; this.mMP = MP; this.mDexterity = Dex; this.mIntelligence = Int; if (mItemtype == ItemType.equipmentWeapon || mItemtype == ItemType.equipmentHelm || mItemtype == ItemType.equipmentChest) { if (mStrength < 0) { mStrength = 0; } if (mDexterity < 0) { mDexterity = 0; } if (mIntelligence < 0) { mIntelligence = 0; } if (mDefense < 0) { mDefense = 0; } if (mDam < 0) { mDam = 0; } if (mHealth < 0) { mHealth = 0; } if (mMP < 0) { mMP = 0; } } }
private void Awake() { animator = GetComponent <Animator>(); animator.runtimeAnimatorController = data.animatorController; if (data.itemEffect != null) { itemEffect = (ItemEffect)gameObject.AddComponent(data.itemEffect.GetType()); itemEffect.item = this; } if (data.decays) { gameObject.AddComponent(typeof(ItemDecay)); } rb = GetComponent <Rigidbody>(); itemCollider = GetComponent <Collider>(); }
// Use this for initialization void Start() { if (networkView.isMine) { boxRect = new Rect(nativeWidth - 565, nativeHeight - 300, 210, 240); goldLabel = new Rect(nativeWidth - 550, nativeHeight - 90, 100, 40); coinRect = new Rect(nativeWidth - 475, nativeHeight - 80, 15, 15); itemEf = gameObject.GetComponent <ItemEffect>(); soundEffects = GameObject.Find("AudioEffectsManager").GetComponent <SoundEffects>(); texInv = null; } }
public void RemoveItemEffect(ItemEffect effect) { bool applied = Health.RemoveItemEffect(effect); if(applied) return; ModifiableStat stat = GetStatByName(effect.TargetStat); if(stat != default(ModifiableStat)) { stat.FixedModifier -= effect.FixedEffect; stat.ScalingModifier -= effect.ScalingEffect - 1; } }
private void SetDefaults() { Consumes = CONSUMES_DEFAULT; ConsumeRate = CONSUMERATE_DEFAULT; UseCooldown = USECOOLDOWN_DEFAULT; Name = ""; Description = DESCRIPTION_DEFAULT; MaxAmount = MAXAMOUNT_DEFAULT; TypeWhenEmpty = -1; PassiveEffects = new ItemEffect[0]; ActiveEffects = new ItemEffect[0]; }
public bool RemoveItemEffect(ItemEffect effect) { int hpChangeIndicator = GetStatByName(effect.TargetStat); if(hpChangeIndicator == -1) return false; int hpChange = (int)(effect.FixedEffect * effect.ScalingEffect); string statName = effect.TargetStat.ToLower(); switch(statName) { case "hp": HP -= hpChangeIndicator; break; case "max hp": MaxHP -= hpChange; break; case "effective max hp": EffectiveMaxHP -= hpChange; break; default: throw new Exception("Unexpected Health System stat name: " + statName); } return true; }