Esempio n. 1
0
        void Awake()
        {
            layout = new HexLayout(hexRad, transform.position, offset);
            Vector3[] ngrd = NewGridCoords(gridWidth, gridHeight, offset);

            int layerMask = 1 << LayerMask.NameToLayer("NavMesh");

            coords = HitCoords(ngrd, layerMask);
            //		foreach (var item in coords) {
            //			GameObject go = GameObject.CreatePrimitive(PrimitiveType.Sphere);
            //			go.transform.localScale = Vector3.one*0.3f;
            //			go.transform.position = item;
            //			go.name = "Hex mark";
            //		}
            HexGrid.instance = new HexGrid(coords);
            if (HexMark.instance == null)
            {
                HexMark.instance = new HexMark();
            }
            HexMark.instance.GetRoot().gameObject.AddComponent <FieldOrientationAssistant>();
                        #if UNITY_EDITOR
            QualitySettings.vSyncCount  = 0;
            Application.targetFrameRate = 30;
                        #else
            Application.targetFrameRate = 50;
                        #endif
        }
Esempio n. 2
0
        public HexLayout(float hexRad, Vector3 origin, Vector2 offset)
        {
            this.origin = origin;
            this.offset = offset;
            instance    = this;

            wide_width   = ((hexRad * 2) / SQRT3) * 2;     // dist between opposing vertices. Large diameter
            narrow_width = wide_width * 3 / 4;             // dist between centers of adjacent hexes
            hex_height   = wide_width * 0.5f * SQRT3;      //dist between opposing edges. Small diameter
        }