example script to separate folders

This commit is contained in:
2016-10-22 18:18:27 +07:00
parent 4326c80a68
commit 83ced8f772
19 changed files with 87 additions and 69 deletions

View File

@@ -87,14 +87,14 @@
<Compile Include="Assets\IsoTools\Addons\Tiled\TiledMapLayer.cs" />
<Compile Include="Assets\IsoTools\Addons\Tiled\TiledMapProperties.cs" />
<Compile Include="Assets\IsoTools\Addons\Tiled\TiledMapTileset.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\AlienBallController.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\AlienBallSpawner.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\AlienDestroyer.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\CircleFly.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\CubeAutoMovement.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\IsoEchoListener.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\PlayerController.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Kenney\AlienBallController.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Kenney\AlienBallSpawner.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Kenney\AlienDestroyer.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Kenney\PhysicEchoListener.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Kenney\PlayerController.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\SceneController.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Simple\CircleFly.cs" />
<Compile Include="Assets\IsoTools\Examples\Scripts\Simple\CubeAutoMovement.cs" />
<Compile Include="Assets\IsoTools\Scripts\Internal\IsoAssocList.cs" />
<Compile Include="Assets\IsoTools\Scripts\Internal\IsoFakeCollider.cs" />
<Compile Include="Assets\IsoTools\Scripts\Internal\IsoFakeCollisionListener.cs" />

View File

@@ -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<IsoObject>();
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

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: 66f999d096e6f49eabd1470c91178c1d
folderAsset: yes
timeCreated: 1477133717
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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<AlienBallController>() ) {
Destroy(alien_go);
}

View File

@@ -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
}

View File

@@ -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
}

View File

@@ -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);
}
}
}
}

View File

@@ -0,0 +1,9 @@
fileFormatVersion: 2
guid: a185e32da5ddc49f4ac1eb35ae3664f0
folderAsset: yes
timeCreated: 1477134153
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -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
}

View File

@@ -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<IsoObject>();
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);
}
}
}
}