Ejemplo n.º 1
0
        public MainWindow()
        {
            InitializeComponent();
            timer.Interval = 15;
            timer.Tick    += Timer_Tick;
            try
            {
                Names.AddRange(File.ReadLines("resources/nomes.txt"));
            }
            catch (Exception ex)
            {
                //System.Windows.MessageBox.Show(ex.Message);
            }



            bugsMaxQty = 10;
            object syncLock = new object();

            lock (syncLock)
            {
                for (int i = 0; i <= bugsMaxQty * 10; i++)
                {
                    Foods.Add(new Food());
                }

                for (int i = 0; i <= bugsMaxQty; i++)
                {
                    Bugs.Add(new Autobug());
                }
                for (int i = 0; i <= bugsMaxQty; i++)
                {
                    Labels.Add(new BugLabel());
                }
                foreach (BugLabel label in Labels)
                {
                    label.IsOn        = chkLabels.IsChecked.Value;
                    label.RelativeAge = chkRelativeAge.IsChecked.Value;
                    Stage.Children.Add(label);
                }

                foreach (Food food in Foods)
                {
                    Stage.Children.Add(food);
                    food.hatch();
                }
                foreach (Autobug bug in Bugs)
                {
                    int nameIndex = Measure2.Random(Names.Count);
                    UsedNames.Add(nameIndex);
                    string newName = Names[nameIndex];
                    bug.Name = newName;
                    Stage.Children.Add(bug);
                    bug.hatch();
                }
            }


            timer.Start();
        }
Ejemplo n.º 2
0
        public void hatch()
        {
            _sizeMultiplyier = _speedMultiplyier = _biteSizeMultiplyier = _lifespanMultiplyier = 1;
            _size            = 2;
            ActualPosition   = new Vector(Measure2.Random(-300, 300), Measure2.Random(-300, 300));
            _speed           = 0.1;
            _biteSize        = 0.05;

            hatch(_size, ActualPosition, _speed, _biteSize, 2000);
        }
Ejemplo n.º 3
0
        public void hatch(bool SuperFood = true)
        {
            _growRate  = Measure2.RandomDouble();
            _minSize   = 2;
            _maxSize   = Measure2.Random(5, 10);
            ActualSize = InicialSize;
            if (SuperFood)
            {
                IsSuperFood = (Measure2.Random(1000) == 1) ? true : false;
            }

            Position = new Vector(Measure2.Random(-300, 300), Measure2.Random(-300, 300));

            Color = Brushes.Red;
        }
Ejemplo n.º 4
0
        private void GenType()
        {
            double multiplyer = 2;

            switch (Measure2.Random(5))
            {
            case 0:
                Type = "GLUTÃO";
                _biteSizeMultiplyier = multiplyer;
                break;

            case 1:
                Type = "APRESSADINHO";
                _speedMultiplyier = multiplyer;
                break;

            case 2:
                Type = "ZÉ";
                _biteSizeMultiplyier = 1;
                break;

            case 3:
                Type = "MATUSALÉM";
                _lifespanMultiplyier = multiplyer;
                break;

            case 4:
                Type     = "EINSTEIN";
                LifeSpan = 1;
                goto case 5;

            case 5:
                Type = "ZÉ";
                break;

            default:
                break;
            }
        }