Exemple #1
0
    //Each message button will call this method with the message object
    void MessagedClicked(MessageData message, GameObject messageObj)
    {
        string oldState = message.state.ToString();

        switch (message.state)
        {
        case MessageData.State.Incompleted:
            message.state = MessageData.State.Completed;
            break;

        case MessageData.State.Completed:
            message.state = MessageData.State.NotRelated;
            break;

        case MessageData.State.NotRelated:
            message.state = MessageData.State.Incompleted;
            break;

        default:
            Debug.LogError("Unidentified message state when a message was clicked on PhoneMenu.cs");
            break;
        }
        DrawMessage(message, messageObj);
        PlayerEventHandler.ChangeMessageState(message, oldState);
    }
 public override void OnPointerClick(PointerEventData eventData)
 {
     if (!beingDragged)
     {
         if (eventData.button == PointerEventData.InputButton.Left)
         {
             //Go to next state
             if (diagramController.NodeLeftClicked(this) == DiagramController.Modes.selecting)
             {
                 //Only change state if we are not linking/unlinking
                 string oldState = nodeAttached.nodeName;
                 if (index == states.Count - 1)
                 {
                     index = 0;
                 }
                 else
                 {
                     index++;
                 }
                 textComp.text = states[index];
                 nodeAttached.Rename(states[index]);
                 PlayerEventHandler.ChangeGenType(nodeAttached, oldState);
             }
         }
         else if (eventData.button == PointerEventData.InputButton.Right)
         {
             //Go to next state
             diagramController.OpenGeneralizationMenu(eventData);
         }
     }
 }
Exemple #3
0
 public void OnContinue()
 {
     SceneHandler.Pause(false);
     Hide();
     OverlayMenu.Show();
     PlayerEventHandler.CloseMenu();
 }
Exemple #4
0
 private void RaiseEventChanged (PlayerEventArgs args)
 {
     PlayerEventHandler handler = EventChanged;
     if (handler != null) {
         handler (args);
     }
 }
Exemple #5
0
    public void DestroyThisGrid()
    {
        PlayerEventHandler.UnRegisterToMouseClicked(gridEventHandler.MouseInteractionOnGridStarted);
        PlayerEventHandler.UnRegisterToMouseUnClicked(gridEventHandler.MouseInteractionOnGridEnded);

        GameObject.Destroy(gridParentObject);
    }
 public void OnPointerClick(PointerEventData eventData)
 {
     if (eventData.button == PointerEventData.InputButton.Left)
     {
         //Go to next state
         if (index == states.Count - 1)
         {
             index = 0;
         }
         else
         {
             index++;
         }
         textComp.text          = states[index];
         linkAttached.nodeState = states[index];
         LinkData.LinkTypes oldType = linkAttached.type;
         if (oldType == LinkData.LinkTypes.Specialization)
         {
             linkAttached.type = LinkData.LinkTypes.Generalization;
         }
         else
         {
             linkAttached.type = LinkData.LinkTypes.Specialization;
         }
         PlayerEventHandler.ChangeGenLinkType(linkAttached, oldType.ToString());
     }
     else if (eventData.button == PointerEventData.InputButton.Right)
     {
         linkAttached.participationIsTotal = !linkAttached.participationIsTotal;
         UpdateLineSprite();
     }
 }
    private void RemLink(GameObject node1, GameObject node2)
    {
        LinkData link = erDiagram_.RemLink(node1, node2);

        PlayerEventHandler.RemLink(link);
        erData_.RemoveLink(link);
    }
 public void OnConfirm()
 {
     PlayerEventHandler.UserClosedGame();
     PlayerEventHandler.GenerateLog();
     //Close the app
     Application.Quit();
 }
Exemple #9
0
 public static void CloseDiagram()
 {
     PlayerEventHandler.RoomMovement("Diagram", previousRoomName);
     SceneManager.LoadScene(previousRoomName);
     SceneManager.LoadScene("PlayerUI", LoadSceneMode.Additive);
     inUIscene = false;
     Pause(inUIscene);
 }
Exemple #10
0
        public void Initialize(Transform t, PlayerEventHandler pl, AudioSource aS)
        {
            m_Transform = t;
            // m_Player = pl;
            //m_Audio = aS;

            m_Pulse = new AlphaPulse(m_PreviewColor, m_PulseMin, m_PulseMax);
        }
Exemple #11
0
 public static void StartDiagram()
 {
     previousRoomName = SceneManager.GetActiveScene().name;
     PlayerEventHandler.RoomMovement(previousRoomName, "Diagram");
     SceneManager.LoadScene("Diagram");
     SceneManager.LoadScene("PlayerUI", LoadSceneMode.Additive);
     inUIscene = true;
 }
Exemple #12
0
 public static void NextRoom(string sceneName)
 {
     PlayerEventHandler.RoomMovement(SceneManager.GetActiveScene().name, sceneName);
     SceneManager.LoadScene(sceneName);
     SceneManager.LoadScene("PlayerUI", LoadSceneMode.Additive);
     inUIscene = false;
     Pause(inUIscene);
 }
Exemple #13
0
    public void AddListener(EventType EventType, PlayerEventHandler delegateFunc)
    {
        if (_delegateDic.ContainsKey(EventType) == false)
        {
            _delegateDic.Add(EventType, delegateFunc);
        }

        _delegateDic[EventType] += delegateFunc;
    }
Exemple #14
0
 public static void NextRoom(string sceneName, string diagramCode)
 {
     PlayerEventHandler.RoomMovement(SceneManager.GetActiveScene().name, sceneName);
     DiagramKeeper.SetDiagramCode(diagramCode);
     DiagramKeeper.GetCurrDiagram();
     SceneManager.LoadScene(sceneName);
     SceneManager.LoadScene("PlayerUI", LoadSceneMode.Additive);
     inUIscene = false;
 }
Exemple #15
0
        protected void onPlayerInRange(Player player)
        {
            PlayerEventHandler handler = PlayerInRangeEvent;

            if (handler != null)
            {
                handler(this, new PlayerEventArgs(player));
            }
        }
        private static void RaisePlayerIpBanEvent(string text, OutputParseResult outputParseResult, IPlayerAction playerAction)
        {
            PlayerEventHandler handler = PlayerIpBan;

            if (handler != null)
            {
                handler(text, outputParseResult, playerAction);
            }
        }
Exemple #17
0
    //New eventHandler is created when new Grid is spawned
    private void ApplyGridStartingSettings()
    {
        gridEventHandler = new GridEventHandler();

        PlayerEventHandler.RegisterToMouseClicked(gridEventHandler.MouseInteractionOnGridStarted);
        PlayerEventHandler.RegisterToMouseUnClicked(gridEventHandler.MouseInteractionOnGridEnded);

        gridEventHandler.NewGridCreatedInvoke(this.center, this.width, this.length);
    }
Exemple #18
0
 public void DisconnectEvent(PlayerEventHandler handler)
 {
     lock (event_handlers) {
         LinkedListNode <PlayerEventHandlerSlot> node = FindEventNode(handler);
         if (node != null)
         {
             event_handlers.Remove(node);
         }
     }
 }
 public void CheckPlayerLuck(PlayerEventHandler eventHandler, PlayerManager playerManager, PlayerModel player)
 {
     if (playerManager.IndentifyPlayerLuck(player) > 10)
     {
         eventHandler.IdentifyPlayerLuck += message.PlayerTypicalMessage;
     }
     else
     {
         eventHandler.IdentifyPlayerLuck += message.PlayerStrangeMessage;
     }
 }
Exemple #20
0
    public void Delete()
    {
        string path = Path.Combine(Path.Combine(Application.persistentDataPath, "Saves"), "Diagram-" + diagramCode + ".json");

        if (File.Exists(path))
        {
            Debug.Log("Delete");
            File.Delete(path);
        }
        PlayerEventHandler.DeleteDiagram(this);
    }
    public void AddNode(NodeTypeClass typeClass)
    {
        Vector2 nodePos;

        RectTransformUtility.ScreenPointToLocalPointInRectangle(scroll.content, selectedPos, mainCamera, out nodePos);
        NodeData nodeData = new NodeData(typeClass.nodeType, nodePos, erData_.lastId++);

        erDiagram_.DrawNode(nodeData);
        erData_.AddNodeData(nodeData);
        PlayerEventHandler.AddNode(nodeData);
    }
    public void ChangeNameAtr()
    {
        string oldName;
        string newName = nameListAttr.options[nameListAttr.value].text;

        selectedNode.name = newName;
        erDiagram_.objToNode[selectedNode].Rename(newName);
        NodeData node = erDiagram_.UpdateName(selectedNode, out oldName);

        PlayerEventHandler.ChangeName(node, oldName);
    }
Exemple #23
0
 public void PlayGame()
 {
     if (nameInput.text != "")
     {
         PlayerEventHandler.SetPlayer(nameInput.text);
         SceneHandler.NextRoom("Pasillo");
     }
     else
     {
         errorDisplay.text = "Debes introducir tu identificador antes de comenzar el juego";
     }
 }
Exemple #24
0
 private void Update()
 {
     if (!Input.anyKey)
     {
         return;
     }
     if (Input.GetKeyDown(KeyCode.Escape))
     {
         SceneHandler.Pause(false);
         Hide();
         OverlayMenu.Show();
         PlayerEventHandler.CloseMenu();
     }
 }
 public void CheckPlayerDeck(PlayerEventHandler eventHandler, DeckModel deck)
 {
     foreach (CardModel item in deck.Deck)
     {
         if (item.Health > 2 && item.Damage < 4)
         {
             eventHandler.IdentifyPlayerDeck += message.PlayerGoodDeckMessage;
         }
         else
         {
             eventHandler.IdentifyPlayerDeck += message.PlayerAwfulDeckMessage;
         }
     }
 }
Exemple #26
0
 public void Update()
 {
     if (!Input.anyKey)
     {
         return;
     }
     if (Input.GetKeyDown(KeyCode.F))
     {
         SceneHandler.Pause(false);
         Hide();
         OverlayMenu.Show();
         PlayerEventHandler.ClosePhone();
     }
 }
Exemple #27
0
    public void Save()
    {
        string path = Path.Combine(Path.Combine(Application.persistentDataPath, "Saves"), "Diagram-" + diagramCode + ".json");

        using (FileStream stream = new FileStream(path, FileMode.Create, FileAccess.Write))
        {
            using (StreamWriter writer = new StreamWriter(stream))
            {
                string jsonString = JsonConvert.SerializeObject(this);
                writer.Write(jsonString);
            }
        }
        PlayerEventHandler.SaveDiagram(this);
    }
Exemple #28
0
        public void ModifyEvent(PlayerEvent eventMask, PlayerEventHandler handler)
        {
            lock (event_handlers) {
                VerifyEventMask(eventMask);

                LinkedListNode <PlayerEventHandlerSlot> node = FindEventNode(handler);
                if (node != null)
                {
                    PlayerEventHandlerSlot slot = node.Value;
                    slot.EventMask = eventMask;
                    node.Value     = slot;
                }
            }
        }
Exemple #29
0
        private void Start()
        {
            m_Player = GameController.LocalPlayer;
            m_BuildingHelpers.Initialize(transform, m_Player, m_AudioSource);

            m_Player.PlaceObject.SetTryer(Try_Place);
            m_Player.PlaceObject.AddListener(m_BuildingHelpers.PlacePiece);

            m_Player.RotateObject.SetTryer(Try_RotateObject);

            m_Player.EquippedItem.AddChangeListener(OnChanged_EquippedItem);
            m_Player.SelectedBuildable.AddChangeListener(OnChanged_SelectedBuildable);

            m_InventoryContainer = GUIController.Instance.GetContainer("Inventory");
        }
Exemple #30
0
        private LinkedListNode <PlayerEventHandlerSlot> FindEventNode(PlayerEventHandler handler)
        {
            LinkedListNode <PlayerEventHandlerSlot> node = event_handlers.First;

            while (node != null)
            {
                if (node.Value.Handler == handler)
                {
                    return(node);
                }
                node = node.Next;
            }

            return(null);
        }
Exemple #31
0
        private void WaitUntil (PlayerEvent? @event, PlayerState? state, System.Action action)
        {
            if (action == null) {
                throw new ArgumentNullException ("action");
            }
            if (@event == null && state == null) {
                throw new ArgumentException ("Event or state must be non-null");
            }
            if (@event != null && state != null) {
                throw new ArgumentException ("Event and state cannot be both non-null");
            }

            object lock_object = new object ();
            string evnt_or_state_desc = @event != null ? @event.Value.ToString () : state.Value.ToString ();

            Exception exception = null;


            Func<PlayerEventArgs, bool> matches = (a) => {
                if (a == null) {
                    throw new ArgumentNullException ("a");
                }
                var sca = a as PlayerEventStateChangeArgs;
                PlayerEvent? last_event = a.Event;
                PlayerState? last_state = null;
                if (sca != null) {
                    last_state = sca.Current;
                }

                return (@event != null && @event.Value.Equals (last_event.Value))
                || (state != null && last_state != null && state.Value.Equals (last_state.Value));
            };
            var args_queue = new Queue<PlayerEventArgs> ();

            var reset_event = new ManualResetEvent (false);
            reset_event.Reset ();

            var handler = new PlayerEventHandler (a => {
                try {
                    lock (lock_object) {
                        args_queue.Enqueue (a);
                    }
                } catch (Exception ex) {
                    exception = ex;
                }
                reset_event.Set ();
            });
            service.ConnectEvent (handler);

            bool return_early = (state != null && service.CurrentState.Equals (state.Value));
            action ();
            if (return_early) {
                return;
            }

            const int seconds = 3;
            int count = 0;
            const int max_count = 10;

            string event_or_state_desc = @event != null ? @event.ToString () : state.ToString ();

            bool found = false;
            do {
                if (!reset_event.WaitOne (TimeSpan.FromSeconds (seconds))) {
                    Assert.Fail (String.Format ("Waited {0}s for {1} at iteration {2}, but didn't happen",
                                                seconds, evnt_or_state_desc, count));
                    break;
                }
                lock (lock_object) {
                    while (args_queue.Count > 0) {
                        var arg = args_queue.Dequeue ();
                        if (matches (arg)) {
                            found = true;
                            break;
                        }
                        count++;
                    }
                }

                if (exception != null) {
                    throw exception;
                }
                if (count > max_count) {
                    Assert.Fail (String.Format ("More than {0} events/states happened, but not {1}", max_count, event_or_state_desc));
                }
            } while (!found);

            service.DisconnectEvent (handler);
        }
Exemple #32
0
        private void AssertTransition(System.Func<PlayerState?, PlayerEvent?, bool> ignore, System.Action action, params object [] states)
        {
            Log.DebugFormat ("AssertTransition: {0}", String.Join (", ", states.Select (s => s.ToString ()).ToArray ()));

            foreach (var state in states) {
                if (state == null) {
                    throw new ArgumentException ("states array cannot contain nulls");
                }
                if (state.GetType () != typeof (PlayerEvent) && state.GetType () != typeof (PlayerState)) {
                    throw new ArgumentException ("states array can only contain states or events, not " + state.GetType ().FullName);
                }
            }

            int result_count = 0;
            var reset_event = new ManualResetEvent (false);
            var handler = new Action<PlayerEventArgs> (a => {
                lock (states) {
                    if (result_count < states.Length) {
                        var sca = a as PlayerEventStateChangeArgs;

                        var last_state = sca != null ? sca.Current : service.CurrentState;
                        var last_event = a.Event;

                        if (ignore != null && ignore (last_state, last_event)) {
                            Log.DebugFormat ("   > ignoring {0}/{1}", last_event, last_state);
                            return;
                        }

                        if (sca == null) {
                            Log.DebugFormat ("   > {0}", a.Event);
                        } else {
                            Log.DebugFormat ("   > {0}", last_state);
                        }

                        var evnt = (states[result_count] as PlayerEvent?) ?? PlayerEvent.StateChange;
                        var state = states[result_count] as PlayerState?;

                        var evnt_or_state_desc = (evnt == PlayerEvent.StateChange ?
                            evnt.ToString() + ">" + states[result_count].ToString () : evnt.ToString ());
                        var last_evnt_or_state_desc = (last_event == PlayerEvent.StateChange ?
                            last_event.ToString () + ">" + sca.Current.ToString () : last_event.ToString ());

                        Assert.That (last_event, Is.EqualTo (evnt),
                            String.Format ("Event[{0}] doesn't match (should be {1}, it was {2})",
                                           result_count, evnt_or_state_desc, last_evnt_or_state_desc));
                        if (state != null) {
                            Assert.That (last_state, Is.EqualTo (state), String.Format ("State[{0}] doesn't match", result_count));
                        }

                        result_count++;
                    }
                }
                reset_event.Set ();
            });

            AssertionException exception = null;
            var guarded_handler = new PlayerEventHandler (args => {
                try {
                    handler (args);
                } catch (AssertionException ae) {
                    exception = ae;
                }
            });
            service.ConnectEvent (guarded_handler);

            if (action != null) action ();

            const int seconds = 3;
            while (result_count < states.Length) {
                reset_event.Reset ();
                if (!reset_event.WaitOne (TimeSpan.FromSeconds (seconds))) {
                    Assert.Fail (String.Format ("Waited {0}s for state/event, didn't happen", seconds));
                    break;
                }
                if (exception != null) {
                    throw new AssertionException (exception.Message, exception);
                }
            }

            service.DisconnectEvent (guarded_handler);
        }
Exemple #33
0
        private LinkedListNode<PlayerEventHandlerSlot> FindEventNode(PlayerEventHandler handler)
        {
            LinkedListNode<PlayerEventHandlerSlot> node = event_handlers.First;
            while (node != null) {
                if (node.Value.Handler == handler) {
                    return node;
                }
                node = node.Next;
            }

            return null;
        }
Exemple #34
0
        public void ModifyEvent(PlayerEvent eventMask, PlayerEventHandler handler)
        {
            lock (event_handlers) {
                VerifyEventMask (eventMask);

                LinkedListNode<PlayerEventHandlerSlot> node = FindEventNode (handler);
                if (node != null) {
                    PlayerEventHandlerSlot slot = node.Value;
                    slot.EventMask = eventMask;
                    node.Value = slot;
                }
            }
        }
Exemple #35
0
 public void DisconnectEvent(PlayerEventHandler handler)
 {
     lock (event_handlers) {
         LinkedListNode<PlayerEventHandlerSlot> node = FindEventNode (handler);
         if (node != null) {
             event_handlers.Remove (node);
         }
     }
 }
Exemple #36
0
        public void ConnectEvent(PlayerEventHandler handler, PlayerEvent eventMask, bool connectAfter)
        {
            lock (event_handlers) {
                VerifyEventMask (eventMask);

                PlayerEventHandlerSlot slot = new PlayerEventHandlerSlot (eventMask, handler);

                if (connectAfter) {
                    event_handlers.AddLast (slot);
                } else {
                    event_handlers.AddFirst (slot);
                }
            }
        }
Exemple #37
0
 public void ConnectEvent(PlayerEventHandler handler, bool connectAfter)
 {
     ConnectEvent (handler, event_default_mask, connectAfter);
 }
Exemple #38
0
 public void ConnectEvent(PlayerEventHandler handler, PlayerEvent eventMask)
 {
     ConnectEvent (handler, eventMask, false);
 }
Exemple #39
0
 public void ConnectEvent(PlayerEventHandler handler)
 {
     ConnectEvent (handler, event_default_mask, false);
 }
Exemple #40
0
 public PlayerEventHandlerSlot(PlayerEvent mask, PlayerEventHandler handler)
 {
     EventMask = mask;
     Handler = handler;
 }
Exemple #41
0
        private void AssertTransition (System.Func<PlayerState?, PlayerEvent?, bool> ignore, System.Action action, params object [] states)
        {
            Log.DebugFormat ("AssertTransition: {0}", String.Join (", ", states.Select (s => s.ToString ()).ToArray ()));
            int result_count = 0;
            var reset_event = new ManualResetEvent (false);
            var handler = new PlayerEventHandler (a => {
                lock (states) {
                    if (result_count < states.Length) {
                        var sca = a as PlayerEventStateChangeArgs;

                        var last_state = sca != null ? sca.Current : service.CurrentState;
                        var last_event = a.Event;

                        if (ignore != null && ignore (last_state, last_event)) {
                            Log.DebugFormat ("   > ignoring {0}/{1}", last_event, last_state);
                            return;
                        }

                        if (sca == null) {
                            Log.DebugFormat ("   > {0}", a.Event);
                        } else {
                            Log.DebugFormat ("   > {0}", last_state);
                        }

                        var evnt = (states[result_count] as PlayerEvent?) ?? PlayerEvent.StateChange;
                        var state = states[result_count] as PlayerState?;

                        result_count++;
                        Assert.AreEqual (evnt, last_event);
                        if (state != null) {
                            Assert.AreEqual (state, last_state);
                        }
                    }
                }
                reset_event.Set ();
            });

            service.ConnectEvent (handler);

            if (action != null) action ();

            while (result_count < states.Length) {
                reset_event.Reset ();
                if (!reset_event.WaitOne (3000)) {
                    Assert.Fail (String.Format ("Waited 3s for state/event, didnt' happen"));
                    break;
                }
            }

            service.DisconnectEvent (handler);
        }