public CraftingInventoryWorkbenchCB(InventoryPlayer inventoryplayer, World world, int i, int j, int k) { craftMatrix = new InventoryCrafting(this, 3, 3); craftResult = new InventoryCraftResult(); field_20150_c = world; field_20149_h = i; field_20148_i = j; field_20147_j = k; addSlot(new SlotCrafting(craftMatrix, craftResult, 0, 124, 35)); for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 3; k1++) { addSlot(new Slot(craftMatrix, k1 + l * 3, 30 + k1 * 18, 17 + l * 18)); } } for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { addSlot(new Slot(inventoryplayer, l1 + i1 * 9 + 9, 8 + l1 * 18, 84 + i1 * 18)); } } for (int j1 = 0; j1 < 9; j1++) { addSlot(new Slot(inventoryplayer, j1, 8 + j1 * 18, 142)); } onCraftMatrixChanged(craftMatrix); }
void Awake() { m_MotionController = GetComponent <MotionController>(); m_InventoryPlayer = GetComponent <InventoryPlayer>(); // Initialise speed overrides speedOverrides = new DataOverride[m_SpeedData.Length]; for (int i = 0; i < speedOverrides.Length; ++i) { speedOverrides[i] = new DataOverride { name = m_SpeedData[i] } } ; // Initialise strength overrides strengthOverrides = new DataOverride[m_StrengthData.Length]; for (int i = 0; i < strengthOverrides.Length; ++i) { strengthOverrides[i] = new DataOverride { name = m_StrengthData[i] } } ; } IEnumerator Start() { yield return(null); m_SpeedStat = m_InventoryPlayer.stats.Get(m_SpeedStatCategory, m_SpeedStatName); m_StrengthStat = m_InventoryPlayer.stats.Get(m_StrengthStatCategory, m_StrengthStatName); m_MotionController.motionGraph.ApplyDataOverrides(this); }
public ContainerWorkbench(InventoryPlayer par1InventoryPlayer, World par2World, int par3, int par4, int par5) { CraftMatrix = new InventoryCrafting(this, 3, 3); CraftResult = new InventoryCraftResult(); WorldObj = par2World; PosX = par3; PosY = par4; PosZ = par5; AddSlot(new SlotCrafting(par1InventoryPlayer.Player, CraftMatrix, CraftResult, 0, 124, 35)); for (int i = 0; i < 3; i++) { for (int l = 0; l < 3; l++) { AddSlot(new Slot(CraftMatrix, l + i * 3, 30 + l * 18, 17 + i * 18)); } } for (int j = 0; j < 3; j++) { for (int i1 = 0; i1 < 9; i1++) { AddSlot(new Slot(par1InventoryPlayer, i1 + j * 9 + 9, 8 + i1 * 18, 84 + j * 18)); } } for (int k = 0; k < 9; k++) { AddSlot(new Slot(par1InventoryPlayer, k, 8 + k * 18, 142)); } OnCraftMatrixChanged(CraftMatrix); }
public CraftingInventoryWorkbenchCB(InventoryPlayer inventoryplayer, World world, int i, int j, int k) { craftMatrix = new InventoryCrafting(this, 3, 3); craftResult = new InventoryCraftResult(); field_20150_c = world; field_20149_h = i; field_20148_i = j; field_20147_j = k; addSlot(new SlotCrafting(craftMatrix, craftResult, 0, 124, 35)); for (int l = 0; l < 3; l++) { for (int k1 = 0; k1 < 3; k1++) { addSlot(new Slot(craftMatrix, k1 + l*3, 30 + k1*18, 17 + l*18)); } } for (int i1 = 0; i1 < 3; i1++) { for (int l1 = 0; l1 < 9; l1++) { addSlot(new Slot(inventoryplayer, l1 + i1*9 + 9, 8 + l1*18, 84 + i1*18)); } } for (int j1 = 0; j1 < 9; j1++) { addSlot(new Slot(inventoryplayer, j1, 8 + j1*18, 142)); } onCraftMatrixChanged(craftMatrix); }
void Start() { GameObject go = GameObject.Find("InventoryPlayer" + numberPlayer); if (go != null) { inventoryPlayer = go.GetComponent <InventoryPlayer>(); } else { Debug.Log("NULO EL INVENTARIO"); } rigidbody2 = GetComponent <Rigidbody2D>(); auxLinearDrag = rigidbody2.drag; rigidbody2.velocity = Vector2.zero; auxDelayJump = delayJump; rightVector = new Vector3(transform.right.x, 0, 0); leftVector = new Vector3(-transform.right.x, 0, 0); upVector = new Vector3(0, transform.up.y, 0); downVector = new Vector3(0, -transform.up.y, 0); auxSpeed = speed; if (OnTakePoint != null) { OnTakePoint(inventoryPlayer); } }
public PlayerData(InventoryPlayer inventory) { level = InventoryPlayer.instance.level; position = new float[3]; position[0] = inventory.transform.position.x; position[1] = inventory.transform.position.y; position[2] = inventory.transform.position.z; }
// <inheritdoc /> public void Start() { player = GetComponent<InventoryPlayer>(); eventHandler = GetComponent<CharactersEventHandler>(); player.characterCollection.OnAddedItem += OnAddedItemPly; player.characterCollection.OnRemovedItem += OnRemovedItemPly; player.characterCollection.OnSwappedItems += OnSwappedItemsPly; }
public SupplierPlayer(string name, float money, float markup, float maximumInventorySpace, int shopItemSlotCount) : base(name) { Money = money; MarkupPercentage = markup; CustomerTolerance = 1f; WarehouseInventory = new InventoryPlayer(maximumInventorySpace); Shop = new PlayerShop(shopItemSlotCount); ResetMoneyStart(); }
protected virtual void DrawEquipmentCollections(InventoryPlayer t, CollectionGroup <IEquippableItemInstance, IEquipmentCollection <IEquippableItemInstance> > g) { using (new VerticalLayoutBlock("box")) { GUILayout.Label(new GUIContent("Equipment"), UnityEditor.EditorStyles.boldLabel); foreach (var collection in g.collections) { DrawCollection(collection.collection, collection.priority.GetGeneralPriority()); } } }
protected virtual void DrawCurrencyCollections(InventoryPlayer t, CurrencyCollectionGroup <ICurrency> g) { using (new VerticalLayoutBlock("box")) { GUILayout.Label(new GUIContent("Currencies"), UnityEditor.EditorStyles.boldLabel); foreach (var collection in g.collections) { DrawCollection(collection.collection, collection.priority.GetGeneralPriority()); } } }
public static void SavePlayer(InventoryPlayer inventory) { BinaryFormatter formatter = new BinaryFormatter(); string path = Application.persistentDataPath + "/player.fun"; FileStream stream = new FileStream(path, FileMode.Create); PlayerData data = new PlayerData(inventory); formatter.Serialize(stream, data); stream.Close(); }
public EquippableSlot[] GetEquippableSlots(EquippableInventoryItem item, InventoryPlayer player) { if (player == null || player.characterUI == null) { return(new EquippableSlot[0]); } player.characterUI.IndexManuallyDefinedCollection(); player.characterUI.UpdateEquippableSlots(); return(player.characterUI.GetEquippableSlots(item)); }
private void PositionNow(InventoryPlayer player) { if (_trigger.window.window != null) { _trigger.window.window.transform.position = transform.position; _trigger.window.window.transform.rotation = transform.rotation; _trigger.window.window.transform.Rotate(windowRotationOffset); //+(transform.forward * windowPositionOffset.z) _trigger.window.window.transform.Translate(windowPositionOffset); } }
/// <summary> /// Copy the ItemStack contents from another InventoryPlayer instance /// </summary> public virtual void CopyInventory(InventoryPlayer par1InventoryPlayer) { for (int i = 0; i < MainInventory.Length; i++) { MainInventory[i] = ItemStack.CopyItemStack(par1InventoryPlayer.MainInventory[i]); } for (int j = 0; j < ArmorInventory.Length; j++) { ArmorInventory[j] = ItemStack.CopyItemStack(par1InventoryPlayer.ArmorInventory[j]); } }
private void PositionNow(InventoryPlayer player) { if (triggerer.window != null) { triggerer.window.transform.position = transform.position; triggerer.window.transform.rotation = transform.rotation; triggerer.window.transform.Rotate(windowRotationOffset); //+(transform.forward * windowPositionOffset.z) triggerer.window.transform.Translate(windowPositionOffset); } }
// <inheritdoc /> public void Start() { player = GetComponent <InventoryPlayer>(); eventHandler = GetComponent <CharactersEventHandler>(); if (player.characterUI != null) { player.characterUI.OnAddedItem += OnAddedItemPly; player.characterUI.OnRemovedItem += OnRemovedItemPly; player.characterUI.OnSwappedItems += OnSwappedItemsPly; } }
public void AddPoint(InventoryPlayer inventoryPlayer) { if (inventoryPlayer == null) { return; } //Debug.Log(inventoryPlayer.currentCoin); if (inventoryPlayer.currentCoin >= neededPointsForFinishLevel) { neededPoints = true; } CheckFinishLevel(); }
public void LoadWorld() { string data = SaveSystem.Load(environementName); if (data != null) { saveObject = JsonUtility.FromJson <SaveData> (data); Loader.Scene currentScene = Loader.getCurrentScene(); StartCoroutine(setEnv(saveObject.env)); RessouceGenerator.listSavedRessource = saveObject.listRessource; InventoryPlayer.setSavedInventory(saveObject.inventoryPlayer); QuestManager.SetSavableData(saveObject.questPlayer); } }
private void OnPlayerChanged(InventoryPlayer oldPlayer, InventoryPlayer newPlayer) { // Remove the old if (oldPlayer != null && oldPlayer.characterCollection != null) oldPlayer.characterCollection.OnStatChanged -= Repaint; player = newPlayer; // Add the new if (player.characterCollection != null) { player.characterCollection.OnStatChanged += Repaint; Repaint(player.characterCollection.GetStat(statCategory, statName)); } }
public void removeItemTest() { InventoryPlayer inv = InitInventory(ITEM_REMOVE_TEST); Assert.IsFalse(inv.removeItem(Item.getItem("sword"), 10), "Removed 10 Swords, didn't have 10."); Assert.IsFalse(inv.removeItem(Item.getItem("hpPot"), 5), "Removed 5 hpPot, didn't have 5."); Assert.IsTrue(inv.removeItem(Item.getItem("sword")), "Didn't remove 1 sword, had 1."); Assert.IsFalse(inv.containsItem(Item.getItem("sword")), "Contains a sword, but should have been removed."); Assert.IsTrue(inv.containsItem(Item.getItem("hpPot")), "No longer has a hpPot, but shouldn't have been removed."); Assert.IsTrue(inv.removeItem(Item.getItem("hpPot"))); Assert.IsFalse(inv.containsItem(Item.getItem("sword"))); Assert.IsFalse(inv.containsItem(Item.getItem("hpPot"))); }
//protected virtual void OnDisable() //{ // objectTriggerer.OnPickup -= ObjectTriggererOnPickup; //} protected virtual void ObjectTriggererOnPickup(InventoryPlayer inventoryPlayer) { // Player picked up the item (Triggered by event) #if UFPS_MULTIPLAYER vp_MPNetworkPlayer player; if (!vp_MPNetworkPlayer.Players.TryGetValue(InventoryPlayerManager.instance.currentPlayer.transform, out player)) return; InventoryMPUFPSPickupManager.instance.photonView.RPC("InventoryPlayerPickedUpItem", PhotonTargets.Others, ID, player.ID, transform.position, transform.rotation); #endif }
void HandleTowerPlacementMechanic() { //TOWER PLACING MECHANIC if (Input.GetButtonDown("BuildMode" + this.transform.tag[6]) && showTower[index] != true || Input.GetButtonDown("BuildModeK")) { Debug.DrawRay(transform.position, transform.forward * towerPlacingRange, Color.green, 10f); showTower[index] = true; } if (Input.GetButtonDown("ExitBuildMode" + this.tag[6]) || Input.GetButtonDown("ExitBuildModeK")) { showTower[index] = false; tower.SetActive(false); } if (showTower[index] == true) { if (controller.isDead == true) { tower.SetActive(false); } tower.transform.position = transform.position + (transform.forward * towerPlacingRange); if (tower.activeSelf != true) { tower.SetActive(true); } if ((Input.GetButtonDown("ConfirmBuild" + this.tag[6]) || Input.GetButtonDown("ConfirmBuildK")) && tower.GetComponent <TowerBehaviour>().isColliding != true) { InventoryPlayer inventory = GetComponent <customCharController>().Inventory; Item log = inventory.mItems[0]; //Debug.Log(inventory.mItems.Count + "W"); if (inventory.mItems.Count >= 3) { GameObject placedTower = Instantiate(tower, transform.position + (transform.forward * towerPlacingRange), tower.transform.rotation); tower.SetActive(false); placedTower.GetComponent <TowerBehaviour>().enabled = true; placedTower.SetActive(true); placedTower.GetComponent <TowerBehaviour>().SetOpaque(); placedTower.GetComponent <TowerBehaviour>().isPlaced = true; showTower[index] = false; placedTower.transform.tag = "tower"; inventory.RemoveAllItems(log); } } } }
private void Awake() { if (_instance != null) { Destroy(gameObject); } else { _instance = this; initInventory(); if (background != null) { background.GetComponent <RectTransform> ().anchoredPosition = offsetBackground; } } }
public void addItemTest() { InventoryPlayer inv = InitInventory(ITEM_ADD_TEST); inv.addItem(Item.getItem("sword"), 3); inv.addItem(Item.getItem("hpPot")); inv.addItem(Item.getItem("hpPot"), 50); Assert.IsTrue(inv.containsItem(Item.getItem("sword"), 2)); Assert.IsTrue(inv.containsItem(Item.getItem("sword"), 3)); Assert.IsFalse(inv.containsItem(Item.getItem("sword"), 4)); Assert.IsTrue(inv.containsItem(Item.getItem("hpPot"))); Assert.IsTrue(inv.containsItem(Item.getItem("hpPot"), 5)); Assert.IsTrue(inv.containsItem(Item.getItem("hpPot"), 40)); Assert.IsFalse(inv.containsItem(Item.getItem("hpPot"), 100)); }
void Start() { // Get player m_InventoryPlayer = GetComponent <InventoryPlayer>(); // Get and initialise health stat m_HealthStat = m_InventoryPlayer.stats.Get(m_StatCategory, m_StatName); if (m_HealthStat == null) { Debug.LogError(string.Format("Player health stat not found: {0}.{1}", m_StatCategory, m_StatName)); } else { m_TrackedHealth = m_HealthStat.currentValue; m_HealthStat.OnValueChanged += OnStatValueChanged; } }
public void containsItemTest() { InventoryPlayer inv = InitInventory(ITEM_CONTAINS_TEST); Assert.IsTrue(inv.containsItem(Item.getItem("sword"))); Assert.IsFalse(inv.containsItem(Item.getItem("sword"), 2)); Assert.IsTrue(inv.containsItem(Item.getItem("hpPot"))); Assert.IsFalse(inv.containsItem(Item.getItem("hpPot"), 5)); try { Assert.IsFalse(inv.containsItem(Item.getItem("hpPot"), -1)); Assert.Fail(); } catch (ArgumentException) { } }
private void DoGetStat() { if (player == null) { player = PlayerManager.instance.currentPlayer.inventoryPlayer; } var stat = player.stats.Get(statCategoryName.Value, statName.Value); if (stat == null) { LogWarning("Stat in category " + statCategoryName + " with name " + statName + " does not exist."); return; } result.Value = stat.currentValue; }
public void UpdateScore(InventoryPlayer p) { if (p != null) { if (textScore != null) { textScore.text = "" + p.currentCoin; } if (textNeedScore != null) { if (p.currentCoin <= countNeedScore) { textNeedScore.text = p.currentCoin + "/" + countNeedScore; } } } }
protected virtual void SetItemProperties(InventoryPlayer player, InventoryItemUtility.SetItemPropertiesAction action) { switch (action) { case InventoryItemUtility.SetItemPropertiesAction.Use: player.stats.SetAll(stats); break; case InventoryItemUtility.SetItemPropertiesAction.UnUse: player.stats.SetAll(stats, -1f); break; default: throw new ArgumentOutOfRangeException("action", action, null); } SetPlyGameValues(player); }
protected virtual void SetPlyGameValues(InventoryPlayer player) { foreach (var attr in plyAttributes) { var a = Player.Instance.actor.actorClass.attributes.FirstOrDefault(attribute => attribute.id.Value == attr.id.Value); if (a != null) { if (attr.addToBonus) { a.lastInfluence = gameObject; a.ChangeSimpleBonus(attr.toAdd); } else { a.lastInfluence = gameObject; a.SetConsumableValue(a.ConsumableValue + attr.toAdd, gameObject); } } } }
public InventoryPlayer InitInventory(int flag) { FileManager f = new FileManager(); Item.loadItems(f); RPG.Gui.Screens.InventoryScreen screen = new Gui.Screens.InventoryScreen("font"); InventoryPlayer inv = new InventoryPlayer(screen, "font"); if (flag == ITEM_ADD_TEST) { return(inv); } if (flag == ITEM_CONTAINS_TEST || flag == ITEM_REMOVE_TEST) { inv.addItem(Item.getItem("sword")); inv.addItem(Item.getItem("hpPot")); } return(inv); }
private void DoSetStat() { if (player == null) { player = PlayerManager.instance.currentPlayer.inventoryPlayer; } var stat = player.stats.Get(statCategoryName.Value, statName.Value); if (stat == null) { LogWarning("Stat in category " + statCategoryName + " with name " + statName + " does not exist."); return; } switch (changeType) { case ChangeType.MaxValue: stat.SetMaxValueRaw(setToAmount.Value, increaseCurrentWhenIncreasingMax); break; case ChangeType.MaxFactor: stat.SetFactorMax(setToAmount.Value, increaseCurrentWhenIncreasingMax); break; case ChangeType.Factor: stat.SetFactor(setToAmount.Value); break; case ChangeType.CurrentValue: stat.SetCurrentValueRaw(setToAmount.Value); break; default: break; } result.Value = stat.currentValue; }
public ContainerBrewingStand(InventoryPlayer par1InventoryPlayer, TileEntityBrewingStand par2TileEntityBrewingStand) { BrewTime = 0; TileBrewingStand = par2TileEntityBrewingStand; AddSlot(new SlotBrewingStandPotion(this, par1InventoryPlayer.Player, par2TileEntityBrewingStand, 0, 56, 46)); AddSlot(new SlotBrewingStandPotion(this, par1InventoryPlayer.Player, par2TileEntityBrewingStand, 1, 79, 53)); AddSlot(new SlotBrewingStandPotion(this, par1InventoryPlayer.Player, par2TileEntityBrewingStand, 2, 102, 46)); AddSlot(new SlotBrewingStandIngredient(this, par2TileEntityBrewingStand, 3, 79, 17)); for (int i = 0; i < 3; i++) { for (int k = 0; k < 9; k++) { AddSlot(new Slot(par1InventoryPlayer, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); } } for (int j = 0; j < 9; j++) { AddSlot(new Slot(par1InventoryPlayer, j, 8 + j * 18, 142)); } }
public EntityPlayer(World world) : base(world) { inventory = new InventoryPlayer(this); field_9152_am = 0; score = 0; isSwinging = false; swingProgressInt = 0; damageRemainder = 0; fishEntity = null; personalCraftingInventory = new CraftingInventoryPlayerCB(inventory, !world.singleplayerWorld); currentCraftingInventory = personalCraftingInventory; yOffset = 1.62F; ChunkCoordinates chunkcoordinates = world.func_22078_l(); setLocationAndAngles(chunkcoordinates.posX + 0.5D, chunkcoordinates.posY + 1, chunkcoordinates.posZ + 0.5D, 0.0F, 0.0F); health = 20; entityType = "humanoid"; field_9117_aI = 180F; fireResistance = 20; texture = "/mob/char.png"; }
public ContainerFurnace(InventoryPlayer par1InventoryPlayer, TileEntityFurnace par2TileEntityFurnace) { LastCookTime = 0; LastBurnTime = 0; LastItemBurnTime = 0; Furnace = par2TileEntityFurnace; AddSlot(new Slot(par2TileEntityFurnace, 0, 56, 17)); AddSlot(new Slot(par2TileEntityFurnace, 1, 56, 53)); AddSlot(new SlotFurnace(par1InventoryPlayer.Player, par2TileEntityFurnace, 2, 116, 35)); for (int i = 0; i < 3; i++) { for (int k = 0; k < 9; k++) { AddSlot(new Slot(par1InventoryPlayer, k + i * 9 + 9, 8 + k * 18, 84 + i * 18)); } } for (int j = 0; j < 9; j++) { AddSlot(new Slot(par1InventoryPlayer, j, 8 + j * 18, 142)); } }
public ContainerPlayer(InventoryPlayer par1InventoryPlayer, bool par2) { CraftMatrix = new InventoryCrafting(this, 2, 2); CraftResult = new InventoryCraftResult(); IsLocalWorld = false; IsLocalWorld = par2; AddSlot(new SlotCrafting(par1InventoryPlayer.Player, CraftMatrix, CraftResult, 0, 144, 36)); for (int i = 0; i < 2; i++) { for (int i1 = 0; i1 < 2; i1++) { AddSlot(new Slot(CraftMatrix, i1 + i * 2, 88 + i1 * 18, 26 + i * 18)); } } for (int j = 0; j < 4; j++) { int j1 = j; AddSlot(new SlotArmor(this, par1InventoryPlayer, par1InventoryPlayer.GetSizeInventory() - 1 - j, 8, 8 + j * 18, j1)); } for (int k = 0; k < 3; k++) { for (int k1 = 0; k1 < 9; k1++) { AddSlot(new Slot(par1InventoryPlayer, k1 + (k + 1) * 9, 8 + k1 * 18, 84 + k * 18)); } } for (int l = 0; l < 9; l++) { AddSlot(new Slot(par1InventoryPlayer, l, 8 + l * 18, 142)); } OnCraftMatrixChanged(CraftMatrix); }
public CraftingInventoryPlayerCB(InventoryPlayer inventoryplayer, bool flag) { craftMatrix = new InventoryCrafting(this, 2, 2); craftResult = new InventoryCraftResult(); isMP = false; isMP = flag; addSlot(new SlotCrafting(craftMatrix, craftResult, 0, 144, 36)); for (int i = 0; i < 2; i++) { for (int i1 = 0; i1 < 2; i1++) { addSlot(new Slot(craftMatrix, i1 + i*2, 88 + i1*18, 26 + i*18)); } } for (int j = 0; j < 4; j++) { int j1 = j; addSlot(new SlotArmor(this, inventoryplayer, inventoryplayer.getSizeInventory() - 1 - j, 8, 8 + j*18, j1)); } for (int k = 0; k < 3; k++) { for (int k1 = 0; k1 < 9; k1++) { addSlot(new Slot(inventoryplayer, k1 + (k + 1)*9, 8 + k1*18, 84 + k*18)); } } for (int l = 0; l < 9; l++) { addSlot(new Slot(inventoryplayer, l, 8 + l*18, 142)); } onCraftMatrixChanged(craftMatrix); }
public InventoryEquippableField[] GetEquippableSlots(EquippableInventoryItem item, InventoryPlayer player) { if (player == null || player.characterCollection == null || player.characterCollection.container == null) return new InventoryEquippableField[0]; var equipSlots = new List<InventoryEquippableField>(4); foreach (var field in player.characterCollection.container.GetComponentsInChildren<InventoryEquippableField>(true)) { foreach (var type in field._equipTypes) { if (item._equipType == type) { equipSlots.Add(field); } } } return equipSlots.ToArray(); }
public CraftingInventoryPlayerCB(InventoryPlayer inventoryplayer) : this(inventoryplayer, true) { }
public InventoryEquippableField GetBestEquipSlot(EquippableInventoryItem item, InventoryEquippableField[] fields, InventoryPlayer player) { if (fields.Length > 0) return fields[0]; return null; }
public override void OnEnable() { base.OnEnable(); tar = (InventoryPlayer)target; equipLocations = serializedObject.FindProperty("equipLocations"); dynamicallyFindUIElements = serializedObject.FindProperty("dynamicallyFindUIElements"); characterUIPath = serializedObject.FindProperty("characterUIPath"); inventoryPaths = serializedObject.FindProperty("inventoryPaths"); skillbarPath = serializedObject.FindProperty("skillbarPath"); characterCollection = serializedObject.FindProperty("characterCollection"); inventoryCollections = serializedObject.FindProperty("inventoryCollections"); skillbarCollection = serializedObject.FindProperty("skillbarCollection"); itemDatabase = InventoryEditorUtility.GetItemDatabase(true, false); if (itemDatabase == null) Debug.LogError("No item database found in scene, cannot edit item."); list = new UnityEditorInternal.ReorderableList(serializedObject, equipLocations, false, true, false, false); list.elementHeight = 66; list.drawHeaderCallback += rect => { EditorGUI.LabelField(rect, "Equipment binding"); }; list.drawElementCallback += (rect, index, active, focused) => { rect.height = 16; rect.y += 2; var r3 = rect; r3.width = 25; rect.x += 30; rect.width -= 30; var r = rect; var r2 = rect; r2.width -= EditorGUIUtility.labelWidth; r2.x += EditorGUIUtility.labelWidth; r3.x += 8; r3.y += 24; var t = equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipTransform").objectReferenceValue as Transform; if (t != null && t.IsChildOf(((InventoryPlayer) target).transform)) { EditorGUI.Toggle(r3, GUIContent.none, true, "VisibilityToggle"); } else { EditorGUI.Toggle(r3, GUIContent.none, false, "VisibilityToggle"); } GUI.enabled = false; EditorGUI.ObjectField(r, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("associatedField"), new GUIContent("Associated field")); GUI.enabled = true; rect.y += 18; EditorGUI.PropertyField(rect, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipTransform")); if (t != null && t.IsChildOf(((InventoryPlayer)target).transform) == false) { rect.y += 18; EditorGUI.HelpBox(rect, "Equip transform has to be a child of this character.", MessageType.Error); } rect.y += 18; EditorGUI.PropertyField(rect, equipLocations.GetArrayElementAtIndex(index).FindPropertyRelative("equipHandlerType")); }; if (tar.characterCollection != null && tar.characterCollection.container != null) { if (IsOutOfSync()) { ReSync(); } } }
protected override void OnCustomInspectorGUI(params CustomOverrideProperty[] extraOverride) { var l = new List<CustomOverrideProperty>(extraOverride); l.Add(new CustomOverrideProperty("_equipType", () => { EditorGUILayout.BeginHorizontal(); EditorGUILayout.LabelField("Equip type", GUILayout.Width(EditorGUIUtility.labelWidth - 5)); EditorGUILayout.BeginVertical(); EditorGUILayout.HelpBox("Edit types in the Equip editor", MessageType.Info); equipType.intValue = EditorGUILayout.Popup(equipType.intValue, InventoryEditorUtility.equipTypesStrings); EditorGUILayout.EndVertical(); EditorGUILayout.EndHorizontal(); })); l.Add(new CustomOverrideProperty("equipVisually", () => { EditorGUILayout.PropertyField(equipVisually); })); l.Add(new CustomOverrideProperty("equipPosition", () => { GUI.enabled = equipVisually.boolValue; if (currentlyPositionedEquippable == null) { if (GUILayout.Button("Position now")) { currentInventoryPlayer = GetPlayer(); if (currentInventoryPlayer != null) { var t = (EquippableInventoryItem)target; var equipFields = GetEquippableSlots(t, currentInventoryPlayer); currenctlyPositionedBinder = currentInventoryPlayer.equipHelper.FindEquipLocation(t, GetBestEquipSlot(t, equipFields, currentInventoryPlayer)); if (currenctlyPositionedBinder == null) { Debug.Log("No suitable equip location found"); return; } currentlyPositionedEquippable = (EquippableInventoryItem)PrefabUtility.InstantiatePrefab(t); //currentInventoryPlayer.equipHelper.HandleEquipType(currentlyPositionedEquippable, currenctlyPositionedBinder); } } } else { GUI.color = Color.green; if (GUILayout.Button("Save state")) { var obj = (GameObject)PrefabUtility.GetPrefabParent(currentlyPositionedEquippable.gameObject); var equippable = obj.GetComponent<EquippableInventoryItem>(); equippable.equipPosition = currentlyPositionedEquippable.transform.localPosition; equippable.equipRotation = currentlyPositionedEquippable.transform.localRotation; equippable.gameObject.SetActive(true); EditorUtility.SetDirty(equippable); GUI.changed = true; AssetDatabase.SaveAssets(); // Save it DestroyImmediate(currentlyPositionedEquippable.gameObject); // Get rid of positioning object //SceneView.currentDrawingSceneView.SetSceneViewFiltering(false); } GUI.color = Color.white; } if (currentlyPositionedEquippable != null) GUI.enabled = false; GUILayout.Space(5); EditorGUILayout.BeginHorizontal(InventoryEditorStyles.boxStyle); EditorGUILayout.PropertyField(equipPosition); GUILayout.Space(20); equipRotation.quaternionValue = ToQuat(EditorGUILayout.Vector4Field("Equip Rotation", ToVec4(equipRotation.quaternionValue))); EditorGUILayout.EndHorizontal(); GUILayout.Space(10); GUI.enabled = true; })); l.Add(new CustomOverrideProperty("equipRotation", null)); if (currentlyPositionedEquippable != null && currentlyPositionedEquippable.transform.parent == null) { currentInventoryPlayer.equipHelper.HandleEquipType(currentlyPositionedEquippable, currenctlyPositionedBinder); Selection.activeObject = currentlyPositionedEquippable.gameObject; if (SceneView.currentDrawingSceneView != null) SceneView.currentDrawingSceneView.LookAt(currentlyPositionedEquippable.transform.position); } base.OnCustomInspectorGUI(l.ToArray()); }
public InventoryCharacterStat(InventoryPlayer player, InventoryItemProperty property) : this(player, property.name, property.valueStringFormat, property.baseValue, property.maxValue, property.showInUI) { }
public InventoryCharacterStat(InventoryPlayer player, string statName, string valueStringFormat, float baseValue, float maxValue, bool showInUI) { this.player = player; this.statName = statName; this.showInUI = showInUI; this.valueStringFormat = valueStringFormat; currentFactor = 1.0f; currentFactorMax = 1.0f; SetMaxValueRaw(maxValue, false); SetBaseValue(baseValue, false); }