示例#1
0
 private PalletRack CreatePalletRack(double x, double y, double z)
 {
     PalletRack rack = new PalletRack(x, y, z, 0, 0, 0);
     worldObjects.Add(rack);
     return rack;
 }
示例#2
0
        public override bool Update(int tick)
        {
            if (tasks != null)
            {
                if (tasks.First().TaskComplete(this))
                {
                    tasks.RemoveAt(0);
                    if (currentPath != null && isEnd(this))
                    {
                        this.rack.Move(this.x + 1000, this.y, this.z);
                        this.rack = null;

                        this.Move(this.x, this.y, this.z + 90);
                        currentPath = Pathfinding.Listnodes(currentNode, "Y" + this._name, Pathfinding.listOfNodes, this.path);
                        this.AddTask(new TruckMove(currentPath));
                    }

                    if (tasks.Count == 0)
                    {
                        tasks = null;
                    }
                    else
                    {
                        tasks.First().StartTask(this);
                    }
                }
            }
            if (this.rack != null)
            {
                this.rack.Move(this.x, this.y + 1, this.z + 1.5);
                if (tasks == null)
                {
                    currentPath.Clear();
                    this.currentPath = Pathfinding.Listnodes(currentNode, "Z" + this._name, Pathfinding.listOfNodes, this.path);
                    tasks            = new List <ITruckTask>();
                    this.AddTask(new TruckMove(this.currentPath));
                }
            }
            if (this.currentPath != null && this.currentPath.Count != 0)
            {
                this._x = Math.Round(this._x, 1);
                this._z = Math.Round(this._z, 1);

                if (this._x < currentPath[0].GetX())
                {
                    this.Move(this.x + 0.1, this.y, this.z);
                }
                else if (this._x > currentPath[0].GetX())
                {
                    this.Move(this.x - 0.1, this.y, this.z);
                }
                else if (this._z < currentPath[0].GetZ())
                {
                    this.Move(this.x, this.y, this.z + 0.1);
                }
                else if (this._z > currentPath[0].GetZ())
                {
                    this.Move(this.x, this.y, this.z - 0.1);
                }
                else
                {
                    this.currentNode = currentPath[0].GetName();
                    currentPath.RemoveAt(0);
                }
            }
            return(base.Update(tick));
        }
示例#3
0
        /// <summary>
        /// Het updaten van de robot (nieuwe tasks, overgeven van een pallet aan de verbonden truck als die wacht bij het laaddok, positie etc.)
        /// </summary>
        /// <param name="tick">hoe vaak</param>
        /// <returns></returns>
        public override bool Update(int tick)
        {
            if (tasks != null)
            {
                if (tasks.First().TaskComplete(this))
                {
                    tasks.RemoveAt(0);
                    if (currentPath != null && this.isHome() && this._truck.isHome(this._truck))
                    {
                        this.GiveRack();
                        if (i < 4)
                        {
                            this.currentPath.Clear();
                            this.currentPath = Pathfinding.Listnodes("A", NextRack(this, i), Pathfinding.listOfNodes, this.path);
                            this.AddTask(new RobotMove(this.currentPath));
                            i++;
                        }
                    }

                    if (tasks.Count == 0)
                    {
                        tasks = null;
                    }
                    else
                    {
                        tasks.First().StartTask(this);
                    }
                }
            }

            if (tasks == null && currentPath != null && this.isHome() && this._truck.isHome(this._truck) && this.rack != null)
            {
                tasks = new List <IRobotTask>();
                this.GiveRack();
                if (i < 4)
                {
                    this.currentPath.Clear();
                    this.currentPath = Pathfinding.Listnodes("A", NextRack(this, i), Pathfinding.listOfNodes, this.path);
                    this.AddTask(new RobotMove(this.currentPath));
                    i++;
                }
                else
                {
                    tasks = null;
                }
            }

            if (this.currentPath != null && this.currentPath.Count != 0)
            {
                this._x = Math.Round(this._x, 1);
                this._z = Math.Round(this._z, 1);
                //bewegen
                if (currentPath[0].HasRack() && rack == null && currentPath.Count == 1)
                {
                    if (this._x == currentPath[0].GetX() && this._z == currentPath[0].GetZ())
                    {
                        this.rack = currentPath[0].GetRack();
                        this.rack.Move(this.x, this.y + 1.4, this.z);

                        this.currentNode = currentPath[0].GetName();
                        currentPath[0].SetRack(null);
                        currentPath.Clear();

                        this.currentPath = Pathfinding.Listnodes(currentNode, "J", Pathfinding.listOfNodes, this.path);
                        if (tasks == null)
                        {
                            tasks = new List <IRobotTask>();
                            this.AddTask(new RobotMove(this.currentPath));
                        }
                    }
                }
                if (rack != null)
                {
                    this.rack.Move(this.x, this.y + 1.4, this.z);
                }

                if (this._x < currentPath[0].GetX())
                {
                    this.Move(this.x + 0.1, this.y, this.z);
                }
                else if (this._x > currentPath[0].GetX())
                {
                    this.Move(this.x - 0.1, this.y, this.z);
                }
                else if (this._z < currentPath[0].GetZ())
                {
                    this.Move(this.x, this.y, this.z + 0.1);
                }
                else if (this._z > currentPath[0].GetZ())
                {
                    this.Move(this.x, this.y, this.z - 0.1);
                }
                else
                {
                    currentPath.RemoveAt(0);
                }
            }
            return(base.Update(tick));
        }
示例#4
0
 public void GetRack(PalletRack p)
 {
     this.rack = p;
 }
示例#5
0
 private void GiveRack()
 {
     this._truck.GetRack(this.rack);
     this.rack = null;
 }