mirror of
https://github.com/BlackMATov/unity-iso-tools.git
synced 2025-12-16 22:16:55 +07:00
sample scenes
This commit is contained in:
27
Assets/IsoTools/Examples/Scripts/AlienBallController.cs
Normal file
27
Assets/IsoTools/Examples/Scripts/AlienBallController.cs
Normal file
@@ -0,0 +1,27 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace IsoTools.Examples {
|
||||
[RequireComponent(typeof(IsoRigidbody))]
|
||||
public class AlienBallController : MonoBehaviour {
|
||||
|
||||
IsoRigidbody _isoRigidbody = null;
|
||||
|
||||
void Start() {
|
||||
_isoRigidbody = GetComponent<IsoRigidbody>();
|
||||
if ( !_isoRigidbody ) {
|
||||
throw new UnityException("AlienBallController. IsoRigidbody component not found!");
|
||||
}
|
||||
StartCoroutine("AddRndForce");
|
||||
}
|
||||
|
||||
IEnumerator AddRndForce() {
|
||||
while ( true ) {
|
||||
var dx = Random.Range(0.0f, 2.0f);
|
||||
var dy = Random.Range(0.0f, 2.0f);
|
||||
_isoRigidbody.AddForce(new Vector3(dx, dy, 0.0f), ForceMode.Impulse);
|
||||
yield return new WaitForSeconds(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools.Examples
|
||||
@@ -1,8 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 449e21ec66627fb49a67d615cd9d240a
|
||||
guid: 37ebe9d751ab149af908326d25f141a6
|
||||
timeCreated: 1436702622
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
24
Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs
Normal file
24
Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs
Normal file
@@ -0,0 +1,24 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace IsoTools.Examples {
|
||||
public class AlienBallSpawner : MonoBehaviour {
|
||||
|
||||
public GameObject alienBallPrefab = null;
|
||||
|
||||
void Start() {
|
||||
StartCoroutine("SpawnAlienBall");
|
||||
}
|
||||
|
||||
IEnumerator SpawnAlienBall() {
|
||||
while ( true ) {
|
||||
var dx = Random.Range(1.0f, 4.0f);
|
||||
var dy = Random.Range(1.0f, 4.0f);
|
||||
var alien_ball_go = Instantiate(alienBallPrefab);
|
||||
var alien_iso_obj = alien_ball_go.GetComponent<IsoObject>();
|
||||
alien_iso_obj.position = new Vector3(dx, dy, 5.0f);
|
||||
yield return new WaitForSeconds(Random.Range(2.0f, 5.0f));
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools.Examples
|
||||
12
Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs.meta
Normal file
12
Assets/IsoTools/Examples/Scripts/AlienBallSpawner.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9c4844f94ab7c465d89b59b1741b9f39
|
||||
timeCreated: 1436703164
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,8 +1,8 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace IsoTools { namespace Examples {
|
||||
public class IsoAutoController : MonoBehaviour {
|
||||
namespace IsoTools.Examples {
|
||||
public class CubeAutoMovement : MonoBehaviour {
|
||||
public float stepTicks = 0.5f;
|
||||
public float stepRndTicks = 0.5f;
|
||||
|
||||
@@ -30,4 +30,4 @@ namespace IsoTools { namespace Examples {
|
||||
}
|
||||
}
|
||||
}
|
||||
}} // namespace IsoTools::Examples
|
||||
} // namespace IsoTools.Examples
|
||||
@@ -1,36 +0,0 @@
|
||||
using UnityEngine;
|
||||
using System.Collections;
|
||||
|
||||
namespace IsoTools { namespace Examples {
|
||||
public class IsoController : MonoBehaviour {
|
||||
void MoveIsoObject(Vector3 dir) {
|
||||
var iso_object = GetComponent<IsoObject>();
|
||||
var iso_rigidbody = GetComponent<IsoRigidbody>();
|
||||
if ( iso_rigidbody ) {
|
||||
iso_rigidbody.velocity = dir;
|
||||
} else if ( iso_object) {
|
||||
iso_object.position += dir * Time.deltaTime;
|
||||
}
|
||||
}
|
||||
void Update () {
|
||||
if ( Input.GetKey(KeyCode.LeftArrow) ) {
|
||||
MoveIsoObject(new Vector3(-1, 0, 0));
|
||||
}
|
||||
if ( Input.GetKey(KeyCode.RightArrow) ) {
|
||||
MoveIsoObject(new Vector3(1, 0, 0));
|
||||
}
|
||||
if ( Input.GetKey(KeyCode.DownArrow) ) {
|
||||
MoveIsoObject(new Vector3(0, -1, 0));
|
||||
}
|
||||
if ( Input.GetKey(KeyCode.UpArrow) ) {
|
||||
MoveIsoObject(new Vector3(0, 1, 0));
|
||||
}
|
||||
if ( Input.GetKey(KeyCode.A) ) {
|
||||
MoveIsoObject(new Vector3(0, 0, 1));
|
||||
}
|
||||
if ( Input.GetKey(KeyCode.Z) ) {
|
||||
MoveIsoObject(new Vector3(0, 0, -1));
|
||||
}
|
||||
}
|
||||
}
|
||||
}} // namespace IsoTools::Examples
|
||||
42
Assets/IsoTools/Examples/Scripts/PlayerController.cs
Normal file
42
Assets/IsoTools/Examples/Scripts/PlayerController.cs
Normal file
@@ -0,0 +1,42 @@
|
||||
using UnityEngine;
|
||||
|
||||
namespace IsoTools.Examples {
|
||||
[RequireComponent(typeof(IsoRigidbody))]
|
||||
public class PlayerController : MonoBehaviour {
|
||||
|
||||
public float speed = 2.0f;
|
||||
|
||||
IsoRigidbody _isoRigidbody = null;
|
||||
|
||||
void OnIsoCollisionEnter(IsoCollision iso_collision) {
|
||||
if ( iso_collision.gameObject ) {
|
||||
var alient = iso_collision.gameObject.GetComponent<AlienBallController>();
|
||||
if ( alient ) {
|
||||
Destroy(alient.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Start() {
|
||||
_isoRigidbody = GetComponent<IsoRigidbody>();
|
||||
if ( !_isoRigidbody ) {
|
||||
throw new UnityException("PlayerController. IsoRigidbody component not found!");
|
||||
}
|
||||
}
|
||||
|
||||
void Update () {
|
||||
if ( Input.GetKey(KeyCode.LeftArrow) ) {
|
||||
_isoRigidbody.velocity = IsoUtils.Vec3ChangeX(_isoRigidbody.velocity, -speed);
|
||||
}
|
||||
else if ( Input.GetKey(KeyCode.RightArrow) ) {
|
||||
_isoRigidbody.velocity = IsoUtils.Vec3ChangeX(_isoRigidbody.velocity, speed);
|
||||
}
|
||||
else if ( Input.GetKey(KeyCode.DownArrow) ) {
|
||||
_isoRigidbody.velocity = IsoUtils.Vec3ChangeY(_isoRigidbody.velocity, -speed);
|
||||
}
|
||||
else if ( Input.GetKey(KeyCode.UpArrow) ) {
|
||||
_isoRigidbody.velocity = IsoUtils.Vec3ChangeY(_isoRigidbody.velocity, speed);
|
||||
}
|
||||
}
|
||||
}
|
||||
} // namespace IsoTools.Examples
|
||||
12
Assets/IsoTools/Examples/Scripts/PlayerController.cs.meta
Normal file
12
Assets/IsoTools/Examples/Scripts/PlayerController.cs.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 714557b7bad714f488f0567ad164c128
|
||||
timeCreated: 1436697471
|
||||
licenseType: Free
|
||||
MonoImporter:
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user