Beispiel #1
0
        /// <summary>
        /// Loads scene and sends challenge requests based on game and pick mode.
        /// </summary>
        /// <param name="gameMode">game mode of challenge to be initiated</param>
        /// <param name="pickMode">pick mode of challenge to be initiated</param>
        private void InitiateChallenge(GameMode gameMode, PickMode pickMode)
        {
            IsChallengeActive = true;

            myChallenge = new Challenge
            {
                GameMode     = gameMode,
                PickMode     = pickMode,
                Team         = null,
                ChallengeFor = ChatController.Instance.SelectedPlayerLogin
            };

            if (pickMode == PickMode.Draft)
            {
                Scenes.Load(Scenes.DRAFT_SCENE);
                SendChallengeRequest();
            }
            else
            {
                var parameters = new Dictionary <string, string>
                {
                    { Scenes.BATTLE_TYPE, BattleType.ChallengeBattle.ToString() },
                    { Scenes.TEAM_MANAGEMENT_STATE, TeamManagementState.CHALLENGE_CHOOSE.ToString() }
                };
                Scenes.Load(Scenes.TEAMS_MANAGEMENT_SCENE, parameters);
            }
        }
Beispiel #2
0
        public bool DoMouseDown()
        {
            if (targetMeshCollider != null)
            {
                Undo.RecordObject(currentHullPainter.paintingData, "Paint Hull");

                pickMode = PickTriangle(PickMode.Undecided);
                if (pickMode != PickMode.Undecided)
                {
                    //	Debug.Log ("Start drag");

                    Sync();

                    EditorUtility.SetDirty(currentHullPainter.paintingData);

                    isSelectingFaces = true;

                    return(true);
                }
                else
                {
                    //	Debug.Log ("Abandon drag");
                }
            }
            else
            {
                Debug.Log("Mouse down but no targetMeshCollider, ignoring");
            }

            return(false);
        }
Beispiel #3
0
        private PickMode PickTriangle(PickMode pickMode)
        {
            if (Camera.current == null)
            {
                return(PickMode.Undecided);
            }

            Ray pickRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

            int hitTriIndex = -1;

            if (RaycastUtil.Raycast(targetMeshCollider, pickRay, out hitTriIndex, 10000.0f))
            {
                if (currentHullPainter.paintingData.HasActiveHull())
                {
                    Hull hull = currentHullPainter.paintingData.GetActiveHull();
                    if (pickMode == PickMode.Additive)
                    {
                        if (!hull.selectedFaces.Contains(hitTriIndex))
                        {
                            hull.selectedFaces.Add(hitTriIndex);
                        }

                        PickArea(targetMeshCollider, hull, Event.current.mousePosition, true);

                        return(PickMode.Additive);
                    }
                    else if (pickMode == PickMode.Subtractive)
                    {
                        hull.selectedFaces.Remove(hitTriIndex);

                        PickArea(targetMeshCollider, hull, Event.current.mousePosition, false);

                        return(PickMode.Subtractive);
                    }
                    else if (pickMode == PickMode.Undecided)
                    {
                        if (hull.selectedFaces.Contains(hitTriIndex))
                        {
                            hull.selectedFaces.Remove(hitTriIndex);

                            PickArea(targetMeshCollider, hull, Event.current.mousePosition, false);

                            return(PickMode.Subtractive);
                        }
                        else
                        {
                            hull.selectedFaces.Add(hitTriIndex);

                            PickArea(targetMeshCollider, hull, Event.current.mousePosition, true);

                            return(PickMode.Additive);
                        }
                    }
                }
            }

            return(PickMode.Undecided);
        }
Beispiel #4
0
        /// <summary>
        /// Checks whether the specified pickmode is captains
        /// </summary>
        /// <param name="pickMode"></param>
        /// <returns></returns>
        public static bool IsCaptains(PickMode pickMode)
        {
            if (pickMode == PickMode.Random || pickMode == PickMode.TryBalance)
            {
                return(false);
            }

            return(true);
        }
Beispiel #5
0
 public Option(
     string name,
     TEnum type,
     PickMode pickMode = PickMode.StandardPick
     )
 {
     Name     = name;
     Type     = type;
     PickMode = pickMode;
 }
Beispiel #6
0
 /// <summary>
 /// Picks the control.
 /// </summary>
 /// <param name="x">The x.</param>
 /// <param name="y">The y.</param>
 /// <param name="mode">The mode.</param>
 /// <returns>Control.</returns>
 public Control PickControl(int x, int y, PickMode mode)
 {
     if (mode == PickMode.Control)
     {
         return(PickFirst(x, y));
     }
     if (mode == PickMode.Container)
     {
         return(PickDeep(x, y));
     }
     return(null);
 }
Beispiel #7
0
        private void ProcessSceneEvents()
        {
            if (sceneManipulator.Sync())
            {
                Repaint();
            }

            int controlId = GUIUtility.GetControlID(FocusType.Passive);

            if (Event.current.type == EventType.MouseDown && (Event.current.button == 0) && !Event.current.alt)
            {
                // If shift is held then always add, if control then always subtract, otherwise use intelligent pick mode
                PickMode mode = PickMode.Undecided;
                if (Event.current.shift)
                {
                    mode = PickMode.Additive;
                }
                else if (Event.current.control)
                {
                    mode = PickMode.Subtractive;
                }

                bool eventConsumed = sceneManipulator.DoMouseDown(mode);
                if (eventConsumed)
                {
                    activeMouseButton     = Event.current.button;
                    GUIUtility.hotControl = controlId;
                    Event.current.Use();
                }
            }
            else if (Event.current.type == EventType.MouseDrag && Event.current.button == activeMouseButton && !Event.current.alt)
            {
                bool eventConsumed = sceneManipulator.DoMouseDrag();
                if (eventConsumed)
                {
                    GUIUtility.hotControl = controlId;
                    Event.current.Use();
                    Repaint();
                }
            }
            else if (Event.current.type == EventType.MouseUp && Event.current.button == activeMouseButton && !Event.current.alt)
            {
                bool eventConsumed = sceneManipulator.DoMouseUp();
                if (eventConsumed)
                {
                    activeMouseButton     = -1;
                    GUIUtility.hotControl = 0;
                    Event.current.Use();
                }
            }
        }
Beispiel #8
0
        public virtual async Task SetPickModeAsync(PickMode pickMode)
        {
            using (var db = new Database())
            {
                var lobby = db.Lobbies.FirstOrDefault(x => x.ChannelId == Context.Channel.Id);
                if (lobby == null)
                {
                    await SimpleEmbedAsync("Channel is not a lobby.", Color.Red);

                    return;
                }

                lobby.TeamPickMode = pickMode;
                db.Lobbies.Update(lobby);
                db.SaveChanges();
                await SimpleEmbedAsync($"Pick mode set.", Color.Green);
            }
        }
Beispiel #9
0
        public virtual async Task CreateLobbyAsync(int playersPerTeam = 5, PickMode pickMode = PickMode.Captains_RandomHighestRanked)
        {
            using (var db = new Database())
            {
                //Required for foreign key check
                var competition = db.GetOrCreateCompetition(Context.Guild.Id);
                var lobby       = db.Lobbies.FirstOrDefault(x => x.ChannelId == Context.Channel.Id);
                if (lobby != null)
                {
                    await SimpleEmbedAndDeleteAsync("This channel is already a lobby. Remove the lobby before trying top create a new one here.", Color.Red);

                    return;
                }
                var allLobbies = db.Lobbies.Where(x => x.GuildId == Context.Guild.Id).ToArray();
                if (allLobbies.Length >= Premium.PremiumConfig.LobbyLimit)
                {
                    if (!Premium.IsPremium(Context.Guild.Id))
                    {
                        await SimpleEmbedAsync($"This server already has {Premium.PremiumConfig.LobbyLimit} lobbies created. " +
                                               $"In order to create more you must become an ELO premium subscriber at {Premium.PremiumConfig.AltLink} join the server " +
                                               $"{Premium.PremiumConfig.ServerInvite} to recieve your role and then run the `claimpremium` command in your server.");

                        return;
                    }
                }

                lobby = new Lobby
                {
                    ChannelId      = Context.Channel.Id,
                    GuildId        = Context.Guild.Id,
                    PlayersPerTeam = playersPerTeam,
                    TeamPickMode   = pickMode
                };
                db.Lobbies.Add(lobby);
                db.SaveChanges();
                await SimpleEmbedAsync("New Lobby has been created\n" +
                                       $"Players per team: {playersPerTeam}\n" +
                                       $"Pick Mode: {pickMode}\n" +
                                       $"NOTE: You can play multiple games per lobby. After a game has been created simply join the queue again and another game can be played.", Color.Green);
            }
        }
    void SetPickMode(PointerEventData eventData)
    {
        Vector2 localCursor;

        if (!RectTransformUtility.ScreenPointToLocalPointInRectangle(_rect, eventData.position, eventData.pressEventCamera, out localCursor))
        {
            return;
        }
        Vector2 pickPosition = localCursor;

        if (Mathf.Abs(pickPosition.x) <= _saturationValueRectWidth && Mathf.Abs(pickPosition.y) <= _saturationValueRectWidth)
        {
            _currentPickMode = PickMode.SaturationValue;
        }
        else if (Mathf.Abs(pickPosition.x) > _saturationValueRectWidth + 10 || Mathf.Abs(pickPosition.y) > _saturationValueRectWidth + 10)
        {
            _currentPickMode = PickMode.Hue;
        }
        else
        {
            _currentPickMode = PickMode.None;  // prevent dragging from Hue selection into saturationValue selection
        }
    }
Beispiel #11
0
 GeoObjectList IView.PickObjects(System.Drawing.Point MousePoint, PickMode pickMode)
 {
     // TODO:  Add LayoutView.PickObjects implementation
     return(null);
 }
Beispiel #12
0
        public bool DoMouseDown(PickMode initialMode)
        {
            if (currentToolSelection == ToolSelection.TrianglePainting)
            {
                if (targetMeshCollider != null)
                {
                    if (currentHullPainter != null && currentHullPainter.paintingData != null)
                    {
                        Undo.RecordObject(currentHullPainter.paintingData, "Paint Hull");

                        pickMode = PickTriangle(initialMode);
                        if (pickMode != PickMode.Undecided)
                        {
                            //	Debug.Log ("Start drag");

                            Sync();

                            EditorUtility.SetDirty(currentHullPainter.paintingData);

                            isSelectingFaces = true;

                            return(true);
                        }
                        else
                        {
                            //	Debug.Log ("Abandon drag");
                        }
                    }
                    else
                    {
                        // This can happen when unity triggers scene callbacks in an odd order and the currentHullPainter isn't set yet
                        //	Debug.LogError("SceneManipulator has no currentHullPainter!");
                    }
                }
                else
                {
                    Debug.Log("Mouse down but no targetMeshCollider, ignoring");
                }
            }
            else if (currentToolSelection == ToolSelection.Pipette)
            {
                // Raycast against the target mesh collider and see if the triangle we hit is in any current hull

                bool anyFound = false;

                Ray pickRay = HandleUtility.GUIPointToWorldRay(Event.current.mousePosition);

                int hitTriIndex = -1;
                if (targetMeshCollider != null && RaycastUtil.Raycast(targetMeshCollider, pickRay, out hitTriIndex, 10000.0f))
                {
                    for (int i = 0; i < currentHullPainter.paintingData.hulls.Count; i++)
                    {
                        Hull hull = currentHullPainter.paintingData.hulls[i];
                        if (hull.selectedFaces.Contains(hitTriIndex))
                        {
                            // Now painting this hull!
                            currentHullPainter.paintingData.activeHull = i;
                            currentToolSelection = ToolSelection.TrianglePainting;
                            anyFound             = true;
                            break;
                        }
                    }
                }

                if (!anyFound)
                {
                    currentToolSelection = ToolSelection.TrianglePainting;
                    currentHullPainter.paintingData.activeHull = -1;
                }
            }

            return(false);
        }