Exemplo n.º 1
0
 public UIChat()
 {
     if (singleton == null)
     {
         singleton = this;
     }
 }
Exemplo n.º 2
0
    public void DoAddUser(int uid, string user, int selfUid)
    {
        UIChat chat = Camera.main.gameObject.GetComponent <UIChat>();

        if (chat != null)
        {
            chat.AddUser(uid, user, selfUid);
        }
    }
Exemplo n.º 3
0
    public void DoChat(string user, string message, string talkPlayer)
    {
        UIChat chat = Camera.main.gameObject.GetComponent <UIChat>();

        if (chat != null)
        {
            chat.AddChat(user, message, talkPlayer);
        }
    }
Exemplo n.º 4
0
    public void DoRemoveUser(int uid)
    {
        UIChat chat = Camera.main.gameObject.GetComponent <UIChat>();

        if (chat != null)
        {
            chat.RemoveUser(uid);
        }
    }
Exemplo n.º 5
0
 public UIChat()
 {
     // assign singleton only once (to work with DontDestroyOnLoad when
     // using Zones / switching scenes)
     if (singleton == null)
     {
         singleton = this;
     }
 }
Exemplo n.º 6
0
    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");
    }
Exemplo n.º 7
0
    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);
    }
Exemplo n.º 8
0
    void Awake()
    {
        mInst = this;

        if (input != null)
        {
            EventDelegate.Set(input.onSubmit, OnSubmitInternal);
            input.defaultText = Localization.Get("Chat");
            UIEventListener.Get(input.gameObject).onSelect = OnSelectInput;
        }
    }
Exemplo n.º 9
0
	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;

	}
Exemplo n.º 10
0
    // 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);
        }
    }
Exemplo n.º 11
0
 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);
 }
Exemplo n.º 12
0
    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_");
    }
Exemplo n.º 13
0
    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);
    }
Exemplo n.º 14
0
    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);
    }
Exemplo n.º 15
0
	void Awake ()
	{
		mInst = this;

		if (input != null)
		{
			EventDelegate.Set(input.onSubmit, OnSubmitInternal);
			input.defaultText = Localization.Get("Chat");
			UIEventListener.Get(input.gameObject).onSelect = OnSelectInput;
		}
	}
Exemplo n.º 16
0
 public UIChat()
 {
     Instance = this;
 }
Exemplo n.º 17
0
    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.
    }
Exemplo n.º 19
0
    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();
            }
        });
    }
Exemplo n.º 20
0
 public UIChat()
 {
     singleton = this;
 }
Exemplo n.º 21
0
 void OnDestroy()
 {
     mInst = null;
 }
Exemplo n.º 22
0
	void OnDestroy () { mInst = null; }