Esempio n. 1
0
    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);
    }
Esempio n. 2
0
 // 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];
 }
Esempio n. 3
0
    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();
    }
Esempio n. 4
0
        /// <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);
        }
Esempio n. 5
0
	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);
        }
    }
Esempio n. 7
0
    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);
        }
    }
Esempio n. 8
0
    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();
    }
Esempio n. 10
0
    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;
	}
Esempio n. 13
0
 void OnEnable()
 {
     rg = target as GFRectGrid;
     showDrawSettings = EditorPrefs.HasKey("GFRectGridShowDraw") ? EditorPrefs.GetBool("GFRectGridShowDraw") : true;
 }
Esempio n. 14
0
 void OnEnable()
 {
     rg = target as GFRectGrid;
     showDrawSettings = EditorPrefs.HasKey("GFRectGridShowDraw") ? EditorPrefs.GetBool("GFRectGridShowDraw") : true;
 }
Esempio n. 15
0
 // 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];
 }