Ejemplo n.º 1
0
        public PointJSON CaseToCase(CaseJSON case_src, CaseJSON case_dest)
        {
            int       cX = case_dest.X - case_src.X;
            int       cY = case_dest.Y - case_src.Y;
            PointJSON p  = new PointJSON();

            p.X = ((cX - cY) * 100) + case_dest.Adjustment.X - case_src.Adjustment.X;
            p.Y = ((cX + cY) * 50) + case_dest.Adjustment.Y - case_src.Adjustment.Y;
            return(p);
            //return {X:((cX-cY)*100)+case_dest.Adjustment.X-case_src.Adjustment.X,Y:((cX+cY)*50)+case_dest.Adjustment.Y-case_src.Adjustment.Y};
        }
Ejemplo n.º 2
0
        //public CaseJSON CaseFromAdjustment(int adj_X, int adj_Y, int sizecube) { return CaseFrom2((adj_X / 100) * sizecube, ((adj_Y + 50) / 100) * sizecube, sizecube); }
        //public CaseJSON CaseFrom2(int x, int y, int sizecube)//à partir d'un point X:0 Y:0
        //{
        //    CaseJSON c = new CaseJSON();// {X:0,Y:0,Adjustment:{X:0,Y:0}};
        //    y -= (sizecube / 2);
        //    int adj_X = (x / sizecube) * 100;
        //    int adj_Y = (y / sizecube) * 100;
        //    int pY = ((2 * y - x) / 2);
        //    int pX = (x + pY);
        //    c.Y = (int)Math.Round((decimal)(pY / sizecube));
        //    c.X = (int)Math.Round((decimal)(pX / sizecube));
        //    c.Adjustment.X = (int)Math.Round((decimal)(adj_X - ((c.X - c.Y) * 100)));
        //    c.Adjustment.Y = (int)Math.Round((decimal)(adj_Y - ((c.X + c.Y) * 50)));
        //    return c;
        //}
        //public CaseJSON CaseFrom(int x, int y)//, int sizecube)//à partir d'un point X:0 Y:0
        //{
        //    CaseJSON c = new CaseJSON();
        //    int pY = ((2 * y - x) / 2);
        //    int pX = (x + pY);
        //    c.Y = (int)Math.Round((decimal)(pY / 100));
        //    c.X = (int)Math.Round((decimal)(pX / 100));
        //    c.Adjustment.X = (int)Math.Round((decimal)(x - ((c.X - c.Y) * 100)));
        //    c.Adjustment.Y = (int)Math.Round((decimal)(y - ((c.X + c.Y) * 50)));
        //    return c;
        //}
        public CaseJSON CaseFrom(int x, int y)
        {
            CaseJSON c  = new CaseJSON();
            double   pY = ((2 * y - x) / 2);
            double   pX = (x + pY);

            c.Y            = (int)Math.Round((pY / 100));
            c.X            = (int)Math.Round((pX / 100));
            c.Adjustment.X = (int)Math.Round((double)(x - ((c.X - c.Y) * 100)));
            c.Adjustment.Y = (int)Math.Round((double)(y - ((c.X + c.Y) * 50)));
            return(c);
        }
Ejemplo n.º 3
0
        public void OnDistance(Point3D location_dest, PointJSON adjustment)
        {
            MoveDraw.Location.X   = X;
            MoveDraw.Location.Y   = Y;
            MoveDraw.Location.Z   = Z;
            MoveDraw.Adjustment.X = Adjustment.X;
            MoveDraw.Adjustment.Y = Adjustment.Y;

            var Case_src  = new CaseJSON(); // {X:0,Y:0, Adjustment:{X:0,Y:0}};
            var Case_dest = new CaseJSON(); // {X:0,Y:0, Adjustment:{X:0,Y:0}};

            Case_src.X            = MoveDraw.Location.X - MoveDraw.Location.Z;
            Case_src.Y            = MoveDraw.Location.Y - MoveDraw.Location.Z;
            Case_src.Adjustment.X = MoveDraw.Adjustment.X;
            Case_src.Adjustment.Y = MoveDraw.Adjustment.Y;

            Case_dest.X            = location_dest.X - location_dest.Z;
            Case_dest.Y            = location_dest.Y - location_dest.Z;
            Case_dest.Adjustment.X = adjustment.X;
            Case_dest.Adjustment.Y = adjustment.Y;

            MoveDraw.Distance = CaseToCase(Case_src, Case_dest);
            MoveDraw.DrawStep = 0;

            double ratio_X = Math.Abs((double)(this.MoveDraw.Distance.X / 100));
            double ratio_Y = Math.Abs((double)(this.MoveDraw.Distance.Y / 100));

            int ratio_Speed_X = Convert.ToInt32(Move.Speed * ratio_X);
            int ratio_Speed_Y = Convert.ToInt32(Move.Speed * ratio_Y);

            if (ratio_Speed_X > ratio_Speed_Y)
            {
                MoveDraw.Time = ratio_Speed_X;
            }
            else
            {
                MoveDraw.Time = ratio_Speed_Y;
            }

            Direction = ScreenDirection(MoveDraw.Distance.X, MoveDraw.Distance.Y);
        }
Ejemplo n.º 4
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 };
            //}
            //}
        }