Example #1
0
 static bool Comparison(GridBounds bounds1, GridBounds bounds2)
 {
     return
         (bounds1.minX == bounds2.minX &&
          bounds1.maxX == bounds2.maxX &&
          bounds1.minZ == bounds2.minZ &&
          bounds1.maxZ == bounds2.maxZ);
 }
Example #2
0
 void Start()
 {
     meshRenderer = GetComponent <MeshRenderer>();
     gridBounds   = new GridBounds(initialSize);
     SetUpPlane();
     lastUpdateTime = Time.time;
     modelRoot      = GameObject.Find("Model");
 }
Example #3
0
        void Start()
        {
            gridBounds     = new GridBounds(initialSize);
            lastUpdateTime = Time.time;
            modelRoot      = GameObject.Find("Model");
            cam            = UnityEngine.Camera.main;

            float zoom             = Mathf.Abs(cam.transform.position.y - transform.position.y);
            float camFarPlaneScale = 0.2f * 1000.0f / cam.farClipPlane;

            material.SetFloat("_CamFarPlane", cam.farClipPlane * camFarPlaneScale);
            material.SetVector("_CamLook", cam.transform.forward);
            material.SetFloat("_FadeScale", zoom / 10.0f);
            material.SetPass(0);
        }
Example #4
0
        IEnumerator UpdateBoundsCoroutine()
        {
            float time = Time.time - lastUpdateTime;

            if (time < updateTime)
            {
                yield return(new WaitForSeconds(time));
            }

            //get model root
            if (modelRoot != null)
            {
                GridBounds oldBounds = (GridBounds)gridBounds.Clone();

                //get all brick
                var bricks = modelRoot.GetComponentsInChildren <Brick>();
                if (bricks.Length > 0)
                {
                    //calculate all bricks bounds
                    var bounds = bricks[0].GetBounds();
                    for (int i = 1; i < bricks.Length; i++)
                    {
                        if (!(bricks[i] is AgaQTemporaryGroup) && bricks[i].gameObject.activeSelf)
                        {
                            bounds.Encapsulate(bricks[i].GetBounds());
                        }
                    }

                    bounds.Expand(5f);
                    gridBounds.SetSize(bounds);

                    if (oldBounds != gridBounds)
                    {
                        SetUpPlane();
                    }

                    lastUpdateTime = Time.time;
                }
            }
        }
Example #5
0
        /// <summary>
        /// Clone grid structure
        /// </summary>
        /// <returns>The clone.</returns>
        public object Clone()
        {
            GridBounds newBounds = (GridBounds)this.MemberwiseClone();

            return(newBounds);
        }