Ejemplo n.º 1
0
	private void DetectStateTransfer() {
		var state = gameObject.GetComponent<CubeState> ();
		var e = new UserEvent ();
		e.sponsorId = base.gameObjectId;
		e.targetIdList = World.GetInstance ().GetAllGOIds ();
		var ste = new CubeSTE ();
		if (!state.transform.position.Equals (gameObject.transform.position)) {
			var content = new Content();
			content.state = StateEnum.POS;
			content.value.x = gameObject.transform.position.x;
			content.value.y = gameObject.transform.position.y;
			content.value.z = gameObject.transform.position.z;
			ste.content.Add(content);
		}
		if (!state.transform.eulerAngles.Equals (gameObject.transform.eulerAngles)) {
			var content = new Content();
			content.state = StateEnum.ROT;
			content.value.x = transform.eulerAngles.x;
			content.value.y = transform.eulerAngles.y;
			content.value.z = transform.eulerAngles.z;
			ste.content.Add(content);
		}
		e.rawContent = ste as object;
		if (ste.content.Count == 0) {
			return ;
		}

		base.BroadCastEvent (e);
	}
Ejemplo n.º 2
0
	private void ApplyNewState(CubeSTE st) {
		var state = gameObject.GetComponent<CubeState> ();
		foreach (var content in st.content) {
			switch (content.state) {
			case StateEnum.POS:
			{
				state.position = new UnityEngine.Vector3(content.value.x,
				                                         content.value.y,
				                                         content.value.z);
				transform.position = state.position;
				break;
			}
			case StateEnum.ROT:
			{
				state.rotation = new UnityEngine.Vector3(content.value.x,
				                                         content.value.y,
				                                         content.value.z);
				transform.eulerAngles = state.rotation;
				break;
			}
			}
		}
	}