IEnumerator LaunchAttack() { //if (unit.enemy.transform.position.x - gameObject.transform.position.x > 0) { // enemyDirection = Direction.right; //} else { // enemyDirection = Direction.left; //} unit.launchingAttack = true; Vector2 current = gameObject.transform.position; //todo: get direction needs to be updated when chasing from behind Vector2 newPosition = unit.GetFaceDirection().normalized *attackDistance + current; if (gameObject != null) { PetUtility.Coroutine(PetUtility.LinearMove(current, newPosition, 0.15f, gameObject.transform)); } yield return(new WaitForSeconds(0.15f)); if (gameObject != null) { PetUtility.Coroutine(PetUtility.LinearMove(newPosition, current, 0.15f, gameObject.transform)); } yield return(new WaitForSeconds(0.15f)); yield return(null); }
private void Exit() { void startWalking() { unit.enterDoor = false; } PetUtility.Coroutine(PetUtility.LinearZoom(Vector3.zero, originScale, exitTime, gameObject.transform)); PetUtility.WaitAndDo(exitTime, startWalking); }
protected virtual void Attack() { unit.launchingAttack = true; PetUtility.Coroutine(LaunchAttack()); //Debug.Log("try get enemy"); UnitBehaviour enemy = unit.enemy.GetComponent <UnitBehaviour>(); //Debug.Log(enemy != null); int damage = unit.damage; enemy.TakeDamage(damage); }
private void Split() { Debug.Log("try to split"); //split into 2 small ghosts, move from center to 2 sides. GameObject leftGhost, rightGhost; leftGhost = Instantiate(blueGhost, transform.position, Quaternion.identity); rightGhost = Instantiate(redGhost, transform.position, Quaternion.identity); float heightDifference = 0.3f; Vector2 from = (Vector2)transform.position + Vector2.down * heightDifference; Vector2 leftDes = from + Vector2.left * (splitDistance / 2f); Vector2 rightDes = from + Vector2.right * (splitDistance / 2f); PetUtility.Coroutine(PetUtility.SublinearMove(from, leftDes, 0.25f, leftGhost.transform)); PetUtility.Coroutine(PetUtility.SublinearMove(from, rightDes, 0.25f, rightGhost.transform)); }
private void Enter() { //Debug.Log("enter door"); //you want play the animation, wait, teleport and change state if (!entering) { entering = true; void exitDoor() { gameObject.transform.position = door.OtherEndPos(); entering = false; Exit(); } PetUtility.Coroutine (PetUtility.LinearZoom(originScale, Vector3.zero, enterTime, gameObject.transform)); PetUtility.WaitAndDo(enterTime, exitDoor); } }
// Start is called before the first frame update private void OnEnable() { transform.localScale = Vector3.zero; PetUtility.Coroutine(PetUtility.LinearZoom(Vector3.zero, Vector3.one, 0.1f, transform)); }
private void UnShrinkCard() { PetUtility.Coroutine(PetUtility.LinearZoom(transform.localScale, Vector3.one, shrinkDuration, transform)); }
private void ShrinkCard() { PetUtility.Coroutine(PetUtility.LinearZoom(transform.localScale, shrinkRatio * Vector3.one, shrinkDuration, transform)); //Debug.Log("trying to shrink card"); }