示例#1
0
        public PixelPose TranslatePose(float distance, Direction transDirection = Direction.All)
        {
            if (transDirection == Direction.All)
            {
                transDirection = this.direction;
            }

            PixelPose p = new PixelPose(this);

            if (transDirection == Direction.NE)
            {
                p.position += new Vector2(distance / Mathf.Sqrt(3), distance / Mathf.Sqrt(3) / 2);
            }
            if (transDirection == Direction.NW)
            {
                p.position += new Vector2(-distance / Mathf.Sqrt(3), distance / Mathf.Sqrt(3) / 2);
            }
            if (transDirection == Direction.SE)
            {
                p.position += new Vector2(distance / Mathf.Sqrt(3), -distance / Mathf.Sqrt(3) / 2);
            }
            if (transDirection == Direction.SW)
            {
                p.position += new Vector2(-distance / Mathf.Sqrt(3), -distance / Mathf.Sqrt(3) / 2);
            }
            return(p);
        }
示例#2
0
        public KeyValuePair <PixelPose, float> FindBestWayPoint()
        {
            WayPoint NE = FindWayPointInDirection(Direction.NE);
            WayPoint NW = FindWayPointInDirection(Direction.NW);
            WayPoint SE = FindWayPointInDirection(Direction.SE);
            WayPoint SW = FindWayPointInDirection(Direction.SW);

            Debug.DrawLine(topRightWorld, NE.position, Color.white, 3.0f);
            Debug.DrawLine(topLeftWorld, NW.position, Color.black, 3.0f);
            Debug.DrawLine(bottomRightWorld, SE.position, Color.blue, 3.0f);
            Debug.DrawLine(bottomLeftWorld, SW.position, Color.cyan, 3.0f);

            float deltaNE = Vector2.Distance(NE.position, topRightWorld);
            float deltaNW = Vector2.Distance(NW.position, topLeftWorld);
            float deltaSE = Vector2.Distance(SE.position, bottomRightWorld);
            float deltaSW = Vector2.Distance(SW.position, bottomLeftWorld);

            Dictionary <PixelPose, float> dirDic = new Dictionary <PixelPose, float>();
            PixelPose NEpose = new PixelPose(GetPixelRoom(), Direction.SW, NE.position);
            PixelPose NWpose = new PixelPose(GetPixelRoom(), Direction.SE, NW.position);
            PixelPose SEpose = new PixelPose(GetPixelRoom(), Direction.NW, SE.position);
            PixelPose SWpose = new PixelPose(GetPixelRoom(), Direction.NE, SW.position);

            dirDic.Add(NEpose, deltaNE);
            dirDic.Add(NWpose, deltaNW);
            dirDic.Add(SEpose, deltaSE);
            dirDic.Add(SWpose, deltaSW);

            return(dirDic.Aggregate((arg1, arg2) => arg1.Value < arg2.Value ? arg1 : arg2));
        }
示例#3
0
        public PixelPose FindBestWayPointPosition(Vector2 starting)
        {
            WayPoint NE = FindWayPointInDirection(Direction.NE);
            WayPoint NW = FindWayPointInDirection(Direction.NW);
            WayPoint SE = FindWayPointInDirection(Direction.SE);
            WayPoint SW = FindWayPointInDirection(Direction.SW);

            List <PixelPose> dirList = new List <PixelPose>();
            PixelPose        NEpose  = new PixelPose(GetPixelRoom(), Direction.SW, NE.position);
            PixelPose        NWpose  = new PixelPose(GetPixelRoom(), Direction.SE, NW.position);
            PixelPose        SEpose  = new PixelPose(GetPixelRoom(), Direction.NW, SE.position);
            PixelPose        SWpose  = new PixelPose(GetPixelRoom(), Direction.NE, SW.position);

            dirList.Add(NEpose);
            dirList.Add(NWpose);
            dirList.Add(SEpose);
            dirList.Add(SWpose);

            return(dirList.Aggregate((arg1, arg2) => Vector2.Distance(arg1.position, starting) < Vector2.Distance(arg2.position, starting) ? arg1 : arg2));
        }
示例#4
0
        public PixelPose Flip()
        {
            PixelPose p = new PixelPose(this);

            if (p.direction == Direction.NE)
            {
                p.direction = Direction.SW;
            }
            else if (p.direction == Direction.SW)
            {
                p.direction = Direction.NE;
            }
            else if (p.direction == Direction.NW)
            {
                p.direction = Direction.SE;
            }
            else if (p.direction == Direction.SE)
            {
                p.direction = Direction.NW;
            }
            return(p);
        }
示例#5
0
 public PixelPose(PixelPose pose)
 {
     this.pixelRoom = pose.pixelRoom;
     this.direction = pose.direction;
     this.position  = pose.position;
 }