void OnEnable() { eS = target as EquipmentSystem; slotsInTotal = serializedObject.FindProperty("slotsInTotal"); itemTypeOfSlots = serializedObject.FindProperty("itemTypeOfSlots"); }
public LevelScreen(LoderGame game, SystemManager systemManager, EntityManager entityManager) : base(game.screenSystem, ScreenType.Level) { _game = game; _systemManager = systemManager; _entityManager = entityManager; _levelSystem = (LevelSystem)_systemManager.getSystem(SystemType.Level); _content = new ContentManager(_game.Services); _content.RootDirectory = "Content"; _equipmentSystem = (EquipmentSystem)_systemManager.getSystem(SystemType.Equipment); _playerId = PlayerSystem.PLAYER_ID; _pixel = new Texture2D(_game.GraphicsDevice, 1, 1); _pixel.SetData <Color>(new[] { Color.White }); _arial = _content.Load <SpriteFont>("arial"); _dialogePanes = new List <InteractiveDialoguePane>(); _dialogueFont = _content.Load <SpriteFont>("shared_ui/dialogue_font"); _dialogueOptionFont = _content.Load <SpriteFont>("shared_ui/dialogue_option_font"); ToolbarComponent toolbarComponent = (ToolbarComponent)_entityManager.getComponent(LevelSystem.currentLevelUid, _playerId, ComponentType.Toolbar); _toolbarDisplay = new ToolbarDisplay(_game.spriteBatch, _equipmentSystem, toolbarComponent); _inventoryDisplay = new InventoryDisplay(_game.spriteBatch, _equipmentSystem, (InventoryComponent)_entityManager.getComponent(LevelSystem.currentLevelUid, _playerId, ComponentType.Inventory), toolbarComponent); _inventoryDisplay.inFocus = false; _toolbarDisplay.inFocus = true; _healthBar = new LargeHealthBar(_game.spriteBatch); }
public void equipItem() { if (eS == null) eS = UnityEngine.GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInventory>().characterSystem.GetComponent<EquipmentSystem>(); //验证是否可以装备 if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (eS.itemTypeOfSlots[i].Equals(item.itemType)) { //if (eS.transform.GetChild(1).GetChild(i).childCount == 0) //{ // this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); // this.gameObject.GetComponent<RectTransform>().localPosition = Vector3.zero; // eS.gameObject.GetComponent<Inventory>().updateItemList(); // inventory.updateItemList(); // inventory.EquiptItem(item); // gearable = true; // if (duplication != null) // Destroy(duplication.gameObject); // break; //} KBEngine.Avatar p = (KBEngine.Avatar)KBEngineApp.app.player(); if (p != null) { p.equipItemRequest(item.itemIndex, i); deactivateTooltip(); } break; } } } }
public ToolbarDisplay(SpriteBatch spriteBatch, EquipmentSystem equipmentSystem, ToolbarComponent toolbarComponent) { _spriteBatch = spriteBatch; _toolbarComponent = toolbarComponent; _equipmentSystem = equipmentSystem; _pixel = new Texture2D(_spriteBatch.GraphicsDevice, 1, 1); _pixel.SetData <Color>(new[] { Color.White }); }
// startPersistentSystems -- Certain systems (such as WorldMap, Level, Player, etc...) that need to be active throughout the entire game public void startPersistentSystems() { _playerSystem = new PlayerSystem(_systemManager, _entityManager); _equipmentSystem = new EquipmentSystem(_systemManager, _entityManager); _levelSystem = new LevelSystem(this, _systemManager, _entityManager); _systemManager.add(_playerSystem, -1); _systemManager.add(_equipmentSystem, -1); _systemManager.add(_levelSystem, -1); }
public CharacterSnapshot(int turn, EquipmentSystem equipment, LifeSystem lifeSystem, Inventory inventory) { Turn = turn; Health = lifeSystem.CurrentHealth; MaxHealth = lifeSystem.MaxHealth; Inventory = inventory.items.CopyList(); Equipment = equipment.EquipmentSlots.CopyArray(); Damage = equipment.WeaponDamage?.Sum(p => p.Value) ?? 0; Armour = equipment.ArmourResistances?.Sum(p => p.Value) ?? 0; }
void Start() { item = GetComponent<ItemOnObject>().item; if (GameObject.FindGameObjectWithTag("Tooltip") != null) tooltip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent<Tooltip>(); if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) eS = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInventory>().characterSystem.GetComponent<EquipmentSystem>(); if (GameObject.FindGameObjectWithTag("MainInventory") != null) mainInventory = GameObject.FindGameObjectWithTag("MainInventory"); }
void Start() { item = GetComponent <ItemOnObject>().item; if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) { eS = GameObject.FindGameObjectWithTag("Player").GetComponent <ThirdPersonUserControl>().characterSystem.GetComponent <EquipmentSystem>(); } if (GameObject.FindGameObjectWithTag("MainInventory") != null) { mainInventory = GameObject.FindGameObjectWithTag("MainInventory"); } }
void Start () { if (sys == null) { sys = this; } else if (sys != this) { Destroy(gameObject); } var temp = GetComponentsInChildren<Equipable>(); foreach(var equipmnt in temp) { equipments.Add(equipmnt); } animator = GetComponent<Animator>(); }
void Awake() { equipment = GetComponent <EquipmentSystem>(); inventory = GetComponent <Inventory>(); lifeSystem = GetComponent <LifeSystem>(); rewindUI = FindObjectOfType <RewindUI>(); turnSystem = FindObjectOfType <TurnSystem>(); turnSystem.PlayerTurnStarted += TakeSnapshot; turnSystem.PlayerTurnStarted += ReduceCooldown; currentCooldown = 4; }
// Use this for initialization void Start() { UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas"); if (canvas.transform.Find("Tooltip - Inventory(Clone)") != null) tooltip = canvas.transform.Find("Tooltip - Inventory(Clone)").GetComponent<Tooltip>(); eS = this.transform.GetComponent<PlayerInventory>().characterSystem.GetComponent<EquipmentSystem>(); equipInventory = this.transform.GetComponent<PlayerInventory>().characterSystem.GetComponent<Inventory>(); itemInventory = this.transform.GetComponent<PlayerInventory>().inventory.GetComponent<Inventory>(); KBEngine.Event.registerOut("dropItem_re", this, "dropItem_re"); KBEngine.Event.registerOut("pickUp_re", this, "pickUp_re"); KBEngine.Event.registerOut("equipItemRequest_re", this, "equipItemRequest_re"); }
[SyncVar] public bool isWalking; // bools for synchronizing animations #endregion #region //====== MONOBEHAVIOURS ======\\ public override void Start() { base.Start(); // UI nameText.text = Name.ToString(); if (!isLocalPlayer) { onStartIfNotLocal.Invoke(); return; } localPlayer = this; // camera m_Camera = Camera.main; m_Camera.GetComponentInParent <CameraController>().SetTarget(transform); // scripts positionSynchronization = GetComponent <PositionSynchronization>(); weaponController = GetComponent <WeaponController>(); // indicator indicator = Instantiate(indicatorPrefab, Vector3.zero, Quaternion.identity).transform; indicatorAnimator = indicator.GetComponent <Animator>(); onStartIfLocal.Invoke(); StartCoroutine(CheckTarget()); // show inventory InventorySystem.Instance.Reset(); foreach (var key in inventoryData.Keys) { InventorySystem.Instance.OnInventoryUpdate(key, inventoryData[key]); } foreach (var key in equipmentData.Keys) { EquipmentSystem.OnEquipmentUpdate(SyncIDictionary <EquipmentSlot, ItemData> .Operation.OP_ADD, key, equipmentData[key]); } inventoryData.Callback += OnInventoryUpdate; equipmentData.Callback += EquipmentSystem.OnEquipmentUpdate; UIStatsPanel.SetNameText(Name); EquipmentSystem.SetPlayer(this); InventorySystem.LoadToolbar(); }
public EntityMaintenanceSystem(EffectSystem eSys, EntityManager eMan, EquipmentSystem eqSys, ExperienceSystem xSys, GearSystem gSys, ItemInventorySystem invSys, ItemSystem iSys, NameSystem nSys, PlayerSystem pSys, ProfessionSystem profSys, StatsSystem sSys, StatModifierSystem smSys) { effectSystem = eSys; entityManager = eMan; equipmentSystem = eqSys; experienceSystem = xSys; gearSystem = gSys; inventorySystem=invSys; itemSystem = iSys; nameSystem = nSys; playerSystem = pSys; professionSystem = profSys; statsSystem = sSys; modifierSystem = smSys; }
void Start() { setVariables(); deactivateTooltip(); tooltipHeight = this.GetComponent <RectTransform>().rect.height; //if (UnityEngine.GameObject.FindGameObjectWithTag("EquipmentSystem") != null) if (UnityEngine.GameObject.FindGameObjectWithTag("Player")) { eS = UnityEngine.GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); } if (UnityEngine.GameObject.FindGameObjectWithTag("Player")) { inventory = UnityEngine.GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>(); } }
// Use this for initialization void Start() { UnityEngine.GameObject canvas = UnityEngine.GameObject.FindGameObjectWithTag("Canvas"); if (canvas.transform.Find("Tooltip - Inventory(Clone)") != null) { tooltip = canvas.transform.Find("Tooltip - Inventory(Clone)").GetComponent <Tooltip>(); } eS = this.transform.GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); equipInventory = this.transform.GetComponent <PlayerInventory>().characterSystem.GetComponent <Inventory>(); itemInventory = this.transform.GetComponent <PlayerInventory>().inventory.GetComponent <Inventory>(); KBEngine.Event.registerOut("dropItem_re", this, "dropItem_re"); KBEngine.Event.registerOut("pickUp_re", this, "pickUp_re"); KBEngine.Event.registerOut("equipItemRequest_re", this, "equipItemRequest_re"); }
public void UpdateEquipment(EquipmentSystem equipment, StatSystem system) { var head = equipment.GetItem(EquipmentItem.EquipmentSlot.Head); var torso = equipment.GetItem(EquipmentItem.EquipmentSlot.Torso); var legs = equipment.GetItem(EquipmentItem.EquipmentSlot.Legs); var feet = equipment.GetItem(EquipmentItem.EquipmentSlot.Feet); var accessory = equipment.GetItem(EquipmentItem.EquipmentSlot.Accessory); var weapon = equipment.Weapon; HeadSlot.SetupEquipment(head); TorsoSlot.SetupEquipment(torso); LegsSlot.SetupEquipment(legs); FeetSlot.SetupEquipment(feet); AccessorySlot.SetupEquipment(accessory); WeaponSlot.SetupEquipment(weapon); }
void Start() { item = GetComponent <ItemOnObject>().item; if (GameObject.FindGameObjectWithTag("Tooltip") != null) { tooltip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent <Tooltip>(); } if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) { eS = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); } if (GameObject.FindGameObjectWithTag("MainInventory") != null) { mainInventory = GameObject.FindGameObjectWithTag("MainInventory"); } }
// Start is called before the first frame update void Start() { interaction = FindObjectOfType <InteractionUni>(); terminalCamera.enabled = false; weapon = FindObjectOfType <ChangeWeapon>(); flashLight = FindObjectOfType <FlashLight>(); move = FindObjectOfType <PlayerMove>(); mDoc = FindObjectOfType <MissionDocument>(); eq = FindObjectOfType <EquipmentSystem>(); TextAsset asset = (TextAsset)Resources.Load(@"TerminalSCP\SCPTerminal"); terminalXML = new XmlDocument(); terminalXML.LoadXml(asset.text); textLogo.text = terminalXML.GetElementsByTagName("title")[0].InnerText; settings = FindObjectOfType <Settings_options>(); source = GetComponent <AudioSource>(); LoadText("back", 0); }
// Load player inventory public static void loadPlayerInventory() { XElement inventoryData = _playerData.Element("InventoryState"); InventoryComponent inventoryComponent = new InventoryComponent(int.Parse(inventoryData.Attribute("slots").Value)); EquipmentSystem equipmentSystem = _systemManager.getSystem(SystemType.Equipment) as EquipmentSystem; _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, inventoryComponent); foreach (XElement itemStateData in inventoryData.Elements("ItemState")) { ItemDefinition itemDefinition = _itemManager.getItemDefinition(itemStateData.Attribute("item_uid").Value); ItemState itemState = new ItemState( int.Parse(itemStateData.Attribute("quantity").Value), float.Parse(itemStateData.Attribute("current_range_limit").Value), false); ItemComponent itemComponent = new ItemComponent(itemDefinition, itemState, ResourceManager.getTexture(itemDefinition.inventoryTextureUid)); equipmentSystem.addInventoryItem(inventoryComponent, itemComponent); } }
void Start() { player = PlayerManager.Player; playerInventory = PlayerManager.instance.GetComponent <PlayerInventory>(); item = GetComponent <ItemOnObject>().item; if (GameObject.FindGameObjectWithTag("Tooltip") != null) { tooltip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent <Tooltip>(); } if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) { eS = playerInventory.characterSystem.GetComponent <EquipmentSystem>(); } if (GameObject.FindGameObjectWithTag("MainInventory") != null) { mainInventory = GameObject.FindGameObjectWithTag("MainInventory"); } }
// Load player toolbar public static void loadPlayerToolbar() { XElement toolbarData = _playerData.Element("ToolbarState"); ToolbarComponent toolbarComponent = new ToolbarComponent(int.Parse(toolbarData.Attribute("slots").Value), PlayerSystem.PLAYER_ID); EquipmentSystem equipmentSystem = _systemManager.getSystem(SystemType.Equipment) as EquipmentSystem; InventoryComponent inventoryComponent = _entityManager.getComponent("global", PlayerSystem.PLAYER_ID, ComponentType.Inventory) as InventoryComponent; _entityManager.addComponent("global", PlayerSystem.PLAYER_ID, toolbarComponent); foreach (XElement slotData in toolbarData.Elements("Slot")) { equipmentSystem.assignItemToToolbar( "global", equipmentSystem.getInventoryItem(inventoryComponent, int.Parse(slotData.Attribute("inventory_slot").Value)), toolbarComponent, int.Parse(slotData.Attribute("slot_id").Value)); } equipmentSystem.selectToolbarSlot("global", toolbarComponent, int.Parse(toolbarData.Attribute("selected_index").Value)); }
public void SetUp() { systemContainer = Substitute.For <ISystemContainer>(); prototypeSystem = Substitute.For <IPrototypeSystem>(); systemContainer.PrototypeSystem.ReturnsForAnyArgs(prototypeSystem); eventSystem = Substitute.For <IEventSystem>(); systemContainer.EventSystem.ReturnsForAnyArgs(eventSystem); eventSystem.Try(Arg.Any <EventType>(), null, null).ReturnsForAnyArgs(true); entityEngine = Substitute.For <IEntityEngine>(); systemContainer.EntityEngine.ReturnsForAnyArgs(entityEngine); SetUpTestMappings(); equipmentSystem = new EquipmentSystem(systemContainer); entity = GetTestEntity(); }
public EntityManager(StateMachine sMach, DropSystem dSys, PlayerSystem pS, StatsSystem sS, ItemSystem iS, StatModifierSystem mS, EffectSystem efS, EquipmentSystem eqS, AISystem aiS, GearSystem gS, ExperienceSystem xS, ItemInventorySystem invS, NameSystem nS, ProfessionSystem profS, ActionSystem actS, ActionInventorySystem aInvS, CombatSystem cSys, EntityMaintenanceSystem eMS) { stateSystem = sMach; dropSystem = dSys; entMaintenanceSystem = eMS; aInventorySystem = aInvS; combatSystem = cSys; playerSystem = pS; statsSystem = sS; itemSystem = iS; modifierSystem = mS; effectSystem = efS; equipmentSystem = eqS; aiSystem = aiS; gearSystem = gS; experienceSystem = xS; inventorySystem = invS; nameSystem = nS; professionSystem = profS; actionSystem = actS; }
void Start() { item = GetComponent <ItemOnObject>().item; if (GameObject.FindGameObjectWithTag("Tooltip") != null) { tooltip = GameObject.FindGameObjectWithTag("Tooltip").GetComponent <Tooltip>(); } if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) { foreach (GameObject Obj in GameObject.FindGameObjectsWithTag("Player")) { if (Obj.name == "Astronaut") { eS = Obj.GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); } } } if (GameObject.FindGameObjectWithTag("MainInventory") != null) { mainInventory = GameObject.FindGameObjectWithTag("MainInventory"); } }
public void equipItem() { if (eS == null) { eS = UnityEngine.GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); } //验证是否可以装备 if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (eS.itemTypeOfSlots[i].Equals(item.itemType)) { //if (eS.transform.GetChild(1).GetChild(i).childCount == 0) //{ // this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); // this.gameObject.GetComponent<RectTransform>().localPosition = Vector3.zero; // eS.gameObject.GetComponent<Inventory>().updateItemList(); // inventory.updateItemList(); // inventory.EquiptItem(item); // gearable = true; // if (duplication != null) // Destroy(duplication.gameObject); // break; //} KBEngine.Avatar p = (KBEngine.Avatar)KBEngineApp.app.player(); if (p != null) { p.equipItemRequest(item.itemIndex, i); deactivateTooltip(); } break; } } } }
public void consumeIt() { Inventory inventory = transform.parent.parent.parent.GetComponent <Inventory>(); bool gearable = false; if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) { eS = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerInventory>().characterSystem.GetComponent <EquipmentSystem>(); } if (eS != null) { itemTypeOfSlot = eS.itemTypeOfSlots; } Item itemFromDup = null; if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.updateItemList(); inventory.EquiptItem(item); gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent <ItemOnObject>().item); } } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent <PickUpItem>(); dropItem.GetComponent <PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("Player").transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent <RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent <Hotbar>() != null) { createDuplication(otherItemFromCharacterSystem); } this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent <RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) { Destroy(duplication.gameObject); } eS.gameObject.GetComponent <Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { if (duplication != null) { itemFromDup = duplication.GetComponent <ItemOnObject>().item; } inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent <ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) { tooltip.deactivateTooltip(); } inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } }
public void consumeIt() { Inventory inventory = transform.parent.parent.parent.GetComponent<Inventory>(); bool gearable = false; if (GameObject.FindGameObjectWithTag("EquipmentSystem") != null) eS = GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInventory>().characterSystem.GetComponent<EquipmentSystem>(); if (eS != null) itemTypeOfSlot = eS.itemTypeOfSlots; Item itemFromDup = null; if (duplication != null) itemFromDup = duplication.GetComponent<ItemOnObject>().item; bool stop = false; if (eS != null) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount == 0) { stop = true; this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent<RectTransform>().localPosition = Vector3.zero; eS.gameObject.GetComponent<Inventory>().updateItemList(); inventory.updateItemList(); inventory.EquiptItem(item); gearable = true; if (duplication != null) Destroy(duplication.gameObject); break; } } } if (!stop) { for (int i = 0; i < eS.slotsInTotal; i++) { if (itemTypeOfSlot[i].Equals(item.itemType)) { if (eS.transform.GetChild(1).GetChild(i).childCount != 0) { GameObject otherItemFromCharacterSystem = eS.transform.GetChild(1).GetChild(i).GetChild(0).gameObject; Item otherSlotItem = otherItemFromCharacterSystem.GetComponent<ItemOnObject>().item; if (item.itemType == ItemType.UFPS_Weapon) { inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent<ItemOnObject>().item); inventory.EquiptItem(item); } else { inventory.EquiptItem(item); if (item.itemType != ItemType.Backpack) inventory.UnEquipItem1(otherItemFromCharacterSystem.GetComponent<ItemOnObject>().item); } if (this == null) { GameObject dropItem = (GameObject)Instantiate(otherSlotItem.itemModel); dropItem.AddComponent<PickUpItem>(); dropItem.GetComponent<PickUpItem>().item = otherSlotItem; dropItem.transform.localPosition = GameObject.FindGameObjectWithTag("Player").transform.localPosition; inventory.OnUpdateItemList(); } else { otherItemFromCharacterSystem.transform.SetParent(this.transform.parent); otherItemFromCharacterSystem.GetComponent<RectTransform>().localPosition = Vector3.zero; if (this.gameObject.transform.parent.parent.parent.GetComponent<Hotbar>() != null) createDuplication(otherItemFromCharacterSystem); this.gameObject.transform.SetParent(eS.transform.GetChild(1).GetChild(i)); this.gameObject.GetComponent<RectTransform>().localPosition = Vector3.zero; } gearable = true; if (duplication != null) Destroy(duplication.gameObject); eS.gameObject.GetComponent<Inventory>().updateItemList(); inventory.OnUpdateItemList(); break; } } } } } if (!gearable && item.itemType != ItemType.UFPS_Ammo && item.itemType != ItemType.UFPS_Grenade) { if (duplication != null) itemFromDup = duplication.GetComponent<ItemOnObject>().item; inventory.ConsumeItem(item); item.itemValue--; if (itemFromDup != null) { duplication.GetComponent<ItemOnObject>().item.itemValue--; if (itemFromDup.itemValue <= 0) { if (tooltip != null) tooltip.deactivateTooltip(); inventory.deleteItemFromInventory(item); Destroy(duplication.gameObject); } } if (item.itemValue <= 0) { if (tooltip != null) tooltip.deactivateTooltip(); inventory.deleteItemFromInventory(item); Destroy(this.gameObject); } } }
// Save player data public static void savePlayerData() { Logger.log("DataManager.savePlayerData method starting."); string filePath = _playersDirectory + string.Format("player_data_{0}.xml", _playerSlot); using (FileStream fs = new FileStream(filePath, FileMode.Create)) { XDocument doc = new XDocument(); InventoryComponent inventoryComponent = _entityManager.getComponent("global", PlayerSystem.PLAYER_ID, ComponentType.Inventory) as InventoryComponent; ToolbarComponent toolbarComponent = _entityManager.getComponent("global", PlayerSystem.PLAYER_ID, ComponentType.Toolbar) as ToolbarComponent; EquipmentSystem equipmentSystem = _systemManager.getSystem(SystemType.Equipment) as EquipmentSystem; XElement inventoryData = new XElement("InventoryState"); XElement toolbarData = new XElement("ToolbarState"); List <XElement> customFlagsData = new List <XElement>(); List <XElement> customValuesData = new List <XElement>(); List <XElement> customStringsData = new List <XElement>(); // Basic player data _playerData = new XElement( "PlayerData", new XAttribute("name", _playerName), new XAttribute("slot", _playerSlot)); // World map states foreach (WorldMapState worldMapState in _worldMapManager.worldMapStates.Values) { XElement worldMapStateData = new XElement( "WorldMapState", new XAttribute("world_map_uid", worldMapState.definition.uid), new XAttribute("discovered", worldMapState.discovered)); foreach (LevelIconState levelIconState in worldMapState.levelIconStates) { worldMapStateData.Add( new XElement("LevelIconState", new XAttribute("level_icon_uid", levelIconState.definition.uid), new XAttribute("discovered", levelIconState.discovered), new XAttribute("finished", levelIconState.finished))); } foreach (LevelPathState levelPathState in worldMapState.levelPathState) { worldMapStateData.Add(new XElement("LevelPathState", new XAttribute("discovered", levelPathState.discovered))); } _playerData.Add(worldMapStateData); } // Quest states _playerData.Add(_questManager.createData()); // Inventory states inventoryData.SetAttributeValue("slots", inventoryComponent.slots); foreach (KeyValuePair <int, ItemComponent> slotItemPair in inventoryComponent.inventory) { inventoryData.Add( new XElement( "ItemState", new XAttribute("slot_id", slotItemPair.Key), new XAttribute("item_uid", slotItemPair.Value.definition.uid), new XAttribute("quantity", slotItemPair.Value.state.quantity), new XAttribute("current_range_limit", slotItemPair.Value.state.currentRangeLimit))); } _playerData.Add(inventoryData); // Toolbar states toolbarData.SetAttributeValue("slots", toolbarComponent.slots); toolbarData.SetAttributeValue("selected_index", toolbarComponent.selectedIndex); foreach (KeyValuePair <int, ItemComponent> slotItemPair in toolbarComponent.inventory) { if (slotItemPair.Value != null) { toolbarData.Add( new XElement( "Slot", new XAttribute("slot_id", slotItemPair.Key), new XAttribute("inventory_slot", equipmentSystem.getInventorySlot(inventoryComponent, slotItemPair.Value)))); } } _playerData.Add(toolbarData); // Custom flags foreach (KeyValuePair <string, bool> uidFlagPair in _customFlags) { customFlagsData.Add(new XElement("CustomFlag", new XAttribute("uid", uidFlagPair.Key), new XAttribute("value", uidFlagPair.Value))); } _playerData.Add(customFlagsData); // Custom values foreach (KeyValuePair <string, int> uidValuePair in _customValues) { customValuesData.Add(new XElement("CustomValue", new XAttribute("uid", uidValuePair.Key), new XAttribute("value", uidValuePair.Value))); } _playerData.Add(customValuesData); // Custom values foreach (KeyValuePair <string, string> uidStringPair in _customStrings) { customStringsData.Add(new XElement("CustomString", new XAttribute("uid", uidStringPair.Key), new XAttribute("value", uidStringPair.Value))); } _playerData.Add(customStringsData); doc.Add(_playerData); doc.Save(fs); } Logger.log("DataManager.savePlayerData method finished."); }
private void InitializeSystems() { Console.WriteLine("Initializing Game Systems"); professionSystem = new ProfessionSystem(); effectSystem=new EffectSystem(lua); equipmentSystem = new EquipmentSystem(); experienceSystem = new ExperienceSystem(); itemSystem = new ItemSystem(); inventorySystem = new ItemInventorySystem(); modifierSystem = new StatModifierSystem(); nameSystem = new NameSystem(lua); playerSystem = new PlayerSystem(nameSystem, stateSystem); gearSystem = new GearSystem(); statsSystem = new StatsSystem(); aInventorySystem = new ActionInventorySystem(lua, statsSystem); actionSystem = new ActionSystem(lua); aiSystem = new AISystem(); dropSystem = new DropSystem(dropMap); }
public AddNewEquipmentGroupingDialog(EquipmentSystem selectedItem) { InitializeComponent(); system = selectedItem; title.Focus(); }
// Update is called once per frame void Update() { EquipmentSystem eSys = GetComponent <PlayerInventory> ().characterSystem.GetComponent <EquipmentSystem>(); ItemType[] itemTypeOfSlot = eSys.itemTypeOfSlots; string newanimName = ""; for (int i = 0; i < eSys.slotsInTotal; i++) { // if (itemTypeOfSlot [i].Equals (ItemType.Head) && eSys.transform.GetChild (1).GetChild (i).childCount != 0) { // // if (GameObject.FindGameObjectWithTag ("Helm") == null) { // Instantiate (eSys.transform.GetChild (1).GetChild (i).GetChild (0).gameObject.GetComponent<ItemOnObject> ().item.equipModel, gameObject.transform); // GameObject helm = GameObject.FindGameObjectWithTag ("Helm"); // helm.transform.position = helm.transform.parent.position; // helm.transform.localPosition = new Vector3 (0.0099f, 0.101f, -0.0001f); // helm.GetComponent<DirectionalAnimation> ().SetAnimDirection (m_charAnimCtrl.GetAnimDirection ()); // helm.SetActive (true); // // } else if (GameObject.FindGameObjectWithTag ("Helm") != null && GameObject.FindGameObjectWithTag ("Helm").GetComponent<WeapDetails> ().id != eSys.transform.GetChild (1).GetChild (i).GetChild (0).gameObject.GetComponent<ItemOnObject> ().item.itemID) { // Destroy (GameObject.FindGameObjectWithTag ("Helm")); // Instantiate (eSys.transform.GetChild (1).GetChild (i).GetChild (0).gameObject.GetComponent<ItemOnObject> ().item.equipModel, gameObject.transform); // GameObject helm = GameObject.FindGameObjectWithTag ("Helm"); // helm.transform.position = helm.transform.parent.position; // helm.transform.localPosition = new Vector3 (0.0099f, 0.101f, -0.0001f); // helm.GetComponent<DirectionalAnimation> ().SetAnimDirection (m_charAnimCtrl.GetAnimDirection ()); // helm.SetActive (true); // // // } // } // else if (itemTypeOfSlot [i].Equals (ItemType.Head) && eSys.transform.GetChild (1).GetChild (i).childCount == 0){ // if (GameObject.FindGameObjectWithTag ("Helm") != null) // { // Destroy (GameObject.FindGameObjectWithTag ("Helm")); // // } // } if (itemTypeOfSlot [i].Equals(ItemType.Head) && eSys.transform.GetChild(1).GetChild(i).childCount != 0) { if (newanimName == "") { newanimName = eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } else { newanimName = eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } } else if (itemTypeOfSlot [i].Equals(ItemType.Chest) && eSys.transform.GetChild(1).GetChild(i).childCount != 0) { if (newanimName == "") { newanimName = eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } else { newanimName += " " + eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } } else if (itemTypeOfSlot [i].Equals(ItemType.Weapon) && eSys.transform.GetChild(1).GetChild(i).childCount != 0) { if (newanimName == "") { newanimName = eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } else { newanimName += " " + eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } } else if (itemTypeOfSlot [i].Equals(ItemType.Hands) && eSys.transform.GetChild(1).GetChild(i).childCount != 0) { if (newanimName == "") { newanimName = eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } else { newanimName += " " + eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } } else if (itemTypeOfSlot [i].Equals(ItemType.Trouser) && eSys.transform.GetChild(1).GetChild(i).childCount != 0) { if (newanimName == "") { newanimName = eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } else { newanimName += " " + eSys.transform.GetChild(1).GetChild(i).GetChild(0).gameObject.GetComponent <ItemOnObject> ().item.itemName; } } } if (newanimName == "") { newanimName = "Blank char"; } if (newanimName != animName) { animName = newanimName; DirectionalAnimation[] list = GetComponents <DirectionalAnimation> (); for (int i = 0; i < list.Length; i++) { list [i].SetAnim(animName); } } // if (GameObject.FindGameObjectWithTag ("Chest") == null && equipManager.chest != null) { // Instantiate (equipManager.chest.gameObject, gameObject.transform); // GameObject chest = GameObject.FindGameObjectWithTag ("Chest"); // chest.transform.position = chest.transform.parent.position; // chest.transform.localPosition = new Vector3 (0f, 0.062f,0f); // chest.GetComponent<DirectionalAnimation> ().SetAnimDirection (m_charAnimCtrl.GetAnimDirection()); // chest.SetActive (true); // } // if (GameObject.FindGameObjectWithTag ("Legs") == null && equipManager.legs != null) { // Instantiate (equipManager.legs.gameObject, gameObject.transform); // GameObject legs = GameObject.FindGameObjectWithTag ("Legs"); // legs.transform.position = legs.transform.parent.position; // legs.transform.localPosition = new Vector3 (-0.0699f, -0.0702f,0f); // legs.GetComponent<DirectionalAnimation> ().SetAnimDirection (m_charAnimCtrl.GetAnimDirection()); // legs.SetActive (true); // } // if (GameObject.FindGameObjectWithTag ("Weapon") == null && equipManager.weapon != null) { // Instantiate (equipManager.weapon.gameObject, gameObject.transform); // GameObject weapon = GameObject.FindGameObjectWithTag ("Weapon"); // weapon.transform.position = weapon.transform.parent.position; // weapon.GetComponent<DirectionalAnimation> ().SetAnimDirection (m_charAnimCtrl.GetAnimDirection()); // weapon.SetActive (true); // } // if (GameObject.FindGameObjectWithTag ("Shield") == null && equipManager.shield != null) { // Instantiate (equipManager.shield.gameObject, gameObject.transform); // GameObject shield = GameObject.FindGameObjectWithTag ("Shield"); // shield.transform.position = shield.transform.parent.position; // shield.GetComponent<DirectionalAnimation> ().SetAnimDirection (m_charAnimCtrl.GetAnimDirection()); // // shield.SetActive (true); // } }
public NewEquipmentGroupRequestEventArgs(string title, string description, EquipmentSystem system) { Title = title; Description = description; EquipmentSystem = system; }
void Awake() { equipment = GetComponent <EquipmentSystem>(); }
public PlayerStatsSystem(StatsDatum statsDatum, EquipmentSystem equipmentSystem, LevelSystem levelSystem) : base(statsDatum) { this.equipmentSystem = equipmentSystem; this.levelSystem = levelSystem; }
void OnEnable() { eS = target as EquipmentSystem; slotsInTotal = serializedObject.FindProperty("slotsInTotal"); itemTypeOfSlots = serializedObject.FindProperty("itemTypeOfSlots"); }
void Start() { setVariables(); deactivateTooltip(); tooltipHeight = this.GetComponent<RectTransform>().rect.height; //if (UnityEngine.GameObject.FindGameObjectWithTag("EquipmentSystem") != null) if (UnityEngine.GameObject.FindGameObjectWithTag("Player")) eS = UnityEngine.GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInventory>().characterSystem.GetComponent<EquipmentSystem>(); if (UnityEngine.GameObject.FindGameObjectWithTag("Player")) inventory = UnityEngine.GameObject.FindGameObjectWithTag("Player").GetComponent<PlayerInventory>().inventory.GetComponent<Inventory>(); }
void Awake() { equipment = GetComponent <EquipmentSystem>(); animator = GetComponentInChildren <Animator>(); CurrentHealth = MaxHealth; }