unity code style

This commit is contained in:
2015-07-11 15:57:58 +06:00
parent ff2db6d279
commit 3437fa40ce
23 changed files with 926 additions and 923 deletions

View File

@@ -22,15 +22,15 @@ namespace IsoTools {
_iso_zpositions = targets
.Where(p => p as IsoObject)
.Select(p => p as IsoObject)
.ToDictionary(p => p, p => p.Position.z);
.ToDictionary(p => p, p => p.position.z);
_center = _viewCenter = _positions.Aggregate(Vector3.zero, (AccIn, p) => {
return AccIn + IsoUtils.Vec3FromVec2(iso_world.IsoToScreen(p.Key.Position + p.Key.Size * 0.5f));
return AccIn + IsoUtils.Vec3FromVec2(iso_world.IsoToScreen(p.Key.position + p.Key.size * 0.5f));
}) / _positions.Count;
}
}
bool IsAnyAlignment {
get { return _positions.Keys.Any(p => p.Alignment); }
get { return _positions.Keys.Any(p => p.isAlignment); }
}
void AlignmentSelection() {
@@ -41,7 +41,7 @@ namespace IsoTools {
}
void AlignmentIsoObject(IsoObject iso_object) {
iso_object.Position = iso_object.TilePosition;
iso_object.position = iso_object.tilePosition;
iso_object.FixTransform();
}
@@ -51,12 +51,12 @@ namespace IsoTools {
return _iso_zpositions.Aggregate(0.0f, (AccIn, pair) => {
var iso_object = pair.Key;
var iso_orig_z = pair.Value;
iso_object.PositionZ = iso_orig_z + delta;
iso_object.positionZ = iso_orig_z + delta;
iso_object.FixTransform();
if ( is_any_alignment ) {
AlignmentIsoObject(iso_object);
}
var z_delta = iso_object.Position.z - iso_orig_z;
var z_delta = iso_object.position.z - iso_orig_z;
return Mathf.Abs(z_delta) > Mathf.Abs(AccIn) ? z_delta : AccIn;
});
}
@@ -81,10 +81,10 @@ namespace IsoTools {
var iso_world = GameObject.FindObjectOfType<IsoWorld>();
if ( iso_world ) {
Handles.color = Handles.zAxisColor;
var delta = Handles.Slider(_viewCenter, IsoUtils.Vec3OneY) - _viewCenter;
var delta = Handles.Slider(_viewCenter, IsoUtils.vec3OneY) - _viewCenter;
if ( Mathf.Abs(delta.y) > Mathf.Epsilon ) {
float tmp_y = ZMoveIsoObjects((_viewCenter.y - _center.y + delta.y) / iso_world.TileSize);
_viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.TileSize);
float tmp_y = ZMoveIsoObjects((_viewCenter.y - _center.y + delta.y) / iso_world.tileSize);
_viewCenter = _center + IsoUtils.Vec3FromY(tmp_y * iso_world.tileSize);
}
}
}
@@ -134,15 +134,18 @@ namespace IsoTools {
}
void OnDisable() {
if ( Tools.hidden ) {
Tools.hidden = false;
Tools.current = Tool.Move;
}
}
void OnSceneGUI() {
if ( Tools.current == Tool.Move ) {
Tools.hidden = true;
ZMoveSlider();
XYMoveSlider(Handles.xAxisColor, IsoUtils.Vec3OneX);
XYMoveSlider(Handles.yAxisColor, IsoUtils.Vec3OneY);
XYMoveSlider(Handles.xAxisColor, IsoUtils.vec3OneX);
XYMoveSlider(Handles.yAxisColor, IsoUtils.vec3OneY);
XYMoveRectangle();
} else {
Tools.hidden = false;

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 114888}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.29999995, y: .649999976, z: 22.2222233}
m_LocalPosition: {x: 32, y: 16, z: 22.2222233}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 483872}

View File

@@ -39,7 +39,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155780}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: -2.5999999, y: 0, z: 0}
m_LocalPosition: {x: -64, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 457334}

View File

@@ -51,7 +51,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 112436}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 1.29999995, y: -.649999976, z: 0}
m_LocalPosition: {x: 32, y: -16, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 400788}

File diff suppressed because it is too large Load Diff

View File

@@ -3,8 +3,8 @@ using System.Collections;
namespace IsoTools { namespace Examples {
public class CircleFly : MonoBehaviour {
public float FlyRadius = 150.0f;
public float FlySpeed = 1.0f;
public float flyRadius = 150.0f;
public float flySpeed = 1.0f;
Vector3 _start_pos;
float _fly_timer;
@@ -15,10 +15,10 @@ namespace IsoTools { namespace Examples {
}
void Update () {
_fly_timer += FlySpeed * Time.deltaTime;
_fly_timer += flySpeed * Time.deltaTime;
transform.position = new Vector3(
_start_pos.x + Mathf.Cos(_fly_timer) * FlyRadius,
_start_pos.y + Mathf.Sin(_fly_timer) * FlyRadius,
_start_pos.x + Mathf.Cos(_fly_timer) * flyRadius,
_start_pos.y + Mathf.Sin(_fly_timer) * flyRadius,
_start_pos.z);
}
}

View File

@@ -3,15 +3,15 @@ using System.Collections;
namespace IsoTools { namespace Examples {
public class IsoAutoController : MonoBehaviour {
public float StepTicks = 0.5f;
public float StepRndTicks = 0.5f;
public float stepTicks = 0.5f;
public float stepRndTicks = 0.5f;
void Start() {
StartCoroutine("Move");
}
WaitForSeconds RndWait() {
return new WaitForSeconds(StepTicks + Random.Range(0.0f, StepRndTicks));
return new WaitForSeconds(stepTicks + Random.Range(0.0f, stepRndTicks));
}
IEnumerator Move() {
@@ -19,13 +19,13 @@ namespace IsoTools { namespace Examples {
if ( iso_object ) {
for (;;) {
yield return RndWait();
iso_object.Position += new Vector3(1, 0, 0);
iso_object.position += new Vector3(1, 0, 0);
yield return RndWait();
iso_object.Position += new Vector3(0, 1, 0);
iso_object.position += new Vector3(0, 1, 0);
yield return RndWait();
iso_object.Position += new Vector3(-1, 0, 0);
iso_object.position += new Vector3(-1, 0, 0);
yield return RndWait();
iso_object.Position += new Vector3(0, -1, 0);
iso_object.position += new Vector3(0, -1, 0);
}
}
}

View File

@@ -7,9 +7,9 @@ namespace IsoTools { namespace Examples {
var iso_object = GetComponent<IsoObject>();
var iso_rigidbody = GetComponent<IsoRigidbody>();
if ( iso_rigidbody ) {
iso_rigidbody.Velocity = dir;
iso_rigidbody.velocity = dir;
} else if ( iso_object) {
iso_object.Position += dir * Time.deltaTime;
iso_object.position += dir * Time.deltaTime;
}
}
void Update () {

View File

@@ -18,13 +18,13 @@ namespace IsoTools { namespace Examples {
void OnIsoCollisionEnter(IsoCollision iso_collision) {
Debug.LogFormat(
"OnIsoCollisionEnter. self:{0} other:{1}",
gameObject.name, iso_collision.GameObject.name);
gameObject.name, iso_collision.gameObject.name);
}
void OnIsoCollisionExit(IsoCollision iso_collision) {
Debug.LogFormat(
"OnIsoCollisionExit. self:{0} other:{1}",
gameObject.name, iso_collision.GameObject.name);
gameObject.name, iso_collision.gameObject.name);
}
}
}} // namespace IsoTools::Examples

View File

@@ -10,63 +10,63 @@ namespace IsoTools {
[SerializeField]
public Vector3 _size = Vector3.zero;
public Vector3 Size {
public Vector3 size {
get { return _size; }
set {
_size = value;
if ( RealBoxCollider ) {
RealBoxCollider.size = value;
if ( realBoxCollider ) {
realBoxCollider.size = value;
}
}
}
[SerializeField]
public Vector3 _offset = Vector3.zero;
public Vector3 Offset {
public Vector3 offset {
get { return _offset; }
set {
_offset = value;
if ( RealBoxCollider ) {
RealBoxCollider.center = value;
if ( realBoxCollider ) {
realBoxCollider.center = value;
}
}
}
protected override Collider CreateRealCollider(GameObject target) {
var collider = target.AddComponent<BoxCollider>();
collider.size = Size;
collider.center = Offset;
collider.size = size;
collider.center = offset;
return collider;
}
public BoxCollider RealBoxCollider {
get { return RealCollider as BoxCollider; }
public BoxCollider realBoxCollider {
get { return realCollider as BoxCollider; }
}
#if UNITY_EDITOR
protected override void Reset() {
base.Reset();
var iso_object = GetComponent<IsoObject>();
Size = iso_object ? iso_object.Size : Vector3.zero;
Offset = iso_object ? iso_object.Size * 0.5f : Vector3.zero;
size = iso_object ? iso_object.size : Vector3.zero;
offset = iso_object ? iso_object.size * 0.5f : Vector3.zero;
EditorUtility.SetDirty(this);
}
protected override void OnValidate() {
base.OnValidate();
if ( RealBoxCollider ) {
RealBoxCollider.size = Size;
RealBoxCollider.center = Offset;
if ( realBoxCollider ) {
realBoxCollider.size = size;
realBoxCollider.center = offset;
}
}
void OnDrawGizmosSelected() {
var iso_object = GetComponent<IsoObject>();
if ( iso_object && iso_object.IsoWorld ) {
if ( iso_object && iso_object.isoWorld ) {
IsoUtils.DrawCube(
iso_object.IsoWorld,
iso_object.Position + Offset,
Size,
iso_object.isoWorld,
iso_object.position + offset,
size,
Color.green);
}
}

View File

@@ -10,67 +10,67 @@ namespace IsoTools {
protected abstract Collider CreateRealCollider(GameObject target);
Collider _realCollider = null;
protected Collider RealCollider {
protected Collider realCollider {
get { return _realCollider; }
}
protected GameObject IsoFakeObject {
protected GameObject fakeObject {
get {
var helper = IsoUtils.GetOrCreateComponent<IsoPhysicHelper>(gameObject);
return helper ? helper.IsoFakeObject : null;
return helper ? helper.isoFakeObject : null;
}
}
[SerializeField]
public PhysicMaterial _material = null;
public PhysicMaterial Material {
public PhysicMaterial material {
get { return _material; }
set {
_material = value;
if ( RealCollider ) {
RealCollider.material = value;
if ( realCollider ) {
realCollider.material = value;
}
}
}
[SerializeField]
public bool _isTrigger = false;
public bool IsTrigger {
public bool isTrigger {
get { return _isTrigger; }
set {
_isTrigger = value;
if ( RealCollider ) {
RealCollider.isTrigger = value;
if ( realCollider ) {
realCollider.isTrigger = value;
}
}
}
public IsoRigidbody AttachedRigidbody {
public IsoRigidbody attachedRigidbody {
get {
return RealCollider
? IsoUtils.IsoConvertRigidbody(RealCollider.attachedRigidbody)
return realCollider
? IsoUtils.IsoConvertRigidbody(realCollider.attachedRigidbody)
: null;
}
}
public Bounds Bounds {
public Bounds bounds {
get {
return RealCollider
? RealCollider.bounds
return realCollider
? realCollider.bounds
: new Bounds();
}
}
public Vector3 ClosestPointOnBounds(Vector3 position) {
return RealCollider
? RealCollider.ClosestPointOnBounds(position)
return realCollider
? realCollider.ClosestPointOnBounds(position)
: Vector3.zero;
}
public bool Raycast(Ray ray, out IsoRaycastHit iso_hit_info, float max_distance) {
RaycastHit hit_info;
var result = RealCollider
? RealCollider.Raycast(ray, out hit_info, max_distance)
var result = realCollider
? realCollider.Raycast(ray, out hit_info, max_distance)
: false;
iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
return result;
@@ -78,22 +78,22 @@ namespace IsoTools {
void Awake() {
var fake_collider_go = new GameObject();
fake_collider_go.transform.SetParent(IsoFakeObject.transform, false);
fake_collider_go.transform.SetParent(fakeObject.transform, false);
fake_collider_go.AddComponent<IsoFakeCollider>().Init(this);
_realCollider = CreateRealCollider(fake_collider_go);
_realCollider.material = Material;
_realCollider.isTrigger = IsTrigger;
_realCollider.material = material;
_realCollider.isTrigger = isTrigger;
}
void OnEnable() {
if ( RealCollider ) {
RealCollider.enabled = true;
if ( realCollider ) {
realCollider.enabled = true;
}
}
void OnDisable() {
if ( RealCollider ) {
RealCollider.enabled = false;
if ( realCollider ) {
realCollider.enabled = false;
}
}
@@ -106,14 +106,14 @@ namespace IsoTools {
#if UNITY_EDITOR
protected virtual void Reset() {
Material = null;
IsTrigger = false;
material = null;
isTrigger = false;
EditorUtility.SetDirty(this);
}
protected virtual void OnValidate() {
Material = _material;
IsTrigger = _isTrigger;
material = _material;
isTrigger = _isTrigger;
}
#endif
}

View File

@@ -3,18 +3,18 @@
namespace IsoTools {
public class IsoCollision {
public IsoCollider IsoCollider { get; private set; }
public IsoContactPoint[] IsoContacts { get; private set; }
public GameObject GameObject { get; private set; }
public Vector3 RelativeVelocity { get; private set; }
public IsoRigidbody IsoRigidbody { get; private set; }
public IsoCollider collider { get; private set; }
public IsoContactPoint[] contacts { get; private set; }
public GameObject gameObject { get; private set; }
public Vector3 relativeVelocity { get; private set; }
public IsoRigidbody rigidbody { get; private set; }
public IsoCollision(Collision collision) {
IsoCollider = IsoUtils.IsoConvertCollider(collision.collider);
IsoContacts = IsoUtils.IsoConvertContactPoints(collision.contacts);
GameObject = IsoUtils.IsoConvertGameObject(collision.gameObject);
RelativeVelocity = collision.relativeVelocity;
IsoRigidbody = IsoUtils.IsoConvertRigidbody(collision.rigidbody);
collider = IsoUtils.IsoConvertCollider(collision.collider);
contacts = IsoUtils.IsoConvertContactPoints(collision.contacts);
gameObject = IsoUtils.IsoConvertGameObject(collision.gameObject);
relativeVelocity = collision.relativeVelocity;
rigidbody = IsoUtils.IsoConvertRigidbody(collision.rigidbody);
}
}
} // namespace IsoTools

View File

@@ -3,16 +3,16 @@
namespace IsoTools {
public struct IsoContactPoint {
public Vector3 Normal { get; private set; }
public IsoCollider OtherIsoCollider { get; private set; }
public Vector3 Point { get; private set; }
public IsoCollider ThisIsoCollider { get; private set; }
public Vector3 normal { get; private set; }
public IsoCollider otherCollider { get; private set; }
public Vector3 point { get; private set; }
public IsoCollider thisCollider { get; private set; }
public IsoContactPoint(ContactPoint contact_point) {
Normal = contact_point.normal;
OtherIsoCollider = IsoUtils.IsoConvertCollider(contact_point.otherCollider);
Point = contact_point.point;
ThisIsoCollider = IsoUtils.IsoConvertCollider(contact_point.thisCollider);
normal = contact_point.normal;
otherCollider = IsoUtils.IsoConvertCollider(contact_point.otherCollider);
point = contact_point.point;
thisCollider = IsoUtils.IsoConvertCollider(contact_point.thisCollider);
}
}
} // namespace IsoTools

View File

@@ -9,7 +9,7 @@ namespace IsoTools {
_isoCollider = iso_collider;
}
public IsoCollider IsoCollider {
public IsoCollider isoCollider {
get { return _isoCollider; }
}
}

View File

@@ -8,45 +8,45 @@ namespace IsoTools {
public void Init(IsoObject iso_object) {
_isoObject = iso_object;
_lastPosition = iso_object.Position;
transform.position = iso_object.Position;
_lastPosition = iso_object.position;
transform.position = iso_object.position;
}
public IsoObject IsoObject {
public IsoObject isoObject {
get { return _isoObject; }
}
void FixedUpdate() {
if ( !IsoUtils.Vec3Approximately(_lastPosition, IsoObject.Position) ) {
_lastPosition = transform.position = IsoObject.Position;
if ( !IsoUtils.Vec3Approximately(_lastPosition, isoObject.position) ) {
_lastPosition = transform.position = isoObject.position;
} else if ( !IsoUtils.Vec3Approximately(_lastPosition, transform.position) ) {
_lastPosition = IsoObject.Position = transform.position;
_lastPosition = isoObject.position = transform.position;
}
}
void OnTriggerEnter(Collider collider) {
IsoObject.gameObject.SendMessage(
isoObject.gameObject.SendMessage(
"OnIsoTriggerEnter",
IsoUtils.IsoConvertCollider(collider),
SendMessageOptions.DontRequireReceiver);
}
void OnTriggerExit(Collider collider) {
IsoObject.gameObject.SendMessage(
isoObject.gameObject.SendMessage(
"OnIsoTriggerExit",
IsoUtils.IsoConvertCollider(collider),
SendMessageOptions.DontRequireReceiver);
}
void OnCollisionEnter(Collision collision) {
IsoObject.gameObject.SendMessage(
isoObject.gameObject.SendMessage(
"OnIsoCollisionEnter",
new IsoCollision(collision),
SendMessageOptions.DontRequireReceiver);
}
void OnCollisionExit(Collision collision) {
IsoObject.gameObject.SendMessage(
isoObject.gameObject.SendMessage(
"OnIsoCollisionExit",
new IsoCollision(collision),
SendMessageOptions.DontRequireReceiver);

View File

@@ -9,7 +9,7 @@ namespace IsoTools {
_isoRigidbody = iso_rigidbody;
}
public IsoRigidbody IsoRigidbody {
public IsoRigidbody isoRigidbody {
get { return _isoRigidbody; }
}
}

View File

@@ -11,7 +11,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------
//
// Size
// size
//
// ------------------------------------------------------------------------
@@ -19,7 +19,7 @@ namespace IsoTools {
Vector3 _size = Vector3.one;
/// <summary>Isometric object size.</summary>
public Vector3 Size {
public Vector3 size {
get { return _size; }
set {
_size = IsoUtils.Vec3Max(value, Vector3.zero);
@@ -28,41 +28,41 @@ namespace IsoTools {
}
/// <summary>Isometric object size X.</summary>
public float SizeX {
get { return Size.x; }
set { Size = IsoUtils.Vec3ChangeX(Size, value); }
public float sizeX {
get { return size.x; }
set { size = IsoUtils.Vec3ChangeX(size, value); }
}
/// <summary>Isometric object size Y.</summary>
public float SizeY {
get { return Size.y; }
set { Size = IsoUtils.Vec3ChangeY(Size, value); }
public float sizeY {
get { return size.y; }
set { size = IsoUtils.Vec3ChangeY(size, value); }
}
/// <summary>Isometric object size Z.</summary>
public float SizeZ {
get { return Size.z; }
set { Size = IsoUtils.Vec3ChangeZ(Size, value); }
public float sizeZ {
get { return size.z; }
set { size = IsoUtils.Vec3ChangeZ(size, value); }
}
/// <summary>Isometric object size XY.</summary>
public Vector2 SizeXY {
get { return new Vector2(SizeX, SizeY); }
public Vector2 sizeXY {
get { return new Vector2(sizeX, sizeY); }
}
/// <summary>Isometric object size YZ.</summary>
public Vector2 SizeYZ {
get { return new Vector2(SizeY, SizeZ); }
public Vector2 sizeYZ {
get { return new Vector2(sizeY, sizeZ); }
}
/// <summary>Isometric object size XZ.</summary>
public Vector2 SizeXZ {
get { return new Vector2(SizeX, SizeZ); }
public Vector2 sizeXZ {
get { return new Vector2(sizeX, sizeZ); }
}
// ------------------------------------------------------------------------
//
// Position
// position
//
// ------------------------------------------------------------------------
@@ -70,7 +70,7 @@ namespace IsoTools {
Vector3 _position = Vector3.zero;
/// <summary>Isometric object position.</summary>
public Vector3 Position {
public Vector3 position {
get { return _position; }
set {
_position = value;
@@ -79,81 +79,81 @@ namespace IsoTools {
}
/// <summary>Isometric object position X.</summary>
public float PositionX {
get { return Position.x; }
set { Position = IsoUtils.Vec3ChangeX(Position, value); }
public float positionX {
get { return position.x; }
set { position = IsoUtils.Vec3ChangeX(position, value); }
}
/// <summary>Isometric object position Y.</summary>
public float PositionY {
get { return Position.y; }
set { Position = IsoUtils.Vec3ChangeY(Position, value); }
public float positionY {
get { return position.y; }
set { position = IsoUtils.Vec3ChangeY(position, value); }
}
/// <summary>Isometric object position Z.</summary>
public float PositionZ {
get { return Position.z; }
set { Position = IsoUtils.Vec3ChangeZ(Position, value); }
public float positionZ {
get { return position.z; }
set { position = IsoUtils.Vec3ChangeZ(position, value); }
}
/// <summary>Isometric object position XY.</summary>
public Vector2 PositionXY {
get { return new Vector2(PositionX, PositionY); }
public Vector2 positionXY {
get { return new Vector2(positionX, positionY); }
}
/// <summary>Isometric object position YZ.</summary>
public Vector2 PositionYZ {
get { return new Vector2(PositionY, PositionZ); }
public Vector2 positionYZ {
get { return new Vector2(positionY, positionZ); }
}
/// <summary>Isometric object position XZ.</summary>
public Vector2 PositionXZ {
get { return new Vector2(PositionX, PositionZ); }
public Vector2 positionXZ {
get { return new Vector2(positionX, positionZ); }
}
// ------------------------------------------------------------------------
//
// TilePosition
// tilePosition
//
// ------------------------------------------------------------------------
/// <summary>Isometric object tile position.</summary>
public Vector3 TilePosition {
get { return IsoUtils.Vec3Round(Position); }
set { Position = value; }
public Vector3 tilePosition {
get { return IsoUtils.Vec3Round(position); }
set { position = value; }
}
/// <summary>Isometric object tile position X.</summary>
public float TilePositionX {
get { return TilePosition.x; }
set { TilePosition = IsoUtils.Vec3ChangeX(TilePosition, value); }
public float tilePositionX {
get { return tilePosition.x; }
set { tilePosition = IsoUtils.Vec3ChangeX(tilePosition, value); }
}
/// <summary>Isometric object tile position Y.</summary>
public float TilePositionY {
get { return TilePosition.y; }
set { TilePosition = IsoUtils.Vec3ChangeY(TilePosition, value); }
public float tilePositionY {
get { return tilePosition.y; }
set { tilePosition = IsoUtils.Vec3ChangeY(tilePosition, value); }
}
/// <summary>Isometric object tile position Z.</summary>
public float TilePositionZ {
get { return TilePosition.z; }
set { TilePosition = IsoUtils.Vec3ChangeZ(TilePosition, value); }
public float tilePositionZ {
get { return tilePosition.z; }
set { tilePosition = IsoUtils.Vec3ChangeZ(tilePosition, value); }
}
/// <summary>Isometric object tile position XY.</summary>
public Vector2 TilePositionXY {
get { return new Vector2(TilePositionX, TilePositionY); }
public Vector2 tilePositionXY {
get { return new Vector2(tilePositionX, tilePositionY); }
}
/// <summary>Isometric object tile position YZ.</summary>
public Vector2 TilePositionYZ {
get { return new Vector2(TilePositionY, TilePositionZ); }
public Vector2 tilePositionYZ {
get { return new Vector2(tilePositionY, tilePositionZ); }
}
/// <summary>Isometric object tile position XZ.</summary>
public Vector2 TilePositionXZ {
get { return new Vector2(TilePositionX, TilePositionZ); }
public Vector2 tilePositionXZ {
get { return new Vector2(tilePositionX, tilePositionZ); }
}
// ------------------------------------------------------------------------
@@ -167,15 +167,15 @@ namespace IsoTools {
Vector3 _lastPosition = Vector3.zero;
Vector2 _lastTransform = Vector2.zero;
[SerializeField] bool _alignment = true;
[SerializeField] bool _showBounds = false;
[SerializeField] bool _isAlignment = true;
[SerializeField] bool _isShowBounds = false;
public bool Alignment {
get { return _alignment; }
public bool isAlignment {
get { return _isAlignment; }
}
public bool ShowBounds {
get { return _showBounds; }
public bool isShowBounds {
get { return _isShowBounds; }
}
#endif
@@ -186,7 +186,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------
IsoWorld _isoWorld = null;
public IsoWorld IsoWorld {
public IsoWorld isoWorld {
get {
if ( (object)_isoWorld == null ) {
_isoWorld = GameObject.FindObjectOfType<IsoWorld>();
@@ -204,12 +204,12 @@ namespace IsoTools {
public void FixTransform() {
#if UNITY_EDITOR
if ( Application.isEditor && !Application.isPlaying && Alignment ) {
_position = TilePosition;
if ( Application.isEditor && !Application.isPlaying && isAlignment ) {
_position = tilePosition;
}
#endif
transform.position = IsoUtils.Vec3ChangeZ(
IsoWorld.IsoToScreen(Position),
isoWorld.IsoToScreen(position),
transform.position.z);
FixLastProperties();
MartDirtyIsoWorld();
@@ -217,21 +217,21 @@ namespace IsoTools {
}
public void FixIsoPosition() {
Position = IsoWorld.ScreenToIso(
position = isoWorld.ScreenToIso(
transform.position,
PositionZ);
positionZ);
}
void FixLastProperties() {
#if UNITY_EDITOR
_lastSize = Size;
_lastPosition = Position;
_lastSize = size;
_lastPosition = position;
_lastTransform = transform.position;
#endif
}
void MartDirtyIsoWorld() {
IsoWorld.MarkDirty(this);
isoWorld.MarkDirty(this);
}
void MarkEditorObjectDirty() {
@@ -253,28 +253,28 @@ namespace IsoTools {
#if UNITY_EDITOR
void Reset() {
Size = Vector3.one;
Position = Vector3.zero;
size = Vector3.one;
position = Vector3.zero;
}
void OnValidate() {
Size = _size;
Position = _position;
size = _size;
position = _position;
}
void OnDrawGizmos() {
if ( ShowBounds && IsoWorld ) {
IsoUtils.DrawCube(IsoWorld, Position + Size * 0.5f, Size, Color.red);
if ( isShowBounds && isoWorld ) {
IsoUtils.DrawCube(isoWorld, position + size * 0.5f, size, Color.red);
}
}
void Update() {
if ( Application.isEditor ) {
if ( !IsoUtils.Vec3Approximately(_lastSize, _size) ) {
Size = _size;
size = _size;
}
if ( !IsoUtils.Vec3Approximately(_lastPosition, _position) ) {
Position = _position;
position = _position;
}
if ( !IsoUtils.Vec2Approximately(_lastTransform, transform.position) ) {
FixIsoPosition();

View File

@@ -6,7 +6,7 @@ namespace IsoTools {
public class IsoPhysicHelper : MonoBehaviour {
GameObject _isoFakeObject = null;
public GameObject IsoFakeObject {
public GameObject isoFakeObject {
get { return _isoFakeObject; }
}

View File

@@ -3,18 +3,18 @@
namespace IsoTools {
public struct IsoRaycastHit {
public IsoCollider IsoCollider { get; private set; }
public float Distance { get; private set; }
public Vector3 Normal { get; private set; }
public Vector3 Point { get; private set; }
public IsoRigidbody IsoRigidbody { get; private set; }
public IsoCollider collider { get; private set; }
public float distance { get; private set; }
public Vector3 normal { get; private set; }
public Vector3 point { get; private set; }
public IsoRigidbody rigidbody { get; private set; }
public IsoRaycastHit(RaycastHit hit_info) {
IsoCollider = IsoUtils.IsoConvertCollider(hit_info.collider);
Distance = hit_info.distance;
Normal = hit_info.normal;
Point = hit_info.point;
IsoRigidbody = IsoUtils.IsoConvertRigidbody(hit_info.rigidbody);
collider = IsoUtils.IsoConvertCollider(hit_info.collider);
distance = hit_info.distance;
normal = hit_info.normal;
point = hit_info.point;
rigidbody = IsoUtils.IsoConvertRigidbody(hit_info.rigidbody);
}
}
} // namespace IsoTools

View File

@@ -10,136 +10,136 @@ namespace IsoTools {
public class IsoRigidbody : MonoBehaviour {
Rigidbody _realRigidbody = null;
protected Rigidbody RealRigidbody {
protected Rigidbody realRigidbody {
get { return _realRigidbody; }
}
protected GameObject IsoFakeObject {
protected GameObject fakeObject {
get {
var helper = IsoUtils.GetOrCreateComponent<IsoPhysicHelper>(gameObject);
return helper ? helper.IsoFakeObject : null;
return helper ? helper.isoFakeObject : null;
}
}
[SerializeField]
public bool _isKinematic = false;
public bool IsKinematic {
public bool isKinematic {
get { return _isKinematic; }
set {
_isKinematic = value;
if ( RealRigidbody ) {
RealRigidbody.isKinematic = value;
if ( realRigidbody ) {
realRigidbody.isKinematic = value;
}
}
}
[SerializeField]
public RigidbodyInterpolation _interpolation = RigidbodyInterpolation.None;
public RigidbodyInterpolation Interpolation {
public RigidbodyInterpolation interpolation {
get { return _interpolation; }
set {
_interpolation = value;
if ( RealRigidbody ) {
RealRigidbody.interpolation = value;
if ( realRigidbody ) {
realRigidbody.interpolation = value;
}
}
}
[SerializeField]
public CollisionDetectionMode _collisionDetectionMode = CollisionDetectionMode.Discrete;
public CollisionDetectionMode CollisionDetectionMode {
public CollisionDetectionMode collisionDetectionMode {
get { return _collisionDetectionMode; }
set {
_collisionDetectionMode = value;
if ( RealRigidbody ) {
RealRigidbody.collisionDetectionMode = value;
if ( realRigidbody ) {
realRigidbody.collisionDetectionMode = value;
}
}
}
public Vector3 CenterOfMass {
get { return RealRigidbody ? RealRigidbody.centerOfMass : Vector3.zero; }
public Vector3 centerOfMass {
get { return realRigidbody ? realRigidbody.centerOfMass : Vector3.zero; }
set {
if ( RealRigidbody ) {
RealRigidbody.centerOfMass = value;
if ( realRigidbody ) {
realRigidbody.centerOfMass = value;
}
}
}
public float Drag {
get { return RealRigidbody ? RealRigidbody.drag : 0.0f; }
public float drag {
get { return realRigidbody ? realRigidbody.drag : 0.0f; }
set {
if ( RealRigidbody ) {
RealRigidbody.drag = value;
if ( realRigidbody ) {
realRigidbody.drag = value;
}
}
}
public Vector3 InertiaTensor {
get { return RealRigidbody ? RealRigidbody.inertiaTensor : Vector3.zero; }
public Vector3 inertiaTensor {
get { return realRigidbody ? realRigidbody.inertiaTensor : Vector3.zero; }
set {
if ( RealRigidbody ) {
RealRigidbody.inertiaTensor = value;
if ( realRigidbody ) {
realRigidbody.inertiaTensor = value;
}
}
}
public float Mass {
get { return RealRigidbody ? RealRigidbody.mass : 0.0f; }
public float mass {
get { return realRigidbody ? realRigidbody.mass : 0.0f; }
set {
if ( RealRigidbody ) {
RealRigidbody.mass = value;
if ( realRigidbody ) {
realRigidbody.mass = value;
}
}
}
public float MaxDepenetrationVelocity {
get { return RealRigidbody ? RealRigidbody.maxDepenetrationVelocity : 0.0f; }
public float maxDepenetrationVelocity {
get { return realRigidbody ? realRigidbody.maxDepenetrationVelocity : 0.0f; }
set {
if ( RealRigidbody ) {
RealRigidbody.maxDepenetrationVelocity = value;
if ( realRigidbody ) {
realRigidbody.maxDepenetrationVelocity = value;
}
}
}
public float SleepThreshold {
get { return RealRigidbody ? RealRigidbody.sleepThreshold : 0.0f; }
public float sleepThreshold {
get { return realRigidbody ? realRigidbody.sleepThreshold : 0.0f; }
set {
if ( RealRigidbody ) {
RealRigidbody.sleepThreshold = value;
if ( realRigidbody ) {
realRigidbody.sleepThreshold = value;
}
}
}
public int SolverIterationCount {
get { return RealRigidbody ? RealRigidbody.solverIterationCount : 0; }
public int solverIterationCount {
get { return realRigidbody ? realRigidbody.solverIterationCount : 0; }
set {
if ( RealRigidbody ) {
RealRigidbody.solverIterationCount = value;
if ( realRigidbody ) {
realRigidbody.solverIterationCount = value;
}
}
}
public bool UseGravity {
get { return RealRigidbody ? RealRigidbody.useGravity : false; }
public bool useGravity {
get { return realRigidbody ? realRigidbody.useGravity : false; }
set {
if ( RealRigidbody ) {
RealRigidbody.useGravity = value;
if ( realRigidbody ) {
realRigidbody.useGravity = value;
}
}
}
public Vector3 Velocity {
get { return RealRigidbody ? RealRigidbody.velocity : Vector3.zero; }
public Vector3 velocity {
get { return realRigidbody ? realRigidbody.velocity : Vector3.zero; }
set {
if ( RealRigidbody ) {
RealRigidbody.velocity = value;
if ( realRigidbody ) {
realRigidbody.velocity = value;
}
}
}
public Vector3 worldCenterOfMass {
get { return RealRigidbody ? RealRigidbody.worldCenterOfMass : Vector3.zero; }
get { return realRigidbody ? realRigidbody.worldCenterOfMass : Vector3.zero; }
}
public void AddExplosionForce(
@@ -163,8 +163,8 @@ namespace IsoTools {
float explosion_force, Vector3 explosion_position, float explosion_radius,
float upwards_modifier, ForceMode mode)
{
if ( RealRigidbody ) {
RealRigidbody.AddExplosionForce(
if ( realRigidbody ) {
realRigidbody.AddExplosionForce(
explosion_force, explosion_position, explosion_radius,
upwards_modifier, mode);
}
@@ -175,8 +175,8 @@ namespace IsoTools {
}
public void AddForce(Vector3 force, ForceMode mode) {
if ( RealRigidbody ) {
RealRigidbody.AddForce(force, mode);
if ( realRigidbody ) {
realRigidbody.AddForce(force, mode);
}
}
@@ -185,8 +185,8 @@ namespace IsoTools {
}
public void AddRelativeForce(Vector3 force, ForceMode mode) {
if ( RealRigidbody ) {
RealRigidbody.AddRelativeForce(force, mode);
if ( realRigidbody ) {
realRigidbody.AddRelativeForce(force, mode);
}
}
@@ -195,38 +195,38 @@ namespace IsoTools {
}
public void AddForceAtPosition(Vector3 force, Vector3 position, ForceMode mode) {
if ( RealRigidbody ) {
RealRigidbody.AddForceAtPosition(force, position, mode);
if ( realRigidbody ) {
realRigidbody.AddForceAtPosition(force, position, mode);
}
}
public Vector3 ClosestPointOnBounds(Vector3 position) {
return RealRigidbody
? RealRigidbody.ClosestPointOnBounds(position)
return realRigidbody
? realRigidbody.ClosestPointOnBounds(position)
: Vector3.zero;
}
public bool IsSleeping() {
return RealRigidbody
? RealRigidbody.IsSleeping()
return realRigidbody
? realRigidbody.IsSleeping()
: false;
}
public void SetDensity(float density) {
if ( RealRigidbody ) {
RealRigidbody.SetDensity(density);
if ( realRigidbody ) {
realRigidbody.SetDensity(density);
}
}
public void Sleep() {
if ( RealRigidbody ) {
RealRigidbody.Sleep();
if ( realRigidbody ) {
realRigidbody.Sleep();
}
}
public void WakeUp() {
if ( RealRigidbody ) {
RealRigidbody.WakeUp();
if ( realRigidbody ) {
realRigidbody.WakeUp();
}
}
@@ -236,8 +236,8 @@ namespace IsoTools {
public bool SweepTest(Vector3 direction, out IsoRaycastHit iso_hit_info, float max_distance) {
RaycastHit hit_info;
var result = RealRigidbody
? RealRigidbody.SweepTest(direction, out hit_info, max_distance)
var result = realRigidbody
? realRigidbody.SweepTest(direction, out hit_info, max_distance)
: false;
iso_hit_info = result ? new IsoRaycastHit(hit_info) : new IsoRaycastHit();
return result;
@@ -248,35 +248,35 @@ namespace IsoTools {
}
public IsoRaycastHit[] SweepTestAll(Vector3 direction, float max_distance) {
return RealRigidbody
? IsoUtils.IsoConvertRaycastHits(RealRigidbody.SweepTestAll(direction, max_distance))
return realRigidbody
? IsoUtils.IsoConvertRaycastHits(realRigidbody.SweepTestAll(direction, max_distance))
: new IsoRaycastHit[0];
}
void Awake() {
IsoFakeObject.AddComponent<IsoFakeRigidbody>().Init(this);
_realRigidbody = IsoFakeObject.AddComponent<Rigidbody>();
fakeObject.AddComponent<IsoFakeRigidbody>().Init(this);
_realRigidbody = fakeObject.AddComponent<Rigidbody>();
_realRigidbody.freezeRotation = true;
_realRigidbody.isKinematic = IsKinematic;
_realRigidbody.interpolation = Interpolation;
_realRigidbody.collisionDetectionMode = CollisionDetectionMode;
_realRigidbody.isKinematic = isKinematic;
_realRigidbody.interpolation = interpolation;
_realRigidbody.collisionDetectionMode = collisionDetectionMode;
}
void OnEnable() {
if ( RealRigidbody ) {
RealRigidbody.detectCollisions = true;
if ( realRigidbody ) {
realRigidbody.detectCollisions = true;
}
}
void OnDisable() {
if ( RealRigidbody ) {
RealRigidbody.detectCollisions = false;
if ( realRigidbody ) {
realRigidbody.detectCollisions = false;
}
}
void OnDestroy() {
if ( _realRigidbody ) {
Destroy(IsoFakeObject.GetComponent<IsoFakeRigidbody>());
Destroy(fakeObject.GetComponent<IsoFakeRigidbody>());
Destroy(_realRigidbody);
_realRigidbody = null;
}
@@ -284,17 +284,17 @@ namespace IsoTools {
#if UNITY_EDITOR
void Reset() {
IsKinematic = false;
Interpolation = RigidbodyInterpolation.None;
CollisionDetectionMode = CollisionDetectionMode.Discrete;
isKinematic = false;
interpolation = RigidbodyInterpolation.None;
collisionDetectionMode = CollisionDetectionMode.Discrete;
EditorUtility.SetDirty(this);
}
void OnValidate() {
if ( RealRigidbody ) {
RealRigidbody.isKinematic = IsKinematic;
RealRigidbody.interpolation = Interpolation;
RealRigidbody.collisionDetectionMode = CollisionDetectionMode;
if ( realRigidbody ) {
realRigidbody.isKinematic = isKinematic;
realRigidbody.interpolation = interpolation;
realRigidbody.collisionDetectionMode = collisionDetectionMode;
}
}
#endif

View File

@@ -10,63 +10,63 @@ namespace IsoTools {
[SerializeField]
public float _radius = 0.0f;
public float Radius {
public float radius {
get { return _radius; }
set {
_radius = value;
if ( RealSphereCollider ) {
RealSphereCollider.radius = value;
if ( realSphereCollider ) {
realSphereCollider.radius = value;
}
}
}
[SerializeField]
public Vector3 _offset = Vector3.zero;
public Vector3 Offset {
public Vector3 offset {
get { return _offset; }
set {
_offset = value;
if ( RealSphereCollider ) {
RealSphereCollider.center = value;
if ( realSphereCollider ) {
realSphereCollider.center = value;
}
}
}
protected override Collider CreateRealCollider(GameObject target) {
var collider = target.AddComponent<SphereCollider>();
collider.radius = Radius;
collider.center = Offset;
collider.radius = radius;
collider.center = offset;
return collider;
}
public SphereCollider RealSphereCollider {
get { return RealCollider as SphereCollider; }
public SphereCollider realSphereCollider {
get { return realCollider as SphereCollider; }
}
#if UNITY_EDITOR
protected override void Reset() {
base.Reset();
var iso_object = GetComponent<IsoObject>();
Radius = iso_object ? IsoUtils.Vec3MinF(iso_object.Size) * 0.5f : 0.0f;
Offset = iso_object ? iso_object.Size * 0.5f : Vector3.zero;
radius = iso_object ? IsoUtils.Vec3MinF(iso_object.size) * 0.5f : 0.0f;
offset = iso_object ? iso_object.size * 0.5f : Vector3.zero;
EditorUtility.SetDirty(this);
}
protected override void OnValidate() {
base.OnValidate();
if ( RealSphereCollider ) {
RealSphereCollider.radius = Radius;
RealSphereCollider.center = Offset;
if ( realSphereCollider ) {
realSphereCollider.radius = radius;
realSphereCollider.center = offset;
}
}
void OnDrawGizmosSelected() {
var iso_object = GetComponent<IsoObject>();
if ( iso_object && iso_object.IsoWorld ) {
if ( iso_object && iso_object.isoWorld ) {
IsoUtils.DrawSphere(
iso_object.IsoWorld,
iso_object.Position + Offset,
Radius,
iso_object.isoWorld,
iso_object.position + offset,
radius,
Color.green);
}
}

View File

@@ -13,16 +13,16 @@ namespace IsoTools {
//
// ---------------------------------------------------------------------
public static Vector3 Vec2OneX { get { return new Vector2(1.0f, 0.0f); } }
public static Vector3 Vec2OneY { get { return new Vector2(0.0f, 1.0f); } }
public static Vector3 Vec2OneXY { get { return new Vector2(1.0f, 1.0f); } }
public static Vector3 vec2OneX { get { return new Vector2(1.0f, 0.0f); } }
public static Vector3 vec2OneY { get { return new Vector2(0.0f, 1.0f); } }
public static Vector3 vec2OneXY { get { return new Vector2(1.0f, 1.0f); } }
public static Vector3 Vec3OneX { get { return new Vector3(1.0f, 0.0f, 0.0f); } }
public static Vector3 Vec3OneY { get { return new Vector3(0.0f, 1.0f, 0.0f); } }
public static Vector3 Vec3OneZ { get { return new Vector3(0.0f, 0.0f, 1.0f); } }
public static Vector3 Vec3OneXY { get { return new Vector3(1.0f, 1.0f, 0.0f); } }
public static Vector3 Vec3OneYZ { get { return new Vector3(0.0f, 1.0f, 1.0f); } }
public static Vector3 Vec3OneXZ { get { return new Vector3(1.0f, 0.0f, 1.0f); } }
public static Vector3 vec3OneX { get { return new Vector3(1.0f, 0.0f, 0.0f); } }
public static Vector3 vec3OneY { get { return new Vector3(0.0f, 1.0f, 0.0f); } }
public static Vector3 vec3OneZ { get { return new Vector3(0.0f, 0.0f, 1.0f); } }
public static Vector3 vec3OneXY { get { return new Vector3(1.0f, 1.0f, 0.0f); } }
public static Vector3 vec3OneYZ { get { return new Vector3(0.0f, 1.0f, 1.0f); } }
public static Vector3 vec3OneXZ { get { return new Vector3(1.0f, 0.0f, 1.0f); } }
// ---------------------------------------------------------------------
//
@@ -372,17 +372,17 @@ namespace IsoTools {
public static IsoCollider IsoConvertCollider(Collider collider) {
var fake_collider = collider ? collider.GetComponent<IsoFakeCollider>() : null;
return fake_collider ? fake_collider.IsoCollider : null;
return fake_collider ? fake_collider.isoCollider : null;
}
public static IsoRigidbody IsoConvertRigidbody(Rigidbody rigidbody) {
var fake_rigidbody = rigidbody ? rigidbody.GetComponent<IsoFakeRigidbody>() : null;
return fake_rigidbody ? fake_rigidbody.IsoRigidbody : null;
return fake_rigidbody ? fake_rigidbody.isoRigidbody : null;
}
public static GameObject IsoConvertGameObject(GameObject game_object) {
var fake_object = game_object ? game_object.GetComponent<IsoFakeObject>() : null;
var iso_object = fake_object ? fake_object.IsoObject : null;
var iso_object = fake_object ? fake_object.isoObject : null;
return iso_object ? iso_object.gameObject : null;
}
@@ -452,7 +452,7 @@ namespace IsoTools {
Handles.RadiusHandle(
Quaternion.Euler(45.0f, 45.0f, 0.0f),
iso_world.IsoToScreen(pos),
radius * iso_world.TileSize * 2.0f);
radius * iso_world.tileSize * 2.0f);
}
}
#endif

View File

@@ -12,31 +12,31 @@ namespace IsoTools {
public class IsoWorld : MonoBehaviour {
class ObjectInfo {
public int Index;
public IsoObject IsoObject;
public Vector3 MinSector;
public Vector3 MaxSector;
public int index;
public IsoObject isoObject;
public Vector3 minSector;
public Vector3 maxSector;
public bool Visited;
public int BeginDepend;
public int EndDepend;
public bool visited;
public int beginDepend;
public int endDepend;
public ObjectInfo(int index, IsoObject iso_object, Vector3 min_sector, Vector3 max_sector) {
Index = index;
IsoObject = iso_object;
MinSector = min_sector;
MaxSector = max_sector;
this.index = index;
this.isoObject = iso_object;
this.minSector = min_sector;
this.maxSector = max_sector;
}
public void Init(int first_depend) {
Visited = false;
BeginDepend = first_depend;
EndDepend = first_depend;
this.visited = false;
this.beginDepend = first_depend;
this.endDepend = first_depend;
}
}
class SectorInfo {
public List<int> Objects = new List<int>();
public List<int> objects = new List<int>();
}
bool _dirty = true;
@@ -52,7 +52,7 @@ namespace IsoTools {
[SerializeField]
public float _tileSize = 32.0f;
/// <summary>Isometric tile size.</summary>
public float TileSize {
public float tileSize {
get { return _tileSize; }
set {
_tileSize = Mathf.Max(value, Mathf.Epsilon);
@@ -63,7 +63,7 @@ namespace IsoTools {
[SerializeField]
public float _minDepth = 0.0f;
/// <summary>Min sorting depth value.</summary>
public float MinDepth {
public float minDepth {
get { return _minDepth; }
set {
_minDepth = value;
@@ -74,7 +74,7 @@ namespace IsoTools {
[SerializeField]
public float _maxDepth = 100.0f;
/// <summary>Max sorting depth value.</summary>
public float MaxDepth {
public float maxDepth {
get { return _maxDepth; }
set {
_maxDepth = value;
@@ -114,7 +114,7 @@ namespace IsoTools {
public Vector2 IsoToScreen(Vector3 pos) {
return new Vector2(
(pos.x - pos.y),
(pos.x + pos.y) * 0.5f + pos.z) * TileSize;
(pos.x + pos.y) * 0.5f + pos.z) * tileSize;
}
// ------------------------------------------------------------------------
@@ -128,7 +128,7 @@ namespace IsoTools {
return new Vector3(
(pos.x * 0.5f + pos.y),
(pos.y - pos.x * 0.5f),
0.0f) / TileSize;
0.0f) / tileSize;
}
// ------------------------------------------------------------------------
@@ -141,7 +141,7 @@ namespace IsoTools {
// ------------------------------------------------------------------------
public Vector3 ScreenToIso(Vector2 pos, float iso_z) {
return IsoUtils.Vec3ChangeZ(
ScreenToIso(new Vector2(pos.x, pos.y - iso_z * TileSize)),
ScreenToIso(new Vector2(pos.x, pos.y - iso_z * tileSize)),
iso_z);
}
@@ -289,7 +289,7 @@ namespace IsoTools {
var objsSum = 0;
foreach ( var obj in _visibles ) {
++objsSum;
_objsSectorSize += Mathf.Max(obj.Size.x, obj.Size.y, obj.Size.z);
_objsSectorSize += IsoUtils.Vec3MaxF(obj.size);
}
_objsSectorSize = Mathf.Round(Mathf.Max(3.0f, _objsSectorSize / objsSum));
}
@@ -299,9 +299,9 @@ namespace IsoTools {
_objsMinNumPos = Vector3.zero;
_objsMaxNumPos = Vector3.one;
foreach ( var obj in _visibles ) {
var max_size = IsoUtils.Vec3Max(Vector3.one, obj.Size);
var min_npos = IsoUtils.Vec3DivFloor(obj.Position, _objsSectorSize);
var max_npos = IsoUtils.Vec3DivCeil(obj.Position + max_size, _objsSectorSize);
var max_size = IsoUtils.Vec3Max(Vector3.one, obj.size);
var min_npos = IsoUtils.Vec3DivFloor(obj.position, _objsSectorSize);
var max_npos = IsoUtils.Vec3DivCeil(obj.position + max_size, _objsSectorSize);
_objsMinNumPos = IsoUtils.Vec3Min(_objsMinNumPos, min_npos);
_objsMaxNumPos = IsoUtils.Vec3Max(_objsMaxNumPos, max_npos);
_objects.Add(new ObjectInfo(_objects.Count, obj, min_npos, max_npos));
@@ -316,12 +316,12 @@ namespace IsoTools {
_sectors.Add(new SectorInfo());
}
foreach ( var obj in _objects ) {
obj.MinSector -= _objsMinNumPos;
obj.MaxSector -= _objsMinNumPos;
IsoUtils.LookUpCube(obj.MinSector, obj.MaxSector, p => {
obj.minSector -= _objsMinNumPos;
obj.maxSector -= _objsMinNumPos;
IsoUtils.LookUpCube(obj.minSector, obj.maxSector, p => {
var sector = FindSector(p);
if ( sector != null ) {
sector.Objects.Add(obj.Index);
sector.objects.Add(obj.index);
}
});
}
@@ -331,14 +331,14 @@ namespace IsoTools {
_depends.Clear();
foreach ( var obj_a in _objects ) {
obj_a.Init(_depends.Count);
var obj_ao = obj_a.IsoObject;
IsoUtils.LookUpCube(obj_a.MinSector, obj_a.MaxSector, num_pos => {
var obj_ao = obj_a.isoObject;
IsoUtils.LookUpCube(obj_a.minSector, obj_a.maxSector, num_pos => {
LookUpSectorDepends(num_pos, sec => {
foreach ( var obj_bi in sec.Objects ) {
var obj_bo = _objects[obj_bi].IsoObject;
if ( obj_ao != obj_bo && IsDepends(obj_ao.Position, obj_ao.Size, obj_bo.Position, obj_bo.Size) ) {
foreach ( var obj_bi in sec.objects ) {
var obj_bo = _objects[obj_bi].isoObject;
if ( obj_ao != obj_bo && IsDepends(obj_ao.position, obj_ao.size, obj_bo.position, obj_bo.size) ) {
_depends.Add(obj_bi);
++obj_a.EndDepend;
++obj_a.endDepend;
}
}
});
@@ -347,7 +347,7 @@ namespace IsoTools {
}
void PlaceAllObjects() {
var depth = MinDepth;
var depth = minDepth;
foreach ( var info in _objects ) {
depth = PlaceObject(info, depth);
}
@@ -362,17 +362,17 @@ namespace IsoTools {
}
float PlaceObject(ObjectInfo info, float depth) {
if ( info.Visited ) {
if ( info.visited ) {
return depth;
}
info.Visited = true;
for ( var i = info.BeginDepend; i < info.EndDepend && i < _depends.Count; ++i ) {
info.visited = true;
for ( var i = info.beginDepend; i < info.endDepend && i < _depends.Count; ++i ) {
var obj_index = _depends[i];
var obj = _objects[obj_index];
depth = PlaceObject(obj, depth);
}
PlaceObject(info.IsoObject, depth);
return depth + (MaxDepth - MinDepth) / _objects.Count;
PlaceObject(info.isoObject, depth);
return depth + (maxDepth - minDepth) / _objects.Count;
}
void StepSort() {
@@ -407,15 +407,15 @@ namespace IsoTools {
#if UNITY_EDITOR
void Reset() {
TileSize = 32.0f;
MinDepth = 0.0f;
MaxDepth = 100.0f;
tileSize = 32.0f;
minDepth = 0.0f;
maxDepth = 100.0f;
}
void OnValidate() {
TileSize = _tileSize;
MinDepth = _minDepth;
MaxDepth = _maxDepth;
tileSize = _tileSize;
minDepth = _minDepth;
maxDepth = _maxDepth;
}
void OnRenderObject() {