private static bool RectIsAdjacent(GFRectGrid theGrid, Vector3 position, Vector3 reference) { bool isAdjacent = Mathf.Abs(position.x - reference.x) <= 1.25f && Mathf.Abs(position.y - reference.y) <= 1.25f; bool isDiagonal = 0.25f <= Mathf.Abs(position.x - reference.x) && 0.25f <= Mathf.Abs(position.y - reference.y) && isAdjacent; return(isAdjacent && !isDiagonal); }
// Use this for initialization void Start() { grid = GetComponent <GFRectGrid>(); xMax = Mathf.CeilToInt(Mathf.Abs(grid.renderTo.x) + Mathf.Abs(grid.renderFrom.x)); yMax = Mathf.CeilToInt(Mathf.Abs(grid.renderTo.y) + Mathf.Abs(grid.renderFrom.y)); matrix = new GameObject[xMax, yMax]; }
protected override void Init() { base.Init(); GridInstance.renderGrid = false; GridInstance.hideGrid = true; GridCollider = GridInstance.gameObject.AddComponent <BoxCollider>(); GridCollider.size = 2 * GridInstance.size; GameObject go = new GameObject("ValidDeployGridField"); ValidDeployGrid = go.AddComponent <GFRectGrid>(); ValidDeployGrid.renderLineWidth = GridWidth; ValidDeployGrid.size = ValidDeployGridSize; ValidDeployGrid.spacing = GridSpace; ValidDeployGrid.axisColors = GridColors; go.transform.SetParent(transform); go.transform.localScale = Vector3.one; go.transform.localPosition = AreaPosition; CreateDeployObstacle(); }
/// <summary>Construct a new grid made of two rectangular grids.</summary> public Grid(GFRectGrid primary, GFRectGrid secondary, float height) { this.primary = primary; this.secondary = secondary; this.spacing = 10.0f; this.mode = Mode.Flex; this.Update(height); }
void Start(){ cachedTransform = transform; grid = ForbiddenTilesExample.movementGrid; //make a check to prevent getting stuck in a null exception if(grid){ //snap to the grid no matter where we are grid.AlignTransform(cachedTransform); } }
void Start() { grid = ForbiddenTilesExample.movementGrid; //make a check to prevent getting stuck in a null exception if (grid) { //snap to the grid no matter where we are grid.AlignTransform(transform); } }
void Start() { grid = ForbiddenTilesVores.movementGrid; ani = gameObject.GetComponent <Animator> (); //make a check to prevent getting stuck in a null exception if (grid) { //snap to the grid no matter where we are grid.AlignTransform(transform); } }
protected virtual void Init() { transform.SetParent(Root); transform.localScale = Vector3.one; transform.eulerAngles = Vector3.zero; transform.localPosition = Vector3.zero; GameObject go = new GameObject("Grid"); GridInstance = go.AddComponent <GFRectGrid>(); GridInstance.renderLineWidth = GridWidth; //设置格子线条的宽度 GridInstance.size = GridSize; //设置格子的大小 GridInstance.spacing = GridSpace; //设置格子单位的大小 GridInstance.axisColors = GridColors; //设置格子线条的颜色 go.transform.SetParent(transform); go.transform.localScale = Vector3.one; go.transform.localPosition = AreaPosition; }
void Awake() { if (!_heightMap) { return; } // make sure the needed components exist and store them; // CheckComponent<T>() is defined in this script near the bottom mf = CheckComponent <MeshFilter>(); mc = CheckComponent <MeshCollider>(); mr = CheckComponent <MeshRenderer>(); grid = GetComponent <GFRectGrid> (); // create the mesh BuildMesh(); // then assign it to the components that need it AssignMesh(); // show the height map in the GUI UpdateHeightString(); }
public static int[] originSquare; //the grid coordinates of the lower left square used for reference (X and Y only) //builds the matrix and sets everything up, gets called by a script attached to the grid object public static void Initialize(GFRectGrid theGrid) { movementGrid = theGrid; BuildMatrix(); //builds a default matrix that has all entries set to tru SetOriginSquare(); //stores the X and Y grid coordinates of the lower left square }
//builds the matrix and sets everything up, gets called by a script attached to the grid object public static void Initialize(GFRectGrid theGrid) { movementGrid = theGrid; BuildMatrix(); //builds a default matrix that has all entries set to tru SetOriginSquare(); //stores the X and Y grid coordinates of the lower left square }
private static bool RectIsAdjacent(GFRectGrid theGrid, Vector3 position, Vector3 reference){ bool isAdjacent = Mathf.Abs(position.x-reference.x) <= 1.25f && Mathf.Abs(position.y-reference.y) <= 1.25f; bool isDiagonal = 0.25f <= Mathf.Abs(position.x-reference.x) && 0.25f <= Mathf.Abs(position.y-reference.y) && isAdjacent; return isAdjacent && !isDiagonal; }
void OnEnable() { rg = target as GFRectGrid; showDrawSettings = EditorPrefs.HasKey("GFRectGridShowDraw") ? EditorPrefs.GetBool("GFRectGridShowDraw") : true; }
// Use this for initialization void Start() { grid = GetComponent<GFRectGrid>(); xMax = Mathf.CeilToInt(Mathf.Abs (grid.renderTo.x) + Mathf.Abs (grid.renderFrom.x)); yMax = Mathf.CeilToInt(Mathf.Abs (grid.renderTo.y) + Mathf.Abs (grid.renderFrom.y)); matrix = new GameObject[xMax, yMax]; }