using System.Collections; using System.Collections.Generic; using UnityEngine; namespace BuildSystem { public static class LogicGridExtensions { public static void BindLeftAndThis(this Grid self, Grid left) { left.right = self; self.left = left; } public static void BindDownAndThis(this Grid self, Grid down) { down.up = self; self.down = down; } /// /// 判断是否可以放置, /// 首先判断是不是万能, /// 如果是再判断是否有车道, /// 如果是再判断车道是否相同 /// /// /// /// public static bool IsCanPlace(this Grid self, PlaceObject placeObject) { bool isCanPlace = true; if (self.up!=null && isCanPlace) { isCanPlace = (self.up.isHaves[2] == IsHave.None) || ((self.up.isHaves[2] == placeObject.ishave[0]) && (self.up.type[2] == placeObject.type[0] || (self.up.isHaves[2] == IsHave.No && IsHave.No == placeObject.ishave[0]))); } if (self.right != null && isCanPlace) { isCanPlace = (self.right.isHaves[3] == IsHave.None) || ((self.right.isHaves[3] == placeObject.ishave[1]) && (self.right.type[3] == placeObject.type[1] || (self.right.isHaves[3] == IsHave.No && IsHave.No == placeObject.ishave[1]))); } if (self.down != null && isCanPlace) { isCanPlace = (self.down.isHaves[0] == IsHave.None) || ((self.down.isHaves[0] == placeObject.ishave[2]) && (self.down.type[0] == placeObject.type[2] || (self.down.isHaves[0] == IsHave.No && IsHave.No == placeObject.ishave[2]))); } if (self.left != null && isCanPlace) { isCanPlace = (self.left.isHaves[1] == IsHave.None) || ((self.left.isHaves[1] == placeObject.ishave[3]) && (self.left.type[1] == placeObject.type[3] || (self.left.isHaves[1] == IsHave.No && IsHave.No == placeObject.ishave[3]))); } return isCanPlace; } } }