示例#1
0
        /// <summary>
        ///  Gets the unity position of a building with a 2x2 size whose lower left position is given by
        ///  <paramref name="lowerLeft"/>
        /// </summary>
        public static Vector3 GetCenterOf2x2(GridCoordinate lowerLeft)
        {
            var location = lowerLeft.ToVector3();

            location.x += 0.5f;
            location.y += 0.5f;
            return(location);
        }
示例#2
0
        /// <summary>
        ///   Creates an instance of this placeable in the world grid, so that the various systems (physics,
        ///   graphics, etc) can interact with it.
        /// </summary>
        public GameObject CreateInstanceInWorld(IOwner owner, GridCoordinate coordinate)
        {
            var absolutePosition = coordinate.ToVector3();
            var instance         = Template.CreateInstance(new PositionAndRotation(absolutePosition, Quaternion.identity));
            var behavior         = instance.GetComponent <StructureBehavior>();

            behavior?.Initialize(this, owner, coordinate);
            return(instance);
        }
        /// <summary>
        ///  Marks the designated coordinate as walkable or unwalkable depending on the value of
        ///  <paramref name="isWalkable"/>.
        /// </summary>
        /// <param name="coordinate"> The grid position which should be marked as walkable/unwalkable. </param>
        /// <param name="isWalkable"> True if the position should be walkable, false otherwise. </param>
        public static void MarkWalkable(GridCoordinate coordinate, bool isWalkable)
        {
            var bounds            = new Bounds(coordinate.ToVector3(), new Vector3(0.5f, 0.5f, 0));
            var graphUpdateObject = new GraphUpdateObject(bounds)
            {
                modifyWalkability = true,
                setWalkability    = isWalkable,
            };

            AstarPath.active.UpdateGraphs(graphUpdateObject);
        }
示例#4
0
 /// <summary>
 ///  Gets the unity position of a building with a 1x1 size whose lower left position is given by
 ///  <paramref name="lowerLeft"/>
 /// </summary>
 public static Vector3 GetCenterOf1x1(GridCoordinate lowerLeft)
 {
     return(lowerLeft.ToVector3());
 }