public override void inbox(ExtraMegaBlob.References.Event ev) { //ThingReferences.Globals.Instance.Data[]; if (object.Equals(null, Globals.Instance.Users[ev._Endpoint])) { Globals.Instance.Users[ev._Endpoint] = new User(); Globals.Instance.Users[ev._Endpoint].Name = "User"; } switch (ev._Keyword) { case KeyWord.EVENT_CHATMESSAGE: if (ev._Source_FullyQualifiedName == "ClientMain") { string senderName = Globals.Instance.Users[ev._Endpoint].Name; string message = ev._Memories["text"].Value; log(" >>>> " + senderName + " >>>> " + message); if (message == "/name") { Globals.Instance.Users[ev._Endpoint].Name = ev._Endpoint; break; } if (message.Length > 6) { if (message.Substring(0, 6) == "/name ") { string newname = message.Substring(6, message.Length - 6); newname = newname.Trim(); if (newname != "") { Globals.Instance.Users[ev._Endpoint].Name = newname; break; } } } Event outevent = new Event(); outevent._Keyword = KeyWord.EVENT_CHATMESSAGE; outevent._IntendedRecipients = EventTransfer.SERVERTOCLIENT; outevent._Memories = new Memories(); outevent._Memories.Add(new Memory("text", KeyWord.NIL, message, null)); outevent._Memories.Add(new Memory("username", KeyWord.NIL, senderName, null)); outboxMessage(this, outevent); } break; case KeyWord.CARTESIAN_SECRETPLAYERLOCATION: Globals.Instance.Users[ev._Endpoint].Location.x = float.Parse(ev._Memories[KeyWord.CARTESIAN_X].Value); Globals.Instance.Users[ev._Endpoint].Location.y = float.Parse(ev._Memories[KeyWord.CARTESIAN_Y].Value); Globals.Instance.Users[ev._Endpoint].Location.z = float.Parse(ev._Memories[KeyWord.CARTESIAN_Z].Value); break; default: // log(ev._Keyword + " from " + ev._Source_FullyQualifiedName); break; } }
public override void inbox(ExtraMegaBlob.References.Event ev) { if (ev._Keyword == References.KeyWord.PREVENTMOUSEPICK) { string name = ev._Memories["Name"].Value; if (!preventSelect.Contains(name)) { preventSelect.Add(name); log("Disabling Mouse Picker for: \"" + name + "\""); } } }
public override void inbox(ExtraMegaBlob.References.Event ev) { //ThingReferences.Globals.Instance.Data[]; switch (ev._Keyword) { case KeyWord.CARTESIAN_SECRETPLAYERLOCATION: References.Vector3 loc = new Vector3(float.Parse(ev._Memories[KeyWord.CARTESIAN_X].Value), float.Parse(ev._Memories[KeyWord.CARTESIAN_Y].Value), float.Parse(ev._Memories[KeyWord.CARTESIAN_Z].Value)); if (!globals.Users.Contains(ev._Endpoint)) { globals.Users.Add(new User("", loc, ev._Endpoint)); log("adding: " + ev._Endpoint); } globals.Users[ev._Endpoint].Location = loc; broadcastPlayerLocationAllExcept(ev._Endpoint, loc); float dist = References.Math.distanceBetweenPythagCartesian(loc, tableLocation); log(dist.ToString()); if (dist < 30f && !globals.Users[ev._Endpoint].inRange) { globals.Users[ev._Endpoint].inRange = true; invite(ev._Endpoint); } if (dist > 30f && globals.Users[ev._Endpoint].inRange) { globals.Users[ev._Endpoint].inRange = false; } break; case KeyWord.TONGITS_PLAYER_INVITE_ACCEPTED: if (numPlayers < NUMPLRS) { numPlayers++; sendPlayerNumber(ev._Endpoint, numPlayers); if (numPlayers == NUMPLRS) startNewGame(); } break; default: // log(ev._Keyword + " from " + ev._Source_FullyQualifiedName); break; } }
public override void inbox(ExtraMegaBlob.References.Event ev) { if (!ready) return; switch (ev._Keyword) { case KeyWord.PLAYER_RESET: chat("resetting player"); Quaternion q = new Quaternion( float.Parse(ev._Memories[KeyWord.DATA_QUATERNION_W].Value), float.Parse(ev._Memories[KeyWord.DATA_QUATERNION_X].Value), float.Parse(ev._Memories[KeyWord.DATA_QUATERNION_Y].Value), float.Parse(ev._Memories[KeyWord.DATA_QUATERNION_Z].Value)); Mogre.Vector3 v = new Mogre.Vector3( float.Parse(ev._Memories[KeyWord.DATA_VECTOR3_X].Value), float.Parse(ev._Memories[KeyWord.DATA_VECTOR3_Y].Value), float.Parse(ev._Memories[KeyWord.DATA_VECTOR3_Z].Value)); resetPlayer2(v, q); break; case KeyWord.CMD_GO: this.logConsole("parsing coordinates"); string arguments = ev._Memories[KeyWord.DATA_STRING].Value.Trim(); if (arguments == "") return; //" -63.60852f, 95.18869f, -115.0435f " //resetPlayer2(v, q); string[] x = arguments.Split(','); int a = 0; Mogre.Vector3 u = new Mogre.Vector3(); try { for (int s = 0; s < x.Length; s++) { string j = x[s].Trim().Replace("f", ""); if (j != "") { switch (a) { case 0: u.x = float.Parse(j); a++; break; case 1: u.y = float.Parse(j); a++; break; case 2: u.z = float.Parse(j); a++; break; default: break; } } } } catch { } resetPlayer2(u, nodes["drone"].Orientation); this.logConsole("coordinates: " + u.ToString()); break; case KeyWord.PLAYER_FREEZE: player_freeze = true; break; case KeyWord.PLAYER_UNFREEZE: player_freeze = false; break; default: break; } }
public User(String Name, ExtraMegaBlob.References.Vector3 Location, String Endpoint) { this.Name = Name; this.Location = Location; this.Endpoint = Endpoint; }
public override void inbox(ExtraMegaBlob.References.Event ev) { }