예제 #1
0
    private void InputMove()
    {
        GearEntity gear = gears[currentGear_];

        // Get the gear positions in Vector2 so the z coordinate will always be 0
        Vector2 uiPosition    = Input.mousePosition;
        Vector2 worldPosition = camera_.ScreenToWorldPoint(uiPosition);

        // Set the gear positions
        gear.ui.position = uiPosition;
        gear.world.transform.position = worldPosition;

        // Changes the visible gear whether the input is in or outside the inventory
        gear.VisibleGear(RectTransformUtility.RectangleContainsScreenPoint(inventory, uiPosition));
    }
예제 #2
0
    /// <summary>
    /// configures the gear using the destination information.
    /// </summary>
    /// <param name="gearIndex"> Which gear? </param>
    /// <param name="destinyIndex"> The index of the destination. </param>
    /// <param name="inInventory"> Is the destiny an inventory slot (true) or a gear placement (false)? </param>
    private void GearArrived(int gearIndex, int destinyIndex, bool inInventory)
    {
        GearEntity gear = gears[gearIndex];

        // Sets the new origin information up
        gear.origin.location = inInventory ? GearLocation.SlotUI : GearLocation.WorldPlacement;
        gear.origin.index    = destinyIndex;

        // Clears up the destiny information
        gear.destiny.Clear();

        Vector2 position;

        // Positions the gear and applies the default settings from where it is
        if (inInventory)
        {
            gear.ui.position = slots[destinyIndex].position;
            position         = camera_.ScreenToWorldPoint(gear.ui.position);

            gear.world.transform.position = position;
            gear.world.transform.rotation = worldGearsRotation_;
        }
        else
        {
            gear.world.transform.position = gearPlacements[destinyIndex].transform.position;
            position = camera_.WorldToScreenPoint(gear.world.transform.position);

            gear.ui.position  = position;
            gear.ui.sizeDelta = uiToWorldSize_;
        }

        // Returns the world gear to the default sorting order, switchs the visibilities and stops the gear. At last, checks if all gears are in position
        gear.world.sortingOrder = 0;
        gear.currentScale       = gear.ui.sizeDelta;

        gear.VisibleGear(inInventory);
        gear.moving = false;

        gears[gearIndex] = gear;
        AllGearsPositioned();
    }