示例#1
0
        public static GlassType CreateGlassTypeObject(string name, GameObject _parent)
        {
            GlassType glassType = null;

            foreach (GlassType gt in _parent.GetComponents <GlassType>())
            {
                if (gt.presetName == name)
                {
                    glassType = gt;
                }
            }
            if (glassType == null)
            {
                glassType = _parent.AddComponent <GlassType>();
            }

            /*
             * foreach (GlassType gt in GameObject.FindObjectsOfType<GlassType>())
             * {
             *  if (gt.presetName == name)
             *  {
             *      glassType = gt;
             *  }
             * }
             * if (glassType == null)
             * {
             *  GameObject go = new GameObject(name);
             *  go.transform.parent = _parent.transform;
             *  glassType = go.AddComponent<GlassType>();
             * }
             */
            return(glassType);
        }
示例#2
0
 public void RemoveNullypes()
 {
     while (glassTypes.Contains(null))
     {
         glassTypes.Remove(null);
     }
     for (int i = glassTypes.Count - 1; i >= 0; i--)
     {
         GlassType glassType = glassTypes[i];
         if (glassType.isCopy)
         {
             if (glassType.original == null)
             {
                 RemoveCopy(glassType);
             }
             else
             {
                 if (!glassType.original.IsCopy(glassType))
                 {
                     RemoveCopy(glassType);
                 }
             }
         }
     }
     foreach (GlassType glassType in glassTypes)
     {
         glassType.RemoveNullObjects();
     }
 }
示例#3
0
 public void AddCopy(GlassType copy, GlassType original)
 {
     glassTypes.Insert(glassTypes.IndexOf(original) + 1, copy);
     copy.previousIndex     = glassTypes.IndexOf(copy);
     copy.previousItemAbove = original;
     copy.previousItemBelow = GetGlassTypeAfter(copy);
 }
示例#4
0
        public static GlassType Create(GlassType original, GlassRenderOrderManager manager)
        {
            GlassType glassType = CreateGlassTypeObject(CopyName(original), manager.gameObject);

            glassType.hideFlags = glassTypeHideFlags;
            glassType.Setup(original);
            return(glassType);
        }
示例#5
0
        public static GlassType Create(Glass instance, GlassRenderOrderManager manager)
        {
            GlassType glassType = CreateGlassTypeObject(instance.presetName, manager.gameObject);

            glassType.hideFlags = glassTypeHideFlags;
            glassType.Setup(instance);
            return(glassType);
        }
示例#6
0
 public int CopyNumber(GlassType glassType)
 {
     if (!IsCopy(glassType))
     {
         return(-1);
     }
     return(copies.IndexOf(glassType) + 2);
 }
示例#7
0
 void FinishedMoveChecks()
 {
     for (int i = 0; i < glassTypes.Count; i++)
     {
         GlassType glassType = glassTypes[i];
         glassType.FinishedMoveChecks(i, GetGlassType(i - 1), GetGlassType(i + 1));
     }
 }
示例#8
0
 public bool MatchingRenderOrder(GlassType other)
 {
     if (other == null)
     {
         return(false);
     }
     return(renderOrder == other.renderOrder);
 }
示例#9
0
        public void DepthQualityChanged_Other(Glass glass)
        {
            GlassType glassType = FindType(glass);

            if (glassType != null)
            {
                glassType.DepthQualityChanged_Other(glass);
            }
        }
示例#10
0
        /*
         * public GlassType(Material _nonGlassMaterial)
         * {
         *  Setup(_nonGlassMaterial);
         * }
         *
         * public GlassType(Glass instance)
         * {
         *  Setup(instance);
         * }
         *
         * public GlassType(GlassType glassType)
         * {
         *  Setup(glassType);
         * }
         */

        public void Setup(GlassType glassType)
        {
            presetName     = glassType.presetName;
            material_front = glassType.material_front;
            material_back  = glassType.material_back;
            manager        = glassType.manager;
            renderOrder    = glassType.renderOrder;
            hideFlags      = glassTypeHideFlags;
        }
示例#11
0
        public static GlassType Create(Material _nonGlassMaterial, GlassRenderOrderManager manager)
        {
            GlassType glassType = CreateGlassTypeObject(_nonGlassMaterial.name, manager.gameObject);

            glassType.hideFlags = glassTypeHideFlags;
            glassType.Setup(_nonGlassMaterial);
            glassType.isGlass = false;
            return(glassType);
        }
示例#12
0
 private void CopyMaterials(GlassType original)
 {
     material_back = new Material(Shader.Find(original.material_back.shader.name));
     material_back.CopyPropertiesFromMaterial(original.material_back);
     material_back.renderQueue = material_back.renderQueue;
     //
     material_front = new Material(Shader.Find(original.material_front.shader.name));
     material_front.CopyPropertiesFromMaterial(original.material_front);
     material_front.renderQueue = material_front.renderQueue;
 }
示例#13
0
 public List <GlassType> GetGlassTypesAfter(GlassType movedType)
 {
     if (movedType != null)
     {
         return(GetGlassTypesAfter(movedType.previousIndex));
     }
     else
     {
         return(new List <GlassType>());
     }
 }
示例#14
0
        bool SwapRenderOrder(int makeEarliest, int makeLatest)
        {
            GlassType earliestType = glassTypes[makeEarliest];
            GlassType latestType   = glassTypes[makeLatest];
            int       renderOrder1 = earliestType.renderOrder;
            int       renderOrder2 = latestType.renderOrder;

            earliestType.renderOrder = Mathf.Min(renderOrder1, renderOrder2);
            latestType.renderOrder   = Mathf.Max(renderOrder1, renderOrder2);
            return(earliestType.renderOrder != latestType.renderOrder);
        }
示例#15
0
 public bool IsCopyOrOriginal(GlassType glassType)
 {
     if (IsOriginal(glassType))
     {
         return(true);
     }
     else
     {
         return(IsCopy(glassType));
     }
 }
示例#16
0
 public bool IsCopy(GlassType potentialCopy)
 {
     if (potentialCopy == this)
     {
         return(false);
     }
     if (potentialCopy == null)
     {
         return(false);
     }
     return(copies.Contains(potentialCopy));
 }
示例#17
0
        public static void DestroyGlassType(GlassType glassType)
        {
            if (glassType == null)
            {
                return;
            }
#if UNITY_EDITOR
            DestroyImmediate(glassType);
#else
            Destroy(glassType);
#endif
        }
示例#18
0
 public bool IsOriginal(GlassType potentialOriginal)
 {
     if (potentialOriginal == null)
     {
         return(false);
     }
     if (original == null)
     {
         return(false);
     }
     return(original == potentialOriginal);
 }
示例#19
0
        public void AddGlassType(Material nonGlassMaterial)
        {
            GlassType glassType = GlassType.Create(nonGlassMaterial, this); //new GlassType(nonGlassMaterial);

            glassType.previousIndex = glassTypes.Count;
            if (glassTypes.Count > 0)
            {
                glassType.previousItemAbove = glassTypes[glassTypes.Count - 1];
                glassTypes[glassTypes.Count - 1].previousItemBelow = glassType;
            }
            glassTypes.Add(glassType);
        }
示例#20
0
 bool MakeSureRenderOrderAfter(ref GlassType typeToMove, GlassType pivot)
 {
     if (pivot == null)
     {
         return(false);
     }
     if (typeToMove == null)
     {
         return(false);
     }
     return(typeToMove.MakeSureRendeOrderAfter(pivot.renderOrder));
 }
示例#21
0
        public void SetRenderOrderFromOrder(int index, GlassType itemAbove, GlassType itemBelow)
        {
            bool canChangeOrder   = true;
            bool valueAfterAbove  = false;
            bool valueBeforeBelow = false;

            //
            if (previousIndex == index)
            {
                canChangeOrder = false;
            }
            //
            if (itemAbove == previousItemAbove && itemBelow == previousItemBelow)
            {
                canChangeOrder = false;
            }
            //
            else if (itemAbove != previousItemAbove)
            {
                canChangeOrder  = false;
                valueAfterAbove = true;
            }
            //
            else if (itemBelow != previousItemBelow)
            {
                canChangeOrder   = false;
                valueBeforeBelow = true;
            }

            //
            previousIndex     = index;
            previousItemAbove = itemAbove;
            previousItemBelow = itemBelow;
            //
            if (canChangeOrder)
            {
                SetRenderOrder(Glass.default_customRenderOrder + index);
            }
            else if (valueAfterAbove)
            {
                if (previousItemAbove != null)
                {
                    SetRenderOrder(previousItemAbove.renderOrder + 1);
                }
            }
            else if (valueBeforeBelow)
            {
                if (previousItemBelow != null)
                {
                    SetRenderOrder(previousItemBelow.renderOrder - 1);
                }
            }
        }
示例#22
0
        public void AddGlassType(Glass glass)
        {
            GlassType glassType = GlassType.Create(glass, this);//new GlassType(glass);

            glassType.previousIndex = glassTypes.Count;
            if (glassTypes.Count > 0)
            {
                glassType.previousItemAbove = glassTypes[glassTypes.Count - 1];
                glassTypes[glassTypes.Count - 1].previousItemBelow = glassType;
            }
            glassType.AddInstance(glass);
            glassTypes.Add(glassType);
        }
示例#23
0
        public GlassType GetGlassTypeBefore(GlassType glassType)
        {
            int index = glassTypes.IndexOf(glassType);

            index--;
            if (index >= 0)
            {
                return(glassTypes[index]);
            }
            else
            {
                return(null);
            }
        }
示例#24
0
        public static GlassType CreateCopy(GlassType original, GlassRenderOrderManager _manager)
        {
            GlassType copy = CreateGlassTypeObject(CopyName(original), _manager.gameObject);

            copy.Setup(original);

            copy.isCopy   = true;
            copy.original = original;
            original.copies.Add(copy);

            copy.CopyMaterials(original);

            return(copy);
        }
示例#25
0
        public GlassType GetGlassTypeAfter(GlassType glassType)
        {
            int index = glassTypes.IndexOf(glassType);

            index++;
            if (index < glassTypes.Count)
            {
                return(glassTypes[index]);
            }
            else
            {
                return(null);
            }
        }
示例#26
0
 public void UpdateGlassTypes()
 {
     for (int i = 0; i < glassTypes.Count; i++)
     {
         GlassType glassType = glassTypes[i];
         glassType.UpdateGlassValues();
         if (glassType.previousIndex == -1)
         {
             glassType.previousIndex     = i;
             glassType.previousItemAbove = GetGlassTypeBefore(glassType);
             glassType.previousItemBelow = GetGlassTypeAfter(glassType);
         }
     }
 }
示例#27
0
        public void RemoveCopy(GlassType copy)
        {
            if (!copy.isCopy)
            {
                return;
            }
            GlassType original = copy.original;

            if (original != null)
            {
                original.RemoveCopy(copy);
            }
            glassTypes.Remove(copy);
            DestroyGlassType(copy);
        }
示例#28
0
        void CalculateMoveData(ref GlassType movedType, ref int moveDirection)
        {
            int moveAmount = 0;

            for (int i = 0; i < glassTypes.Count; i++)
            {
                GlassType glassType = glassTypes[i];
                moveAmount = glassType.MoveAmount(i, GetGlassType(i - 1), GetGlassType(i + 1));
                if (moveAmount != 0)
                {
                    movedType     = glassType;
                    moveDirection = moveAmount;
                }
            }
        }
示例#29
0
        /// <summary>
        /// MoveAmount based on new index, item above (less than), and item below (more than)
        /// </summary>
        /// <param name="i"></param>
        /// <param name="glassTypeAbove"></param>
        /// <param name="glassTypeBelow"></param>
        /// <returns></returns>
        public int MoveAmount(int index, GlassType itemAbove, GlassType itemBelow)
        {
            bool moved = true;

            int direction = 0;

            if (index == previousIndex)
            {
                moved = false;
            }
            else if (itemAbove == previousItemAbove || itemBelow == previousItemBelow)
            {
                moved = false;
            }

            if (moved)
            {
                direction = previousIndex - index;
            }

            return(direction);
        }
示例#30
0
 public void RemoveEmptyTypes()
 {
     for (int i = glassTypes.Count - 1; i >= 0; i--)
     {
         GlassType glassType = glassTypes[i];
         if (!glassType.isCopy && glassType.isGlass)
         {
             if (glassType.instances.Count == 0)
             {
                 glassTypes.Remove(glassType);
                 DestroyGlassType(glassType);
             }
         }
         else if (glassType.isGlass)
         {
             if (glassType.original == null)
             {
                 glassTypes.Remove(glassType);
                 DestroyGlassType(glassType);
             }
         }
     }
 }