예제 #1
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));
        }
예제 #2
0
        public virtual void MoveTo(int dest_X, int dest_Y, int dest_Z, int Adjustment_X, int Adjustment_Y)
        {
            if (!CanMove || !CanMoveTo(dest_X, dest_Y, dest_Z, Map))
            {
                return;
            }
            MoveJSON tmp_Move = new MoveJSON();

            tmp_Move.Speed  = 1000;
            tmp_Move.Body   = Body_Move;
            tmp_Move.Street = OnStreet(dest_X, dest_Y, dest_Z);
            if (tmp_Move.Street != null)
            {
                Adjustment.X          = Adjustment_X;
                Adjustment.Y          = Adjustment_Y;
                tmp_Move.Adjustment.X = Adjustment_X;
                tmp_Move.Adjustment.Y = Adjustment_Y;
                Move = tmp_Move;
                MoveStart();
            }
        }
예제 #3
0
        public EntityJSON(Entity entity)
        {
            ID         = entity.ID;
            X          = entity.X;
            Y          = entity.Y;
            Z          = entity.Z;
            Adjustment = entity.Adjustment;

            Name      = entity.Name;
            Width     = entity.Width;
            Height    = entity.Height;
            Direction = entity.Direction;
            Flag      = entity.Flag.Value;

            CanMove   = entity.CanMove;
            CanTarget = entity.CanTarget;
            Cross     = entity.Cross;
            Move      = entity.Move;

            MoveDraw = entity.MoveDraw;

            Body = entity.Body;
        }
예제 #4
0
 public virtual void MoveEnd()
 {
     Move = null;
 }
예제 #5
0
        public void Movement()
        {
            //var entitysdraw = EntitysDraw;
            //for(var e = 0; e < entitysdraw.length; e++)
            //{
            //    var entitydraw = entitysdraw[e];

            //    if(!entitydraw.CanMove || entitydraw.Move == null || entitydraw.MoveDraw.Index == -1)
            //    {
            //        var C3D = FindCaseLocation(entitydraw.X, entitydraw.Y, entitydraw.Z);
            //        if( C3D != null)
            //        {
            //            C3D.EntitysDraw[C3D.EntitysDraw.length] = entitydraw;
            //        }
            //        continue;
            //    }

//#######################################################################################################

            if (MoveDraw.Index == -1)
            {
                return;
            }
            MoveJSON move = Move;

            if (MoveDraw.Index == 0)
            {
                MoveDraw.Index++;
                OnDistance(move.Street[MoveDraw.Index], move.Adjustment);
            }

            Point3D move_src  = MoveDraw.Location;
            Point3D move_dest = move.Street[MoveDraw.Index];

            //var C3D_src = FindCaseLocation(move_src.X, move_src.Y, move_src.Z);
            //var C3D_dest = FindCaseLocation(move_dest.X, move_dest.Y, move_dest.Z);

            MoveDraw.DrawStep += Map.Step;//DrawStep;

            double ratio_Speed = 0;

            if (MoveDraw.Time > 0)
            {
                ratio_Speed = MoveDraw.DrawStep / MoveDraw.Time;
            }

            int dist_X = (int)Math.Floor((double)(MoveDraw.Distance.X * ratio_Speed));
            int dist_Y = (int)Math.Floor((double)(MoveDraw.Distance.Y * ratio_Speed));

            CaseJSON c1 = CaseFrom(dist_X + MoveDraw.Adjustment.X, dist_Y + MoveDraw.Adjustment.Y);//, 100);// PageInfo.MapInfo.SizeCube);

            //if(C3D_src != null && C3D_dest != null)
            //{
            //    if((c1.X != 0 || c1.Y != 0) && C3D_src.X + c1.X == C3D_dest.X && C3D_src.Y + c1.Y == C3D_dest.Y)
            //    {
            //        entitydraw.X = move_dest.X;
            //        entitydraw.Y = move_dest.Y;
            //        entitydraw.Z = move_dest.Z;
            //        entitydraw.Adjustment.X = c1.Adjustment.X;
            //        entitydraw.Adjustment.Y = c1.Adjustment.Y;
            //        C3D_dest.EntitysDraw[C3D_dest.EntitysDraw.length] = entitysdraw[e];
            //    }
            //    else
            //    {
            //        entitydraw.Adjustment.X = dist_X+entitydraw.MoveDraw.Adjustment.X;
            //        entitydraw.Adjustment.Y = dist_Y+entitydraw.MoveDraw.Adjustment.Y;
            //        C3D_src.EntitysDraw[C3D_src.EntitysDraw.length] = entitysdraw[e];
            //    }
            //}
            //else
            //{
            int C3D_src_X  = move_src.X - move_src.Z;
            int C3D_src_Y  = move_src.Y - move_src.Z;
            int C3D_dest_X = move_dest.X - move_dest.Z;
            int C3D_dest_Y = move_dest.Y - move_dest.Z;

            if ((c1.X != 0 || c1.Y != 0) && C3D_src_X + c1.X == C3D_dest_X && C3D_src_Y + c1.Y == C3D_dest_Y)
            {
                X            = move_dest.X;
                Y            = move_dest.Y;
                Z            = move_dest.Z;
                Adjustment.X = c1.Adjustment.X;
                Adjustment.Y = c1.Adjustment.Y;
            }
            else
            {
                Adjustment.X = dist_X + MoveDraw.Adjustment.X;
                Adjustment.Y = dist_Y + MoveDraw.Adjustment.Y;
            }
            //}

            if (MoveDraw.DrawStep > MoveDraw.Time)
            {
                MoveDraw.Index++;
                if (MoveDraw.Index < move.Street.Length)
                {
                    OnDistance(move.Street[MoveDraw.Index], move.Adjustment);
                }
                else
                {
                    MoveDraw.Index = -1;
                }
            }

            ////##### ligne de points rouge!
            //var C3D_e = FindCaseLocation(entitydraw.X, entitydraw.Y, entitydraw.Z);
            //if(C3D_e != null)
            //{
            //    var eX = C3D_e.Screen.X;
            //    eX += ((entitydraw.Adjustment.X/100)*PageInfo.MapInfo.SizeCube)
            //    var eY = C3D_e.Screen.Y;
            //    eY += PageInfo.MapInfo.SizeCube/2;
            //    eY += ((entitydraw.Adjustment.Y/100)*PageInfo.MapInfo.SizeCube)
            //    MovementInfo.Pixel[MovementInfo.Pixel.length] = {X:eX , Y:eY };
            //}
            //}
        }