Exemplo n.º 1
0
        public MovingAgent(Texture2D texture, Vector2 position, int size, float mass,
                           float sightRadius, float lateralRadius)
            : base(texture, position, size)
        {
            // this.mass = mass;
            //this.sightRadius = sightRadius;
            this.lateralRadius = lateralRadius;

            Energy    = Utilities.AgentEnergy;
            maxEnergy = Energy;

            timeAlive = 0;

            velocity = new Vector2();


            Random rand     = new Random();
            double rotation = rand.NextDouble() * (Math.PI * 2);

            heading = new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation));

            maxForce = Utilities.MaxForce;

            behaviourManager = new BehaviourManager(this);


            localPreyInSight   = new List <MovingAgent>();
            localPreyInLateral = new List <MovingAgent>();

            isAddedToPool = false;
        }
Exemplo n.º 2
0
        public virtual void Reset()
        {
            Energy = Utilities.AgentEnergy;

            timeAlive = 0;

            velocity = new Vector2();

            IsAlive = true;

            localPreyInSight   = new List <MovingAgent>();
            localPreyInLateral = new List <MovingAgent>();


            Random rand     = new Random();
            double rotation = rand.NextDouble() * (Math.PI * 2);

            heading = new Vector2((float)Math.Sin(rotation), (float)-Math.Cos(rotation));


            int tempX = (int)Utilities.RandomMinMax(0 + Utilities.AgentTextureSize, Utilities.ScreenWidth - Utilities.AgentTextureSize);
            int tempY = (int)Utilities.RandomMinMax(0 + Utilities.AgentTextureSize, Utilities.ScreenHeight - Utilities.AgentTextureSize);

            Position = new Vector2(tempX, tempY);

            behaviourManager = new BehaviourManager(this);

            isAddedToPool = false;
        }