예제 #1
0
    void RaycastItems(Ray r, bool hitUI)
    {
        RaycastHit[] hits = Physics.RaycastAll(r, 1000.0f);
        HitItem = hits.Length > 0;
        if (hitUI)
        {
            HitItem = false;
        }
        System.Predicate <string> nameCheck = hitName => !hitName.Contains(Strings.BLOCKINGOBJECT) && !hitName.Contains("Wall") && !hitName.Contains(Strings.PREVIEW);
        raycastHit = HitItem ? GetClosestHit(hits, nameCheck) : null;


        if (HitItem)
        {
            if (raycastHit == null)
            {
                raycastHit = hits[0];
            }
            currentMouseWorldPosition = raycastHit.Value.transform.position;
            currentHoveredObject      = raycastHit.Value.transform.gameObject;
            currentItem  = currentHoveredObject.GetComponent <PLEItem>();
            currentProp  = currentHoveredObject.GetComponent <PLEProp>();
            currentSpawn = currentHoveredObject.GetComponent <PLESpawn>();
        }
        else
        {
            currentHoveredObject = null;
            currentProp          = null;
            currentSpawn         = null;
            currentItem          = null;
        }
    }
예제 #2
0
    protected virtual void InitializeUI()
    {
        scrollAnim.OnUpdate = (val) => { scrollbar.value = val; };
        itemPrefabs.OrderBy(go => go.name).ToList();

        for (int i = 0; i < itemPrefabs.Count; i++)
        {
            GameObject itemPrefab = itemPrefabs[i];
            GameObject toAdd      = Instantiate(iconTemplate);
            PLEItem    pleItem    = itemPrefab.GetComponent <PLEItem>();
            pleItems.Add(pleItem);
            PLEUIItem pleUIItem = toAdd.GetComponent <PLEUIItem>();
            pleUIItems.Add(pleUIItem);
            pleUIItem.InitializeItem(i, this, itemPrefab);

            toAdd.SetActive(true);
            toAdd.name = itemPrefab.name;

            toAdd.transform.SetParent(groupContent.transform);
            RectTransform myRec = toAdd.GetComponent <RectTransform>();
            myRec.localScale    = Vector3.one;
            myRec.localRotation = Quaternion.identity;
            myRec.localPosition = Vector3.zero;
        }

        SelectUIItem(0, false);
    }
예제 #3
0
    protected virtual void DeselectAllGameItems()
    {
        List <PLEItem> items = createdItemsParent.GetComponentsInChildren <PLEItem>().ToList();

        items.ForEach(item => { item.Deselect(); });
        selectedPLEItem = null;
    }
예제 #4
0
    protected override void SelectGameItem(PLEItem selectedItem, bool isPickingUp = false)
    {
        base.SelectGameItem(selectedItem, isPickingUp);
        int spawnAmount    = SelectedSpawn.totalSpawnAmount;
        int requiredAmount = GetRequiredKillCountInCurrentWave(SelectedSpawn);

        UpdateAllFields(spawnAmount, requiredAmount, SelectedSpawn.DisplayName.ToUpper(), SelectedSpawn.iconPreview);
        ChangeSpawnAmountsInternally(spawnAmount, requiredAmount, false);
    }
예제 #5
0
 protected virtual void DeselectItem()
 {
     if (selectedPLEItem != null)
     {
         selectedPLEItem.Deselect();
         selectedPLEItem = null;
     }
     SetMenuButtonInteractabilityByState();
 }
예제 #6
0
 public void InitializeItem(int itemIndex, ScrollGroup scrollGroup, GameObject registeredItem)
 {
     isInteractable   = true;
     this.ItemIndex   = itemIndex;
     this.scrollGroup = scrollGroup;
     colorChangingUI  = GetComponent <ColorChangingUI>();
     colorChangingUI.SetUIIndex(itemIndex);
     this.registeredItem      = registeredItem;
     this.pleItem             = registeredItem.GetComponent <PLEItem>();
     this.imagePreview.sprite = pleItem.iconPreview;
 }
예제 #7
0
 protected virtual void SelectGameItem(PLEItem selectedItem, bool isPickingUp = false)
 {
     DeselectUIItem();
     DeselectAllGameItems();
     selectedItem.Select(highlightColor);
     selectedPLEItem = selectedItem;
     if (isPickingUp)
     {
         selectedItem.tile.blockUnit.RemoveSpawn(selectedItem.gameObject);
     }
 }
예제 #8
0
 protected virtual void CheckToHightlight()
 {
     if (previewItem == null && !(selectedPLEItem != null && Input.GetMouseButton(MouseButtons.LEFT)))
     {
         PLEItem currentItem = MouseHelper.currentItem;
         if (lastHoveredItem != null && (lastHoveredItem != currentItem || currentItem == null))
         {
             lastHoveredItem.TryUnHighlight();
         }
         if (currentItem != null)
         {
             currentItem.TryHighlight(hoverColor);
         }
         lastHoveredItem = currentItem;
     }
 }
예제 #9
0
 protected override void SelectGameItem(PLEItem selectedItem, bool isPickingUp = false)
 {
     base.SelectGameItem(selectedItem, isPickingUp);
     ApplyRotation(selectedPLEItem.transform.localEulerAngles.y);
     SetMenuButtonInteractabilityByState();
 }