// Use this for initialization void Start() { bufferSize = 1024; //4096; // 2048; //1024; initServer(); myBody = new MyBody(new MyBodyPart(Vector3.one, Quaternion.identity), new MyBodyPart(Vector3.one, Quaternion.identity), new MyBodyPart(Vector3.one, Quaternion.identity), new MyBodyPart(Vector3.one, Quaternion.identity), new MyBodyPart(Vector3.one, Quaternion.identity), new MyBodyPart(Vector3.one, Quaternion.identity), new MyBodyPart(Vector3.one, Quaternion.identity)); // myBody = new MyBody (new MyBodyPart (Vector3.one, Quaternion.identity), new MyBodyPart (Vector3.one, Quaternion.identity), new MyBodyPart (Vector3.one, Quaternion.identity)); Connect(); }
public void add(MyBody m) { head.add(m.head); leftHand.add(m.leftHand); rightHand.add(m.rightHand); leftArm.add(m.leftArm); rightArm.add(m.rightArm); leftLeg.add(m.leftLeg); rightLeg.add(m.rightLeg); }
public void No_shots_no_bodies() { var cache = TtlCache<MyFacet, MyBody>.New(); var body = new MyBody(); var facet = new MyFacet(); cache.Store(facet, body); var bodies = cache.GetDeadBodies(1.Milliseconds()); Assert.Null(bodies); }
public void Item_should_be_removed_after_its_deatch() { var cache = TtlCache<MyFacet, MyBody>.New(); var body = new MyBody(); var facet = new MyFacet(); cache.Store(facet, body); facet = null; var bodies = shoot_dead_bodies(cache); Assert.That(bodies[0], Is.SameAs(body)); }
/// <summary> /// update player /// </summary> /// <param name="direction">directional vector</param> public void Update(Vector2 direction, Vector2 mousePos, int left, GameTime gameTime) { if (Dead) { SemiDead = false; } if (!SemiDead) { if (direction.Length() > 0) { MyBody.ApplyLinearImpulse(direction * 3000); } else { MyBody.LinearVelocity = Vector2.Zero; } Rotation = Config.VectorToAngle(mousePos); if (Dead && _hasBody) { MyBody.CollidesWith = Category.Cat3; } if (!Dead && left % BulletDelay == 1 && left > 0) { if (AmmoCount > 0) { BulletEvent.Invoke(new Bullet(id, Position + (Config.AngleToVector(Rotation)), Rotation, Damage, Ammo.DType)); //TODO: speed dependent AmmoCount--; } } } else { MyBody.LinearVelocity = Vector2.Zero; } UpdateLifeStatus(gameTime); UpdateFrame(gameTime, direction); }
public void Double_reference_Item_should_be_removed_after_its_deatch() { var cache = TtlCache<MyFacet, MyBody>.New(); var body = new MyBody(); var facet = new MyFacet(); var facet2 = new MyFacet(); cache.Store(facet, body); cache.Store(facet2, body); cache.Store(facet, body); // should be ignored facet = null; var bodies = shoot_dead_bodies(cache); Assert.Null(bodies); facet2 = null; bodies = shoot_dead_bodies(cache); Assert.That(bodies[0], Is.SameAs(body)); }
public void handleSocketConnection() { byte[] recBuffer = new byte[bufferSize]; byte error; recNetworkEvent = NetworkTransport.Receive(out recHostId, out recConnectionId, out recChannelId, recBuffer, bufferSize, out dataSize, out error); switch (recNetworkEvent) { case NetworkEventType.Nothing: break; case NetworkEventType.ConnectEvent: Debug.Log("incoming connection event received"); connected = true; break; case NetworkEventType.DataEvent: connected = true; Stream stream = new MemoryStream(recBuffer); BinaryFormatter formatter = new BinaryFormatter(); receivedBody = (MyBody)formatter.Deserialize(stream); handleReceivedData(); break; case NetworkEventType.DisconnectEvent: Debug.Log("remote client event disconnected"); connected = false; ball.GetComponent <Rigidbody> ().useGravity = false; break; } }
void Update() { KinectManager km = KinectManager.Instance; uint Player1ID = km.GetPlayer1ID(); if (km.IsGestureComplete(Player1ID, KinectGestures.Gestures.Jump, true)) // || km.IsGestureComplete (Player1ID, KinectGestures.Gestures.RaiseLeftHand, true)) { { jumped = true; //= km.IsGestureComplete (Player1ID, KinectGestures.Gestures.Jump, false); } Debug.Log("update jumped: " + jumped); if (sendingData) { intervalCounter = intervalCounter + Time.deltaTime; /* attempt for smoothing */ if (intervalCounter < sendInterval) { if (bsMessage) { bsMyBody temp = bsbody; populateMyBody(); temp.add(bsbody); bsbody = temp; } else { // kuSkeleton temp = kskel; // populateMyBody (); // temp.add (kskel); // kskel = temp; MyBody temp = myBody; populateMyBody(); temp.add(myBody); myBody = temp; } countsBetweenSending++; // km.ResetPlayerGestures (Player1ID); } /*attempt for smoothing */ //data is being sent only when certain time has passed because if we send too much data(every frame) //it will overload the receiver and create a delay if (intervalCounter > sendInterval) { print(countsBetweenSending); if (bsMessage) { bsbody.divide(countsBetweenSending); bsbody.jump = jumped; } else { myBody.divide(countsBetweenSending); } countsBetweenSending = 0; if (connectionId > 0) { SendSocketMessage(); if (jumped) { jumped = false; } // km.ResetPlayerGestures (Player1ID); } intervalCounter = 0; } // km.ResetPlayerGestures (Player1ID); } handleSocketConnection(); }
public MyBody Post([FromRoute] ObjectId id, [FromBody] MyBody body) { body.Id = id; return(body); }