void OnMsgActiveObject(TcpHost.SocketAccept socket, byte[] protoData) { ProtoIntArray p = new ProtoIntArray(); if (p.Parse(protoData)) { ActiveSceneObject(p.context); } }
/// <summary> /// 同步行为 /// </summary> void OnObjectAction(byte[] data) { ProtoIntArray proto = ObjectPool.protoPool.GetOrCreate <ProtoIntArray>(ProtoPool.ProtoRecycleType.IntArray); if (proto.Parse(data)) { int[] ints = proto.context; SceneModel sceneModel = SceneController.instance.GetModel <SceneModel>(SceneModel.name); sceneModel.SetSceneObjectAciton(data[0], ints); } proto.Recycle(); }
/// <summary> /// 移除对象 /// </summary> void OnRemoveObject(byte[] data) { ProtoIntArray proto = ObjectPool.protoPool.GetOrCreate <ProtoIntArray>(ProtoPool.ProtoRecycleType.IntArray); if (proto.Parse(data)) { int[] ints = proto.context; SceneModel sceneModel = SceneController.instance.GetModel <SceneModel>(SceneModel.name); for (int i = 0; i < ints.Length; i++) { SceneGameObject obj = sceneModel.GetSceneObject(ints[i]); if (obj != null) { obj.RemoveObject(); } } } proto.Recycle(); }
/// <summary> /// 销毁场景单位 /// </summary> /// <param name="indexs"></param> void RemoveSceneObject(TcpHost.SocketAccept socket, byte[] protoData) { int[] indexs = null; ProtoIntArray proto = new ProtoIntArray(); proto.Parse(protoData); indexs = proto.context; if (indexs == null || indexs.Length < 1) { return; } for (int i = 0; i < indexs.Length; i++) { if (sceneObjes.ContainsKey(indexs[i])) { sceneObjes.Remove(indexs[i]); Debug.LogWarning("销毁:" + indexs[i]); } } }