コード例 #1
0
        public void AskMoveUnitTo(Unit unit, int toX, int toY)
        {
            var distance = GetDistance(unit.X, unit.Y, toX, toY);
            var step     = Math.Min((int)Math.Round(distance), unit.Speed);
            var path     = PathFinding.FindNextPoint(_grid, unit.X, unit.Y, toX, toY, step);

            if (path == Vector2.negativeInfinity)
            {
                return;
            }

            MoveUnit(unit, (int)path.x, (int)path.y);
        }
コード例 #2
0
        //public virtual void MoveToLocation(Point3D dest) { MoveToLocation(dest.X, dest.Y, dest.Z); }
        //public virtual void MoveToLocation(int dest_X, int dest_Y, int dest_Z)
        //{
        //    ChangeDirection(dest_X, dest_Y, dest_Z);
        //    X = dest_X;
        //    Y = dest_Y;
        //    Z = dest_Z;
        //}
        public virtual Point3D[] OnStreet(int dest_X, int dest_Y, int dest_Z)
        {
            if (dest_X == X && dest_Y == Y && dest_Z == Z)
            {
                return new Point3D[] { new Point3D(X, Y, Z), new Point3D(X, Y, Z) }
            }
            ;

            if (Path == null)
            {
                Path = new PathFinding(30);              //Ajouter Range!!!
            }
            Path.OnStreet(this);
            return(Path.Find(dest_X, dest_Y, dest_Z));
        }
コード例 #3
0
        public virtual void MoveToRandom()
        {
            MoveJSON tmp_Move = new MoveJSON();

            tmp_Move.Speed = 2000;
            tmp_Move.Body  = Body_Move;
            if (Path == null)
            {
                Path = new PathFinding(15);              //Ajouter Range!!!
            }
            //if (Path == null) Path = new PathFinding(15);//Ajouter Range!!!
            Path.OnStreet(this);
            int random = Info.Random.Next(Path.Roads.Count); //.Length);

            tmp_Move.Street = Path.Roads[random].Street;     //OnStreet(dest_X, dest_Y, dest_Z);
            if (tmp_Move.Street != null)
            {
                Adjustment.X          = 0;
                Adjustment.Y          = 0;
                tmp_Move.Adjustment.X = 0;
                tmp_Move.Adjustment.Y = 0;
                //Adjustment.X = Adjustment_X;
                //Adjustment.Y = Adjustment_Y;
                Move = tmp_Move;
                MoveStart();
            }



            //Path.OnStreet(Entity);
            //int random = Info.Random.Next(Path.Roads.Length);
            //Entity.Move = new MoveJSON();
            //Entity.Move.Body = new BodyJSON(new ImageJSON[] { new ImageJSON("Mobile_Move", 1, 1) }, true, true, 750, -1);
            //Entity.Move.Street = Path.Roads[random].Street;
            ////Entity.Move.Step = 0;
            //Entity.MoveStart();


            //int x = Info.Random.Next(-5, 5);
            //int y = Info.Random.Next(-5, 5);
            //PathFinding.Path.MoveTo(Entity, Entity.X + x, Entity.Y + y, Entity.Z);// + Info.Random.Next(10));
        }