protected void OnPartSet(CarPart newPart, PartSlot previousSlot, PartSlot nextSlot) { if (newPart == null) { if (nextSlot == null) { partSprite.color = new Color(1.0f, 1.0f, 1.0f, 0.0f); emptySprite.enabled = true; hpBar.enabled = false; } else { partSprite.color = new Color(1.0f, 1.0f, 1.0f, 0.5f); emptySprite.enabled = true; hpBar.enabled = false; } } else { newPart.slot = this; partSprite.sprite = newPart.sprite; partSprite.color = new Color(1.0f, 1.0f, 1.0f, 1.0f); emptySprite.enabled = false; hpBar.enabled = true; } }
private void generateEquippedPartItems() { const float itemAnchorStep = 1f / 5f; for (int i = 0; i < handler.EquippedParts.Count; ++i) { PartSlot slot = handler.EquippedParts[i]; EquippedPartsItem item = handler.EquippedPartsItemPool.GetObject().GetComponent <EquippedPartsItem>(); item.transform.SetParent(handler.EquippedPartsItemRoot, false); Vector2 anchorMin = new Vector2(0, 1 - (i + 1) * itemAnchorStep); Vector2 anchorMax = new Vector2(1, 1 - (i) * itemAnchorStep); RectTransform rect = item.GetComponent <RectTransform>(); rect.anchorMin = anchorMin; rect.anchorMax = anchorMax; rect.offsetMin = new Vector2(); rect.offsetMax = new Vector2(); rect.localScale = new Vector3(1, 1, 1); item.Init(slot, handler); item.GetComponent <Button>().onClick.AddListener(delegate { equippedItemSelected(item); }); items.Add(item); } }
public void Init(PartSlot slot, CustomizationHandler _handler) { Slot = slot; handler = _handler; partTypeDisplay.text = Slot.PartType.ToString(); partNameDisplay.text = Slot.Part != null ? Slot.Part.Name : "Empty"; }
public void ForceSet(CarPart newPart, PartSlot previousSlot, PartSlot nextSlot) { part = newPart; if (onPartSet != null) { onPartSet.Invoke(newPart, previousSlot, nextSlot); } }
public void OpenPartEditor(PartSlot partSlot) { this.partSlot = partSlot; this.partSlot.EnterPartEditor(); PopulatePartPicker(); abilityName.text = this.partSlot.abilityName; abilityType.text = this.partSlot.abilityType; abilityDesc.text = this.partSlot.abilityDesc; gameObject.SetActive(true); }
public override bool TrySet(CarPart newPart, PartSlot previousSlot) { if (IsCompatible(newPart.type)) { return(base.TrySet(newPart, previousSlot)); } else { return(false); } }
/** * Returns false if isn't occupied. * Otherwise removes item and returns true. */ public bool TryClear(PartSlot nextSlot) { if (IsSet()) { ForceSet(null, null, nextSlot); return(true); } else { return(false); } }
private static Part handleSimplePart(PrimitivePart primPart, PartSlot slot) { Part part = new Part(); part.PartEquip = new HashSet <PartSlot>(); part.CharacterEquip = new HashSet <Character>(); part.ItemType = ItemType.Part; part.PartEquip.Add(slot); setPartStats(primPart, part); setCharEquip(primPart, part); return(part); }
/** * Returns false if already occupied. * Otherwise sets item at posiiton and returns true. */ public virtual bool TrySet(CarPart newPart, PartSlot previousSlot) { if (!IsSet()) { ForceSet(newPart, previousSlot, null); return(true); } else { return(false); } }
public void UpdateEquippedParts(PartSchematic newPart) { PartSlot curPickedSlot = PickedPartsItem.Slot; PartSchematic oldPart = curPickedSlot.Part; curPickedSlot.UpdatePart(newPart); if (newPart != null && newPart.PType == PartSchematic.PartType.Hull) { HullPartSchematic oldHull = (HullPartSchematic)oldPart; HullPartSchematic newHull = (HullPartSchematic)newPart; if (oldHull.OrigWeaponDirs.Length != newHull.OrigWeaponDirs.Length) { int lengthDiff = newHull.OrigWeaponDirs.Length - oldHull.OrigWeaponDirs.Length; if (lengthDiff > 0) { for (int i = 0; i < lengthDiff; ++i) { EquippedParts.Add(new PartSlot(null, PartSchematic.PartType.Weapon, EquippedParts.Count)); } } else if (lengthDiff < 0) { for (int i = 0; i < Math.Abs(lengthDiff); ++i) { EquippedParts.RemoveAt(EquippedParts.Count - 1); } } } int count = 0; foreach (PartSlot slot in EquippedParts) { if (slot.PartType == PartSchematic.PartType.Weapon) { PartSchematic.WeaponTier tier = newHull.WeaponTierRestrictions[count]; if (slot.Part != null && ((WeaponPartSchematic)slot.Part).Tier > tier) { slot.UpdatePart(null); } count += 1; } } } updateTankDisplayToCurrent(); }
public void ChangePart(PartSlot slot, Part newPart) { // TODO : Put old part to inventory // Set new part and refresh fighter abilties and stats Part changedPart = null; switch (slot) { case PartSlot.LEFT_ARM: changedPart = leftArm; leftArm = newPart; break; case PartSlot.RIGHT_ARM: changedPart = rightArm; rightArm = newPart; break; case PartSlot.LEFT_SHOULDER: changedPart = leftShoulder; leftShoulder = newPart; break; case PartSlot.RIGHT_SHOULDER: changedPart = rightShoulder; rightShoulder = newPart; break; } // Remove old abilities from skillset if used int abilityIndex = -1; for (int ii = 0; ii < 2; ii++) { abilityIndex = ArrayUtility.IndexOf(skillset._abilities, changedPart.abilities[ii]); if (abilityIndex != -1) { skillset._abilities[abilityIndex] = newPart.abilities[ii]; } } // TODO : Handle this trigger somewhere in UI EventManager.TriggerEvent(EventList.FIGHTER_STUFF_UPDATE.ToString(), new { fighter = this }); UpdateAvailableAbilities(); // TODO : Remove new part of the inventory }
private void OnPartSet(CarPart newPart, PartSlot previousSlot, PartSlot nextSlot) { // On drop if (newPart == null) { if (this.previousSlot != null && this.previousSlot != nextSlot) { this.previousSlot.RemoveAfterImage(); } } // On pickup else { this.previousSlot = previousSlot as InteractiveSlot; } }
new private void OnPartSet(CarPart newPart, PartSlot previousSlot, PartSlot nextSlot) { base.OnPartSet(newPart, previousSlot, nextSlot); Car car = FindObjectOfType <Car>(); if (car != null) { if (newPart == null) { car.RemovePart(partType); } else { car.AddPart(partType, newPart); } } }
public void ShowPartsList(GameObject selectedPart) { _lastSelectedSlotType = selectedPart.GetComponent <PartUI>().partType; _lastSelectedSlot = selectedPart.GetComponent <PartUI>().slot; // Trigger evnet to update parts list with valid items EventManager.TriggerEvent(EventList.SHOW_PARTS_LIST.ToString(), new { slot = _lastSelectedSlotType }); availablePartsList.alpha = 1; availablePartsList.interactable = true; memberCustomization.interactable = false; EventSystem.current.SetSelectedGameObject(firstSelectedAvailablePart); _waitingRoutine = StartCoroutine(WaitForPlayerChoice()); }
private void ActionSlot(PartSlot partWanted) { Debug.Log("ActionSlot"); if (partWanted != null && partWanted.Tipo != TipoItem.vazio && cribPart != TipoItem.vazio) { SpaceCrib nave = partWanted.gameObject.GetComponentInParent <SpaceCrib>(); if (partWanted.Tipo == cribPart) { if (nave.AttachPart(cribPart)) { cribPart = TipoItem.vazio; } } else { nave.PlayFailFix(); } } }
public void UpdateHeaderText(PartSlot partSlot) { headerText.text = partSlot.PartType.ToString(); }
public void Cleanup() { Slot = null; this.GetComponent <Button>().onClick.RemoveAllListeners(); this.GetComponent <Button>().interactable = true; }