public void OnPointerEnter(PointerEventData data) { ShipComponentDataHolder shipAttachment = GetShipAttachment(data); if (localDragMe != null) { if (shipAttachment != null) { if (shipAttachment.AttachmentSlot == inventorySlotType) { InvenoryIcon.color = highlightColor; } else if (shipAttachment.AttachmentSlot != inventorySlotType) { InvenoryIcon.color = WrongPartColor; } } else { InvenoryIcon.color = highlightColor; } if (shipAttachment == null && localDragMe.itemData == null) { if (localDragMe.itemData == null) { InvenoryIcon.color = normalColor; } } } }
public void GetComponents(ShipComponentDataHolder shipComponent) { switch (shipComponent.AttachmentSlot) { case SlotType.Attachment: var attachments = GetComponentsInChildren <CAttachmentBehavior>(); foreach (var item in attachments) { AttachmentList.Add(item); } RemoveMissingItemsFromList(SlotType.Attachment); break; case SlotType.Thruster: var Thrusters = GetComponentsInChildren <CThrusterBehavior>(); foreach (var item in Thrusters) { ThrusterList.Add(item); } RemoveMissingItemsFromList(SlotType.Thruster); break; case SlotType.Weapon: var Weapons = GetComponentsInChildren <CWeaponBehavior>(); foreach (var item in Weapons) { weaponsList.Add(item); } RemoveMissingItemsFromList(SlotType.Weapon); break; } }
public void OnPointerEnter(PointerEventData data) { ShipComponentDataHolder shipAttachment = GetShipAttachment(data); if (InvenoryIcon == null) { return; } if (isShipPart) { if (shipAttachment != null) { if (shipAttachment.AttachmentSlot == inventorySlotType) { InvenoryIcon.color = highlightColor; } else if (shipAttachment.AttachmentSlot != inventorySlotType) { InvenoryIcon.color = WrongPartColor; } } } else { InvenoryIcon.color = highlightColor; } }
private void CreateComponentForShip(ShipComponentDataHolder attachmentItem, Transform attachmentPos, int EquipSLot) { var newAtch = Instantiate(attachmentItem.prefab, attachmentPos.position, attachmentPos.rotation); newAtch.transform.SetParent(PlayerStats.instance.transform); newAtch.GetComponent <ComponentBehaviorBase>().OnItemChanged(attachmentItem, EquipSLot, inventorySlotType); }
public void OnItemChanged(ShipComponentDataHolder ShipComp, int weaponPlace, SlotType inventorySlotType) { equipmentType = inventorySlotType; currentShipComponent = ShipComp; ship = PlayerStats.instance.transform; equipmentSlot = weaponPlace; }
public void OnDrop(PointerEventData data) { Sprite dropSprite = GetDropSprite(data); ShipComponentDataHolder shipAttachment = GetShipAttachment(data); if (dropSprite == null) { return; } if (isShipPart) { if (shipAttachment != null) { if (shipAttachment.AttachmentSlot != inventorySlotType) { return; } } } var DropMe = dragMe.GetComponent <DropMe>(); var localDragMe = GetComponent <DragMe>(); if (DropMe == null) { if (shipAttachment.cost < PlayerStats.instance.score) { dragMe.GetComponent <BuyMe>().BuyItem(shipAttachment.cost); } else { AddTextToLog.instance.AddTextToEventLog("Not enough credits!"); return; } } if (!isShipPart) { if (dropSprite != null) { if (localDragMe.itemData != null) { ChangeImageAndItem(dropSprite, true); } else { ChangeImageAndItem(dropSprite, false); } } } if (DropMe != null) { if (DropMe.isShipPart || isShipPart || !isShipPart) { DestroyUnequippedComponents(DropMe); } } if (isShipPart) { bool isNull = true; if (localDragMe.itemData != null) { isNull = false; if (!DropMe.isShipPart && isShipPart) { SwichIconsAndAttachments(localDragMe); //receiving slot shipPart and both slots have item. CreateComponentForShip(shipAttachment, transform, weaponSlot); } if (DropMe.isShipPart && isShipPart) { DestroyUnequippedComponents(this); DestroyUnequippedComponents(DropMe); CreateComponentForShip(localDragMe.itemData, dragMe.transform, DropMe.weaponSlot); CreateComponentForShip(dragMe.itemData, transform, weaponSlot); SwichIconsAndAttachments(localDragMe); // molemmat ovat aseita } } else { isNull = true; } if (isNull) { localDragMe.itemData = dragMe.itemData; CreateComponentForShip(shipAttachment, transform, weaponSlot); DropMe.containerImage.color = HiddenColor; containerImage.sprite = GetDropSprite(data); //receiving slot is ShipPart and its empty dragMe.itemData = null; dragMe.GetComponent <Image>().sprite = null; } containerImage.color = normalColor; PlayerStats.instance.GetComponent <GetShipComponents>().GetComponents(shipAttachment); } }