示例#1
0
        public override void Resume()
        {
            GResource.LoadTextures();

            var imageFon = new GImage(Game);

            imageFon.SetTexture(GResource.game_fon);
            imageFon.SetWidth(Game.GetWindowWidth());
            imageFon.SetHeight(Game.GetWindowHeight());
            imageFon.SetX(Game.GetWindowWidth() / 2);
            imageFon.SetY(Game.GetWindowHeight() / 2);
            AddElement(imageFon);

            tree = new ChristmasTree(Game);
            tree.GenerateDecorations(3);

            train = new Train(Game, GResource.train);
            train.Initialize(Game.GetWindowWidth() / 2, 65, 90, 30);
            train.SetChristmasTree(tree);

            cat = new Cat(Game, Game.GetWindowWidth() / 2, Game.GetWindowHeight() / 2, 50, 50);
            cat.AddTextures(GResource.lcat, Cat.STATE.LEFT);
            cat.AddTextures(GResource.rcat, Cat.STATE.RIGHT);
            cat.Bump();
            cat.SetChristmasTree(tree);
            //	AddElement(imageCat);
        }
示例#2
0
        public void TestMethod()
        {
            ChristmasTree tree   = new ChristmasTree(5, false);
            var           result = tree.Draw();

            Assert.That(result.Count, Is.EqualTo(6));
        }
示例#3
0
        public void TreeWithStarShouldHaveOnlElementMore()
        {
            ChristmasTree tree   = new ChristmasTree(5, true);
            var           result = tree.Draw();

            Assert.That(result.Count, Is.EqualTo(7));
        }
示例#4
0
 public TaggedPhoto(ChristmasTree p, string t)
 {
     _photo = p;
     _tag   = t;
     Tags.Add(t);
     _number = ++_count;
 }
示例#5
0
 public ChoppingWoodState(ChristmasTree _resource, Warehouse _warehouse, GameObject transform)
 {
     tree = _resource;
     warehouse = _warehouse;
     resourceManger = ResourceManager.GetManager();
     currentGameObject = transform;
     gathering = true;
 }
示例#6
0
 public ToppedTree(ChristmasTree p)
 {
     _image  = new Bitmap(@"C:\Users\Johannes\Dropbox\Schoolspul\Stenden\Jaar 3\Design Patterns\treetop.png");
     _image2 = new Bitmap(_image, new Size(_image.Width, _image.Height));
     _tree   = p;
     _xPos   = Mouse.X;
     _yPos   = Mouse.Y;
 }
示例#7
0
        public void TestTreeWidthWithoutStar(int treeSize, int expectedWidth)
        {
            ChristmasTree tree = new ChristmasTree(treeSize, true);

            tree.Draw();
            var result = tree.GetWidth();

            Assert.That(result, Is.EqualTo(expectedWidth));
        }
示例#8
0
        public void TestTreeHeightWithoutStar(int treeSize, int expectedHeight)
        {
            ChristmasTree tree = new ChristmasTree(treeSize, false);

            tree.Draw();
            var result = tree.GetHeight();

            Assert.That(result, Is.EqualTo(expectedHeight));
        }
        private static bool CheckBuilding(ChristmasTree tree)
        {
            DecayEntity decay = tree.GetComponent <DecayEntity>();

            if (decay == null)
            {
                return(false);
            }
            return(decay.GetBuilding() != null);
        }
示例#10
0
        public void Test_Create_ChristmasTree(int height)
        {
            var cut = new ChristmasTree();

            var actual = cut.Draw(height);

            Assert.Equal(height + 1, actual.Count);
            Assert.Contains(" X ", actual[0]);
            Assert.Equal(new string('X', (height - 1) * 2 + 1), actual[height - 1]);
            Assert.Contains(" X ", actual[height]);
        }
示例#11
0
        static void Main()
        {
            ChristmasTree christmasTree = new ChristmasTree();
            ChristmasToy  christmasToy  = new ChristmasToy("red");

            christmasTree.HangToy(christmasToy);
            christmasTree.HangToy(new ChristmasToy("black"));
            christmasTree.HangToy(new ChristmasToy("green"));

            var enumerator = christmasTree.GetEnumerator();

            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.GetCurrent());
            }

            Console.WriteLine("\n\nChange Toy:\n");
            christmasTree.TakeOffToy(christmasToy);
            christmasTree.HangToy(new ChristmasToy("golden"));

            enumerator.Reset();
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.GetCurrent());
            }

            Console.WriteLine("\n\nBox with Toys also:\n");
            BoxWithToys boxWithToys = new BoxWithToys();

            boxWithToys.PutToy(new ChristmasToy("red"));
            boxWithToys.PutToy(new ChristmasToy("green"));
            boxWithToys.PutToy(new ChristmasToy("blue"));
            enumerator = boxWithToys.GetEnumerator();
            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.GetCurrent());
            }

            Console.WriteLine("\n\nPour out Toys:\n");
            boxWithToys.PourOutToys();
            enumerator.Reset();

            while (enumerator.MoveNext())
            {
                Console.WriteLine(enumerator.GetCurrent());
            }

            Console.ReadKey();
        }
示例#12
0
        static void Main()
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            var treesWithBalls = new List <BalledTree>();
            var tree           = new ChristmasTree();

            Application.Run(tree);

            var ball = new BalledTree(tree);

            treesWithBalls.Add(ball);
            Application.Run(ball);

            var t = MessageBox.Show(@"Ok for new ball, cancel resume", @"   ", MessageBoxButtons.OKCancel);

            while (t == DialogResult.OK)
            {
                switch (t)
                {
                case DialogResult.OK:
                    treesWithBalls.Add(new BalledTree(treesWithBalls.ElementAt(treesWithBalls.Count - 1)));
                    Application.Run(treesWithBalls.ElementAt(treesWithBalls.Count - 1));
                    t = MessageBox.Show(@"Ok for new ball, press cancel to position topper.", @"   ", MessageBoxButtons.OKCancel);

                    break;

                case DialogResult.Cancel:

                    break;

                default:
                    break;
                }
            }
            var top = new ToppedTree(treesWithBalls.ElementAt(treesWithBalls.Count - 1));

            Application.Run(top);
            try
            {
                Application.Run(tree);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
        }
 private void SpawnPresents(ChristmasTree tree)
 {
     if (treeNeedsAllOrnaments)
     {
         if (!CheckOrnaments(tree))
         {
             return;
         }
     }
     if (treeNeedsToBeOnFoundation)
     {
         if (!CheckBuilding(tree))
         {
             return;
         }
     }
     for (int i = 0; i < UnityEngine.Random.Range(minNumOfPresents, maxNumOfPresents + 1); i++)
     {
         CreatePresent(new Vector3(UnityEngine.Random.Range(-1.2f, 1.2f), 0, UnityEngine.Random.Range(-1.2f, 1.2f)) + tree.transform.localPosition, Quaternion.Euler(0f, UnityEngine.Random.Range(0f, 360f), 0f));
     }
 }
 private static bool CheckOrnaments(ChristmasTree tree)
 {
     return(tree.GetComponent <StorageContainer>().inventory.IsFull());
 }
示例#15
0
 public void Setup()
 {
     _christmasTree = new ChristmasTree();
 }
示例#16
0
文件: Program.cs 项目: SlicR97/Katas
        static void Main(string[] args)
        {
            var christmasTree = new ChristmasTree();

            System.Console.WriteLine(christmasTree.Draw(5, true));
        }
示例#17
0
    public void ReachedResource()
    {
        var animator = currentGameObject.GetComponent<Animator>();
        var navAgent = currentGameObject.GetComponent<NavMeshAgent>();
        //Debug.Log("Chopping in session.");

        if (tree.WoodQuantity <= 0)
        {
            gathering = false;
            navAgent.updateRotation = true;
        }

        //else if(Vector3.Distance(currentGameObject.transform.position,
        //	tree.transform.position) < 2f)
        //{
        //	gathering = true;
        //}

        if(!gathering)
        {
            //this is actually attack. which is actually mine  or chop wood :)
            animator.SetBool("Crouch", false);
            goToTarget = warehouse.transform.position;

            if(Vector3.Distance(goToTarget, currentGameObject.transform.position) < 10f)
            {
                //do some complex collision shit to get this. Will do tomorrow. Hopefully I can show rebecca wood chopping sim.
                //Debug.Log("Dumping stuff!!");
                if (quantityHeld > 0)
                {
                    warehouse.DropOffResources(ResourceType.Wood, quantityHeld);
                    quantityHeld = 0;

                    //then we find a new tree :)
                    var nearestTree = RTSUnitQueryCollection.FindNearestObjectOfType<ChristmasTree>(currentGameObject);

                    if(nearestTree != null)
                    {
                        gathering = true;
                        tree = nearestTree;
                    }
                }
            }
        }
        else
        {
            if(tree == null)
            {
                return;
            }

            goToTarget = tree.transform.position;

            if (gathered < gatherSpeed)
            {
                gathered += Time.deltaTime;
                navAgent.updateRotation = false;
                animator.SetBool("Crouch", false);
                Quaternion rotation = Quaternion.LookRotation(goToTarget - currentGameObject.transform.position);
                currentGameObject.transform.rotation = Quaternion.Slerp(currentGameObject.transform.rotation, rotation, Time.deltaTime * 2);
            }
            else if(Vector3.Distance(goToTarget, currentGameObject.transform.position) < 3f)
            {
                gathered = 0;
                // this tries to take a certain amount, if successful then we're done.
                quantityHeld += tree.TakeWood(5);
                animator.SetBool("Crouch", true);
                //once the tree is ded, find a new tree!
            }
        }

        //switch states when we get to the spot.
        var worker = currentGameObject.GetComponent<Worker>();
        worker.SetTask(goToTarget, 1, 0, WorkerTask.Lumberjack);
    }
示例#18
0
        static void Main(string[] args)
        {
            ChristmasTree christmasTree = new ChristmasTree();
            christmasTree.TopHight = 12;
            christmasTree.Shape = ShapeTypeBranches.Half;
            christmasTree.DrawChristmasThree();

            Console.WriteLine();

            christmasTree = new ChristmasTree();
            christmasTree.TopHight = 12;
            christmasTree.DrawChristmasThree();

            Console.WriteLine();

            christmasTree = new ChristmasTree();
            christmasTree.TopHight = 12;
            christmasTree.BottomHight = 4;
            christmasTree.DrawChristmasThree();

            Console.WriteLine();

            christmasTree = new ChristmasTree(12, 6, 6, ShapeTypeBranches.Complete);
            christmasTree.DrawChristmasThree();

            Console.ReadKey();
        }