Ejemplo n.º 1
0
 /// <summary>
 /// Called by Orb that has beginning to get dragged
 /// </summary>
 /// <param name="orb">Orb instance that get drag</param>
 /// <param name="row">Row number of the Orb instance</param>
 /// <param name="column">Column number of the Orb instance</param>
 public static void OnBeginDrag(Orb orb, int row, int column)
 {
     // Check if player movement should be processed
     if (Coordinator.Coordinator.GetOrbMovable())
     {
         spawnTrackingOrb(orb);
         orb.OnSelectedOrb();
         selectedOrb          = orb;
         originalSelectedType = orb.getType();
         Coordinator.Coordinator.NotifyRoundStarted();
         foreach (Orb o in orbs)
         {
             o.ActivateExtendedHitbox();
         }
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Called continuously during the drag to swap Orb if required
 /// </summary>
 /// <param name="ev">Current pointer data</param>
 public static void OnDrag(PointerEventData ev)
 {
     // Check if player movement should be processed
     if (Coordinator.Coordinator.GetOrbMovable())
     {
         // Activate timer if not done so already
         if (!timerActivated)
         {
             // Attach event listener
             Canvas.HealthBar.instance.TimeReached += PostTimerReached;
             // Activate timer
             Canvas.HealthBar.instance.RequestCountdown();
             // Set flag
             timerActivated = true;
         }
         // Update tracker position
         Vector3 pointerPos = Camera.main.ScreenToWorldPoint(new Vector3(ev.position.x, ev.position.y, 10));
         pointerPos.z = trackingZ;
         currentTracker.transform.position = pointerPos;
         // Check if any orbs has to be swapped
         // Do a ray cast from the pointer position and try to find a game object
         RaycastHit2D hit;
         hit = Physics2D.Raycast(pointerPos, Vector2.zero);
         // Set raycaster object to be the collider or null (if nothing was raycasted to)
         GameObject raycastedObj = hit.collider == null ? null : hit.collider.gameObject;
         if (raycastedObj != null)
         {
             Orb newSelectedOrb = raycastedObj.GetComponent <Orb>();
             if (newSelectedOrb != null && newSelectedOrb != selectedOrb)
             {
                 // Swap the type of the 2 orb
                 selectedOrb.OnSwap(newSelectedOrb.getType());
                 newSelectedOrb.OnSwap(selectedOrb.getType());
                 // Select the new orb
                 selectedOrb.OnDeselectOrb();
                 newSelectedOrb.OnSelectedOrb();
                 selectedOrb = newSelectedOrb;
                 // Set orb swapped in this drag
                 orbSwapped = true;
                 // Play movement sound
                 Sound.SoundSystem.instance.playMovementSFX();
             }
         }
     }
 }