Ejemplo n.º 1
0
    void OnPlayerMove(SocketIOEvent socketIOEvent)
    {
        string   data           = socketIOEvent.data.ToString();
        UserJSON userJSON       = UserJSON.CreateFromJSON(data);
        Vector3  playerPosition = new Vector3(userJSON.playerPosition[0], userJSON.playerPosition[1], userJSON.playerPosition[2]);

        if (userJSON.name == playerNameInput.text)
        {
            return;
        }
        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            p.transform.position = playerPosition;
        }
        Debug.Log(userJSON.name + " moved! ! !");
    }
Ejemplo n.º 2
0
    void OnPlayerTurn(SocketIOEvent socketIOEvent)
    {
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Quaternion rotation = Quaternion.Euler(float.Parse(userJSON.rotation[0]), float.Parse(userJSON.rotation[1]), float.Parse(userJSON.rotation[2]));

        // if it is the current player exit
        if (userJSON.name == playerNameInput.text)
        {
            return;
        }
        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            p.transform.rotation = rotation;
        }
    }
Ejemplo n.º 3
0
    void OnPlay(SocketIOEvent socketIOEvent)
    {
        print("you joined");
        string     data            = socketIOEvent.data.ToString();
        UserJSON   currentUserJSON = UserJSON.CreateFromJSON(data);
        Vector3    position        = new Vector3(currentUserJSON.position[0], currentUserJSON.position[1], currentUserJSON.position[2]);
        Quaternion rotation        = Quaternion.Euler(currentUserJSON.rotation[0], currentUserJSON.rotation[1], currentUserJSON.rotation[2]);
        GameObject p = Instantiate(player, position, rotation) as GameObject;

        PlayerController pc         = p.GetComponent <PlayerController>();
        Transform        t          = p.transform.Find("Healthbar Canvas");
        Transform        t1         = t.transform.Find("Player Name");
        Text             playerName = t1.GetComponent <Text>();

        playerName.text  = currentUserJSON.name;
        pc.isLocalPlayer = true;
        p.name           = currentUserJSON.name;
    }
Ejemplo n.º 4
0
    void OnPlayerTurn(SocketIOEvent socketIOEvent)
    {
        string     data           = socketIOEvent.data.ToString();
        UserJSON   userJSON       = UserJSON.CreateFromJSON(data);
        Quaternion playerRotation = Quaternion.Euler(userJSON.playerRotation[0], userJSON.playerRotation[1], userJSON.playerRotation[2]);

        if (userJSON.name == playerNameInput.text)
        {
            return;
        }
        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            p.transform.rotation = playerRotation;
        }
        Debug.Log(userJSON.name + " turned! ! !");
    }
Ejemplo n.º 5
0
    void OnPlayerMove(SocketIOEvent socketIOEvent)
    {
        string   data     = socketIOEvent.data.ToString();
        UserJSON userJSON = UserJSON.CreateFromJSON(data);
        Vector3  position = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);

        // if it is the current player exit
        if (userJSON.name == playerNameInput.text)
        {
            return;
        }
        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            p.transform.position = position;
        }
    }
Ejemplo n.º 6
0
    void OnOtherPlayerConnected(SocketIOEvent socketIOEvent)
    {
        print("Someone else Joined ");
        string   data     = socketIOEvent.data.ToString();
        UserJSON userJSON = UserJSON.CreateFromJSON(data);

        Debug.Log("userJSON is ganerated : " + data);
        Vector3    position = new Vector3(userJSON.playerPosition[0], userJSON.playerPosition[1], userJSON.playerPosition[2]);
        Quaternion rotation = Quaternion.Euler(userJSON.playerRotation[0], userJSON.playerRotation[1], userJSON.playerRotation[2]);
        GameObject o        = GameObject.Find(userJSON.name) as GameObject;

        Debug.Log("O is : " + o);
        if (o != null)
        {
            return;
        }
        Debug.Log("Again O is : " + o);
        GameObject p = Instantiate(player, position, rotation) as GameObject;

        Debug.Log(userJSON.name + " :  body is generated ");
        GameObject EyeCamera = p.transform.Find("Other Head Avator").gameObject;

        EyeCamera.gameObject.SetActive(true);
        GameObject OtherRightHand = p.transform.Find("Other R Hand").gameObject;

        OtherRightHand.gameObject.SetActive(true);
        GameObject OtherLeftHand = p.transform.Find("Other L Hand").gameObject;

        OtherLeftHand.gameObject.SetActive(true);
        MultiPlayerController pc = p.GetComponent <MultiPlayerController>();
        Transform             t  = p.transform.Find("Healthbar Canvas");
        Transform             t1 = t.transform.Find("Player Name");
        Text playerName          = t1.GetComponent <Text>();

        playerName.text  = userJSON.name;
        pc.isLocalPlayer = false;
        p.name           = userJSON.name;
        Debug.Log("Joining player name is : " + p.name);
        Health h = p.GetComponent <Health>();

        h.currentHealth = userJSON.health;
        h.OnChangeHealth();
    }
Ejemplo n.º 7
0
    void OnPlayerTurn(SocketIOEvent socketIOEvent)
    {
        string     data          = socketIOEvent.data.ToString();
        UserJSON   userJSON      = UserJSON.CreateFromJSON(data);
        Quaternion otherRotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);

        GameObject p  = GameObject.Find(userJSON.name) as GameObject;
        Controller pc = p.GetComponent <Controller>();

        pc.inputRotation(otherRotation);

        if (p != null)
        {
            if (p.transform.rotation != otherRotation)
            {
                p.transform.rotation = otherRotation;
            }
        }
    }
Ejemplo n.º 8
0
    void OnPlayerMove(SocketIOEvent socketIOEvent)
    {
        string   data          = socketIOEvent.data.ToString();
        UserJSON userJSON      = UserJSON.CreateFromJSON(data);
        Vector3  otherPosition = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);

        GameObject p  = GameObject.Find(userJSON.name) as GameObject;
        Controller pc = p.GetComponent <Controller>();

        pc.inputPosition(otherPosition);

        if (p != null)
        {
            if (p.transform.position != otherPosition)
            {
                p.transform.position = otherPosition;
            }
        }
    }
Ejemplo n.º 9
0
    void OnPlay(SocketIOEvent socketIOEvent)
    {
        print("Entraste Al Juego");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Vector3    pos      = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);
        Quaternion rot      = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);
        GameObject p        = GameObject.Find(userJSON.nombre);

        if (p == null)
        {
            p = Instantiate(jugador, pos, rot) as GameObject;
        }
        ControlPersonaje cp = p.GetComponent <ControlPersonaje>();

        cp.Inicializar(userJSON.nombre, true);
        // Inicializo el nombre en el Manager
        nombreDelJugador = userJSON.nombre;
    }
Ejemplo n.º 10
0
    void OnPlayerTurn(SocketIOEvent socketIOEvent)
    {
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);

        // if it is the current player exit
        if (userJSON.name == playerNameInput.text)
        {
            return;
        }
        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            p.GetComponent <PlayerController>().Gun.rotation = rotation;
            //   p.transform.rotation = rotation;
        }
    }
Ejemplo n.º 11
0
    void OnOtherPlayerConnected(SocketIOEvent socketIOEvent)
    {
        print("Someone else joined");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Vector3    position = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);
        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);
        GameObject o        = GameObject.Find(userJSON.name) as GameObject;

        if (o != null)
        {
            return;
        }
        GameObject    p  = Instantiate(player, position, rotation) as GameObject;
        PlayerManager pc = p.GetComponent <PlayerManager>();

        pc.isLocalPlayer = false;
        p.name           = userJSON.name;
    }
Ejemplo n.º 12
0
    void UpdateStatus(SocketIOEvent socketIOEvent)
    {
        string   data     = socketIOEvent.data.ToString();
        UserJSON userJSON = UserJSON.CreateFromJSON(data);
        // if it is the current player exit

        /*    if (userJSON.name == playerNameInput.text)
         *  {
         *
         *      return;
         *  }*/
        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            Player pc = p.GetComponent <Player>();
            pc.setstatus(userJSON.status);
        }
    }
Ejemplo n.º 13
0
    void OnPlay(SocketIOEvent socketIOEvent)
    {
        print("you joined");
        string       data            = socketIOEvent.data.ToString();
        UserJSON     currentUserJSON = UserJSON.CreateFromJSON(data);
        Vector3      position        = new Vector3(float.Parse(currentUserJSON.position[0]), float.Parse(currentUserJSON.position[1]), float.Parse(currentUserJSON.position[2]));
        Quaternion   rotation        = Quaternion.Euler(float.Parse(currentUserJSON.rotation[0]), float.Parse(currentUserJSON.rotation[1]), float.Parse(currentUserJSON.rotation[2]));
        GameObject   p  = Instantiate(player, position, rotation) as GameObject;
        TankMovement pc = p.GetComponent <TankMovement>();

        //Transform t = p.transform.Find("Healthbar Canvas");
        //Transform t1 = t.transform.Find("Player Name");
        //Text playerName = t1.GetComponent<Text>();
        //playerName.text = currentUserJSON.name;
        pc.isLocalPlayer = true;
        p.name           = currentUserJSON.name;
        p.transform.Find("HealthCanvas").Find("NameText").GetComponent <Text>().text = currentUserJSON.name;
        maincamera.SetActive(false);
    }
Ejemplo n.º 14
0
    void OnPlay(SocketIOEvent socketIOEvent)
    {
        Debug.Log("You joined");
        string     data            = socketIOEvent.data.ToString();
        UserJSON   currentUserJSON = UserJSON.CreateFromJSON(data);
        Vector2    position        = new Vector2(currentUserJSON.position[0], currentUserJSON.position[1]);
        Quaternion rotation        = Quaternion.Euler(currentUserJSON.rotation[0], currentUserJSON.rotation[1], currentUserJSON.rotation[2]);
        GameObject ply             = Instantiate(player, position, rotation) as GameObject;
        Player     playerScript    = ply.GetComponent <Player>();

        playerScript.canControl = true;
        ply.name = currentUserJSON.name;
        cameraFollowScript.currentPlayer = ply.name;
        ScoreScript.currentPlayerName    = ply.name;
        ply.transform.GetChild(1).gameObject.SetActive(true);
        pointShootScript.crosshairs = ply.transform.GetChild(1).gameObject;
        ply.transform.GetComponentInChildren <Text>().text = ply.name;
        playerList.Add(new PlayerList(ply.name, ply.transform));
    }
Ejemplo n.º 15
0
    void OnPlayerTurn(SocketIOEvent socketIOEvent)
    {
        string   data     = socketIOEvent.data.ToString();
        UserJSON userJSON = UserJSON.CreateFromJSON(data);

        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);

        // 만약 현재 플레이어에 관한 것이면 아무것도 하지 않는다.
        if (userJSON.name == playerNameInput.text)
        {
            return;
        }

        GameObject p = GameObject.Find(userJSON.name) as GameObject;

        if (p != null)
        {
            p.transform.rotation = rotation;
        }
    }
Ejemplo n.º 16
0
    void OnOtherPlayerConnected(SocketIOEvent socketIOEvent)
    {
        print("Someone else joined");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Vector3    position = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);
        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);

        if (connectPlayer.ContainsKey(userJSON.name))
        {
            return;
        }
        GameObject p = Instantiate(player, position, rotation) as GameObject;

        p.name = userJSON.name;
        connectPlayer.Add(userJSON.name, p);
        ThirdPersonUserControl pc = p.GetComponent <ThirdPersonUserControl>();

        pc.isLocal = false;
    }
Ejemplo n.º 17
0
    void OnPlay(SocketIOEvent socketIOEvent)
    {
        print("you joined");
        AudioManager.Instance.PlayBGM(AUDIO.BGM_DANGER, 0.1f);
        string           data            = socketIOEvent.data.ToString();
        UserJSON         currentUserJSON = UserJSON.CreateFromJSON(data);
        Vector3          position        = new Vector3(currentUserJSON.position[0], currentUserJSON.position[1], currentUserJSON.position[2]);
        Quaternion       rotation        = Quaternion.Euler(currentUserJSON.rotation[0], currentUserJSON.rotation[1], currentUserJSON.rotation[2]);
        GameObject       p          = Instantiate(player, position, rotation) as GameObject;
        PlayerController pc         = p.GetComponent <PlayerController>();
        Transform        t          = p.transform.Find("HealthbarCanvas");
        Transform        panel      = t.transform.Find("Panel");
        Transform        t1         = panel.transform.Find("Player Name");
        Text             playerName = t1.GetComponent <Text>();

        playerName.text = currentUserJSON.name;
        //panel.localPosition = new Vector3(-299, -192, 0);
        pc.isLocaPlayer = true;
        p.name          = currentUserJSON.name;
    }
Ejemplo n.º 18
0
    void onPlayerConnected(SocketIOEvent socketIOEvent)
    {
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userData = UserJSON.CreateFromJSON(data);
        Vector3    position = new Vector3(userData.position [0], userData.position [1], userData.position [2]);
        Quaternion rotation = Quaternion.Euler(0f, userData.rotation, 0f);
        Color      playerColor;

        ColorUtility.TryParseHtmlString(userData.playerColor, out playerColor);

        var tank = GameObject.Find(userData.name) as GameObject;

        if (tank != null)
        {
            return;
        }
        GameObject p = Instantiate(player, position, rotation) as GameObject;

        p.name = userData.name;

        TankMovement movement = p.GetComponent <TankMovement> ();

        movement.isLocalPlayer = false;

        TankShooting shooting = p.GetComponent <TankShooting> ();

        shooting.isLocalPlayer = false;
        shooting.playerName    = userData.name;

        TankHealth health = p.GetComponent <TankHealth> ();

        health.m_CurrentHealth = userData.health;
        health.OnHealthChange();

        MeshRenderer[] renderers = p.GetComponentsInChildren <MeshRenderer> ();
        for (int i = 0; i < renderers.Length; i++)
        {
            renderers[i].material.color = playerColor;
        }
    }
Ejemplo n.º 19
0
    void OnOtherPlayerConnected(SocketIOEvent socketIOEvent)
    {
        Debug.Log("Player joined");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        Vector2    position = new Vector2(userJSON.position[0], userJSON.position[1]);
        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);
        GameObject obj      = GameObject.Find(userJSON.name) as GameObject;

        if (obj != null)
        {
            return;
        }
        GameObject ply          = Instantiate(player, position, rotation) as GameObject;
        Player     playerScript = ply.GetComponent <Player>();

        playerScript.canControl = false;
        ply.name = userJSON.name;
        ply.transform.GetChild(2).GetChild(0).GetComponent <Text>().text = ply.name;
        playerList.Add(new PlayerList(ply.name, ply.transform));
        timer = 20;
    }
Ejemplo n.º 20
0
    void OnOtherPlayerConnected(SocketIOEvent socketIOEvent)
    {
        print("Someone else joined");
        string   data     = socketIOEvent.data.ToString();
        UserJSON userJSON = UserJSON.CreateFromJSON(data);

        GameObject o = GameObject.Find(userJSON.name) as GameObject;

        if (o != null)
        {
            return;
        }
        GameObject p = Instantiate(player) as GameObject;

        p.transform.SetParent(PlayerPanel);
        p.transform.localScale = new Vector3(1, 1, 1);
        // here we are setting up their other fields name and if they are local
        Player pc = p.GetComponent <Player>();

        pc.setname(userJSON.name, userJSON.status);

        pc.isLocalPlayer = false;
        p.name           = userJSON.name;
    }
Ejemplo n.º 21
0
    void OnOtherPlayerConnect(SocketIOEvent socketIOEvent)
    {
        print("Someone else joined");
        string     data     = socketIOEvent.data.ToString();
        UserJSON   userJSON = UserJSON.CreateFromJSON(data);
        string     name     = (userJSON.name).ToString();
        Vector3    position = new Vector3(userJSON.position[0], userJSON.position[1], userJSON.position[2]);
        Quaternion rotation = Quaternion.Euler(userJSON.rotation[0], userJSON.rotation[1], userJSON.rotation[2]);
        GameObject o        = GameObject.Find(name) as GameObject;

        if (o != null)
        {
            return;
        }
        GameObject       p          = Instantiate(player, position, rotation) as GameObject;
        PlayerController pc         = p.GetComponent <PlayerController>();
        Transform        t          = p.transform.Find("Healthbar Canvas");
        Transform        t1         = t.transform.Find("Player Name");
        Text             playerName = t1.GetComponent <Text>();

        playerName.text  = name;
        pc.isLocalPlayer = false;
        p.name           = name;
    }
Ejemplo n.º 22
0
 void OnPlay(SocketIOEvent socketIOEvent)
 {
     print("You Joined");
     string   data            = socketIOEvent.data.ToString();
     UserJSON currentUserJSON = UserJSON.CreateFromJSON(data);
 }
Ejemplo n.º 23
0
 void OnPlayerConnected(SocketIOEvent socketIOEvent)
 {
     print("Player Connected");
     string   data     = socketIOEvent.data.ToString();
     UserJSON userJson = UserJSON.CreateFromJSON(data);
 }