예제 #1
0
파일: Player.cs 프로젝트: dsedb/LANgame
	private int creatable_block_num_ = 16; // 生成可能ブロック数

	// リモートオブジェクト生成
	public override void spawnRemote(NetworkObjectData nod)
	{
		// transform は Instantiate で更新済み
		name_ = nod.getName();	// 名前更新
		color_ = nod.color;		// 色更新
		Destroy(GetComponent<Collider>()); // リモートオブジェクトはコリジョンなしにする
	}
예제 #2
0
	// データ受信
	void OnReceiveEvent(NetworkObjectData nod)
	{
		ulong id = nod.getGlobalId();
		GameObject go = null;
		if (object_dict_.ContainsKey(id)) { // 過去に出現したことがある
			// 情報更新のみ
			go = object_dict_[id];
			var nobj = go.GetComponent<NetworkObject>();
			nobj.setRemoteData(nod);
		} else {				// 初めて登場する
			// 生成
			GameObject prefab = null;
			string name = "";
			switch (nod.type) {
				case NetworkObjectData.Type.Player:
					prefab = player_prefab_;
					name = "player_";
					break;
				case NetworkObjectData.Type.Block:
					prefab = block_prefab_;
					name = "block_";
					break;
			}
			if (prefab != null) {
				go = Instantiate(prefab, nod.position, nod.rotation) as GameObject;
				go.name = name + nod.getName();
				var nobj = go.GetComponent<NetworkObject>();
				nobj.isLocal = false;
				object_dict_[id] = go;
				nobj.spawnRemote(nod);
			}
		}

		if (go != null) {
			var nobj = go.GetComponent<NetworkObject>();
			nobj.latestUpdate = Time.time;
		}
	}