Exemplo n.º 1
0
        public void AddToIABuffer(List <Point> path)
        {
            NXTAction action;
            Point     oldPos    = vehicule.Position;
            Point     direction = vehicule.Direction;

            NXTCase currentCase = circuit.getCase(oldPos);

            if (path.Count > 0)
            {
                if (!((currentCase.goThrough(new NXTAction(NXTMovement.STRAIGHT), direction) + oldPos).Equals(path[0]) ||
                      (currentCase.goThrough(new NXTAction(NXTMovement.INTER_LEFT), direction) + oldPos).Equals(path[0]) ||
                      (currentCase.goThrough(new NXTAction(NXTMovement.INTER_RIGHT), direction) + oldPos).Equals(path[0])))
                {
                    this.buffer.Add(new NXTAction(NXTMovement.UTURN), false);
                    direction = Rotate90Clockwise(Rotate90Clockwise(direction));
                }
            }

            foreach (Point p in path)
            {
                action = MovementToAction(circuit.getCase(oldPos), oldPos, direction, p, out direction);

                if (circuit.hasPatient(p) && vehicule.Patients < vehicule.MAX_PATIENTS)
                {
                    action.Action = NXTAction.TAKE;
                }
                else if (circuit.hasHopital(p) && vehicule.Patients > 0)
                {
                    action.Action = NXTAction.DROP;
                }

                this.buffer.Add(action, false);
                oldPos = p;
            }
        }
Exemplo n.º 2
0
        // --------------------------------------------------------------------------
        // METHODS
        // --------------------------------------------------------------------------
        public void Render(SpriteBatch sb)
        {
            for (int x = 0; x < circuit.Width; x++)
            {
                for (int y = 0; y < circuit.Height; y++)
                {
                    NXTCase   c = circuit.getCase(x, y);
                    Texture2D t;
                    Color     col = c.CaseColor;

                    // On trouve la texture (et couleur) adaptée
                    switch (c.TypeCase)
                    {
                    case (Case.EMPTY):
                        t   = tStraight;
                        col = Color.Black;
                        break;

                    case (Case.STRAIGHT):
                        t = tStraight;
                        break;

                    case (Case.VIRAGE):
                        t = tTurn;
                        break;

                    case (Case.INTERSECTION):
                        t = tIntersec;
                        break;

                    default:
                        t   = tStraight;
                        col = Color.Black;
                        break;
                    }

                    //sb.Draw(t, new Vector2(x * 32, y * 32), col);
                    sb.Draw(t, new Vector2(x * 32 + 16, y * 32 + 16), new Rectangle(0, 0, t.Width, t.Height), col, (((float)c.CaseOrientation) / 2) * (float)Math.PI, new Vector2(t.Width / 2, t.Height / 2), 1.0f, SpriteEffects.None, 1f); // Deprecated but OK
                }
            }
        }