Inheritance: SheepBase
Esempio n. 1
0
        /*
         * Creates an Animal object and saves it to the json file.
         * Params:
         *  name: Name of the animal
         *  type: Type of the animal, as high as number of classes inherited from Animal
         *  animalList: List with the animals in json file
         * Return: The Animal object created
         */
        public Animal CreateAnimal(string name, int type, List <Animal> animalsList, User user, List <User> userList)
        {
            Animal animal;
            int    newId;

            newId = (animalsList.Count > 0) ? animalsList[animalsList.Count - 1].ID + 1 : 0;

            switch (type) // Add new cases if new animal classes appears
            {
            case 0: animal = new TyrannosaurusRex(newId, name, user.ID); break;

            case 1: animal = new Cat(newId, name, user.ID); break;

            case 2: animal = new Sheep(newId, name, user.ID); break;

            default: throw new InvalidEnumArgumentException($"There is no animal type with Type = {type}");
            }

            animalsList.Add(animal);
            user.Animals.Add(animal.ID);
            RewriteAnimalsDB(animalsList);
            RewriteUsersDB(userList, user);

            return(animal);
        }
Esempio n. 2
0
    public List <GridSpace> MoveSheep()
    {
        // Create a new tree
        Node tree = new Node();

        tree.isRoot = true;
        tree.value  = 0;

        foreach (Sheep sheep in sheepList)
        {
            // A little Dolly Parton joke there. I don't care if it's against best practices.
            Sheep dolly     = sheep;
            Wolf  wolfClone = wolf;

            Node sheepNode = GenerateTree(tree, 0, true, dolly, wolfClone, GridSpaceStatus.SHEEP);
            sheepNode.movePosition = sheep.position;

            // Generate all possible move paths for this sheep and the enemy wolf.
            // Terminal depth is 7, at which point a given sheep has reached the bottom and can no longer move.
            // Calculate which of these paths has the best value using the Minimax Algorithm.

            tree.children.Add(sheepNode);
        }

        // Compare the 4 sheeps best moves against eachother and pick the highest value move.
        //

        gridSpaces [bestSheep.position].SetGridSpaceStatus(GridSpaceStatus.EMPTY);
        gridSpaces [bestSheep.bestMove].SetGridSpaceStatus(GridSpaceStatus.SHEEP);

        return(gridSpaces);
    }
Esempio n. 3
0
        public async Task <IActionResult> Edit(int id, [Bind("SheepId,SheepName,Gender,BirthDay,MothersName,FathersName,Miscarriage,OwnerId")] Sheep sheep)
        {
            if (id != sheep.SheepId)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(sheep);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!SheepExists(sheep.SheepId))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            ViewData["OwnerId"] = new SelectList(_context.Users, "Id", "Id", sheep.OwnerId);
            return(View(sheep));
        }
Esempio n. 4
0
        static void BasicDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep {
                Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla
            };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\");

            // or over a network via REST API to WCF server *see usage section below*
            //var db = Embark.Client.GetNetworkDB("192.168.1.24", 8030);

            // collections created on-the-fly if needed
            var io = db.GetCollection <Sheep>("sheep");

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Get(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);

            // non-type specific collection if you want to save Apples & Oranges in the same fruit collection
            //var io = db["fruit"];
        }
Esempio n. 5
0
    void CheckCollision()
    {
        Vector3 origin = transform.position;

        ray = new Ray(origin, Vector3.up * direction * rayLength);
        if (Physics.Raycast(ray, out HitInfo, rayLength))
        {
            GetComponent <Animator>().SetTrigger("push");
            GameObject other = HitInfo.collider.gameObject;
            if (other.tag == "Sheep" && !isPushing)
            {
                Sheep otherSheep = other.GetComponent <Sheep>();
                if (isWhite && !otherSheep.isWhite)
                {
                    GameManager.Instance.wWeights[laneIndex] += weight;
                    GameManager.Instance.bWeights[laneIndex] += otherSheep.weight;
                    Vector3 pushEffectPos = transform.position + Vector3.up * direction * rayLength;
                    var     effect        = GameObject.Instantiate(pushEffect, pushEffectPos, Quaternion.identity);
                    GameObject.Destroy(effect, 0.5f);
                }
                if (isWhite && otherSheep.isWhite)
                {
                    GameManager.Instance.wWeights[laneIndex] += weight;
                }
                if (!isWhite && !otherSheep.isWhite)
                {
                    GameManager.Instance.bWeights[laneIndex] += weight;
                }

                isPushing = true;
            }
        }
    }
Esempio n. 6
0
    public Sheep CheckHerdCohesion()
    {
        Vector3 centroid = HerdeCentroid();

        Sheep furthest = null;

        foreach (Sheep s in sheep)
        {
            if (furthest == null)
            {
                furthest = s;
            }
            float current = Vector3.Distance(centroid, furthest.Position);
            float temp    = Vector3.Distance(centroid, s.transform.position);
            if (temp > current)
            {
                furthest = s;
            }
        }

        if (Vector3.Distance(furthest.Position, centroid) > MaxHerdeRadius)
        {
            return(furthest);
        }

        return(null);
    }
Esempio n. 7
0
    void checkClick()
    {
        if (Input.GetMouseButtonDown(0))
        {
            Ray          ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit2D hit = Physics2D.Raycast(ray.origin, ray.direction, Mathf.Infinity, (int)clickTargets);
            if (hit && hit.collider.gameObject.tag.ToLower() == "sheep")
            {
                Sheep sheep = hit.collider.gameObject.GetComponent <Sheep>();

                Sheep startSheepScript = null;
                if (startSheep != null)
                {
                    startSheep.GetComponent <Sheep>();
                }

                if (startSheep != null && sheep == startSheepScript && startSheepScript.startSheep)
                {
                    jump.Play();
                    sheep.ChargeAndStart();
                    isGameOver = false;
                    return;
                }
                if (sheep != null && isGameOver == false)
                {
                    jump.Play();
                    sheep.Jump();
                }
            }
        }
    }
Esempio n. 8
0
    void OnMouseDown()
    {
        if (gmScript.gameState == 3)
        {
            //offset = gameObject.transform.position - Camera.main.ScreenToWorldPoint(new Vector2(Input.mousePosition.x, Input.mousePosition.y));
            gmScript.SheepOnCursor(mySheep);

            pickAudioIndex = Random.Range(0, 3);
            audiosource.PlayOneShot(pickAudio[pickAudioIndex], 1f);

            sheepdeathScript.isDeathTimerRunning = false;

            sheepScript = mySheep.GetComponent <Sheep>();
            dragSens    = sheepScript.dragSensitivity;

            isMouseUp = false;
            canDrag   = true;
            sheepScript.SheepBulge();
            followingCursor = true;

            mySheep.GetComponent <CapsuleCollider2D>().isTrigger = true;
            mySheep.GetComponent <SheepMovement>().enabled       = false;

            sheepcollScript.PrepareForCollision(mySheep);

            StartCoroutine("Save_SheepFromWolf");
        }
    }
Esempio n. 9
0
    public void OnCollisionExit2D(Collision2D other)
    {
        collidedWithSheep = false;
        collidedWithEnemy = false;

        collisionInvolvedSheep = null;
    }
Esempio n. 10
0
        public void GetBetween_ReturnsBetweenItems()
        {
            // arrange
            var allTestCollection = MockDB.SharedRuntimeClient["SelectBetween"];
            var testHerd = new List<Sheep>();

            var oldWooly = new Sheep { Name = "Wooly", Age = 100, FavouriteIceCream = IceCream.Chocolate };
            var oldDusty = new Sheep { Name = "Dusty", Age = 50, FavouriteIceCream = IceCream.Chocolate };
            var youngLassy = new Sheep { Name = "Lassy", Age = 1, FavouriteIceCream = IceCream.Bubblegum };

            testHerd.Add(oldWooly);
            testHerd.Add(oldDusty);
            testHerd.Add(youngLassy);

            var wrappedHerd = new List<WrappedSheep>();
            foreach (var sheep in testHerd)
            {
                var id = allTestCollection.Insert(sheep);
                wrappedHerd.Add(new WrappedSheep { ID = id, Sheep = sheep });
            }

            // act
            var betweenSheep = allTestCollection
                .GetBetween<Sheep>(new { Age = 75 }, new { Age = 25 })
                .Single();

            // assert
            Assert.IsTrue(betweenSheep.Content.Equals(oldDusty));
        }
Esempio n. 11
0
        static void SearchDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep {
                Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla
            };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\"); /* Client.GetLocalDB() defaults to: C:\MyTemp\Embark\Local\ */

            // or over a network
            // var io = Embark.Client.GetNetworkDB("127.0.0.1", 8765);// Not implemented, yet..

            // reference collections when used a lot so you don't have to keep typing them out
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Get <Sheep>(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);

            //io.UpdateBetween(new { FurDensity = 0.7, Name = "A" },
            //    new { FurDensity = 0.6, Name = "B" },
            //    new { Name = "Mass" });
        }
Esempio n. 12
0
        public void DoesSheepHaveFourLegs()
        {
            Sheep sheep = new Sheep();
            int   leg   = sheep.LegAmount;

            Assert.Equal(4, leg);
        }
Esempio n. 13
0
    // Use this for initialization
    void Start()
    {
        this._sheep = GetComponent <Sheep>();

        AddToManager();
        this.name = this.name.Replace("(Clone)", "");
    }
Esempio n. 14
0
    void OnCollisionEnter2D(Collision2D other)
    {
        collisionCount += 1;
        // if (collisionCount > 1) return;
        // Debug.Log(string.Format("collider collisionCount = {0}", collisionCount));
        if (other.gameObject.tag == "Sheep")
        {
            GetComponent <Animator>().SetTrigger("push");

            Sheep otherSheep = other.gameObject.GetComponent <Sheep>();
            if (direction == otherSheep.direction)
            {
                if (isPushing)
                {
                    if (direction == 1)
                    {
                        GameManager.Instance.wWeights[laneIndex] += weight;
                    }
                    else
                    {
                        GameManager.Instance.bWeights[laneIndex] += weight;
                    }
                }
            }
            else if (direction == 1 && otherSheep.direction == -1)
            {
                GameManager.Instance.wWeights[laneIndex] += weight;
                GameManager.Instance.bWeights[laneIndex] += otherSheep.weight;
                Vector3 pushEffectPos = transform.position + Vector3.up * GetComponent <BoxCollider2D>().size.y / 2f;
                var     effect        = GameObject.Instantiate(pushEffect, pushEffectPos, Quaternion.identity);
                GameObject.Destroy(effect, 0.5f);
            }
            AdjustVelocity();
        }
    }
Esempio n. 15
0
 // Use this for initialization
 void Start()
 {
     grassStates = _states.growing;
     grid        = FindObjectOfType <GridGenerator>();
     sheep       = FindObjectOfType <Sheep>();
     hp          = Random.Range(2, 4);
 }
Esempio n. 16
0
        static void Main(string[] args)
        {
            Cat mimi = new Cat("mimi");
            mimi.SHOUTCOUNT = 4;
            mimi.shout();
            Console.WriteLine();

            Cat coco = new Cat("coco");
            coco.SHOUTCOUNT = 2;
            coco.shout();
            Console.WriteLine();

            Dog wangcai = new Dog("wangcai");
            wangcai.SHOUTCOUNT = 8;
            wangcai.shout();
            Console.WriteLine();

            Cow moumou = new Cow("moumou");
            moumou.SHOUTCOUNT = 3;
            moumou.shout();
            Console.WriteLine();

            Sheep miemie = new Sheep("miemie");
            miemie.SHOUTCOUNT = 5;
            miemie.shout();
            Console.WriteLine();

            coco.CatchAnimal();
            wangcai.CatchAnimal();
            Console.ReadLine();
        }
Esempio n. 17
0
 void resetVar()
 {
     hasTarget      = false;
     hasDestination = false;
     killing        = false;
     TargetSheep    = null;
 }
Esempio n. 18
0
    private void HerdRun(Collision2D collision)
    {
        if (collision == null)
        {
            return;
        }

        Sheep tempSheep = collision.collider.GetComponent <Sheep>();

        if (tempSheep && tempSheep.body.velocity.magnitude > body.velocity.magnitude)
        {
            body.AddForce((transform.position - collision.transform.position).normalized * force);
        }

        if (collision.collider.tag == "Wall")
        {
            //*Working but not perfect
            Vector3 collisionPoint = collision.GetContact(0).point;
            body.AddForce((transform.position - collisionPoint).normalized * force * 2);
            //*/

            /*//Not working
             * Vector3 collisionPoint = collision.GetContact(0).point;
             * Vector3 direction = (collisionPoint - transform.position).normalized;
             * float angle = Mathf.Atan2(direction.y, direction.x) * Mathf.Rad2Deg;
             * transform.rotation = Quaternion.AngleAxis(angle, Vector3.forward);
             * body.AddForce(Vector3.forward * force * force);
             * //*/
        }
    }
Esempio n. 19
0
    public FloatingText floater; // assign this PREFAB reference in inspector

    #endregion Fields

    #region Methods

    // the reason this is USEFUL: you no longer have to drag and drop anything
    // 		and you don't have to use GetComponent because this variable lives in code!
    // the reason this is TERRIBLE: anything in the code can read and write to this var
    // 		which means a lot of complexity; if something goes wrong, it could be ANYWHERE
    // Update is called once per frame
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay( Input.mousePosition );
        RaycastHit rayHit = new RaycastHit();

        if ( Physics.Raycast( ray, out rayHit, 10000f ) ) {

            if ( Input.GetMouseButtonDown( 0 ) && rayHit.collider.tag == "Sheep" ) {
                // whatever code runs here is when:
                // 1) the mouse is over a GameObject with a collider and "Sheep" tag
                // 2) AND when the mouse is left-clicked
                Sheep selectedSheep = rayHit.collider.GetComponent<Sheep>();
                fameMeter.text = "sheep fame = " + selectedSheep.fame.ToString();

                // added on 11/14/2013
                currentSheep = selectedSheep; // saves what sheep we clicked on

                // added on 11/21/2013
                // spawn a new floating text object
                FloatingText newFloater = Instantiate ( floater, rayHit.point, Quaternion.identity) as FloatingText;
                newFloater.GetComponent<TextMesh>().text = "FAME: " + selectedSheep.fame.ToString();
            }

            if ( Input.GetMouseButtonDown( 1 ) ) {
                // whatever code runs here is when:
                // 1) the mouse is over anything with a collider
                // 2) AND when the mouse is right-clicked
                Sheep newSheep = Instantiate( dolly, rayHit.point, Quaternion.identity ) as Sheep;
                newSheep.fame = Random.Range( 1, 100 );
            }

        } // this closes out Raycast()
    }
Esempio n. 20
0
 private void OnTriggerExit(Collider other)
 {
     if (other.GetComponent <Sheep>() != null)
     {
         SheepInTrigger = null;
     }
 }
Esempio n. 21
0
    public List <GridSpace> MoveSheep()
    {
        // Create a new tree
        Node tree = new Node();

        tree.isRoot = true;
        tree.value  = 0;

        bestSheep = sheepList [0];
        foreach (Sheep sheep in sheepList)
        {
            // A little Dolly Parton joke there. I don't care if it's against best practices.
            Sheep dolly     = sheep;
            Wolf  wolfClone = wolf;

            Node sheepNode = GenerateTree(tree, 0, true, dolly, wolfClone, GridSpaceStatus.SHEEP);
            sheepNode.movePosition = sheep.position;

            tree.children.Add(sheepNode);
            sheep.bestMove      = dolly.bestMove;
            sheep.bestMoveDepth = dolly.bestMoveDepth;

            if (sheep.bestMoveDepth < bestSheep.bestMoveDepth && sheep.bestMoveValue >= 1)
            {
                this.bestSheep = sheep;
            }
        }

        gridSpaces [bestSheep.position].SetGridSpaceStatus(GridSpaceStatus.EMPTY);
        gridSpaces [bestSheep.bestMove].SetGridSpaceStatus(GridSpaceStatus.SHEEP);

        return(gridSpaces);
    }
Esempio n. 22
0
        private static void GenericDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\");

            // or over a network via REST API to WCF server *see usage section below*
            //var db = Embark.Client.GetNetworkDB("192.168.1.24", 8030);

            // collections created on-the-fly if needed
            var io = db.GetCollection<Sheep>("sheep");

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Get(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);

            // non-type specific collection if you want to save Apples & Oranges in the same fruit collection
            //var io = db["fruit"];
        }
Esempio n. 23
0
    IEnumerator FindTargetRoutine()
    {
        if (LevelController.Instance.IsGameOver)
        {
            ChangeRoutine(GameOverRoutine());
        }
        else
        {
            state = State.Idling;
            animController.SetBool("Idling", true);
            smokeParticleSystem?.Stop();

            targetSheep = null;
            while (targetSheep == null)
            {
                yield return(new WaitForEndOfFrame());

                targetSheep = SheepManager.Instance.GetSheepToTarget();

                if (LevelController.Instance.IsGameOver)
                {
                    ChangeRoutine(GameOverRoutine());
                }
                else if (targetSheep != null && targetSheep.IsDead)
                {
                    ChangeRoutine(AttackCoolDownRoutine());
                }
                else if (targetSheep != null)
                {
                    ChangeRoutine(ChaseRoutine());
                }
            }
        }
    }
Esempio n. 24
0
        private bool GrabSheep(Sheep sheep)
        {
            if (!CanGrab)
            {
                return(false);
            }

            DequeueSheep(sheep);
            _carrying = sheep;

            sheep.OnCarried(_sheepParent);

            Owner.ShephardModel.SkinHelper.Skin = sheep.Tag;

            _state = State.Grabbing;
            _grabEffect.Trigger(() => {
                _state = State.Idle;

                Debug.Log($"Grabbing sheep {sheep.Id}");

                Owner.GamePlayerBehavior.OnCarryingSheepChanged();
            });

            return(true);
        }
Esempio n. 25
0
    public void OnCollisionEnter2D(Collision2D other)
    {
        if (this.HP > 0)
        {
            if (other.gameObject.GetComponent <Package>() != null)
            {
                Package collectedPackage = other.gameObject.GetComponent <Package>();
                this.HP += collectedPackage.LifePoints;
            }

            if (other.gameObject.GetComponent <Sheep>() != null)
            {
                Sheep collectedSheep = other.gameObject.GetComponent <Sheep>();
                this.Coins += collectedSheep.Coins;
                UpdateScore();
            }

            if (other.gameObject.GetComponent <NPCProjectile>() != null)
            {
                NPCProjectile encounteredProjectile = other.gameObject.GetComponent <NPCProjectile>();
                this.HP -= encounteredProjectile.Damage;
            }

            if (other.gameObject.GetComponent <BossProjectile>() != null)
            {
                BossProjectile encounteredProjectile = other.gameObject.GetComponent <BossProjectile>();
                this.HP -= encounteredProjectile.Damage;
            }
        }
    }
Esempio n. 26
0
        static void Main(string[] args)
        {
            try
            {
                //Testing the creation of instances and methods.
                Sheep Frank = new Sheep();
                Frank.MakeNoise();
                Frank.Use();
                Frank.Move();
                Frank.AlternateUse();

                Pig Steve = new Pig(4, 352);
                Steve.Move();
                Steve.Use();
                Steve.AlternateUse();
                Steve.MakeNoise();

                Cow Lucy = new Cow(4, "brown");
                Lucy.Use();
                Lucy.AlternateUse();
                Lucy.Move();
                Lucy.MakeNoise();

                Chicken Carl = new Chicken(8, 18);
                Carl.Move();
                Carl.MakeNoise();
                Carl.Use();
                Carl.AlternateUse();
            }

            catch (Exception e)
            {
                Console.WriteLine(e);
            }
        }
Esempio n. 27
0
 public void Enter(Sheep sheep)
 {
     _sheep = sheep;
     _sheep.sleepyFX.Play();
     _sheep.isSleepState        = true;
     _sheep._navMeshAgent.speed = 0;
 }
Esempio n. 28
0
        public void Update_ModifiesSheep()
        {
            // arrange
            var saved = Sheep.GetTestSheep();

            long id = _MockDB.RuntimeBasicCollection.Insert(saved);

            Sheep source = _MockDB.RuntimeBasicCollection.Get <Sheep>(id);

            Sheep updated = new Sheep {
                Name = source.Name, FavouriteIceCream = source.FavouriteIceCream
            };

            updated.Age = source.Age + 1;

            // act
            bool  hasSheepUpdated = _MockDB.RuntimeBasicCollection.Update(id, updated);
            Sheep loaded          = _MockDB.RuntimeBasicCollection.Get <Sheep>(id);

            // assert
            Assert.True(hasSheepUpdated);
            Assert.Equal(updated.Name, loaded.Name);
            Assert.Equal(updated.Age, loaded.Age);
            Assert.Equal(updated.FavouriteIceCream, loaded.FavouriteIceCream);
            Assert.NotEqual(source.Age, updated.Age);
        }
Esempio n. 29
0
    // Start is called before the first frame update
    void Start()
    {
        Instance      = this;
        currentTarget = GetNewRandomPosition();

        rb           = GetComponent <Rigidbody2D>();
        rb.mass      = UnityEngine.Random.Range(0.2f, 0.5f);
        cameraHeight = 2f * Camera.main.orthographicSize;
        cameraWidth  = cameraHeight * Camera.main.aspect;

        lastFacingPosition = Vector2.zero;
        xBaseTransform     = Math.Abs(transform.localScale.x);

        if (DamageZone.instance != null)
        {
            FunctionPeriodic.Create(() => {
                if (DamageZone.instance.IsOutsideCircle(transform.position))
                {
                    Damage();
                }
            }, .5f);
        }

        animator = GetComponent <Animator>();
    }
Esempio n. 30
0
        public void GetWhere_ReturnsMatchingDocument()
        {
            // arrange
            var oldWooly = new Sheep {
                Name = "Wooly", Age = 100, FavouriteIceCream = IceCream.Chocolate
            };
            var oldDusty = new Sheep {
                Name = "Dusty", Age = 100, FavouriteIceCream = IceCream.Chocolate
            };
            var youngLassy = new Sheep {
                Name = "Lassy", Age = 1, FavouriteIceCream = IceCream.Bubblegum
            };

            _MockDB.RuntimeBasicCollection.Insert(oldWooly);
            _MockDB.RuntimeBasicCollection.Insert(oldDusty);
            _MockDB.RuntimeBasicCollection.Insert(youngLassy);

            // act

            IEnumerable <Sheep> matchQuery = _MockDB.RuntimeBasicCollection.GetWhere <Sheep>(new { Age = 100 }).Unwrap();

            var ancients = matchQuery.ToList();

            // assert
            Assert.Equal(2, ancients.Count);

            Assert.False(ancients.Any(s => s.Age != 100));
            Assert.False(ancients.Any(s => s.Name == "Lassy"));

            Assert.True(ancients.Any(s => s.Name == "Wooly"));
            Assert.True(ancients.Any(s => s.Name == "Dusty"));
        }
Esempio n. 31
0
        public void MixedTypeCollection_CanSave()
        {
            // arrange
            var   io         = MockDB.SharedClient.GetCollection <object>("MixedDataObjects");
            Sheep inputSheep = new Sheep {
                Name = "Mittens"
            };
            object outputObject;

            // act
            io.Insert("non-sheep");
            io.Insert(123);

            var idInput     = io.Insert(inputSheep);
            var outputSheep = io.AsBaseCollection().Get <Sheep>(idInput);

            // act & assert
            RunAllCommands(io, inputSheep, out outputObject);

            // TODO move to seperate test
            //var outSheepText = io.TextConverter.ToText(outputObject);
            //Sheep outputSheep = io.TextConverter.ToObject<Sheep>(outSheepText);

            Assert.AreEqual(inputSheep, outputSheep);
        }
Esempio n. 32
0
 private void OnTriggerStay(Collider other)
 {
     if (other.GetComponent <Sheep>() != null)
     {
         SheepInTrigger = other.GetComponent <Sheep>();
     }
 }
Esempio n. 33
0
    private void Start()
    {
        rb    = GetComponent <Rigidbody>();
        sheep = GetComponent <Sheep>();
#if DEBUG
        animator = GetComponent <Animator>();
#endif
    }
Esempio n. 34
0
    public void PickUp(Sheep sheep)
    {
        // hide the in-world sheep
        sheep.Remove();

        // and move it to the inventory
        fInventory.PickUpSheep();
    }
Esempio n. 35
0
    static void Main()
    {
        Sheep x = new Sheep();
        Console.WriteLine(x.Call()); //baaah

        Tiger y = new Tiger();
        Console.WriteLine(y.Call());
    }
Esempio n. 36
0
 // END CUT HERE
 // BEGIN CUT HERE
 public static void Main()
 {
     try {
     Sheep ___test = new Sheep();
     ___test.run_test(-1);
     } catch(Exception e) {
     //Console.WriteLine(e.StackTrace);
     Console.WriteLine(e.ToString());
     }
 }
        public OrcasAvalonApplicationCanvas()
        {
            Width = DefaultWidth;
            Height = DefaultHeight;

            this.ClipToBounds = true;

            var bg = new Rectangle
            {
                Width = DefaultWidth,
                Height = DefaultHeight,
                Fill = Brushes.White
            }.AttachTo(this);

            var bgi = new Image
            {
                Width = DefaultWidth,
                Height = DefaultHeight,
                Source = "assets/WhiteSheep/bg.png".ToSource()
            }.AttachTo(this);

            30.Times(
                delegate()
                {
                    new Image
                    {
                        Source = "assets/WhiteSheep/grass1.png".ToSource()
                    }.AttachTo(this).MoveTo(DefaultWidth.Random(), DefaultHeight.Random());
                }
            );

            var birds = "assets/WhiteSheep/birds.mp3".ToSound();

            birds.PlaybackComplete += birds.Start;
            birds.Start();

            // say what you want but i have made my mind about you
            5.Times(
                delegate()
                {
                    var x = DefaultWidth.Random();
                    var y = DefaultHeight.Random();
                    var s = new Sheep
                    {
                        Click = () => "assets/WhiteSheep/sheep.mp3".PlaySound()
                    };

                    s.Container.AttachTo(this).MoveTo(100, 100);
                    (1000 / 24).AtIntervalWithCounter(c => s.Container.MoveTo((x + c) % (DefaultWidth + 64) - 32, y));

                }
            );
        }
Esempio n. 38
0
        public void Update_ModifiesSheep()
        {
            // arrange
            var saved = Sheep.GetTestSheep();

            long id = MockDB.RuntimeBasicCollection.Insert(saved);

            Sheep source = MockDB.RuntimeBasicCollection.Get<Sheep>(id);

            Sheep updated = new Sheep { Name = source.Name, FavouriteIceCream = source.FavouriteIceCream };
            updated.Age = source.Age + 1;

            // act
            bool hasSheepUpdated = MockDB.RuntimeBasicCollection.Update(id, updated);
            Sheep loaded = MockDB.RuntimeBasicCollection.Get<Sheep>(id);

            // assert
            Assert.IsTrue(hasSheepUpdated);
            Assert.AreEqual(updated.Name, loaded.Name);
            Assert.AreEqual(updated.Age, loaded.Age);
            Assert.AreEqual(updated.FavouriteIceCream, loaded.FavouriteIceCream);
            Assert.AreNotEqual(source.Age, updated.Age);
        }
Esempio n. 39
0
        static void SearchDemo()
        {
            // arrange some guinea pig
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\"); /* Client.GetLocalDB() defaults to: C:\MyTemp\Embark\Local\ */

            // or over a network
            // var io = Embark.Client.GetNetworkDB("127.0.0.1", 8765);// Not implemented, yet..

            // reference collections when used a lot so you don't have to keep typing them out
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);

            // get
            Sheep fluffy = io.Get<Sheep>(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);

            //io.UpdateBetween(new { FurDensity = 0.7, Name = "A" },
            //    new { FurDensity = 0.6, Name = "B" },
            //    new { Name = "Mass" });
        }
Esempio n. 40
0
        static void MixedTypeDemo()
        {
            // arrange some guinea pigs
            var pet = new Sheep { Name = "Fluffy", FavouriteIceCream = IceCream.Vanilla };
            var mittens = new Cat { Name = "Mittens", FurDensity = 0.1 };

            // save data locally
            var db = Embark.Client.GetLocalDB(@"C:\AnimalsDB\"); /* Client.GetLocalDB() defaults to: C:\MyTemp\Embark\Local\ */

            // or over a network (via REST API)
            //var db = Embark.Client.GetNetworkDB("127.0.0.1", 8030);// Not implemented, yet..

            // collections created on-the-fly if needed
            var io = db["sheep"];

            // insert
            long id = io.Insert(pet);
            long d2 = io.Insert((object)500);
            long d3 = io.Insert("a string!");
            long d4 = io.Insert<Cat>(mittens);

            // get
            Sheep fluffy = io.Get<Sheep>(id);

            var xs = (int)io.Get<object>(d2);
            var ss = io.Get<string>(d3);
            //Cat indy = io.Get<Cat>(d2);
            //var x = io.Get<Object>(d3);
            //string empty = io.Get<string>(d4);

            DocumentWrapper<Sheep> fluffbox = io.GetWrapper<Sheep>(id);

            // update
            fluffy.FavouriteIceCream = IceCream.Strawberry;
            bool fluffyNowLikesStrawberry = io.Update(id, fluffy);

            // delete
            bool hasSheepVanished = io.Delete(id);
        }
Esempio n. 41
0
        public void GetWhere_ReturnsMatchingDocument()
        {
            // arrange
            var oldWooly = new Sheep { Name = "Wooly", Age = 100, FavouriteIceCream = IceCream.Chocolate };
            var oldDusty = new Sheep { Name = "Dusty", Age = 100, FavouriteIceCream = IceCream.Chocolate };
            var youngLassy = new Sheep { Name = "Lassy", Age = 1, FavouriteIceCream = IceCream.Bubblegum };

            MockDB.RuntimeBasicCollection.Insert(oldWooly);
            MockDB.RuntimeBasicCollection.Insert(oldDusty);
            MockDB.RuntimeBasicCollection.Insert(youngLassy);

            // act

            IEnumerable<Sheep> matchQuery = MockDB.RuntimeBasicCollection.GetWhere<Sheep>(new { Age = 100 }).Unwrap();

            var ancients = matchQuery.ToList();

            // assert
            Assert.AreEqual(2, ancients.Count);

            Assert.IsFalse(ancients.Any(s => s.Age != 100));
            Assert.IsFalse(ancients.Any(s => s.Name == "Lassy"));

            Assert.IsTrue(ancients.Any(s => s.Name == "Wooly"));
            Assert.IsTrue(ancients.Any(s => s.Name == "Dusty"));
        }
Esempio n. 42
0
 protected void Merge(Sheep sheep)
 {
     if(this.upgradeCount + sheep.upgradeCount < 2){
         sheep.Upgrade(sheep.upgradeCount + 1);
         if(!preserved){
             Destroy (gameObject);
         }
     }
     preserved = false;
 }