Ejemplo n.º 1
0
 public void AddCar(Car c)
 {
     c.Id     = Cars.Count;
     c.CLogic = this;
     c.PushOutput(" Respawned at " + Logic.PointToString(c.Position));
     Cars.Add(c);
 }
Ejemplo n.º 2
0
 public void SetObjectiveSpeed(float speed)
 {
     if (speed != ObjectiveSpeed)
     {
         PushOutput("Speed was set to " + speed.ToString("0.0000") + " at " + Logic.PointToString(Position));
     }
     //
     ObjectiveSpeed = speed;
 }
Ejemplo n.º 3
0
        public PointF DoTask(Task t)
        {
            PointF IPos = new PointF(0, 0);
            float  dist = Calc.Magnitude(Position, t.Objective);

            //
            if (t.Unread == true)
            {
                t.Unread = false;
                //
                PushOutput("Started going from " + Logic.PointToString(Position) + " to " + Logic.PointToString(t.Objective));
            }
            //
            if (dist <= ErrorMargin)
            {
                if (t.Type == TaskType.Immediate)
                {
                    if (ImmediateTasks.Count > 0)
                    {
                        ImmediateTasks.Pop();
                        PushOutput(" The car reached the objetive " + Logic.PointToString(t.Objective));
                    }
                    else
                    {
                        // Error
                    }
                }
                else if (t.Type == TaskType.Queue)
                {
                    TasksQueue.Dequeue();
                }
            }
            else
            {
                double ang = Calc.GetAngleOfLineBetweenTwoPoints(Position, t.Objective);
                //
                IPos.X += (float)(Math.Cos(ang) * Speed);
                IPos.Y += (float)(Math.Sin(ang) * Speed);
                //
                if (dist > SecureDistance)
                {
                    //SpeedUp();
                    SetObjectiveSpeed(MaximumSpeed);
                }
                else
                {
                    SetObjectiveSpeed(0.5f);
                }
            }
            //
            return(IPos);
        }