Esempio n. 1
0
    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");
        }
    }
Esempio n. 2
0
 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));
 }
Esempio n. 3
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"*/);
        }
Esempio n. 5
0
 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);
     }
 }
Esempio n. 7
0
 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);
 }
Esempio n. 9
0
    /// <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;
                }
            }
        }
    }
Esempio n. 10
0
        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));
        }
Esempio n. 11
0
        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. */
        }
Esempio n. 12
0
    // 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;
        }
    }
Esempio n. 13
0
 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);
     }
 }
Esempio n. 14
0
        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();
        }
Esempio n. 16
0
 public void OnBunnyHit(Bunny bunny)
 {
     Health -= 1;
     if (Health == 0)
     {
         OnGameOver();
     }
 }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
    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);
        }
Esempio n. 21
0
 public Couple(Bunny _bunny1, Bunny _bunny2)
 {
     this.bunny1           = _bunny1;
     this.bunny2           = _bunny2;
     this.timeInFeed       = 0;
     this.timeFemaleInFeed = 0;
     this.doneFeed         = false;
 }
Esempio n. 22
0
        // //////////////
        // BUNNY THREAD//
        // //////////////

        public static void BunnyCall()
        {
            var Bunny = new Bunny();

            var BunnyThread = new Thread(Bunny.Run);

            BunnyThread.Start();
        }
Esempio n. 23
0
    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);
        }
Esempio n. 26
0
 public DrinkAction(Bunny bunny)
 {
     this.bunny  = bunny;
     pathToWater = bunny.sensor.GetClosestWaterPath();
     if (!pathToWater.ValidPath)
     {
         ActionFinished = true;
     }
 }
Esempio n. 27
0
 public WanderAction(Bunny bunny)
 {
     this.bunny = bunny;
     wanderPath = bunny.sensor.GetRandomPath();
     if (!wanderPath.ValidPath)
     {
         ActionFinished = true;
     }
 }
Esempio n. 28
0
 public void Remove(Bunny iBunny)
 {
     lock (_clientUpdateLock)
     {
         _allBunnies.Remove(iBunny);
         _departedBunnyIds.Add(iBunny.Id);
     }
     Interlocked.Decrement(ref _bunnyCount);
 }
Esempio n. 29
0
    // 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);
                }
            }
        }
    }
Esempio n. 30
0
    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);
    }
Esempio n. 31
0
    private void OnTriggerEnter(Collider other)
    {
        Bunny attempt = other.GetComponent <Bunny>();

        if (attempt != null && hasBunny == false)
        {
            hasBunny    = true;
            bunnyTarget = other.gameObject;
        }
    }
Esempio n. 32
0
        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);
            }
        }
Esempio n. 33
0
        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;
        }
Esempio n. 34
0
 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);
 }
Esempio n. 35
0
 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);
 }
Esempio n. 36
0
    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);
    }
Esempio n. 37
0
 private void addBunny()
 {
     Bunny bunny = new Bunny();
     bunny.x = minX;
     bunny.y = maxY;
     holder.AddChild(bunny);
     bunnys.Add(bunny);
 }
Esempio n. 38
0
	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);
        }
Esempio n. 40
0
        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);
        }
Esempio n. 41
0
        /// <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);
        }
Esempio n. 42
0
        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);
        }
Esempio n. 43
0
 private void AddBunnyByName(Bunny bunny)
 {
     this.bunniesByName.Add(bunny.Name, bunny);
 }
Esempio n. 44
0
 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);
        }
Esempio n. 46
0
        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);
        }