示例#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);
        }