Exemplo n.º 1
0
    void OnOthersWakizashi(SocketIOEvent socketIOEvent)
    {
        string           data          = socketIOEvent.data.ToString();
        WakizashiJSON    wakizashiJSON = WakizashiJSON.CreateFromJSON(data);
        Vector3          position      = new Vector3(wakizashiJSON.wakizashiPosition[0], wakizashiJSON.wakizashiPosition[1], wakizashiJSON.wakizashiPosition[2]);
        Quaternion       rotation      = Quaternion.Euler(wakizashiJSON.wakizashiRotation[0], wakizashiJSON.wakizashiRotation[1], wakizashiJSON.wakizashiRotation[2]);
        GameObject       o             = GameObject.Find(wakizashiJSON.name) as GameObject;
        WakizashiSpawner es            = GetComponent <WakizashiSpawner>();

        es.SpawnWakizashis(wakizashiJSON);
    }
Exemplo n.º 2
0
    // プレイヤー接続
    IEnumerator ConnectToServer()
    {
        yield return(new WaitForSeconds(0.5f));

        socket.Emit("player connect");

        yield return(new WaitForSeconds(1f));

        string playerName = "desktop";

        Debug.Log("Input name : " + playerName);
        PlayerSpawner ps = GetComponent <PlayerSpawner>();
        SpawnPoint    playerSpawnPoint    = ps.playerSpawnPoint;
        Vector3       playerSpawnPosition = playerSpawnPoint.spawnPosition;
        Quaternion    playerSpawnRotation = playerSpawnPoint.spawnRotation;
        GameObject    startMenuCamera     = GetComponent <GameObject>();

        PlayerJSON playerJSON = new PlayerJSON(playerName, playerSpawnPosition, playerSpawnRotation);
        string     data       = JsonUtility.ToJson(playerJSON);

        Debug.Log("playerJSON : " + data);
        socket.Emit("play", new JSONObject(data));
        Debug.Log("Emit : play");

        canvas.gameObject.SetActive(false);

        EnemySpawner es = GetComponent <EnemySpawner>();

        es.GenerateSpownPoints();
        List <SpawnPoint> enemySpawnPoints = es.GetComponent <EnemySpawner>().enemySpawnPoints;
        PlayersEnemyJSON  playersEnemyJSON = new PlayersEnemyJSON(playerName, enemySpawnPoints);

        WakizashiSpawner ws = GetComponent <WakizashiSpawner>();

        ws.GenerateSpownPoints();
        List <SpawnPoint>    wakizashiSpawnPoints = ws.GetComponent <WakizashiSpawner>().wakizashiSpawnPoints;
        PlayersWakizashiJSON playersWakizashiJSON = new PlayersWakizashiJSON(playerName, wakizashiSpawnPoints);

        string enemyData     = JsonUtility.ToJson(playersEnemyJSON);
        string wakizashiData = JsonUtility.ToJson(playersWakizashiJSON);

        socket.Emit("enemy", new JSONObject(enemyData));
        socket.Emit("wakizashi", new JSONObject(wakizashiData));
    }