public RuleOperation2D_Rectangular SerializeData() { Assert.AssertIsTrue(IsLegal); var ret = new RuleOperation2D_Rectangular(); ret.xRelative = p1.x - p2.x; ret.yRelative = p1.y - p2.y; return ret; }
public RuleOperation2D_Rectangular SerializeData() { Assert.AssertIsTrue(IsLegal); var ret = new RuleOperation2D_Rectangular(); ret.xRelative = p1.x - p2.x; ret.yRelative = p1.y - p2.y; return(ret); }
public void LoadData(RuleOperation2D_Rectangular rule) { plane.gameObject.SetActive(true); Draw(planeWidth, planeHeight, maskWidth, maskHeight); if (rule.xRelative != 0 || rule.yRelative != 0) { var offset = new Pos2D(rule.xRelative / 2, rule.yRelative / 2); p1 = new Pos2D(2 - offset.x, 2 - offset.y); p2 = new Pos2D(2 + rule.xRelative - offset.x, 2 + rule.yRelative - offset.y); Mark(p1.x, p1.y); Mark(p2.x, p2.y); } }
public static RuleOperation StaticDeserialize(string str) { var tuple = JsonHelper.Deserialize<Tuple<string, string>>(str); switch (tuple.item1) { case RECTANGULAR_2D: var ret = new RuleOperation2D_Rectangular(); ret.Deserialize(tuple.item2); return ret; default: throw new NotSupportedException(); } }
public static RuleOperation StaticDeserialize(string str) { var tuple = JsonHelper.Deserialize <Tuple <string, string> >(str); switch (tuple.item1) { case RECTANGULAR_2D: var ret = new RuleOperation2D_Rectangular(); ret.Deserialize(tuple.item2); return(ret); default: throw new NotSupportedException(); } }
private static bool JudgeOperable(SlotTrait matchingTrait, Container2D_Rectangular container, int xMask, int yMask, int xInMask, int yInMask, RuleMatchBasic2D_Rectangular match, RuleOperation2D_Rectangular operation, bool inverse) { int xRelative = inverse ? -operation.xRelative : operation.xRelative; int yRelative = inverse ? -operation.yRelative : operation.yRelative; int xTouch = xInMask + xRelative; int yTouch = yInMask + yRelative; if (yTouch >= 0 && yTouch < match.maskHeight && xTouch >= 0 && xTouch < match.maskWidth && match.PeekMask(xTouch, yTouch)) { return(false); } var sniffX = xMask + xInMask + xRelative; var sniffY = yMask + yInMask + yRelative; if (!container.IsLegalPosition(sniffX, sniffY)) { return(false); } var sniff = container.GetSlot(sniffX, sniffY); if (!sniff.IsTarget) { return(false); } return(matchingTrait.AbsoluteEqual(sniff.slotAttribute.trait)); }