using UnityEngine;
using System.Collections;
public class blockCoin : MonoBehaviour {
public int coinValue = 3;
public Transform coinParticle;
public AudioClip soundCoinPickup;
public GameObject playerGameObject;
//public GameObject hudConnectObject;
private float coinTime = 0.2f;
private aniSprite aniPlay;
// Use this for initialization
IEnumerator Start () {
aniPlay = GetComponent<aniSprite>();
//hudConnectObject = GameObject.FindWithTag("hud");
playerGameObject = GameObject.FindWithTag("Player");
yield return StartCoroutine(KillCoin());
Destroy(gameObject);
}
// Update is called once per frame
void Update ()
{
//aniPlay.aniPlay(16, 2, 0, 0, 21, 12);
transform.Translate(0, Time.deltaTime*5, 0);
//print("Particle play update1");
}
IEnumerator KillCoin()
{
print("Particle play 1");
yield return new WaitForSeconds(coinTime);
print("Particle play 2");
Instantiate(coinParticle, transform.position, transform.rotation);
AddToCoins();
print("Particle play end");
}
void AddToCoins()
{
//hudController hudConnect = (hudController)hudConnectObject.GetComponent("hudController");
//hudConnect.coin += coinValue;
playerProperties playerConnect = (playerProperties)playerGameObject.GetComponent(typeof(playerProperties));
playerConnect.coins += coinValue;
}
}
using UnityEngine;
using System.Collections;
public class spawnTubePoints4401 : MonoBehaviour {
public float timeToPort = 2.0f;
public Transform tubePortalTo;
public AudioClip soundTube;
void OnTriggerStay(Collider other)
{
//print("Test");
if (other.tag == "Player")
{
if (Input.GetAxis("Vertical") < 0)
{
print("Going Tube");
}
}
}
}
using UnityEngine;
using System.Collections;
public class spawnTubePoints4402 : MonoBehaviour {
public float timeToPort = 2.0f;
public Transform tubePortalTo;
public AudioClip soundTube;
private bool moveDown = false;
private bool moveUp = false;
//private playerControls playerCon;
private aniSprite aniSpr;
//private GameObject player;
void OnTriggerStay(Collider other)
{
//print("Test");
if (other.tag == "Player")
{
if (Input.GetAxis("Vertical") < 0)
{
//playerCon = other.GetComponent<playerControls>().velocity.x;
float velX = other.GetComponent<playerControls>().velocity.x;
int moveDir = other.GetComponent<playerControls>().moveDirection;
aniSpr = other.GetComponent<aniSprite>();
if (moveDir == 0)
{
velX = 0;
aniSpr.aniPlay(16, 16, 0, 9, 16, 16);
}
if (moveDir == 1)
{
velX = 0;
aniSpr.aniPlay(16, 16, 0, 8, 16, 16);
}
other.GetComponent<playerControls>().enabled = false;
moveDown = true;
}
}
}
}
using UnityEngine;
using System.Collections;
public class spawnTubePoints : MonoBehaviour {
public float timeToPort = 2.0f;
public Transform tubePortalTo;
public AudioClip soundTube;
private bool moveDown = false;
private bool moveUp = false;
//private playerControls playerCon;
private aniSprite aniSpr;
//private GameObject player;
public float soundDelay = 0.0f;
public float soundRate = 0.0f;
IEnumerator PlaySound(AudioClip soundName, float soundDelay)
{
if (!audio.isPlaying && Time.time > soundRate)
{
soundRate = Time.time + soundDelay;
audio.clip = soundName;
audio.Play();
yield return new WaitForSeconds(audio.clip.length);
}
}
IEnumerator OnTriggerStay(Collider other)
{
//print("Test");
if (other.tag == "Player")
{
if (Input.GetAxis("Vertical") < 0)
{
//playerCon = other.GetComponent<playerControls>().velocity.x;
float velX = other.GetComponent<playerControls>().velocity.x;
int moveDir = other.GetComponent<playerControls>().moveDirection;
aniSpr = other.GetComponent<aniSprite>();
if (moveDir == 0)
{
velX = 0;
aniSpr.aniPlay(16, 16, 0, 9, 16, 16);
}
if (moveDir == 1)
{
velX = 0;
aniSpr.aniPlay(16, 16, 0, 8, 16, 16);
}
other.GetComponent<playerControls>().enabled = false;
moveDown = true;
if (moveDown)
{
other.transform.Translate(0, -3 * Time.deltaTime, 0);
//StartCoroutine(PlaySound(soundTube, 0));
StartCoroutine(other.GetComponent<playerControls>().PlaySound(soundTube, 0));
yield return new WaitForSeconds(0.2f);
other.renderer.enabled = false;
yield return new WaitForSeconds(timeToPort);
other.transform.position = tubePortalTo.transform.position;
moveDown = false;
moveUp = true;
}
if (moveUp)
{
yield return new WaitForSeconds(1.0f);
//StartCoroutine(PlaySound(soundTube, 0));
StartCoroutine(other.GetComponent<playerControls>().PlaySound(soundTube, 0));
other.GetComponent<playerControls>().gravity = 0.0f;
other.renderer.enabled = true;
other.transform.Translate(0, 5 * Time.deltaTime, 0);
yield return new WaitForSeconds(0.3f);
other.GetComponent<playerControls>().gravity = 20.0f;
other.GetComponent<playerControls>().enabled = true;
moveUp = false;
}
}
}
}
}
other.GetComponet<playerControls>().PlaySound(soundTube, 0)을 호출하기 위해서는 playerControls.PlaySound() 함수를 public으로 설정하여야 한다.
using UnityEngine;
using System.Collections;
public class enemyGumba4701 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpri;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
// Update is called once per frame
void Update()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba4702 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpri;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
}
void PatrolLeft()
{
}
void IdleRight()
{
}
void IdleLeft()
{
}
void JumpRight()
{
}
void JumpLeft()
{
}
void DieRight()
{
}
void DieLeft()
{
}
void ChasePlayer()
{
}
void GoHome()
{
}
void OnDrawGizmos()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba4801 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
}
void PatrolLeft()
{
}
void IdleRight()
{
}
void IdleLeft()
{
}
void JumpRight()
{
}
void JumpLeft()
{
}
void DieRight()
{
}
void DieLeft()
{
}
void ChasePlayer()
{
}
void GoHome()
{
}
void OnDrawGizmos()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba4901 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
if (controller.isGrounded)
{
switch (gumbaState)
{
case GumbaState.moveLeft:
PatrolLeft();
break;
case GumbaState.moveRight:
PatrolRight();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight();
else
IdleLeft();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight();
else
JumpLeft();
break;
case GumbaState.enemyDie:
if (isRight)
DieRight();
else
DieLeft();
break;
case GumbaState.gohome:
GoHome();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
}
void PatrolLeft()
{
}
void IdleRight()
{
}
void IdleLeft()
{
}
void JumpRight()
{
}
void JumpLeft()
{
}
void DieRight()
{
}
void DieLeft()
{
}
void ChasePlayer()
{
}
void GoHome()
{
}
void OnDrawGizmos()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5001 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
if (controller.isGrounded)
{
switch (gumbaState)
{
case GumbaState.moveLeft:
PatrolLeft();
break;
case GumbaState.moveRight:
PatrolRight();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight();
else
IdleLeft();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight();
else
JumpLeft();
break;
case GumbaState.enemyDie:
if (isRight)
DieRight();
else
DieLeft();
break;
case GumbaState.gohome:
GoHome();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
//print("go....");
//print(velocity.x);
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight()
{
}
void JumpLeft()
{
}
void DieRight()
{
}
void DieLeft()
{
}
void ChasePlayer()
{
}
void GoHome()
{
}
void OnDrawGizmos()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5101 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
if (controller.isGrounded)
{
switch (gumbaState)
{
case GumbaState.moveLeft:
PatrolLeft();
break;
case GumbaState.moveRight:
PatrolRight();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight();
else
IdleLeft();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight();
else
JumpLeft();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine(DieRight());
else
StartCoroutine(DieLeft());
break;
case GumbaState.gohome:
GoHome();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
//print("go....");
//print(velocity.x);
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer()
{
}
void GoHome()
{
}
void OnDrawGizmos()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5201 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 2.0f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
distanceToTorget = Vector3.Distance(chaseTarget.transform.position, transform.position);
if (distanceToTorget <= searchRange)
{
ChasePlayer();
}
if (controller.isGrounded)
{
switch (gumbaState)
{
case GumbaState.moveLeft:
PatrolLeft();
break;
case GumbaState.moveRight:
PatrolRight();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight();
else
IdleLeft();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight();
else
JumpLeft();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine(DieRight());
else
StartCoroutine(DieLeft());
break;
case GumbaState.gohome:
GoHome();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
//print("go....");
//print(velocity.x);
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer()
{
if (transform.position.x <= chaseTarget.position.x)
{
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= chaseTarget.position.x)
{
gumbaState = GumbaState.moveLeft;
}
}
void GoHome()
{
}
void OnDrawGizmos()
{
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5301 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 0.5f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
distanceToTorget = Vector3.Distance(chaseTarget.transform.position, transform.position);
if (distanceToTorget <= searchRange)
{
ChasePlayer();
if (distanceToTorget <= attackRange)
{
ChasePlayer();
moveSpeed = attackMoveSpeed;
}
else
{
ChasePlayer();
moveSpeed = resetMoveSpeed;
}
}
if (controller.isGrounded)
{
switch (gumbaState)
{
case GumbaState.moveLeft:
PatrolLeft();
break;
case GumbaState.moveRight:
PatrolRight();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight();
else
IdleLeft();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight();
else
JumpLeft();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine(DieRight());
else
StartCoroutine(DieLeft());
break;
case GumbaState.gohome:
GoHome();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
//print("go....");
//print(velocity.x);
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer()
{
if (transform.position.x <= chaseTarget.position.x - changeDirectionDistance)
{
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= chaseTarget.position.x + changeDirectionDistance)
{
gumbaState = GumbaState.moveLeft;
}
}
void GoHome()
{
}
void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere(transform.position, searchRange);
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5302 : MonoBehaviour {
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState { moveLeft = 0, moveRight = 1, moveStop = 2, jumpAir = 3, enemyDie = 4, gohome = 5 }
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 0.5f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController>();
aniSpr = GetComponent<aniSprite>();
}
// Update is called once per frame
void Update()
{
distanceToTorget = Vector3.Distance(chaseTarget.transform.position, transform.position);
if (distanceToTorget <= searchRange)
{
ChasePlayer();
if (distanceToTorget <= attackRange)
{
ChasePlayer();
moveSpeed = attackMoveSpeed;
}
else
{
ChasePlayer();
moveSpeed = resetMoveSpeed;
}
} else {
distanceToHome = Vector3.Distance(homePosition.position, transform.position);
if(distanceToHome > returnHomeRange) {
GoHome();
}
}
if (controller.isGrounded)
{
switch (gumbaState)
{
case GumbaState.moveLeft:
PatrolLeft();
break;
case GumbaState.moveRight:
PatrolRight();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight();
else
IdleLeft();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight();
else
JumpLeft();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine(DieRight());
else
StartCoroutine(DieLeft());
break;
case GumbaState.gohome:
GoHome();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move(velocity * Time.deltaTime);
//print("go....");
//print(velocity.x);
}
void OnTriggerEnter(Collider other)
{
}
void PatrolRight()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay(16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft()
{
velocity.x = 0;
aniSpr.aniPlay(16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay(16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay(16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer()
{
if (transform.position.x <= chaseTarget.position.x - changeDirectionDistance)
{
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= chaseTarget.position.x + changeDirectionDistance)
{
gumbaState = GumbaState.moveLeft;
}
}
void GoHome()
{
if(transform.position.x <= homePosition.position.x) {
gumbaState = GumbaState.moveRight;
}
if(transform.position.x >= homePosition.position.x) {
gumbaState = GumbaState.moveLeft;
}
}
void OnDrawGizmos()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere(transform.position, attackRange);
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere(transform.position, searchRange);
Gizmos.color = Color.green;
Gizmos.DrawWireSphere(homePosition.position, returnHomeRange);
}
}
using UnityEngine;
using System.Collections;
public class pathNode5501 : MonoBehaviour {
public enum PathInStruction { moveLeft =0, moveRight =1, moveStop =2, jumpAir =3}
public PathInStruction pathInStruction = PathInStruction.moveStop;
void OnTriggerEnter(Collider other)
{
if (other.tag == "enemy")
{
print("Gumba is here");
}
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5501 : MonoBehaviour
{
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState
{
moveLeft = 0,
moveRight = 1,
moveStop = 2,
jumpAir = 3,
enemyDie = 4,
gohome = 5
}
public GumbaState gumbaState = GumbaState.moveLeft;
public bool Change = false;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 0.5f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start ()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController> ();
aniSpr = GetComponent<aniSprite> ();
}
// Update is called once per frame
void Update ()
{
distanceToTorget = Vector3.Distance (chaseTarget.transform.position, transform.position);
if (distanceToTorget <= searchRange) {
ChasePlayer ();
if (distanceToTorget <= attackRange) {
ChasePlayer ();
moveSpeed = attackMoveSpeed;
} else {
ChasePlayer ();
moveSpeed = resetMoveSpeed;
}
} else {
distanceToHome = Vector3.Distance (homePosition.position, transform.position);
if (distanceToHome > returnHomeRange) {
GoHome ();
}
}
if (controller.isGrounded) {
switch (gumbaState) {
case GumbaState.moveLeft:
PatrolLeft ();
break;
case GumbaState.moveRight:
PatrolRight ();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight ();
else
IdleLeft ();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight ();
else
JumpLeft ();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine (DieRight ());
else
StartCoroutine (DieLeft ());
break;
case GumbaState.gohome:
GoHome ();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move (velocity * Time.deltaTime);
}
void OnTriggerEnter (Collider other)
{
if (other.tag == "pathNode") {
pathNode linkToPathNode = other.GetComponent<pathNode>();
switch (linkToPathNode.pathInStruction) {
case pathNode.PathInStruction.moveStop:
gumbaState = GumbaState.moveStop;
Change = true;
break;
}
}
}
void PatrolRight ()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay (16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft ()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay (16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight ()
{
velocity.x = 0;
aniSpr.aniPlay (16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft ()
{
velocity.x = 0;
aniSpr.aniPlay (16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight ()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay (16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft ()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay (16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight ()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay (16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft ()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay (16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer ()
{
if (transform.position.x <= chaseTarget.position.x - changeDirectionDistance) {
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= chaseTarget.position.x + changeDirectionDistance) {
gumbaState = GumbaState.moveLeft;
}
}
void GoHome ()
{
if (transform.position.x <= homePosition.position.x) {
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= homePosition.position.x) {
gumbaState = GumbaState.moveLeft;
}
}
void OnDrawGizmos ()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere (transform.position, attackRange);
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere (transform.position, searchRange);
Gizmos.color = Color.green;
Gizmos.DrawWireSphere (homePosition.position, returnHomeRange);
}
}
using UnityEngine;
using System.Collections;
public class pathNode5601 : MonoBehaviour
{
public enum PathInStruction
{
moveLeft =0,
moveRight =1,
moveStop =2,
jumpAir =3
}
public PathInStruction pathInStruction = PathInStruction.moveStop;
public bool overrideJump = false;
public float jumpOverride = 1.5f;
public bool changePathInstructionTo = false;
public enum ChangeTo
{
moveLeft =0,
moveRight=1,
moveStop=2,
jumpAir=3,
removeTrigger=4
}
public ChangeTo changeTo = ChangeTo.moveRight;
public int triggerCountDown = 3;
public bool removeOnTrigger = false;
public float removeTimeCountDown = 1.0f;
private int getChangeTo;
void OnTriggerEnter (Collider other)
{
if (other.tag == "enemy") {
print("Gumba is here");
if (changePathInstructionTo) {
print("Gumba is here...................");
if (triggerCountDown <= 0) {
if (changeTo == ChangeTo.removeTrigger) {
Destroy (gameObject);
} else {
//getChangeTo = changeTo;
print("Gumba is here...");
pathInStruction = (PathInStruction)changeTo;
}
} else {
triggerCountDown--;
}
}
if (removeOnTrigger) {
Destroy (gameObject, removeTimeCountDown);
}
}
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba5601 : MonoBehaviour
{
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState
{
moveLeft = 0,
moveRight = 1,
moveStop = 2,
jumpAir = 3,
enemyDie = 4,
gohome = 5
}
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 0.5f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start ()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController> ();
aniSpr = GetComponent<aniSprite> ();
}
// Update is called once per frame
void Update ()
{
distanceToTorget = Vector3.Distance (chaseTarget.transform.position, transform.position);
if (distanceToTorget <= searchRange) {
ChasePlayer ();
if (distanceToTorget <= attackRange) {
ChasePlayer ();
moveSpeed = attackMoveSpeed;
} else {
ChasePlayer ();
moveSpeed = resetMoveSpeed;
}
} else {
distanceToHome = Vector3.Distance (homePosition.position, transform.position);
if (distanceToHome > returnHomeRange) {
GoHome ();
}
}
if (controller.isGrounded) {
switch (gumbaState) {
case GumbaState.moveLeft:
PatrolLeft ();
break;
case GumbaState.moveRight:
PatrolRight ();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight ();
else
IdleLeft ();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight ();
else
JumpLeft ();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine (DieRight ());
else
StartCoroutine (DieLeft ());
break;
case GumbaState.gohome:
GoHome ();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move (velocity * Time.deltaTime);
}
void OnTriggerEnter (Collider other)
{
if (other.tag == "pathNode") {
pathNode linkToPathNode = other.GetComponent<pathNode>();
print("GumbaState:" + linkToPathNode.pathInStruction);
switch (linkToPathNode.pathInStruction) {
case pathNode.PathInStruction.moveStop:
gumbaState = GumbaState.moveStop;
print("GumbaState:" + gumbaState);
break;
case pathNode.PathInStruction.jumpAir:
gumbaState = GumbaState.jumpAir;
jumpSpeed = linkToPathNode.jumpOverride;
break;
}
}
}
void PatrolRight ()
{
velocity.x = moveSpeed * Time.deltaTime;
aniSpr.aniPlay (16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft ()
{
velocity.x = -moveSpeed * Time.deltaTime;
aniSpr.aniPlay (16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight ()
{
velocity.x = 0;
aniSpr.aniPlay (16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft ()
{
velocity.x = 0;
aniSpr.aniPlay (16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight ()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay (16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft ()
{
velocity.y = jumpSpeed;
aniSpr.aniPlay (16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight ()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay (16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft ()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay (16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer ()
{
if (transform.position.x <= chaseTarget.position.x - changeDirectionDistance) {
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= chaseTarget.position.x + changeDirectionDistance) {
gumbaState = GumbaState.moveLeft;
}
}
void GoHome ()
{
if (transform.position.x <= homePosition.position.x) {
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= homePosition.position.x) {
gumbaState = GumbaState.moveLeft;
}
}
void OnDrawGizmos ()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere (transform.position, attackRange);
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere (transform.position, searchRange);
Gizmos.color = Color.green;
Gizmos.DrawWireSphere (homePosition.position, returnHomeRange);
}
}
using UnityEngine;
using System.Collections;
public class enemyGumba : MonoBehaviour
{
public float moveSpeed = 20.0f;
public float attackMoveSpeed = 35.0f;
public float jumpSpeed = 3.0f;
public enum GumbaState
{
moveLeft = 0,
moveRight = 1,
moveStop = 2,
jumpAir = 3,
enemyDie = 4,
gohome = 5
}
public GumbaState gumbaState = GumbaState.moveLeft;
public float attackRange = 2.0f;
public float searchRange = 3.0f;
public float returnHomeRange = 4.0f;
public float changeDirectionDistance = 0.5f;
public Transform chaseTarget;
public Transform homePosition;
public float deathforth = 3.0f;
public bool gizmoToggle = true;
private Vector3 velocity = Vector3.zero;
private float gravity = 20.0f;
private GumbaState currentState;
private aniSprite aniSpr;
private bool isRight = false;
private Vector3 myTransform;
private float resetMoveSpeed = 0.0f;
private float distanceToHome = 0.0f;
private float distanceToTorget = 0.0f;
private CharacterController controller;
void Start ()
{
myTransform = transform.position;
resetMoveSpeed = moveSpeed;
//linkToToPlayerProperties = (playerProperties)GetComponent("playerProperties");
controller = GetComponent<CharacterController> ();
aniSpr = GetComponent<aniSprite> ();
}
// Update is called once per frame
void Update ()
{
distanceToTorget = Vector3.Distance (chaseTarget.transform.position, transform.position);
if (distanceToTorget <= searchRange) {
ChasePlayer ();
if (distanceToTorget <= attackRange) {
ChasePlayer ();
moveSpeed = attackMoveSpeed;
} else {
ChasePlayer ();
moveSpeed = resetMoveSpeed;
}
} else {
distanceToHome = Vector3.Distance (homePosition.position, transform.position);
if (distanceToHome > returnHomeRange) {
GoHome ();
}
}
if (controller.isGrounded) {
switch (gumbaState) {
case GumbaState.moveLeft:
PatrolLeft ();
break;
case GumbaState.moveRight:
PatrolRight ();
break;
case GumbaState.moveStop:
if (isRight)
IdleRight ();
else
IdleLeft ();
break;
case GumbaState.jumpAir:
if (isRight)
JumpRight ();
else
JumpLeft ();
break;
case GumbaState.enemyDie:
if (isRight)
StartCoroutine (DieRight ());
else
StartCoroutine (DieLeft ());
break;
case GumbaState.gohome:
GoHome ();
break;
}
}
velocity.y -= gravity * Time.deltaTime;
controller.Move (velocity * Time.deltaTime);
}
void OnTriggerEnter (Collider other)
{
if (other.tag == "pathNode") {
pathNode linkToPathNode = other.GetComponent<pathNode>();
print("GumbaState:" + linkToPathNode.pathInStruction);
switch (linkToPathNode.pathInStruction) {
case pathNode.PathInStruction.moveStop:
gumbaState = GumbaState.moveStop;
print("GumbaState:" + gumbaState);
break;
case pathNode.PathInStruction.jumpAir:
gumbaState = GumbaState.jumpAir;
jumpSpeed = linkToPathNode.jumpOverride;
break;
}
}
}
void PatrolRight ()
{
velocity.x = moveSpeed * Time.deltaTime;
currentState = gumbaState;
aniSpr.aniPlay (16, 16, 0, 6, 16, 24);
isRight = true;
}
void PatrolLeft ()
{
velocity.x = -moveSpeed * Time.deltaTime;
currentState = gumbaState;
aniSpr.aniPlay (16, 16, 0, 7, 16, 24);
isRight = false;
}
void IdleRight ()
{
velocity.x = 0;
currentState = gumbaState;
aniSpr.aniPlay (16, 16, 0, 0, 29, 24);
isRight = true;
}
void IdleLeft ()
{
velocity.x = 0;
currentState = gumbaState;
aniSpr.aniPlay (16, 16, 0, 2, 31, 24);
isRight = false;
}
void JumpRight ()
{
velocity.y = jumpSpeed;
gumbaState = currentState;
aniSpr.aniPlay (16, 16, 7, 8, 1, 24);
isRight = true;
}
void JumpLeft ()
{
velocity.y = jumpSpeed;
gumbaState = currentState;
aniSpr.aniPlay (16, 16, 7, 9, 1, 24);
isRight = false;
}
IEnumerator DieRight ()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay (16, 16, 0, 10, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
IEnumerator DieLeft ()
{
velocity.x = 0;
yield return new WaitForSeconds(0.1f);
aniSpr.aniPlay (16, 16, 0, 11, 16, 24);
yield return new WaitForSeconds(0.4f);
//Destroy(gameObject);
}
void ChasePlayer ()
{
if (transform.position.x <= chaseTarget.position.x - changeDirectionDistance) {
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= chaseTarget.position.x + changeDirectionDistance) {
gumbaState = GumbaState.moveLeft;
}
}
void GoHome ()
{
if (transform.position.x <= homePosition.position.x) {
gumbaState = GumbaState.moveRight;
}
if (transform.position.x >= homePosition.position.x) {
gumbaState = GumbaState.moveLeft;
}
}
void OnDrawGizmos ()
{
Gizmos.color = Color.red;
Gizmos.DrawWireSphere (transform.position, attackRange);
Gizmos.color = Color.blue;
Gizmos.DrawWireSphere (transform.position, searchRange);
Gizmos.color = Color.green;
Gizmos.DrawWireSphere (homePosition.position, returnHomeRange);
}
}
currentState / gumbaState : Jump함수에서는 이전 상태의 값을 받아 오고 있음 >> 즉, 한번만 점프를 할 수 있도록 하게 하고 있음