コード例 #1
0
        public virtual void ValidateInEditor()
        {
            Vector3 offset;

            switch (OffsetType)
            {
            case OffsetTypeEnum.Size64:
                offset = new Vector3();
                break;

            case OffsetTypeEnum.Size128:
                offset = new Vector3(.5f, .5f, .5f);
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }

            var expected = GridCoordinate.FromVector3(transform.position - offset).ToVector3() + offset;

            if (transform.position != expected)
            {
                transform.position = expected;
            }
        }
コード例 #2
0
        /// <summary>
        ///  Converts a vector3 position to a grid coordinate for an object which is 2x2 in size.
        /// </summary>
        public static GridCoordinate GetGridCoordinateFor2x2(Vector3 position)
        {
            position.x -= 0.5f;
            position.y -= 0.5f;

            return(GridCoordinate.FromVector3(position));
        }
        public void Start()
        {
            var position  = GetComponent <Transform>().position;
            var lowerLeft = position - (new Vector3(Width, Height, 0) / 2.0f);

            // move into the center of the square
            lowerLeft += new Vector3(0.5f, 0.5f);

            GridUpdate.MarkWalkable(GridCoordinate.FromVector3(lowerLeft), new Size(Width, Height), false);
        }
コード例 #4
0
 /// <summary>
 ///  Converts a vector3 position to a grid coordinate for an object which is 1x1 in size.
 /// </summary>
 public static GridCoordinate GetGridCoordinateFor1x1(Vector3 position)
 {
     return(GridCoordinate.FromVector3(position));
 }