コード例 #1
0
    public void Init()
    {
        roomsContainer = transform.Find("RoomList").Find("Viewport").Find("Content").gameObject;
        userNameInput  = transform.Find("Username").GetComponent <TMP_InputField>();
        createButton   = transform.Find("CreateButton").GetComponent <Button>();
        redButton      = transform.Find("ButtonRed").GetComponent <Button>();
        blueButton     = transform.Find("ButtonBlue").GetComponent <Button>();

        string userName = PlayerPrefs.GetString("username");
        int    color    = PlayerPrefs.GetInt("color");

        if (userName.Length > 0)
        {
            userNameInput.text = userName;
        }
        else
        {
            userNameInput.text = usernames[Random.Range(0, usernames.Length)];
        }
        redButton.onClick.AddListener(() => onChangeColor.Invoke("red"));
        blueButton.onClick.AddListener(() => onChangeColor.Invoke("blue"));
        if (color == 0)
        {
            redButton.Select();
            redButton.onClick.Invoke();
        }
        else
        {
            blueButton.Select();
            blueButton.onClick.Invoke();
        }
        userNameInput.onEndEdit.AddListener((string text) => { onChangeUsername.Invoke(userNameInput.text); });
        userNameInput.onEndEdit.Invoke(userNameInput.text);
        createButton.onClick.AddListener(() => onCreateRoom.Invoke(userNameInput.text + " game"));
    }
コード例 #2
0
        protected virtual void Start()
        {
            foreach (Target target in TargetList)
            {
                target.Button.OnValidate.AddListener(() => {
                    if (CanDoAction())
                    {
                        m_lockAction = true;
                        PreAction();
                        OnActionStart.Invoke(target.Room, () => {
                            m_lockAction = false;
                            DoAction(target.Room);
                        });

                        if (forceActionWithoutEventCallback)
                        {
                            m_lockAction = false;
                            DoAction(target.Room);
                        }
                        //StartCoroutine(StartAction(target.Room));
                    }
                });
            }

            StartCoroutine(RefreshButtonVisibility());
        }
コード例 #3
0
ファイル: Room.cs プロジェクト: nikchernyakov/game-cyberpank
 public void EnterRoom()
 {
     if (m_roomEvent != null)
     {
         m_roomEvent.Invoke(this);
     }
 }
コード例 #4
0
    private void OnTriggerExit(Collider other)
    {
        if (other.gameObject.layer == LayerMask.NameToLayer("Room"))
        {
            Room room = other.GetComponent <Room>();

            onExitRoom.Invoke(room);

            if (room == enteredRoom)
            {
                enteredRoom    = null;
                isEnterNewRoom = false;
            }
            else if (other.gameObject.tag == "CurrentRoom")
            {
                if (isEnterNewRoom)
                {
                    onEnterNewRoom.Invoke(enteredRoom);
                }
            }
        }
        else if (other.gameObject.layer == LayerMask.NameToLayer("Real Space"))
        {
            Debug.Log("User exited real space");
        }
    }
コード例 #5
0
        IEnumerator TransitionRoutine(NumericBoundariesSettings numericBoundariesSettings, float targetSize, float transitionDuration = 1f, EaseType transitionEaseType = EaseType.EaseOut)
        {
            _transitioning = true;

            // Disable the current numeric boundaries
            _numericBoundaries.UseNumericBoundaries = false;

            // Size
            var initialSize = ProCamera2D.ScreenSizeInWorldCoordinates.y / 2f;

            //Position
            var initialCamPosH = Vector3H(ProCamera2D.LocalPosition);
            var initialCamPosV = Vector3V(ProCamera2D.LocalPosition);

            // Transition
            var t = 0f;

            while (t <= 1.0f)
            {
                t += ProCamera2D.DeltaTime / transitionDuration;

                // Size
                _newSize = Utils.EaseFromTo(initialSize, targetSize, t, transitionEaseType);

                // Position
                var targetPosH = ProCamera2D.CameraTargetPositionSmoothed.x;
                var targetPosV = ProCamera2D.CameraTargetPositionSmoothed.y;

                LimitToNumericBoundaries(
                    ref targetPosH,
                    ref targetPosV,
                    targetSize * ProCamera2D.GameCamera.aspect,
                    targetSize,
                    numericBoundariesSettings);

                var newPosH = Utils.EaseFromTo(initialCamPosH, targetPosH, t, transitionEaseType);
                var newPosV = Utils.EaseFromTo(initialCamPosV, targetPosV, t, transitionEaseType);
                _newPos = VectorHVD(newPosH, newPosV, 0);

                yield return(ProCamera2D.GetYield());
            }

            _transitioning = false;

            _numericBoundaries.Settings = numericBoundariesSettings;

            _transitionRoutine = null;

            if (OnFinishedTransition != null)
            {
                OnFinishedTransition.Invoke(_currentRoomIndex, _previousRoomIndex);
            }

            _previousRoomIndex = _currentRoomIndex;
        }
コード例 #6
0
        /// <summary>
        /// Enter a room. Only use when the AutomaticRoomActivation is set to false.
        /// </summary>
        /// <param name="roomIndex">The room number on the list</param>
        /// <param name="useTransition">Use a camera movement transition</param>
        public void EnterRoom(int roomIndex, bool useTransition = true)
        {
            if (roomIndex < 0 || roomIndex > Rooms.Count - 1)
            {
                throw new System.Exception("Can't find room with index: " + roomIndex);
            }

            if (roomIndex == _currentRoomIndex)
            {
                return;
            }

            _previousRoomIndex = _currentRoomIndex;
            _currentRoomIndex  = roomIndex;

            TransitionToRoom(Rooms[_currentRoomIndex], useTransition);

            if (OnStartedTransition != null)
            {
                OnStartedTransition.Invoke(roomIndex, _previousRoomIndex);
            }
        }
コード例 #7
0
    public void AddRoom(string roomId, string roomName)
    {
        if (rooms.Find(x => x.roomId == roomId) != null)
        {
            return;
        }
        RoomItem roomItem = Instantiate(roomItemPrefab, roomsContainer.transform).GetComponent <RoomItem>();

        roomItem.SetId(roomId);
        roomItem.SetName(roomName);
        roomItem.onJoinRoom.AddListener(() => { onJoinRoom.Invoke(roomId); });
        rooms.Add(roomItem);
    }
コード例 #8
0
        /// <summary>
        /// Enter a room. Only use when the AutomaticRoomActivation is set to false.
        /// </summary>
        /// <param name="roomIndex">The room number on the list</param>
        public void EnterRoom(int roomIndex)
        {
            if (roomIndex < 0 || roomIndex > Rooms.Count - 1)
            {
                Debug.LogError("Can't find room with index: " + roomIndex);
                return;
            }

            if (roomIndex == _currentRoomIndex)
            {
                return;
            }

            _previousRoomIndex = _currentRoomIndex;
            _currentRoomIndex  = roomIndex;

            TransitionToRoom(Rooms[_currentRoomIndex]);

            if (OnStartedTransition != null)
            {
                OnStartedTransition.Invoke(roomIndex, _previousRoomIndex);
            }
        }
コード例 #9
0
 public void InvokeRoomEvent(RoomModel model)
 {
     roomEvent.Invoke(model);
 }
コード例 #10
0
ファイル: Networking.cs プロジェクト: spacebit/killer7dfps
 private static void OnRoomListReceived(List <NetworkRoom> rooms)
 {
     sendRoomJoinRequestEvent.Invoke(rooms[0]);
 }