예제 #1
0
    /// <summary>
    /// This function helper for crate Hexagon Controller by coordinate.
    /// </summary>
    private SlotController CreateSlot(int x, int y)
    {
        Coordinate coordinate     = new Coordinate(x, y);
        Vector2    targetPosition = Vector2.zero;

        targetPosition.x += (coordinate.x * CommonTypes.HEXAGON_WIDTH * 0.75F);
        targetPosition.y -= coordinate.x % 2 == 0 ? coordinate.y * CommonTypes.HEXAGON_HEIGHT : CommonTypes.HEXAGON_HEIGHT / 2 + CommonTypes.HEXAGON_HEIGHT * coordinate.y;

        Slot           slot           = new Slot(coordinate);
        SlotController slotController = Instantiate(gameSettings.SlotPrefab, InterfaceManager.Instance.GetPlayArea(), false);

        slotController.transform.localPosition = targetPosition;

        slotController.name = $"Slot_({x}, {y})";
        slotController.Initialize(slot);

        slotControllers.Add(slotController);

        return(slotController);
    }