Exemple #1
0
 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;
     }
 }
Exemple #2
0
    void Start()
    {
        carPartFactory = FindObjectOfType <CarPartFactory>();

        for (int c = 0; c < cols; ++c)
        {
            for (int r = 0; r < rows; ++r)
            {
                InteractiveSlot slot          = Instantiate(slotPrefab) as InteractiveSlot;
                RectTransform   slotTransform = slot.GetComponent <RectTransform>();
                slotTransform.SetParent(GetComponent <RectTransform>(), false);
                slotTransform.anchoredPosition = new Vector2(slotTransform.rect.width * c, -slotTransform.rect.height * r);
                slots.Add(slot);
            }
        }
    }