void OnCollisionEnter(Collision collision) { if (collision.gameObject.CompareTag("bunny")) { //Debug.Log("---OnTriggerEnter---Bunny---"); setTemperature(mTemperature + tempPerCollision); animator.SetTrigger("knockback"); animator.SetTrigger("run"); Bunny other = collision.gameObject.GetComponent <Bunny>(); //Debug.Log("------mayPair"+ mayPair+" other.mayPair:"+ other.mayPair + " mTemperature:"+ mTemperature + " other.mTemperature:" + other.mTemperature); if (mayPair && other.mayPair && mTemperature < pairingThreshold && other.mTemperature < pairingThreshold) { if (onPairing != null) { onPairing(this); } disableMayPairFor(0.5f); } } else if (collision.gameObject.CompareTag("pylon")) { //Debug.Log("---OnTriggerEnter---pylon---"); setTemperature(mTemperature + tempPerCollision * 1.5f); animator.SetTrigger("knockback"); animator.SetTrigger("run"); } }
public Level() { platforms = new List <Platform>(); platforms.Add(new Platform(100, 100, new Point(200, 200), 400)); platforms.Add(new Platform(250, 100, new Point(300, 300), 400)); bun = new Bunny(new Vector2(0, 0)); }
// Update is called once per frame void Update() { Collider[] objectsNearby = Physics.OverlapSphere(gameObject.transform.position, searchRange, 256); //Debug.Log(objectsNearby[0].name); //Debug.Log(LayerMask.GetMask("Findable Objects")); if (objectsNearby.Length != 0) { for (int i = 0; i < objectsNearby.Length; i++) { GameObject objectFound = objectsNearby[0].gameObject; // Debug.Log(LayerMask.GetMask("Findable Objects")); if (objectFound.name == "Bunny" && objectFound.GetInstanceID() != gameObject.GetInstanceID()) { Bunny foundBunny = objectFound.GetComponent <Bunny>(); if (matingMode) { if (foundBunny.gender != gender) { gameObject.GetComponent <Bunny>().destination = objectFound.transform.position; } } } } } }
public void BunnyShouldBeAliveWhenInstantiated() { //Bunny bunny = new Bunny(); var bunny = new Bunny(); Assert.IsTrue(bunny.IsAlive /*, "Bunny should be alive when created"*/); }
public void AddBunnyInLove(Bunny newBunny) { if (!_bunniesInLove.Contains(newBunny)) { _bunniesInLove.Add(newBunny); } }
public override void Use(Bunny user, Fighter[] targets) { foreach (Fighter fighter in targets) { fighter.Heal(healAmount); } }
void Start() { playerBunny = Instantiate(bunny, transform.position, Quaternion.identity); gameObject.transform.parent = playerBunny.transform; bunnyScript = playerBunny.GetComponent <Bunny>(); mousePosition = Vector3.forward; }
private static void ProcessMessage(Bunny bunny) { var rand = new Random((int)DateTime.Now.Ticks); var processingTime = rand.Next(50, 100); System.Threading.Thread.Sleep(processingTime); Console.WriteLine("Processed msg [{0}], priority [{1}] in [{2}] ms\n", bunny.Name, bunny.Age, processingTime); }
/// <summary> /// When another collider enters ours, we assign our rigidbody's velocity to his. /// </summary> /// <param name="other"></param> private void OnTriggerEnter(Collider other) { Bunny colBunny = other.GetComponent <Bunny>(); //Checking if its a Bunny, with a Rigidbody and that is not moving. if (colBunny != null) { if (other.GetComponent <Rigidbody>() && !colBunny._moving) { if (_rigidbody.velocity.y <= -2) { colBunny.anim.SetTrigger("Squeeze"); colBunny.GetHit(hit: false); } else if (_rigidbody.velocity.magnitude > 2f) { //Send a call to GetHit() which delays for X seconds the Bunny's detection with the real world. //Since the Bunny is already on the floor, it might return true for collision the moment the baseball bat touches it. colBunny.GetHit(hit: true); //Assign our velocity with some changes. I found that it feels better when it's half the force. other.GetComponent <Rigidbody>().velocity = _rigidbody.velocity / 2; } } } }
public IHttpActionResult PutBunny(int id, Bunny bunny) { if (!ModelState.IsValid) { return(BadRequest(ModelState)); } if (id != bunny.Id) { return(BadRequest()); } db.Entry(bunny).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BunnyExists(id)) { return(NotFound()); } else { throw; } } return(StatusCode(HttpStatusCode.NoContent)); }
static void Main() { //This would allow us to construct a Bunny as follows: Bunny b1 = new Bunny(name: "Bo", likesCarrots: true); /* An advantage to this approach is that we could make Bunny's fields * (or properties) read-only if we choose. Making fields or properties * read-only is good practice when there's not valid reason forthem to * change throughout the life of the object. * * The disadvantage in this approach is that each optional parameter is * baked into the calling site. In other words, C# translates our * constructor call into this: */ Bunny b1 = new Bunny("Bo", true, false); /* This can be problematic if we instantiate the Bunny class from * another assembly, and later modify Bunny by adding another * optional parameter-such as likesCats. Unless the referencing * assembly is also recompiled, it will continue to call the (now * nonexistent) constructor with three parameters and fail at * runtime. (A subtler problem is that if we changed the value * of one of the optional parameters, callers in other assemblies * would continue to use the old optional value until they were * recompiled.) * * Hence, you should excercise caution with optional parameters in * public functions if you want to offer compatibility between * assembly versions. */ }
// Update is called once per frame private void OnTriggerEnter2D(Collider2D collision) { if (bunny == null) { bunny = gameObject.GetComponentInParent <Bunny>(); return; } switch (collision.gameObject.tag) { case "Bunny": bunny.lastBun = collision.gameObject.transform.position; break; case "Water": bunny.lastWater = collision.gameObject.transform.position; break; case "Food": bunny.lastFood = collision.gameObject.transform.position; break; case "Predator": bunny.lastPredator = collision.gameObject; break; } }
private void OnCollisionEnter(Collision collision) { if (collision.gameObject.tag == "Terrain") // hitting any terrain { // stick the spear spear_rb.Sleep(); spear_rb.collisionDetectionMode = CollisionDetectionMode.ContinuousSpeculative; spear_rb.isKinematic = true; can_pick_up = true; } else if (collision.gameObject.tag == "Bunny") { Bunny bunny = collision.gameObject.GetComponent <Bunny>(); int remaining_health = bunny.GetHealth(); remaining_health -= spear_damage; if (remaining_health <= 0) { bunny.SetHealth(remaining_health); bunny.spear_go = this.gameObject; bunny.SkewerBunnyWrapper(); // make bunny ghost mode bunny.MakeGhostWrapper(); bunny.Die(); } } if (PhotonNetwork.IsMasterClient) { photonView.RPC("FadeOut", RpcTarget.All); } }
static void Main(string[] args) { var pipe = Bunny.ConnectSingleWith(); IBunny bunny = pipe.Connect(); Console.ReadLine(); }
public async Task ConfirmsAndAcksWork() { IBunny bunny = Bunny.ConnectSingle(ConnectSimple.BasicAmqp); IQueue queue = bunny.Setup() .Queue("constraint") .MaxLength(1) .QueueExpiry(1500) .Bind("amq.direct", "constraint-key") .OverflowReject(); bool isNacked = false; bool isAcked = false; var publisher = bunny.Publisher <TestMessage>("amq.direct"); Func <BasicNackEventArgs, Task> nacker = ea => { isNacked = true; return(Task.CompletedTask); }; Func <BasicAckEventArgs, Task> acker = ea => { isAcked = true; return(Task.CompletedTask); }; await publisher.WithQueueDeclare(queue) .WithConfirm(acker, nacker) .WithRoutingKey("constraint-key") .SendAsync(new TestMessage() { Text = "Confirm-1st" }); await publisher.WithQueueDeclare(queue) .WithConfirm(acker, nacker) .SendAsync(new TestMessage() { Text = "Confirm-2nd" }); Assert.True(isAcked); Assert.True(isNacked); bunny.Dispose(); }
public void OnBunnyHit(Bunny bunny) { Health -= 1; if (Health == 0) { OnGameOver(); } }
public async Task GetReturnsOperationResultFailIfNoMessages() { IBunny bunny = Bunny.ConnectSingle(ConnectSimple.BasicAmqp); var opResult = await bunny.Consumer <ConsumeMessage>(get).AsAutoAck().GetAsync(carrot => Task.CompletedTask); Assert.NotNull(opResult); Assert.Equal(OperationState.GetFailed, opResult.State); }
private void InvertBunnyDirection(Bunny animal, ref Vector2 velocity) { animal.direction = -animal.direction.normalized; int reverseWallHeading = animal.collisionInfo.right ? -1 : 1; Vector2 leap = animal.wallBumpLeap * reverseWallHeading; velocity += leap; }
public void ConnectToSingleNodeWithConnectionPipe() { var pipe = Bunny.ConnectSingleWith(); // not configuring anything uses default IBunny bunny = pipe.Connect(); Assert.NotNull(bunny); }
public Couple(Bunny _bunny1, Bunny _bunny2) { this.bunny1 = _bunny1; this.bunny2 = _bunny2; this.timeInFeed = 0; this.timeFemaleInFeed = 0; this.doneFeed = false; }
// ////////////// // BUNNY THREAD// // ////////////// public static void BunnyCall() { var Bunny = new Bunny(); var BunnyThread = new Thread(Bunny.Run); BunnyThread.Start(); }
public void CreateCouple(Bunny bunny1, Bunny bunny2) { Couple newCouple = new Couple(bunny1, bunny2); bunny1.GoIdle(); bunny2.GoIdle(); couples.Add(newCouple); }
public async Task <IActionResult> Create([FromBody] Bunny bunny) { context.Bunny.Add(bunny); await context.SaveChangesAsync(); var bunnyUri = Url.Link("GetBunny", new { id = bunny.Id }); return(Created(bunnyUri, bunny)); }
public void BunnyShouldNotHaveMoreThan100Health() { var attacker = new Bunny(); var defender = new Bunny(); attacker.Attack(defender, -20); //Assert.AreEqual(100, defender.Health); }
public DrinkAction(Bunny bunny) { this.bunny = bunny; pathToWater = bunny.sensor.GetClosestWaterPath(); if (!pathToWater.ValidPath) { ActionFinished = true; } }
public WanderAction(Bunny bunny) { this.bunny = bunny; wanderPath = bunny.sensor.GetRandomPath(); if (!wanderPath.ValidPath) { ActionFinished = true; } }
public void Remove(Bunny iBunny) { lock (_clientUpdateLock) { _allBunnies.Remove(iBunny); _departedBunnyIds.Add(iBunny.Id); } Interlocked.Decrement(ref _bunnyCount); }
// Update is called once per frame void Update() { Touch[] touches = Controls.GetTouchesAndMouse(); if (!IsCountingDown) { foreach (Touch touch in touches) { Vector2 touchPos = Camera.main.ScreenToWorldPoint(touch.position); // check for click if (touch.phase == TouchPhase.Began && collider.OverlapPoint(touchPos)) { Controls.mode = Controls.Mode.pulling; } if (Controls.mode == Controls.Mode.pulling) { if (touch.phase == TouchPhase.Moved || touch.phase == TouchPhase.Stationary) { // Drag transform.position = touchPos; } else if (touch.phase == TouchPhase.Ended) { LandTile tile = Controls.GetComponentAtPos <LandTile>(transform.position, "Tile"); // a bunny obsructs your path! Bunny bunny = Controls.GetComponentAtPos <Bunny>(transform.position, "Bunny"); if (tile != null && bunny == null && tile.watered && tile.status == LandTile.Status.ready) { transform.position = (Vector2)tile.transform.position; tile.status = LandTile.Status.pulling; StartCoroutine(StartCountdown()); } } } } if (touches.Length <= 0) { // Drop with Lerp if (Vector2.Distance(transform.position, init_position) < 2f) { transform.position = init_position; Controls.mode = Controls.Mode.gathering_seeds; } else { transform.position = Vector2.Lerp(transform.position, init_position, 9 * Time.deltaTime); } } } }
public void add_bunny() { var bunny = new Bunny { Texture = bunnyTexture }; bunnies.AddChild(bunny); bunny.Position = new Vector2(screenSize.x / 2, screenSize.y / 2); bunny.Speed = new Vector2(randomNumberGenerator.Randi() % 200 + 50, randomNumberGenerator.Randi() % 200 + 50); }
private void OnTriggerEnter(Collider other) { Bunny attempt = other.GetComponent <Bunny>(); if (attempt != null && hasBunny == false) { hasBunny = true; bunnyTarget = other.gameObject; } }
public static void RelayPeer(Client client, Bunny.Utility.Tuple<Muid,Muid,Muid> uids) { using (var packet = new PacketWriter(Operation.AgentRelayPeer, CryptFlags.Encrypt)) { packet.Write(uids.First); packet.Write(uids.Second); packet.Write(uids.Third); client.Send(packet); } }
public void AddBunnies(int count = 100) { for (int i = 0; i < count; i++) { Bunny bunny = new Bunny(Content); bunny.SpeedX = (float)random.NextDouble() * 5; bunny.SpeedY = (float)random.NextDouble() * 5; textures.Add(bunny); } bunniesCount += count; }
public static void ProcessMessage(Bunny bunny) { var rand = new Random((int)DateTime.Now.Ticks); var processingTime = rand.Next(1000, 1500); if (bunny.Age % 5 == 0) { throw new Exception( "This is a test exception to demonstrate how a message is handled once something wrong happens: " + "Got a bad bunny, It should be put to Error Queue ;)"); } System.Threading.Thread.Sleep(processingTime); Console.WriteLine("Processed msg [{0}], priority [{1}] in [{2}] ms\n", bunny.Name, bunny.Age, processingTime); }
public static void ProcessMessage(Bunny bunny) { var rand = new Random((int)DateTime.Now.Ticks); var processingTime = rand.Next(1000, 1500); if (processingTime % 3 == 0) { throw new Exception( "This is a test exception to demonstrate how a message is handled once something wrong happens: " + "Got a bad bunny, It should be put to Burrow.Queue.Error ;)"); } System.Threading.Thread.Sleep(processingTime); Global.DefaultWatcher.InfoFormat("Processed msg [{0}], priority [{1}] in [{2}] ms\n", bunny.Name, bunny.Age, processingTime); }
static void Main(string[] args) { Bunny b1 = new Bunny () { Name="Bo", likesCarrots=true, likesHumans=false }; Bunny b2 = new Bunny("bo") { likesCarrots = true, likesHumans = false }; Console.WriteLine(b1); }
private void addBunny() { Bunny bunny = new Bunny(); bunny.x = minX; bunny.y = maxY; holder.AddChild(bunny); bunnys.Add(bunny); }
void handleUpdate (VariantMap eventData) { if (isAdding) { var scale = new Vector2 (); var initPos = new Vector2 (minX, maxY); for (var i = 0; i < amount; i++) { var bunny = new Bunny (); bunnies.Add (bunny); var node = scene.CreateChild (); bunny.node = node; var sprite = (StaticSprite2D)node.CreateComponent ("StaticSprite2D"); sprite.BlendMode = BlendMode.BLEND_ALPHA; sprite.Sprite = currentTexture; node.Position2D = bunny.position = initPos; bunny.speed.x = (float)(random.NextDouble () * 10); bunny.speed.y = (float)(random.NextDouble () * 10) - 5; scale.x = scale.y = (0.5f + ((float)random.NextDouble ()) * 0.5f); node.Scale2D = scale; node.Rotation2D = (((float)random.NextDouble ()) - 0.5f); } } foreach (var bunny in bunnies) { var px = bunny.position.x; var py = bunny.position.y; var speedX = bunny.speed.x; var speedY = bunny.speed.y; px += speedX * .002f; py += speedY * .002f; if (px > maxX) { speedX *= -1; px = maxX; } else if (px < minX) { speedX *= -1; px = minX; } if (py > maxY) { speedY = 0; py = maxY; } else if (py < minY) { speedY *= -0.95f; if (((float)random.NextDouble ()) > 0.5f) { speedY -= ((float)random.NextDouble ()) * 6f; } py = minY; } bunny.speed.x = speedX; bunny.speed.y = speedY + gravity; bunny.position.x = px; bunny.position.y = py; bunny.node.Position2D = bunny.position; ; } }
public IHttpActionResult PutBunny(int id, Bunny bunny) { if (!ModelState.IsValid) { return BadRequest(ModelState); } if (id != bunny.Id) { return BadRequest(); } db.Entry(bunny).State = EntityState.Modified; try { db.SaveChanges(); } catch (DbUpdateConcurrencyException) { if (!BunnyExists(id)) { return NotFound(); } else { throw; } } return StatusCode(HttpStatusCode.NoContent); }
private void AddBunnyByRoom(Bunny bunny) { if (!this.roomsById[bunny.RoomId].ContainsKey(bunny.Team)) { this.roomsById[bunny.RoomId].Add(bunny.Team, new List<Bunny>()); } this.roomsById[bunny.RoomId][bunny.Team].Add(bunny); }
/// <summary> /// Creates a bunny and adds it to the game. /// </summary> /// <param name="name">The name of the bunny. It can contain any symbol</param> /// <param name="team">The team of the bunny. The teams ids are from 0 to 4</param> /// <param name="roomId">The id of the room in which the bunny will start the game.</param> /// <exception cref="ArgumentException"> If the room or bunny already exists throws an ArgumentException.</exception> /// <exception cref="IndexOutOfRangeException"> If the team is not in the range of 0 to 4 throws an IndexOutOfRangeException.</exception> public void AddBunny(string name, int team, int roomId) { if (bunniesByName.ContainsKey(name)) { throw new ArgumentException("The bunny already exists!"); } if (!roomsById.ContainsKey(roomId)) { throw new ArgumentException("The room does not exist!"); } if (team < 0 || team > 4) { throw new IndexOutOfRangeException("The team can be a with id from 0 to 4"); } Bunny bunny = new Bunny(name, team, roomId); this.AddBunnyByTeam(bunny); this.AddBunnyByName(bunny); this.AddBunnyByRoom(bunny); }
private void AddBunnyByTeam(Bunny bunny) { if (!this.bunniesByTeam.ContainsKey(bunny.Team)) { this.bunniesByTeam.Add(bunny.Team, new SortedSet<Bunny>()); } this.bunniesByTeam[bunny.Team].Add(bunny); }
private void AddBunnyByName(Bunny bunny) { this.bunniesByName.Add(bunny.Name, bunny); }
public void Should_Return_Docs_On_View() { var db = client.GetDatabase(baseDatabase); var jobj = JObject.Parse( "{\"_id\": \"_design/Patient\",\"views\": {\"all\": {\"map\": \"function (doc) {\n emit(doc._id, null);\n }\"}},\"type\": \"designdoc\"}"); db.CreateDocument(jobj.ToString()); var bunny = new Bunny {Name = "Roger"}; db.CreateDocument(new Document<Bunny>(bunny)); var result = db.View("all", new ViewOptions {IncludeDocs = true}, "Patient"); Assert.IsTrue(result.Docs.Any()); }
public IHttpActionResult PostBunny(Bunny bunny) { if (!ModelState.IsValid) { return BadRequest(ModelState); } db.Bunnies.Add(bunny); db.SaveChanges(); return CreatedAtRoute("DefaultApi", new { id = bunny.Id }, bunny); }
public void Should_Save_And_Retrieve_A_Document_With_Generics() { var id = Guid.NewGuid().ToString(); var db = client.GetDatabase(baseDatabase); var bunny = new Bunny {Id=id, Name = "Hippity Hop"}; var doc = new Document<Bunny>(bunny); byte[] attachment = File.ReadAllBytes("../../Files/martin.jpg"); doc.AddAttachment("martin.jpg", attachment); db.SaveDocument(doc); var persistedBunny= db.GetDocument<Bunny>(id); Assert.IsTrue(persistedBunny.HasAttachment); }