コード例 #1
0
ファイル: Food.cs プロジェクト: Spadar/MachineLearning
 protected virtual void OnFoodEatenEvent(Food source, EventArgs e)
 {
     if (OnFoodEaten != null)
     {
         OnFoodEaten(source, e);
     }
 }
コード例 #2
0
ファイル: FoodVisual.cs プロジェクト: Spadar/MachineLearning
        public FoodVisual(Food source, Ellipse food)
        {
            this.source = source;

            this.food = food;

            food.Dispatcher.Invoke(new Action(() => food.Height = Food.getSize()));
            food.Dispatcher.Invoke(new Action(() => food.Width = Food.getSize()));

            food.Dispatcher.Invoke(new Action(() => food.Fill = new SolidColorBrush(Colors.LightGreen)));

            source.OnFoodEaten += source_OnFoodEaten;
        }
コード例 #3
0
ファイル: FoodVisual.cs プロジェクト: Spadar/MachineLearning
 void source_OnFoodEaten(Food source, EventArgs e)
 {
     OnSourceEatenEvent(EventArgs.Empty);
 }
コード例 #4
0
        void MainWindow_OnFoodAddition(Food source, EventArgs e)
        {
            FoodVisual visual = null;
            Dispatcher.Invoke(new Action(() => visual = new FoodVisual(source, new Ellipse())));
            foodVisuals.Add(visual);
            Dispatcher.Invoke(new Action(() => canvas.Children.Add(visual.getVisual())));
            visual.OnSourceEaten += visual_OnSourceEaten;

            visual.update();
        }
コード例 #5
0
ファイル: FoodManager.cs プロジェクト: Spadar/MachineLearning
        private void removeFood(Food food)
        {
            int[] arrayLocation = food.getArrayLocation();
            foodGrid[arrayLocation[0],arrayLocation[1],arrayLocation[2]] = null;
            activeFood.Remove(food);

            OnFoodDeletionEvent(food, EventArgs.Empty);
        }
コード例 #6
0
ファイル: FoodManager.cs プロジェクト: Spadar/MachineLearning
 void food_OnFoodEaten(Food source, EventArgs e)
 {
     //When a food is eaten. Remove it and replace it with a new one.
     removeFood(source);
     //addFood();
 }
コード例 #7
0
ファイル: FoodManager.cs プロジェクト: Spadar/MachineLearning
        private void addFood()
        {
            retry:
            Point position = new Point(ranGen.NextDouble() * world.getWorldSize().X, ranGen.NextDouble() * world.getWorldSize().Y);

            int[] arrayPosition = new int[3];

            int[] xyPos = findGridCell(position);

            int zPos = 0;

            //Find an empty slot in the foodGrid
            Food arrayTest = null;
            while((arrayTest = foodGrid[xyPos[0],xyPos[1],zPos]) != null)
            {
                zPos++;
                if(zPos > arrayDepth)
                {
                    goto retry;
                }
            }

            arrayPosition[0] = xyPos[0];
            arrayPosition[1] = xyPos[1];
            arrayPosition[2] = zPos;

            Food food = new Food(position, arrayPosition);

            foodGrid[arrayPosition[0], arrayPosition[1], arrayPosition[2]] = food;
            activeFood.Add(food);

            food.OnFoodEaten += food_OnFoodEaten;

            OnFoodAdditionEvent(food, EventArgs.Empty);
        }
コード例 #8
0
ファイル: FoodManager.cs プロジェクト: Spadar/MachineLearning
 protected virtual void OnFoodDeletionEvent(Food source, EventArgs e)
 {
     if (OnFoodDeletion != null)
     {
         OnFoodDeletion(source, e);
     }
 }