Ejemplo n.º 1
0
 public void AddColliderFurniture(FurnitureInfo fi)
 {
     if (!colliderFurnitures.Contains(fi))
     {
         colliderFurnitures.Add(fi);
     }
 }
Ejemplo n.º 2
0
 private void GetFurnitureSetting()
 {
     if (null == furniture)
     {
         return;
     }
     furnitureInfo = furniture.GetComponent <FurnitureInfo>();
 }
Ejemplo n.º 3
0
 private void Release()
 {
     prefab = null;
     if (null != furniture)
     {
         DestroyImmediate(furniture);
         furniture = null;
     }
     furnitureInfo = null;
 }
Ejemplo n.º 4
0
        private void CreateNextFurniture()
        {
            lastFurniture     = buildingFurniture;
            buildingFurniture = null;
            FurnitureInfo info = lastFurniture.TheInfo;

            if (info.furnitureType == FurnitureType.ground || info.furnitureType == FurnitureType.wall)
            {
                BuildingFurniture(lastFurniture.res, lastFurniture.Layer);
            }
        }
Ejemplo n.º 5
0
 private void DrawNoFurnitureInfo()
 {
     GUILayout.BeginHorizontal();
     EditorGUILayout.LabelField("没有挂载建筑物体脚本", GUILayout.Width(120));
     if (GUILayout.Button("挂载", GUILayout.Width(120f)))
     {
         if (null != furniture)
         {
             furnitureInfo = furniture.AddComponent <FurnitureInfo>();
         }
     }
     GUILayout.EndHorizontal();
 }
Ejemplo n.º 6
0
        private void OnTriggerExit(Collider other)
        {
            if (!isBuilding)
            {
                return;
            }
            var furnitureCollider = other.GetComponent <FurnitureCollider>();

            if (furnitureCollider != null)
            {
                FurnitureInfo fi = furnitureCollider.info as FurnitureInfo;
                if (fi != null)
                {
                    BuilderHelper.Instance.RemoveColliderFurniture(fi);
                }
            }
            else
            {
                BuilderHelper.Instance.ObstacleCollider--;
                Debug.Log("Collider Furniture is:" + other.name);
            }
            BuilderHelper.Instance.TriggerStateChanged = true;
        }
Ejemplo n.º 7
0
        private bool CanPlaceFurniture(FurnitureItem furniture)
        {
            if (null == furniture || ObstacleCollider > 0)
            {
                return(false);
            }
            FurnitureInfo fi           = furniture.TheInfo;
            bool          canPlaceItem = false;

            switch (fi.furnitureType)
            {
            case FurnitureType.wall:
                foreach (var temp in colliderFurnitures)
                {
                    if (temp.furnitureType == FurnitureType.wall)
                    {
                        int tempNum = temp.direction - fi.direction;
                        if (tempNum % 2 == 0)
                        {
                            return(false);
                        }
                    }

                    if (temp.furnitureType == FurnitureType.ground)
                    {
                        canPlaceItem = fi.layer >= temp.layer;
                    }
                }
                break;

            case FurnitureType.ground:
                foreach (var temp in colliderFurnitures)
                {
                    if (temp.furnitureType == FurnitureType.ground || temp.furnitureType == FurnitureType.furniture)
                    {
                        return(false);
                    }
                }

                canPlaceItem = true;
                break;

            case FurnitureType.furniture:
                int floorCount = 0;
                foreach (var temp in colliderFurnitures)
                {
                    if (temp.furnitureType == FurnitureType.furniture || temp.furnitureType == FurnitureType.wall)
                    {
                        return(false);
                    }

                    if (temp.furnitureType == FurnitureType.ground)
                    {
                        if (fi.layer > temp.layer)
                        {
                            return(false);
                        }
                        floorCount++;
                    }
                }
                canPlaceItem = (fi.furnitureSpace <= floorCount);
                break;
            }
            return(canPlaceItem);
        }
Ejemplo n.º 8
0
 public void RemoveColliderFurniture(FurnitureInfo fi)
 {
     colliderFurnitures.Remove(fi);
 }
Ejemplo n.º 9
0
 private void OnLoaded()
 {
     theInfo       = rootModel.GetComponent <FurnitureInfo>();
     theInfo.layer = layer;
     this.InfoRef();
 }