public UIChat() { if (singleton == null) { singleton = this; } }
public void DoAddUser(int uid, string user, int selfUid) { UIChat chat = Camera.main.gameObject.GetComponent <UIChat>(); if (chat != null) { chat.AddUser(uid, user, selfUid); } }
public void DoChat(string user, string message, string talkPlayer) { UIChat chat = Camera.main.gameObject.GetComponent <UIChat>(); if (chat != null) { chat.AddChat(user, message, talkPlayer); } }
public void DoRemoveUser(int uid) { UIChat chat = Camera.main.gameObject.GetComponent <UIChat>(); if (chat != null) { chat.RemoveUser(uid); } }
public UIChat() { // assign singleton only once (to work with DontDestroyOnLoad when // using Zones / switching scenes) if (singleton == null) { singleton = this; } }
public override void OnStartClient() { base.OnStartClient(); chat = FindObjectOfType <UIChat>(); chat.sendButton.onClick.AddListener(OnSendButton); playerColor = new Color(Random.Range(0, 256) / 256f, Random.Range(0, 256) / 256f, Random.Range(0, 256) / 256f); Debug.Log("Client"); }
public void OnCharacterSay(int avatarID, string text) { UIChat chat = Instantiate(uiChat_to_instantiate); chat.transform.SetParent(container); chat.transform.localScale = Vector3.one; chat.transform.localEulerAngles = Vector3.zero; chat.Init(avatarID, text); }
void Awake() { mInst = this; if (input != null) { EventDelegate.Set(input.onSubmit, OnSubmitInternal); input.defaultText = Localization.Get("Chat"); UIEventListener.Get(input.gameObject).onSelect = OnSelectInput; } }
void Awake() { instance = this; mParent = gameObject.transform.FindChild(ParentPath).gameObject; mScrollView = gameObject.transform.FindChild(mScrollViewPath).GetComponent<UIScrollView>(); mGo_Input = gameObject.transform.FindChild(mGo_Input_Path).GetComponent<UIInput>(); mInputLabel = mGo_Input.transform.FindChild ("Label").transform.GetComponent<UILabel>(); mGo_Send = gameObject.transform.FindChild(mBt_Send_Path).gameObject; UIEventListener.Get(mGo_Send).onClick += OnSubmit; }
// Use this for initialization void Awake() { Input.backButtonLeavesApp = true; self = this; colorMap[0] = Color.green; colorMap[1] = Color.blue; colorMap[2] = new Color(0f, 1f, 1f); colorMap[3] = Color.black; colorMap[4] = Color.red; colorMap[5] = new Color(1f, 0f, 1f); colorMap[6] = new Color(1f, 1f, 0f); Mesh tileMesh = TilePrefab.GetComponent <MeshFilter>().sharedMesh; baseMainVerts = tileMesh.vertices; convertToSides(tileMesh, baseMainVerts, ref sideVerts); tileMesh.vertices = baseMainVerts; sideView = false; inventory = new Inventory(GameObject.FindGameObjectWithTag("inventory"), false); equipment = new Inventory(GameObject.FindGameObjectWithTag("equipS"), true); myCam = GameObject.FindGameObjectWithTag("Cam2").GetComponent <Camera> (); mainCam = GameObject.FindGameObjectWithTag("MainCamera").GetComponent <Camera> (); soundUI = myCam.transform.GetChild(1).GetComponent <AudioSource> (); soundEquip = myCam.transform.GetChild(2).GetComponent <AudioSource> (); playerLocation = GameObject.FindGameObjectWithTag("Player").GetComponent <Transform> (); //playerAnim = playerLocation.GetComponent<Animator> (); //playerFollowL = GameObject.FindGameObjectWithTag ("PlayerFollow").GetComponent<Transform> (); UIInventory.SetActive(false); UINormal.SetActive(false); UIEdit.SetActive(false); UIMove.SetActive(false); UIChat.SetActive(false); UIStats.SetActive(false); UIHaS.SetActive(false); UICompass.SetActive(false); UIOptions.SetActive(false); chCam = chatCam.GetComponent <Camera> (); chCam.enabled = false; //chatCam.SetActive (false); selBox = GameObject.FindGameObjectWithTag("selectBox"); selCirc = GameObject.FindGameObjectWithTag("selectCircle"); selBox.SetActive(false); selCirc.SetActive(false); selectBox = selBox; foreach (EnemyType type in Enum.GetValues(EnemyType.archer.GetType())) { GameObject prefab = Resources.Load <GameObject>("Prefabs/enemy/" + type.ToString()); enemyPrefabs.Add(type, prefab); } }
protected override void Init() { base.Init(); instance = this; bg = transform.Find("BgBtn"); chatEffect = transform.Find("ChatBtn/UI_XiaoXi_TiXing_01"); chatBtn = transform.Find("ChatBtn").GetComponent <GUISingleButton>(); channelLabel = transform.Find("Channel").GetComponent <UILabel>(); contentLabel = transform.Find("Content").GetComponent <UILabel>(); //nickNameLabel = transform.Find("NickName").GetComponent<UILabel>(); sprite = transform.Find("Sprite").GetComponent <UISprite>(); speakRateLimit = 3; speakTimer = 3; chatBtn.onClick = OnChatBtnClick; bgBtn.onClick = OnChatBtnClick; playerData.GetInstance().NewChatHint += SetNewChatHint; SetNewChatHint(null); chatEffect.gameObject.SetActive(GetNotReadCount() > 0 ? true : false); }
public override void OnStartLocalPlayer() { // cache the UI chat component so we don't have to call FindObject each time // -> only the local player needs it, no reason to waste computations for // all players here chat = FindObjectOfType <UIChat>(); // test messages chat.AddMessage(new ChatMessage("", info.identifierIn, "Use /w NAME to whisper", "", info.color)); chat.AddMessage(new ChatMessage("", info.identifierIn, "Use /p for party chat", "", info.color)); chat.AddMessage(new ChatMessage("", info.identifierIn, "Use /g for guild chat", "", info.color)); chat.AddMessage(new ChatMessage("", info.identifierIn, "Or click on a message to reply", "", info.color)); chat.AddMessage(new ChatMessage("Someone", guild.identifierIn, "Anyone here?", "/g ", guild.color)); chat.AddMessage(new ChatMessage("Someone", party.identifierIn, "Let's hunt!", "/p ", party.color)); chat.AddMessage(new ChatMessage("Someone", whisper.identifierIn, "Are you there?", "/w Someone ", whisper.color)); chat.AddMessage(new ChatMessage("Someone", local.identifierIn, "Hello!", "/w Someone ", local.color)); // addon system hooks Utils.InvokeMany(typeof(Chat), this, "OnStartLocalPlayer_"); }
protected override bool DoFiringInput() { if (UIChat.IsActive()) { SetFireIsHeld(false); return(false); } if (EventSystem.current.IsPointerOverGameObject()) { return(false); } if (!Input.mousePresent) { return(false); } var mousePressed = Input.GetMouseButton(0); if (IsActiveModule || mousePressed) { var mouseRay = Camera.main.ScreenPointToRay(Input.mousePosition); float hitDist; RaycastHit hit; if (Physics.Raycast(mouseRay, out hit, float.PositiveInfinity, GroundLayerMask)) { SetDesiredFirePosition(hit.point); } else if (FloorPlane.Raycast(mouseRay, out hitDist)) { SetDesiredFirePosition(mouseRay.GetPoint(hitDist)); } } SetFireIsHeld(mousePressed); return(mousePressed); }
protected override bool DoMovementInput() { if (UIChat.IsActive()) { SetDesiredMovementDirection(Vector2.zero); return(false); } var y = Input.GetAxisRaw("Vertical"); var x = Input.GetAxisRaw("Horizontal"); var cameraDirection = new Vector3(x, y, 0); if (cameraDirection.sqrMagnitude <= 0.01f) { SetDesiredMovementDirection(Vector2.zero); return(false); } var worldUp = Camera.main.transform.TransformDirection(Vector3.up); worldUp.y = 0; worldUp.Normalize(); var worldRight = Camera.main.transform.TransformDirection(Vector3.right); worldRight.y = 0; worldRight.Normalize(); var worldDirection = worldUp * y + worldRight * x; var desiredDir = new Vector2(worldDirection.x, worldDirection.z); if (desiredDir.magnitude > 1) { desiredDir.Normalize(); } SetDesiredMovementDirection(desiredDir); return(true); }
void Awake () { mInst = this; if (input != null) { EventDelegate.Set(input.onSubmit, OnSubmitInternal); input.defaultText = Localization.Get("Chat"); UIEventListener.Get(input.gameObject).onSelect = OnSelectInput; } }
public UIChat() { Instance = this; }
private void StartServer() { _isServer = true; LocalTank = AddTank(_publicKey); LocalTank.Follow(); _client.OnMessage += (src, data) => UnityMainThreadDispatcher.Instance().Enqueue(() => { switch (GetMessageType(data)) { case MessageType.JoinEvent: AddTank(src); SendStates(true); break; case MessageType.MovementState: var tank = _tanks[src]; var state = MovementState.FromByteArray(data); var cameraDirection = new Vector3(state.moveX, state.moveY, 0); if (cameraDirection.sqrMagnitude > 0.01f) { var worldUp = Camera.main.transform.TransformDirection(Vector3.up); worldUp.y = 0; worldUp.Normalize(); var worldRight = Camera.main.transform.TransformDirection(Vector3.right); worldRight.y = 0; worldRight.Normalize(); var worldDirection = worldUp * state.moveY + worldRight * state.moveX; var desiredDir = new Vector2(worldDirection.x, worldDirection.z); if (desiredDir.magnitude > 1) { desiredDir.Normalize(); } tank.SetDesiredMovementDirection(new Vector2(state.moveX, state.moveY)); } else { tank.SetDesiredMovementDirection(Vector2.zero); } tank.SetDesiredFirePosition(new Vector3(state.fireX, 0, state.fireY)); tank.SetFireIsHeld(state.fire); break; case MessageType.ChatMessage: var message = ChatMessage.FromByteArray(data); UIChat.ShowMessage(message.Message); break; case MessageType.InitialTankStates: throw new ArgumentOutOfRangeException(); case MessageType.TankStates: throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(); } }); TankInputModule.Instance.Init(LocalTank); HUDController.Instance.InitHudPlayer(LocalTank.Health); }
private void AddMessageClient_Report(ChatMessage mi) { UIChat chat = GameObject.Find("Chat").GetComponent <UIChat>(); chat.AddMessage(mi); //Sends messages from UCE_Help to the chat window. }
private void StartClient() { TankInputModule.Instance.Init(state => Send(Env.ServerName, state)); for (var i = 0; i < 15; i++) { Send(i + "." + Env.ServerName, new JoinEvent()); } _client.OnMessage += (src, data) => UnityMainThreadDispatcher.Instance().Enqueue(() => { Env.ServerName = src; switch (GetMessageType(data)) { case MessageType.InitialTankStates: Debug.Log(src); Debug.Log(_tanks); goto case MessageType.TankStates; case MessageType.TankStates: var tanks = TankStates.FromByteArray(data); for (var i = 0; i < tanks.States.Length; i++) { var state = tanks.States[i]; TankManager tank; if (tanks.Type == MessageType.InitialTankStates) { tank = AddTank(state.publicKey); if (state.publicKey.Equals(_publicKey)) { HUDController.Instance.InitHudPlayer(tank.Health); tank.Follow(); } } else { tank = _tanksList[i]; } if (state.respawned) { tank.Respawn( new Vector3(state.moveX, 0, state.moveY), new Vector3(0, state.rotation.Value, 0) ); } else { tank.SetDesiredMovementPosition(new Vector2(state.moveX, state.moveY)); } tank.SetDesiredFirePosition(new Vector3(state.fireX, 0, state.fireY)); tank.SetFireIsHeld(state.fire); } break; case MessageType.ChatMessage: var message = ChatMessage.FromByteArray(data); UIChat.ShowMessage(message.Message); break; case MessageType.JoinEvent: throw new ArgumentOutOfRangeException(); case MessageType.MovementState: throw new ArgumentOutOfRangeException(); default: throw new ArgumentOutOfRangeException(); } }); }
public UIChat() { singleton = this; }
void OnDestroy() { mInst = null; }
void OnDestroy () { mInst = null; }