public void PlayerItemPickup(ItemBehavior item) { if (OnPlayerItemPickup != null) { OnPlayerItemPickup(item); } }
public ItemBehavior split(int takeAmount) { if (takeAmount == -1) { ItemBehavior ret = Instantiate(this); ret.amount = amount / 2; amount = amount / 2 + amount % 2; return(ret); } else { if (takeAmount > amount) { return(null); } if (takeAmount < 0) { return(null); } amount -= takeAmount; ItemBehavior ret = Instantiate(this); ret.amount = takeAmount; return(ret); } }
public void OnItemConsumed(Inventory inventory, ItemBehavior item, int count, int equipSlot) { Actor actor = inventory.GetComponent <Actor>(); if (actor != null) { for (int i = 0; i < consumeBuffs.Length; i++) { for (int x = 0; x < consumeBuffs[i].buffs.Length; x++) { GameValueModifier mod = consumeBuffs[i].buffs[x]; if ( mod.modifyValueComponent == GameValue.GameValueComponent.Value || mod.modifyValueComponent == GameValue.GameValueComponent.MinValue || mod.modifyValueComponent == GameValue.GameValueComponent.MaxValue ) { Debug.LogError("non permanent stacked buff found in OnItemConsumed. Buff: " + consumeBuffs[i].name + " on " + name); break; } } actor.AddBuffs(consumeBuffs[i], count, item.GetInstanceID()); } } }
public Item(ItemBehavior i_behave) { _value = i_behave.getValue(); _name = i_behave.getName(); _size = i_behave.getSize(); _cost = i_behave.getCost(); }
private void loadJson() { Inventory inventory = new Inventory(); JsonInterpreter.getDataFromJson <Inventory>(ref inventory, JsonInterpreter.getJsonFromFile("inventory")); if (null != inventory) { //create all dynamic slot foreach (Item item in inventory.items) { //instantiate slot GameObject SlotInstance = Instantiate(SlotPrefab); //update the item component ItemBehavior itemComponent = SlotInstance.GetComponent <ItemBehavior>(); if (itemComponent) { itemComponent.init(item); } //add to the grid SlotInstance.transform.SetParent(this.transform); } } }
public void EquipItem(ItemBehavior item) { if (item.weaponSOAsset.weaponScriptName != null && item.weaponSOAsset.weaponScriptName != "") { WeaponEffect weaponEffect = System.Activator.CreateInstance(System.Type.GetType(item.weaponSOAsset.weaponScriptName), new System.Object[] { this, item }) as WeaponEffect; weaponEffect.RegisterEventEffect(); } }
private void OnPlayerItemPickup(ItemBehavior item) { if (item.ItemSpawnType == ItemType.PauseTimer) { fuelTimerPaused = true; pauseTimer = 3; fuelText.color = Color.yellow; } }
public static void RegisterEventHandler(ItemBehavior BehaviorType, ItemEventHandler EventHandler) { if (!mEventHandlers.ContainsKey(BehaviorType)) { mEventHandlers.Add(BehaviorType, new List <ItemEventHandler>()); } mEventHandlers[BehaviorType].Add(EventHandler); }
public static void RegisterEventHandler(ItemBehavior BehaviorType, ItemEventHandler EventHandler) { if (!mEventHandlers.ContainsKey(BehaviorType)) { mEventHandlers.Add(BehaviorType, new List<ItemEventHandler>()); } mEventHandlers[BehaviorType].Add(EventHandler); }
private void AddBehaviorIfNotExists(string name) { ItemBehavior ib = optionsDic[name]; if (!this._selectedItemBehaviors.Contains(ib)) { this._selectedItemBehaviors.Add(ib); } }
void OnFullTradeSubmit(GameObject[] data, object[] customData, Vector2Int submitType) { if (customData != null) { ItemBehavior item = (ItemBehavior)customData[0]; bool updateButtons = false; Inventory trader = (Inventory)customData[1]; Inventory tradee = (Inventory)customData[2]; // single trade if (submitType.x == FULL_TRADE_SINGLE_TRADE_ACTION) { if (item != null) { Debug.LogError("heyyyy"); if (trader.TransferItemTo(item, 1, tradee)) { updateButtons = true; } } } // take all else if (submitType.x == FULL_TRADE_TRADE_ALL_ACTION) { if (trader.TransferInventoryContentsTo(tradee)) { updateButtons = true; } } //consume on selected inventory else if (submitType.x == FULL_TRADE_CONSUME_ACTION) { if (item != null) { // if (item.OnConsume(trader, GetWorkingInventorySlot(UIType.FullTrade))) { int count = 1; if (item.OnConsume(trader, count, submitType.y)) { updateButtons = true; } } } //change working inventory // else if (submitType == 3) { // } if (updateButtons) { UpdateUIButtons(true, trader, tradee, (int)customData[3], (int)customData[4], (int)customData[5]); UpdateUIButtons(true, tradee, trader, (int)customData[3], (int)customData[5], (int)customData[4]); } } }
private void OnPlayerItemPickup(ItemBehavior item) { if (item.ItemSpawnType == ItemType.Shield) { shieldActive = true; var spriteRenderer = GetComponent <SpriteRenderer>(); spriteRenderer.color = new Color(1f, 1f, 1f, 0.5f); } }
public void DecrecementFurniLimitCache(ItemBehavior Behavior) { if (!mItemLimitCache.ContainsKey(Behavior)) { return; } mItemLimitCache[Behavior]--; }
public void IncrecementFurniLimitCache(ItemBehavior Behavior) { if (!mItemLimitCache.ContainsKey(Behavior)) { mItemLimitCache.Add(Behavior, 1); return; } mItemLimitCache[Behavior]++; }
/// <summary> /// Base constructor /// </summary> public ItemWeapon() : base() { Behavior = new ItemBehavior() { Obtainable = true, Storable = true, RandomDrop = true }; Slot = ItemSlot.OneHandedWeapon; }
private static void UpdateItemOptions() { optionsDic.Clear(); string[] behaviors = AssetDatabase.FindAssets("", new[] { _ITEM_BEHAVIORS_ASSETS_PATH }); foreach (string guid in behaviors) { ItemBehavior ib = AssetDatabase.LoadAssetAtPath <ItemBehavior>(AssetDatabase.GUIDToAssetPath(guid)); string assetName = System.IO.Path.GetFileNameWithoutExtension(AssetDatabase.GUIDToAssetPath(guid)); optionsDic.Add(assetName, ib); } }
public void OnItemDropped(Inventory inventory, ItemBehavior item, int count) { Actor actor = inventory.GetComponent <Actor>(); if (actor != null) { for (int i = 0; i < stashBuffs.Length; i++) { actor.RemoveBuffs(stashBuffs[i], count, item.GetInstanceID()); } } }
public ItemInfo(int id, string name, string description, string icon, string rankicon, int quan, int rank, int behavior, int type)//æž„é€ å‡½æ•° { ItemName = name; ItemDescription = description; ItemIcon = icon; RankIcon = rankicon; ItemQuantity = quan; ItemID = id; ItemRank = rank; itemType = (ItemType)type; itemBehavior = (ItemBehavior)behavior; }
private void GetItem(Game.AddressItem item, int address, int amount) { switch (item) { // logical things does nothing case Game.AddressItem.Passenger: { this.mainWalker.PlaySe(Audio.GetSE(Audio.SE.PickUp)); break; } case Game.AddressItem.IncreaseSpawn: { this.mainWalker.PlaySe(Audio.GetSE(Audio.SE.PowerUp)); break; } case Game.AddressItem.Destination: { int score = this.game.GetScore(); this.scoreText.text = "Score:" + score; this.mainWalker.PlaySe(Audio.GetSE(Audio.SE.DropOff)); break; } // scene has reponsibility for visible things case Game.AddressItem.MoveSpeed: { this.mainWalker.walkSpeed += this.moveSpeedItemValue; this.mainWalker.PlaySe(Audio.GetSE(Audio.SE.PowerUp)); break; } case Game.AddressItem.CameraSpeed: { this.mainCamera.orbitSpeed += this.cameraSpeedItemValue; this.mainWalker.PlaySe(Audio.GetSE(Audio.SE.PowerUp)); break; } case Game.AddressItem.None: // noop case Game.AddressItem.Unavailable: // unexpected default: return; } if (this.placedItems.ContainsKey(address)) { ItemBehavior behavior = this.placedItems[address]; GameObject.Destroy(behavior.gameObject); this.placedItems.Remove(address); } }
[SerializeField] private float itemAttractSpeed; // How fast the item will move towards the player. // Update is called once per frame void FixedUpdate() { Collider2D[] nearbyItems = Physics2D.OverlapCircleAll(transform.position, maxAttractDistance); foreach (Collider2D item in nearbyItems) { ItemBehavior itemComponent = item.GetComponent <ItemBehavior>(); if (itemComponent) { itemComponent.MoveItem(itemAttractSpeed); } } }
void OnQuickInventorySubmit(GameObject[] data, object[] customData, Vector2Int submitType) { if (customData != null) { ItemBehavior item = customData[0] as ItemBehavior; if (item) { int count = 1; // item.OnConsume((Inventory)customData[1], GetWorkingInventorySlot(UIType.QuickInventory)); item.OnConsume((Inventory)customData[1], count, submitType.y); } } CloseQuickInventoryUI(); }
private void OnPlayerItemPickup(ItemBehavior item) { if (item.ItemSpawnType == ItemType.EnemySpeedDown) { if (moveSpeed < 4) { moveSpeed = 2; } else { moveSpeed -= 2; } } }
ItemBehavior GetSelectedItem() { Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit hitInfo; if (Physics.Raycast(ray, out hitInfo)) { ItemBehavior behavior = hitInfo.transform.gameObject.GetComponent <ItemBehavior>(); if (behavior != null) { return(behavior); } } return(null); }
private ItemBehavior[,] MakeBoxes() { ItemBehavior[,] ret = new ItemBehavior[DuelResolve.Range, DuelResolve.Range]; for (int i = 0; i < DuelResolve.Range; i++) { DuelResolve row = _tables[i]; for (int j = 0; j < DuelResolve.Range; j++) { DuelOutcome item = row.Outcomes[j]; ItemBehavior behavior = CreateItem(item); ret[i, j] = behavior; } } return(ret); }
private ItemBehavior CreateItem(DuelOutcome item) { Material newMat = new Material(Mat); GameObject obj = GameObject.CreatePrimitive(PrimitiveType.Cube); obj.name = item.SecondTargetHealth + " duels " + item.FirstTargetHealth + " doing " + item.Damage + " damage"; obj.transform.parent = transform; obj.GetComponent <MeshRenderer>().sharedMaterial = newMat; ItemBehavior behavior = obj.AddComponent <ItemBehavior>(); behavior.Data = item; behavior.Mat = newMat; behavior.Main = this; return(behavior); }
private void PlaceItem(Game.AddressItem item, int address) { ItemBehavior behavior = GameObject.Instantiate <ItemBehavior>(this.itemPool); Vector3 pos = this.map.addressToPos(address); behavior.transform.position = new Vector3( pos.x * MapLoader.FieldUnit.x + MapLoader.FieldUnit.x * 0.5f, pos.y * this.CurrentFloor() * MapLoader.FieldUnit.y + MapLoader.FieldUnit.y * 0.5f, pos.z * MapLoader.FieldUnit.z - MapLoader.FieldUnit.z * 0.5f ); behavior.transform.parent = this.mapRoot.transform; behavior.SetSurface(item); behavior.SetLookAtCamera(this.mainCamera.GetComponent <Camera>()); behavior.gameObject.SetActive(true); this.placedItems.Add(address, behavior); }
void OnQuickTradeSubmit(GameObject[] data, object[] customData, Vector2Int submitType) { if (customData != null) { bool updateButtons = false; Inventory trader = (Inventory)customData[1]; Inventory tradee = (Inventory)customData[2]; // single trade if (submitType.x == QUICK_TRADE_SINGLE_TRADE_ACTION) { ItemBehavior item = (ItemBehavior)customData[0]; if (item != null) { if (trader.TransferItemTo(item, 1, tradee)) { updateButtons = true; } } } // take all else if (submitType.x == QUICK_TRADE_TRADE_ALL_ACTION) { Debug.LogError("trade all"); if (trader.TransferInventoryContentsTo(tradee)) { updateButtons = true; } } else if (submitType.x == QUICK_TRADE_SWITCH_TO_FULL_TRADE_ACTION) { CloseQuickTradeUI(); OpenFullTradeUI(trader); } if (updateButtons) { UpdateUIButtons(true, trader, tradee, (int)customData[3], (int)customData[4], (int)customData[5]); } // } } }
void OnFullInventorySubmit(GameObject[] data, object[] customData, Vector2Int submitType) { if (customData != null) { ItemBehavior item = (ItemBehavior)customData[0]; if (item != null) { Inventory forInventory = (Inventory)customData[1]; bool updateButtons = false; if (submitType.x == FULL_INVENTORY_CONSUME_ACTION) { int count = 1; // if (item.OnConsume(forInventory, GetWorkingInventorySlot(UIType.FullInventory))) { if (item.OnConsume(forInventory, count, submitType.y)) { updateButtons = true; } } // drop else if (submitType.x == FULL_INVENTORY_DROP_ACTION) { int itemIndex; if (forInventory.CanDropItem(item, out itemIndex, out _, false)) { forInventory.DropItem(item, 1, true, itemIndex); updateButtons = true; } } // favorite // else if (submitType == FULL_INVENTORY_FAVORITE_ACTION) { // if (forInventory.FavoriteItem(item)) { // updateButtons = true; // } // } if (updateButtons) { UpdateUIButtons(true, (Inventory)customData[1], (Inventory)customData[2], (int)customData[3], (int)customData[4], (int)customData[5]); } } } }
private void HandleToggleLock() { if (!SelectionLocked) { SelectedItem = GetSelectedItem(); } if (Input.GetMouseButtonDown(0)) { _clickPos = Input.mousePosition; } if (Input.GetMouseButtonUp(0)) { float distance = (Input.mousePosition - _clickPos).magnitude; if (distance < 0.1f) { SelectionLocked = SelectedItem != null ? !SelectionLocked : false; ControlsText.text = GetControlText(); } } }
// Use this for initialization void Start() { //grab the door's collider doorCollider = this.gameObject.GetComponent <BoxCollider2D>(); // if the door is locked make it impassable if (isLocked) { doorCollider.isTrigger = false; } if (aKeyObject != null) { //get the item behavior data off the key object theKey = aKeyObject.GetComponent <ItemBehavior>(); } //if the key has real data if (theKey != null) { //make a key for comparison keyToFitLock = theKey.thisItem; } }
public ItemDefinition(uint Id, uint SpriteId, string Name, ItemType Type, ItemBehavior Behavior, int BehaviorData, ItemStackingBehavior StackingBehavior, ItemWalkableMode Walkable, int RoomLimit, int SizeX, int SizeY, float Height, bool AllowRecycle, bool AllowTrade, bool AllowSell, bool AllowGift, bool AllowInventoryStack) { mId = Id; mSpriteId = SpriteId; mName = Name; mType = Type; mBehavior = Behavior; mBehaviorData = BehaviorData; mStackingBehavior = StackingBehavior; mWalkable = Walkable; mRoomLimit = RoomLimit; mSizeX = SizeX; mSizeY = SizeY; mHeight = Height; mAllowRecycle = AllowRecycle; mAllowTrade = AllowTrade; mAllowSell = AllowSell; mAllowGift = AllowGift; mAllowInventoryStack = AllowInventoryStack; }
public ItemDefinition(uint Id, uint SpriteId, string Name, ItemType Type, ItemBehavior Behavior, int BehaviorData, ItemStackingBehavior StackingBehavior, ItemWalkableMode Walkable, int RoomLimit, int SizeX, int SizeY, float Height, bool AllowRecycle, bool AllowTrade, bool AllowSell, bool AllowGift, bool AllowInventoryStack) { mId = Id; mSpriteId = SpriteId; mName = Name; mType = Type; mBehavior = Behavior; mBehaviorData = BehaviorData; mStackingBehavior = StackingBehavior; mWalkable = Walkable; mRoomLimit = RoomLimit; mSizeX = SizeX; mSizeY = SizeY; mHeight = Height; mAllowRecycle = AllowRecycle; mAllowTrade = AllowTrade; mAllowSell = AllowSell; mAllowGift = AllowGift; mAllowInventoryStack = AllowInventoryStack; }
public void IncrecementFurniLimitCache(ItemBehavior Behavior) { if (!mItemLimitCache.ContainsKey(Behavior)) { mItemLimitCache.Add(Behavior, 1); return; } mItemLimitCache[Behavior]++; }
public void DecrecementFurniLimitCache(ItemBehavior Behavior) { if (!mItemLimitCache.ContainsKey(Behavior)) { return; } mItemLimitCache[Behavior]--; }
private void BeginAnimWalk(ItemBehavior target){ ChangeState(AnimState.Walk); // Pick a new point, and generate a path to it. // Also, reset animation variables. Vector3 destination; if(target != null){ targetItem = target; ChangeState(AnimState.FindFood); destination = target.transform.position; destination.z = this.transform.position.z; }else{ ChangeState(AnimState.Walk); destination = pathfinder.RandomPoint(); } animatePath = pathfinder.GetPath(transform.position, destination); animateTimer = 0; animateStep = 0; CheckForTurn(); }