private void InputDown() { // If there's no input, just leave if (!Input.GetMouseButtonDown(0)) { return; } // Gets if the input was inside somewhere, and if it wasn't, then leave GearLocation location = InputInsideSomewhere(Input.mousePosition, out int index); if (location == GearLocation.Nowhere) { return; } // Gets if the input was on top of some gear currentGear_ = GearInsideLocation(location, index); if (currentGear_ >= 0) { // Sets the gear to move following the input gears[currentGear_].PutAhead(); gears[currentGear_].StartScaling(GearLocation.WorldPlacement); // If there's a gear getting out of place, then the task can't be in completed state balloon.text = textDefault; } }
/// <summary> /// Sets everything up for the gear to start scaling. /// </summary> /// <param name="nextSize"> Go to UI size or world size? </param> public void StartScaling(GearLocation nextSize) { // Scale Setup currentScale = ui.sizeDelta; scaling = nextSize; // Set the scaling timer Instance.SetScalingTimer(); }
/// <summary> /// Checks if there's some gear inside of the given location. /// </summary> /// <param name="location"> The location to check. </param> /// <param name="locationIndex"> The index of the location. </param> /// <returns> Returns the index of the gear that's inside that location, returns -1 if there's not. </returns> private int GearInsideLocation(GearLocation location, int locationIndex) { for (int i = 0; i < gears.Length; i++) { if (gears[i].origin.location == location && gears[i].origin.index == locationIndex) { return(i); } } return(-1); }
private void InputUp() { // If there's no input, just leave if (!Input.GetMouseButtonUp(0)) { return; } GearEntity gear = gears[currentGear_]; // Gets if the input was inside of somewhere. If not, the gear returns to its origin, else it gets the coordinates of the new destiny GearLocation location = InputInsideSomewhere(Input.mousePosition, out int index); if (location == GearLocation.Nowhere) { gear.destiny = gear.origin; } else { gear.destiny.location = location; gear.destiny.index = index; // Checks if there was another gear at the new destiny int g = GearInsideLocation(location, index); // If it was, then determines the destiny of this another gear to be the origin of the moving gear if (g >= 0) { gears[g].destiny = gear.origin; SetGear(g); } } gears[currentGear_] = gear; SetGear(currentGear_); // Empties the holder and lock the inputs currentGear_ = -1; lock_ = true; }
public void Clear() { location = GearLocation.Nowhere; index = -1; }