Пример #1
0
        //Execute l'action envoyée en paramètre
        private void executeAction(NXTAction action)
        {
            char    actiontd = action.Action;
            NXTCase caseCur  = currentCase();
            Point   newDir   = ERROR;

            if (actiontd != NXTMovement.PAUSE)
            {
                newDir = caseCur.goThrough(action, this.direction);
            }

            //Console.WriteLine(this.position);
            if (newDir != ERROR && action.Movement != NXTMovement.UTURN)
            {
                this.position = this.position + newDir;
            }

            if (actiontd != NXTMovement.PAUSE)
            {
                this.direction = newDir;
            }

            if (actiontd == NXTAction.TAKE)
            {
                this.takePatient(this.position);
            }
            else if (actiontd == NXTAction.DROP)
            {
                this.dropPatient();
            }
        }
Пример #2
0
        public List <Point> getAllCases()
        {
            List <Point> liste = new List <Point>();

            for (int x = 0; x < width; x++)
            {
                for (int y = 0; y < height; y++)
                {
                    NXTCase c = getCase(x, y);
                    if (c.TypeCase != Case.EMPTY)
                    {
                        liste.Add(new Point(x, y));
                    }
                }
            }

            return(liste);
        }
Пример #3
0
        public NXTCase Duplicate()
        {
            NXTCase c = new NXTCase(this.typeCase, this.orientation);

            return(c);
        }
Пример #4
0
        // Donne une liste de points qui correspondent aux cases accessibles depuis la case fournie en argument
        public List <Point> GetNeighbours(Point p)
        {
            NXTCase      c          = this.getCase(p);
            List <Point> neighbours = new List <Point>();

            if (c.TypeCase == Case.STRAIGHT)
            {
                if (c.CaseOrientation == Orientation.TOP || c.CaseOrientation == Orientation.BOTTOM)
                {
                    neighbours.Add(new Point(p.X, p.Y + 1));
                    neighbours.Add(new Point(p.X, p.Y - 1));
                }
                else
                {
                    neighbours.Add(new Point(p.X + 1, p.Y));
                    neighbours.Add(new Point(p.X - 1, p.Y));
                }
            }
            else if (c.TypeCase == Case.VIRAGE)
            {
                switch (c.CaseOrientation)
                {
                case Orientation.TOP:
                    neighbours.Add(new Point(p.X, p.Y + 1));
                    neighbours.Add(new Point(p.X + 1, p.Y));
                    break;

                case Orientation.RIGHT:
                    neighbours.Add(new Point(p.X, p.Y + 1));
                    neighbours.Add(new Point(p.X - 1, p.Y));
                    break;

                case Orientation.BOTTOM:
                    neighbours.Add(new Point(p.X, p.Y - 1));
                    neighbours.Add(new Point(p.X - 1, p.Y));
                    break;

                case Orientation.LEFT:
                    neighbours.Add(new Point(p.X, p.Y - 1));
                    neighbours.Add(new Point(p.X + 1, p.Y));
                    break;
                }
            }
            else if (c.TypeCase == Case.INTERSECTION)
            {
                switch (c.CaseOrientation)
                {
                case Orientation.TOP:
                    neighbours.Add(new Point(p.X, p.Y + 1));
                    neighbours.Add(new Point(p.X + 1, p.Y));
                    neighbours.Add(new Point(p.X - 1, p.Y));
                    break;

                case Orientation.RIGHT:
                    neighbours.Add(new Point(p.X, p.Y + 1));
                    neighbours.Add(new Point(p.X, p.Y - 1));
                    neighbours.Add(new Point(p.X - 1, p.Y));
                    break;

                case Orientation.BOTTOM:
                    neighbours.Add(new Point(p.X, p.Y - 1));
                    neighbours.Add(new Point(p.X - 1, p.Y));
                    neighbours.Add(new Point(p.X + 1, p.Y));
                    break;

                case Orientation.LEFT:
                    neighbours.Add(new Point(p.X, p.Y - 1));
                    neighbours.Add(new Point(p.X, p.Y + 1));
                    neighbours.Add(new Point(p.X + 1, p.Y));
                    break;
                }
            }

            return(neighbours);
        }
Пример #5
0
        // Surcharge avec int à la place de Point
        public NXTCase[] setCase(int x, int y, NXTCase newCase)
        {
            this.circuit[x + this.width * y] = newCase;

            return(this.circuit);
        }
Пример #6
0
        // Défini la case voulu
        public NXTCase[] setCase(Point coordCase, NXTCase newCase)
        {
            this.circuit[coordCase.X + this.width * coordCase.Y] = newCase;

            return(this.circuit);
        }