public override void OnInspectorGUI() { charComponent cc = (charComponent)target; cc.FlipX = EditorGUILayout.Toggle("Flip X", cc.FlipX); cc.FlipY = EditorGUILayout.Toggle("Flip Y", cc.FlipY); base.OnInspectorGUI(); EditorUtility.SetDirty(target); }
public bool tryContactBelow(charComponent charC) { if (charC.contactDown == null || charC.contactDown.Length <= 0) { return(false); } layer[] ls = level.Instance.layers; if (ls == null || ls.Length <= 0) { return(false); } bool lastBlockedFromBelow = BlockedFromBelow; float ny = transform.position.y; BlockedFromBelow = false; foreach (layer l in ls) { foreach (Transform t in charC.contactDown) { if (t.gameObject.activeSelf) { int b = l.getBlock(t.position.x, t.position.y); if (b >= 0) { float X = l.getXPos(t.position.x) * l.blockSize; float Y = l.getYPos(t.position.y) * l.blockSize; layer.AllBlocks[b].up(this, t, X, Y, l.blockSize, l); } } } } bool ret = BlockedFromBelow; BlockedFromBelow = lastBlockedFromBelow; transform.position = new Vector3(transform.position.x, ny, transform.position.z); return(ret); }
public animation(charComponent Owner, int Index) { owner = Owner; index = Index; }
public void checkContactPoints(charComponent charC) { if (Solid) { layer[] ls = level.Instance.layers; foreach (layer l in ls) { if (charC.contactDown != null && !IgnoreBelowInteraction) { bool bfb = BlockedFromBelow; BlockedFromBelow = false; foreach (Transform t in charC.contactDown) { if (t.gameObject.activeSelf) { int b = l.getBlock(t.position.x, t.position.y); if (b >= 0) { float X = l.getXPos(t.position.x) * l.blockSize; float Y = l.getYPos(t.position.y) * l.blockSize; layer.AllBlocks[b].up(this, t, X, Y, l.blockSize, l); } } } BlockedAngleDetector = false; foreach (Transform t in charC.angleDetector) { if (t.gameObject.activeSelf) { int b = l.getBlock(t.position.x, t.position.y); if (b >= 0) { float X = l.getXPos(t.position.x) * l.blockSize; float Y = l.getYPos(t.position.y) * l.blockSize; layer.AllBlocks[b].angleDetector(this, t, X, Y, l.blockSize, l); } break; } } if (bfb && !BlockedFromBelow && !GuidedByTerrain) { Vector2 v = Rotate(TerrainAngle, XSpeed, YSpeed); XSpeed = v.x; YSpeed = v.y; TerrainAngle = 0; } } if (charC.contactRight != null) { BlockedFromRight = false; foreach (Transform t in charC.contactRight) { if (t.gameObject.activeSelf) { int b = l.getBlock(t.position.x, t.position.y); if (b >= 0) { float X = l.getXPos(t.position.x) * l.blockSize; float Y = l.getYPos(t.position.y) * l.blockSize; layer.AllBlocks[b].left(this, t, X, Y, l.blockSize, l); } } } } if (charC.contactLeft != null) { BlockedFromLeft = false; foreach (Transform t in charC.contactLeft) { if (t.gameObject.activeSelf) { int b = l.getBlock(t.position.x, t.position.y); if (b >= 0) { float X = l.getXPos(t.position.x) * l.blockSize; float Y = l.getYPos(t.position.y) * l.blockSize; layer.AllBlocks[b].right(this, t, X, Y, l.blockSize, l); } } } } } } }