示例#1
0
    public void BulletHitOnServer(MultiPlayerBullet bullet)
    {
        Dictionary <string, string> data = new Dictionary <string, string>();

        data["clientId"]   = "" + bullet.GetSocketId();
        data["bulletUUID"] = bullet.GetBulletUUID();

        socket.Emit("bullet_hit", new JSONObject(data));
    }
示例#2
0
    /* Bullets
     */

    private void BulletSpawn(SocketIO.SocketIOEvent e)
    {
        string eventAsString             = "" + e.data;
        Dictionary <string, string> data = JsonConvert.DeserializeObject <Dictionary <string, string> >(eventAsString);

        GameObject newBullet = Instantiate(bulletPrefabs[int.Parse(data["bulletTypeId"])],
                                           new Vector3(float.Parse(data["x"]), float.Parse(data["y"])),
                                           Quaternion.Euler(0, float.Parse(data["rotY"]), float.Parse(data["rotZ"])));

        MultiPlayerBullet bullet = newBullet.GetComponent <MultiPlayerBullet>();

        bullet.Init(this, data["clientId"], data["clientId"] == this.socket.sid, data["bulletUUID"]);
        bullets.Add(bullet);
    }