public BoidActionSeparation(World world,int id)
 {
     _world = world;
     _id = id;
     _flee = new BoidActionFlee();
     _wander = new BoidActionWander();
 }
 public BoidColonyControl(Color color, Vector2 position, World world)
 {
     InitializeComponent();
     BoidColony = new BoidColony();
     Position = position;
     ColonyColor = color;
     Rect.Fill = new SolidColorBrush(color);
     World = world;
     GiveBirthToANiceBoid(this, new EventArgs());
 }
        public MainPage(Option option)
        {
            this.InitializeComponent();

            MainCanvas.LayoutUpdated += (sender, args) =>
                {
                    if (!once)
                    {
                        WCFLogger.Info("Application started {0}", DateTime.Now.ToShortDateString());

                        this.MainCanvas.Children.Add(this._fleeEllipse);
                        this._world = new World(MainCanvas);

                        menuControl.World = this._world;

                        this._timer = new GameTimer(this.TimerCallback);

                        MainCanvas.MouseMove += this.MainPage_MouseMove;
                        once = true;

                        var scenario = new SavedScenario();
                        scenario.BoidsNumber = 100;

                        switch (option)
                        {
                            case Option.Custom:
                                break;
                            case Option.Wander:
                                scenario.WorldStatus = WorldStatus.GlobalWander;
                                break;
                            case Option.FCAS:
                                scenario.WorldStatus = WorldStatus.GlobalFCAS;
                                break;
                            case Option.Separater:
                                scenario.WorldStatus = WorldStatus.GlobalSeparate;
                                break;
                            case Option.Cohesion:
                                scenario.WorldStatus = WorldStatus.GlobalCohesion;
                                break;
                            default:
                                throw new ArgumentOutOfRangeException("option");
                        }

                        ApplyScenario(scenario);
                    }
                    else
                    {
                        _world.WorldHeight = MainCanvas.ActualHeight;
                        _world.WorldWidth = MainCanvas.ActualWidth;
                    }
                };
        }
 public BoidActionLookFor(IWorldObject objectToLook,World world)
 {
     _objectToLookFor = objectToLook;
     _world = world;
 }
Example #5
0
 public BoidAi(int boidID, World world)
 {
     this.boidID = boidID;
     this.world = world;
 }
Example #6
0
        public void Go(Vector2 dest, World world)
        {
            if (Action != null)
            {
                SteerForce = Action.DoAction(dest, Position, Velocity, MaxSpeed);
                SteerForce = Vector2.Truncate(SteerForce, this.maxForce);
                Acceleration = SteerForce / this.mass;
                Velocity = Vector2.Truncate(Velocity + Acceleration, this.maxSpeed);

                Position = CheckBoundaries(Vector2.Add(Velocity, Position), (int)world.WorldWidth, (int)world.WorldHeight);
            }
        }