From 83ced8f772bdd89e672290769f882fef53054402 Mon Sep 17 00:00:00 2001 From: BlackMATov Date: Sat, 22 Oct 2016 18:18:27 +0700 Subject: [PATCH] example script to separate folders --- Assembly-CSharp.csproj | 14 +++---- .../Examples/Scripts/CubeAutoMovement.cs | 33 ----------------- Assets/IsoTools/Examples/Scripts/Kenney.meta | 9 +++++ .../{ => Kenney}/AlienBallController.cs | 6 +-- .../{ => Kenney}/AlienBallController.cs.meta | 0 .../Scripts/{ => Kenney}/AlienBallSpawner.cs | 9 +++-- .../{ => Kenney}/AlienBallSpawner.cs.meta | 0 .../Scripts/{ => Kenney}/AlienDestroyer.cs | 6 +-- .../{ => Kenney}/AlienDestroyer.cs.meta | 0 .../PhysicEchoListener.cs} | 6 +-- .../PhysicEchoListener.cs.meta} | 0 .../Scripts/{ => Kenney}/PlayerController.cs | 4 +- .../{ => Kenney}/PlayerController.cs.meta | 0 .../Examples/Scripts/SceneController.cs | 19 +++------- Assets/IsoTools/Examples/Scripts/Simple.meta | 9 +++++ .../Scripts/{ => Simple}/CircleFly.cs | 4 +- .../Scripts/{ => Simple}/CircleFly.cs.meta | 0 .../Scripts/Simple/CubeAutoMovement.cs | 37 +++++++++++++++++++ .../{ => Simple}/CubeAutoMovement.cs.meta | 0 19 files changed, 87 insertions(+), 69 deletions(-) delete mode 100644 Assets/IsoTools/Examples/Scripts/CubeAutoMovement.cs create mode 100644 Assets/IsoTools/Examples/Scripts/Kenney.meta rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/AlienBallController.cs (90%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/AlienBallController.cs.meta (100%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/AlienBallSpawner.cs (79%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/AlienBallSpawner.cs.meta (100%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/AlienDestroyer.cs (80%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/AlienDestroyer.cs.meta (100%) rename Assets/IsoTools/Examples/Scripts/{IsoEchoListener.cs => Kenney/PhysicEchoListener.cs} (88%) rename Assets/IsoTools/Examples/Scripts/{IsoEchoListener.cs.meta => Kenney/PhysicEchoListener.cs.meta} (100%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/PlayerController.cs (95%) rename Assets/IsoTools/Examples/Scripts/{ => Kenney}/PlayerController.cs.meta (100%) create mode 100644 Assets/IsoTools/Examples/Scripts/Simple.meta rename Assets/IsoTools/Examples/Scripts/{ => Simple}/CircleFly.cs (89%) rename Assets/IsoTools/Examples/Scripts/{ => Simple}/CircleFly.cs.meta (100%) create mode 100644 Assets/IsoTools/Examples/Scripts/Simple/CubeAutoMovement.cs rename Assets/IsoTools/Examples/Scripts/{ => Simple}/CubeAutoMovement.cs.meta (100%) diff --git a/Assembly-CSharp.csproj b/Assembly-CSharp.csproj index 9a3c8a6..2ed466a 100644 --- a/Assembly-CSharp.csproj +++ b/Assembly-CSharp.csproj @@ -87,14 +87,14 @@ - - - - - - - + + + + + + + diff --git a/Assets/IsoTools/Examples/Scripts/CubeAutoMovement.cs b/Assets/IsoTools/Examples/Scripts/CubeAutoMovement.cs deleted file mode 100644 index 50b8f25..0000000 --- a/Assets/IsoTools/Examples/Scripts/CubeAutoMovement.cs +++ /dev/null @@ -1,33 +0,0 @@ -using UnityEngine; -using System.Collections; - -namespace IsoTools.Examples { - public class CubeAutoMovement : MonoBehaviour { - 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)); - } - - IEnumerator Move() { - var iso_object = GetComponent(); - if ( iso_object ) { - for (;;) { - yield return RndWait(); - iso_object.position += new Vector3(1, 0, 0); - yield return RndWait(); - iso_object.position += new Vector3(0, 1, 0); - yield return RndWait(); - iso_object.position += new Vector3(-1, 0, 0); - yield return RndWait(); - iso_object.position += new Vector3(0, -1, 0); - } - } - } - } -} // namespace IsoTools.Examples \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/Kenney.meta b/Assets/IsoTools/Examples/Scripts/Kenney.meta new file mode 100644 index 0000000..2a842f9 --- /dev/null +++ b/Assets/IsoTools/Examples/Scripts/Kenney.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 66f999d096e6f49eabd1470c91178c1d +folderAsset: yes +timeCreated: 1477133717 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/Examples/Scripts/AlienBallController.cs b/Assets/IsoTools/Examples/Scripts/Kenney/AlienBallController.cs similarity index 90% rename from Assets/IsoTools/Examples/Scripts/AlienBallController.cs rename to Assets/IsoTools/Examples/Scripts/Kenney/AlienBallController.cs index 76a7e30..5802aaa 100644 --- a/Assets/IsoTools/Examples/Scripts/AlienBallController.cs +++ b/Assets/IsoTools/Examples/Scripts/Kenney/AlienBallController.cs @@ -1,7 +1,7 @@ using UnityEngine; using System.Collections; -namespace IsoTools.Examples { +namespace IsoTools.Examples.Kenney { [RequireComponent(typeof(IsoRigidbody))] public class AlienBallController : MonoBehaviour { @@ -17,7 +17,7 @@ namespace IsoTools.Examples { if ( !_isoRigidbody ) { throw new UnityException("AlienBallController. IsoRigidbody component not found!"); } - StartCoroutine("AddRndForce"); + StartCoroutine(AddRndForce()); } void Update() { @@ -35,4 +35,4 @@ namespace IsoTools.Examples { } } } -} // namespace IsoTools.Examples \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/AlienBallController.cs.meta b/Assets/IsoTools/Examples/Scripts/Kenney/AlienBallController.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/AlienBallController.cs.meta rename to Assets/IsoTools/Examples/Scripts/Kenney/AlienBallController.cs.meta diff --git a/Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs b/Assets/IsoTools/Examples/Scripts/Kenney/AlienBallSpawner.cs similarity index 79% rename from Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs rename to Assets/IsoTools/Examples/Scripts/Kenney/AlienBallSpawner.cs index 268d9f8..edfc418 100644 --- a/Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs +++ b/Assets/IsoTools/Examples/Scripts/Kenney/AlienBallSpawner.cs @@ -1,14 +1,17 @@ using UnityEngine; using System.Collections; -namespace IsoTools.Examples { +namespace IsoTools.Examples.Kenney { public class AlienBallSpawner : MonoBehaviour { public int maxAlienCount = 10; public GameObject alienBallPrefab = null; void Start() { - StartCoroutine("SpawnAlienBall"); + if ( !alienBallPrefab ) { + throw new UnityException("AlienBallSpawner. Alien ball prefab not found!"); + } + StartCoroutine(SpawnAlienBall()); } IEnumerator SpawnAlienBall() { @@ -25,4 +28,4 @@ namespace IsoTools.Examples { } } } -} // namespace IsoTools.Examples \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs.meta b/Assets/IsoTools/Examples/Scripts/Kenney/AlienBallSpawner.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs.meta rename to Assets/IsoTools/Examples/Scripts/Kenney/AlienBallSpawner.cs.meta diff --git a/Assets/IsoTools/Examples/Scripts/AlienDestroyer.cs b/Assets/IsoTools/Examples/Scripts/Kenney/AlienDestroyer.cs similarity index 80% rename from Assets/IsoTools/Examples/Scripts/AlienDestroyer.cs rename to Assets/IsoTools/Examples/Scripts/Kenney/AlienDestroyer.cs index 704dc85..316e0f6 100644 --- a/Assets/IsoTools/Examples/Scripts/AlienDestroyer.cs +++ b/Assets/IsoTools/Examples/Scripts/Kenney/AlienDestroyer.cs @@ -1,7 +1,7 @@ using UnityEngine; using System.Collections; -namespace IsoTools.Examples { +namespace IsoTools.Examples.Kenney { public class AlienDestroyer : MonoBehaviour { void Update () { var iso_world = IsoWorld.Instance; @@ -9,8 +9,8 @@ namespace IsoTools.Examples { var iso_mouse_pos = iso_world.MouseIsoPosition(); var ray_from_iso_camera = iso_world.RayFromIsoCameraToIsoPoint(iso_mouse_pos); var hits = iso_world.RaycastAll(ray_from_iso_camera); - foreach ( var hit in hits ) { - var alien_go = hit.collider.gameObject; + for ( var i = 0; i < hits.Length; ++i ) { + var alien_go = hits[i].collider.gameObject; if ( alien_go.GetComponent() ) { Destroy(alien_go); } diff --git a/Assets/IsoTools/Examples/Scripts/AlienDestroyer.cs.meta b/Assets/IsoTools/Examples/Scripts/Kenney/AlienDestroyer.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/AlienDestroyer.cs.meta rename to Assets/IsoTools/Examples/Scripts/Kenney/AlienDestroyer.cs.meta diff --git a/Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs b/Assets/IsoTools/Examples/Scripts/Kenney/PhysicEchoListener.cs similarity index 88% rename from Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs rename to Assets/IsoTools/Examples/Scripts/Kenney/PhysicEchoListener.cs index a48158a..428fadc 100644 --- a/Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs +++ b/Assets/IsoTools/Examples/Scripts/Kenney/PhysicEchoListener.cs @@ -1,9 +1,9 @@ using UnityEngine; using System.Collections; -namespace IsoTools.Examples { +namespace IsoTools.Examples.Kenney { [RequireComponent(typeof(IsoTriggerListener), typeof(IsoCollisionListener))] - public class IsoEchoListener : MonoBehaviour { + public class PhysicEchoListener : MonoBehaviour { void OnIsoTriggerEnter(IsoCollider iso_collider) { Debug.LogFormat( "OnIsoTriggerEnter. self:{0} other:{1}", @@ -28,4 +28,4 @@ namespace IsoTools.Examples { gameObject.name, iso_collision.gameObject.name); } } -} // namespace IsoTools.Examples \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs.meta b/Assets/IsoTools/Examples/Scripts/Kenney/PhysicEchoListener.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/IsoEchoListener.cs.meta rename to Assets/IsoTools/Examples/Scripts/Kenney/PhysicEchoListener.cs.meta diff --git a/Assets/IsoTools/Examples/Scripts/PlayerController.cs b/Assets/IsoTools/Examples/Scripts/Kenney/PlayerController.cs similarity index 95% rename from Assets/IsoTools/Examples/Scripts/PlayerController.cs rename to Assets/IsoTools/Examples/Scripts/Kenney/PlayerController.cs index 60e0c62..9996cd7 100644 --- a/Assets/IsoTools/Examples/Scripts/PlayerController.cs +++ b/Assets/IsoTools/Examples/Scripts/Kenney/PlayerController.cs @@ -1,6 +1,6 @@ using UnityEngine; -namespace IsoTools.Examples { +namespace IsoTools.Examples.Kenney { [RequireComponent(typeof(IsoRigidbody))] public class PlayerController : MonoBehaviour { @@ -47,4 +47,4 @@ namespace IsoTools.Examples { } } } -} // namespace IsoTools.Examples \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/PlayerController.cs.meta b/Assets/IsoTools/Examples/Scripts/Kenney/PlayerController.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/PlayerController.cs.meta rename to Assets/IsoTools/Examples/Scripts/Kenney/PlayerController.cs.meta diff --git a/Assets/IsoTools/Examples/Scripts/SceneController.cs b/Assets/IsoTools/Examples/Scripts/SceneController.cs index 5f3a52d..ea856a2 100644 --- a/Assets/IsoTools/Examples/Scripts/SceneController.cs +++ b/Assets/IsoTools/Examples/Scripts/SceneController.cs @@ -1,9 +1,6 @@ using UnityEngine; using UnityEngine.UI; - -#if UNITY_5_3_OR_NEWER using UnityEngine.SceneManagement; -#endif namespace IsoTools.Examples { public class SceneController : MonoBehaviour { @@ -29,19 +26,15 @@ namespace IsoTools.Examples { } public void NextScene() { - #if UNITY_5_3_OR_NEWER - SceneManager.LoadScene(NextSceneName); - #else - Application.LoadLevel(NextSceneName); - #endif + if ( !string.IsNullOrEmpty(NextSceneName) ) { + SceneManager.LoadScene(NextSceneName); + } } public void PrevScene() { - #if UNITY_5_3_OR_NEWER - SceneManager.LoadScene(PrevSceneName); - #else - Application.LoadLevel(PrevSceneName); - #endif + if ( !string.IsNullOrEmpty(PrevSceneName) ) { + SceneManager.LoadScene(PrevSceneName); + } } } } \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/Simple.meta b/Assets/IsoTools/Examples/Scripts/Simple.meta new file mode 100644 index 0000000..4300949 --- /dev/null +++ b/Assets/IsoTools/Examples/Scripts/Simple.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: a185e32da5ddc49f4ac1eb35ae3664f0 +folderAsset: yes +timeCreated: 1477134153 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/IsoTools/Examples/Scripts/CircleFly.cs b/Assets/IsoTools/Examples/Scripts/Simple/CircleFly.cs similarity index 89% rename from Assets/IsoTools/Examples/Scripts/CircleFly.cs rename to Assets/IsoTools/Examples/Scripts/Simple/CircleFly.cs index 482614f..198d66d 100644 --- a/Assets/IsoTools/Examples/Scripts/CircleFly.cs +++ b/Assets/IsoTools/Examples/Scripts/Simple/CircleFly.cs @@ -1,7 +1,7 @@ using UnityEngine; using System.Collections; -namespace IsoTools.Examples { +namespace IsoTools.Examples.Simple { public class CircleFly : MonoBehaviour { public float flyRadius = 150.0f; public float flySpeed = 1.0f; @@ -22,4 +22,4 @@ namespace IsoTools.Examples { _start_pos.z); } } -} // namespace IsoTools.Examples \ No newline at end of file +} \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/CircleFly.cs.meta b/Assets/IsoTools/Examples/Scripts/Simple/CircleFly.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/CircleFly.cs.meta rename to Assets/IsoTools/Examples/Scripts/Simple/CircleFly.cs.meta diff --git a/Assets/IsoTools/Examples/Scripts/Simple/CubeAutoMovement.cs b/Assets/IsoTools/Examples/Scripts/Simple/CubeAutoMovement.cs new file mode 100644 index 0000000..0d8e401 --- /dev/null +++ b/Assets/IsoTools/Examples/Scripts/Simple/CubeAutoMovement.cs @@ -0,0 +1,37 @@ +using UnityEngine; +using System.Collections; + +namespace IsoTools.Examples.Simple { + [RequireComponent(typeof(IsoObject))] + public class CubeAutoMovement : MonoBehaviour { + public float stepTicks = 0.5f; + public float stepRndTicks = 0.5f; + + IsoObject _isoObject = null; + + void Start() { + _isoObject = GetComponent(); + if ( !_isoObject ) { + throw new UnityException("CubeAutoMovement. IsoObject component not found!"); + } + StartCoroutine(Move()); + } + + WaitForSeconds RndWait() { + return new WaitForSeconds(stepTicks + Random.Range(0.0f, stepRndTicks)); + } + + IEnumerator Move() { + while ( true ) { + yield return RndWait(); + _isoObject.position += new Vector3(1, 0, 0); + yield return RndWait(); + _isoObject.position += new Vector3(0, 1, 0); + yield return RndWait(); + _isoObject.position += new Vector3(-1, 0, 0); + yield return RndWait(); + _isoObject.position += new Vector3(0, -1, 0); + } + } + } +} \ No newline at end of file diff --git a/Assets/IsoTools/Examples/Scripts/CubeAutoMovement.cs.meta b/Assets/IsoTools/Examples/Scripts/Simple/CubeAutoMovement.cs.meta similarity index 100% rename from Assets/IsoTools/Examples/Scripts/CubeAutoMovement.cs.meta rename to Assets/IsoTools/Examples/Scripts/Simple/CubeAutoMovement.cs.meta