init
This commit is contained in:
commit
102013b228
1443 changed files with 1065651 additions and 0 deletions
297
Assets/Scripts/BalloonFight/BallonPlayerController.cs
Normal file
297
Assets/Scripts/BalloonFight/BallonPlayerController.cs
Normal file
|
@ -0,0 +1,297 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BallonPlayerController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ScenesTransitionController scenesTransition;
|
||||
[SerializeField] GameTutorialControler tutorial;
|
||||
[SerializeField] LayerMask whatIsGround = -1;
|
||||
Camera cam;
|
||||
|
||||
[SerializeField] float speed = 6f;
|
||||
[SerializeField] float splashSpeed = 4f;
|
||||
[SerializeField] float gravityScale = 9.8f;
|
||||
[SerializeField] Transform feetPos = default;
|
||||
[SerializeField] float feetRadius = .3f;
|
||||
float currentSpeed;
|
||||
Vector3 velocity;
|
||||
bool isGrounded;
|
||||
|
||||
bool moving;
|
||||
CharacterController controller;
|
||||
|
||||
[SerializeField] Animator anim = default;
|
||||
[SerializeField] float turnSmoothTime = .1f;
|
||||
float turnSmoothVelocity;
|
||||
bool canShootAgain;
|
||||
bool needABalloon;
|
||||
bool charging;
|
||||
bool shooting;
|
||||
bool isDead;
|
||||
|
||||
float yVelocity;
|
||||
float velocityChangeVelocity;
|
||||
|
||||
[SerializeField] Transform shootPos = default;
|
||||
|
||||
[SerializeField, Range(0f, 1f)] float timeToShoot = .5f;
|
||||
float currentTime;
|
||||
|
||||
[Space]
|
||||
[SerializeField, Range(0, 30)] float onSplashDecreaseSpeed = .5f;
|
||||
[SerializeField] float maxHp = 100;
|
||||
public float hp;
|
||||
[SerializeField] GameObject balloon = default;
|
||||
|
||||
[SerializeField] Color splashColor = Color.red;
|
||||
[System.Serializable] public class BodyMaterials{
|
||||
public Material[] bodyMats;
|
||||
}
|
||||
|
||||
[SerializeField] BodyMaterials[] characterMats;
|
||||
CharacterIdController character;
|
||||
|
||||
[Space]
|
||||
[SerializeField] Canvas canvas = default;
|
||||
[SerializeField] UnityEngine.UI.Image chargingBar = default;
|
||||
|
||||
bool scoreDistributed;
|
||||
|
||||
private bool boolSoundActived = false;
|
||||
|
||||
[SerializeField, Range(0, 1f)] float stepsInterval = .35f;
|
||||
float currentStepTime;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
character = GetComponent<CharacterIdController>();
|
||||
hp = maxHp;
|
||||
currentSpeed = speed;
|
||||
moving = true;
|
||||
cam = Camera.main;
|
||||
controller = GetComponent<CharacterController>();
|
||||
|
||||
anim = character.SetPlayerCustom();
|
||||
|
||||
foreach (Material bodyMat in characterMats[character.characterId].bodyMats)
|
||||
bodyMat.SetColor("Color_9AC6EC04", splashColor);
|
||||
|
||||
foreach(BodyMaterials body in characterMats)
|
||||
foreach (Material bodyMat in body.bodyMats)
|
||||
bodyMat.SetFloat("Vector1_104BE5AC", Mathf.Lerp(-1, 1.5f, 1 - hp / maxHp));
|
||||
|
||||
StartCoroutine(AudioManager.instance.FadeIn("transicion", 1));
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update()
|
||||
{
|
||||
|
||||
if (tutorial.gameStarted && !isDead)
|
||||
{
|
||||
if (!boolSoundActived)
|
||||
{
|
||||
boolSoundActived = true;
|
||||
StartCoroutine(AudioManager.instance.FadeOut("transicion", 1));
|
||||
StartCoroutine(AudioManager.instance.FadeIn("05_globos", 1));
|
||||
}
|
||||
|
||||
balloon.SetActive(!needABalloon);
|
||||
|
||||
#region Shoot
|
||||
if (Input.GetMouseButtonUp(0) && currentTime >= timeToShoot && !needABalloon && !charging && canShootAgain)
|
||||
{
|
||||
Shoot();
|
||||
canShootAgain = false;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(0) && canShootAgain && !needABalloon)
|
||||
{
|
||||
Ray ray = cam.ScreenPointToRay(Input.mousePosition);
|
||||
RaycastHit hit;
|
||||
|
||||
if (Physics.Raycast(ray, out hit, whatIsGround))
|
||||
{
|
||||
Vector3 pos = hit.point - transform.position;
|
||||
float rotY = Mathf.Atan2(-pos.z, pos.x) * Mathf.Rad2Deg;
|
||||
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, rotY + 90, ref turnSmoothVelocity, turnSmoothTime);
|
||||
transform.rotation = Quaternion.Euler(0f, angle, 0f);
|
||||
}
|
||||
|
||||
moving = false;
|
||||
currentTime = Mathf.Clamp(currentTime + Time.deltaTime, 0, timeToShoot);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!charging)
|
||||
{
|
||||
currentTime = Mathf.Clamp(currentTime - Time.deltaTime * 2, 0, timeToShoot);
|
||||
if (currentTime <= 0)
|
||||
{
|
||||
canShootAgain = true;
|
||||
}
|
||||
}
|
||||
moving = true;
|
||||
}
|
||||
|
||||
chargingBar.transform.localScale = new Vector3(Mathf.Clamp(currentTime / timeToShoot, 0, 1), 1);
|
||||
#endregion
|
||||
|
||||
isGrounded = Physics.CheckSphere(feetPos.position, feetRadius, whatIsGround);
|
||||
|
||||
if (moving && !shooting)
|
||||
{
|
||||
Vector3 direction = new Vector3(Input.GetAxisRaw("Horizontal"), 0, Input.GetAxisRaw("Vertical")).normalized;
|
||||
|
||||
if (direction.magnitude > .1f)
|
||||
{
|
||||
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
|
||||
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref turnSmoothVelocity, turnSmoothTime);
|
||||
transform.rotation = Quaternion.Euler(0f, angle, 0f);
|
||||
|
||||
controller.Move(direction * currentSpeed * Time.deltaTime);
|
||||
yVelocity = 1;
|
||||
|
||||
currentStepTime += Time.deltaTime;
|
||||
if (currentStepTime >= stepsInterval){
|
||||
AudioManager.instance.PlayOneShot("SFX_paso" + Random.Range(1, 6), true);
|
||||
currentStepTime = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yVelocity = 0;
|
||||
}
|
||||
|
||||
if(hp <= 0 && !isDead){
|
||||
anim.SetTrigger("Die");
|
||||
isDead = true;
|
||||
ReturnToMenu(GameObject.Find("Enemy").GetComponent<CharacterIdController>().characterId, GetComponent<CharacterIdController>().characterId);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yVelocity = 0;
|
||||
}
|
||||
|
||||
anim.SetFloat("VelocityY", Mathf.SmoothDamp(anim.GetFloat("VelocityY"), yVelocity, ref velocityChangeVelocity, .1f));
|
||||
|
||||
if (isGrounded && velocity.y < 0)
|
||||
{
|
||||
velocity.y = -2f;
|
||||
}
|
||||
|
||||
velocity.y -= gravityScale * Time.deltaTime;
|
||||
controller.Move(velocity * Time.deltaTime);
|
||||
|
||||
foreach (Material bodyMat in characterMats[character.characterId].bodyMats)
|
||||
bodyMat.SetFloat("Vector1_104BE5AC", Mathf.Lerp(-1, 1.5f, 1 - hp / maxHp));
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate(){
|
||||
canvas.transform.rotation = Quaternion.Euler(45, 0, 0);
|
||||
}
|
||||
|
||||
void Shoot(){
|
||||
anim.SetTrigger("Throw");
|
||||
needABalloon = true;
|
||||
shooting = true;
|
||||
StartCoroutine(ShootBalloon());
|
||||
}
|
||||
|
||||
IEnumerator ShootBalloon(){
|
||||
yield return new WaitForSeconds(.5f);
|
||||
ObjectPooler.instance.SpawnFromPool("OrangeBalloon", shootPos.position, shootPos.rotation);
|
||||
shooting = false;
|
||||
}
|
||||
|
||||
void OnTriggerStay(Collider col){
|
||||
if (col.CompareTag("BlueSplash")){
|
||||
currentSpeed = splashSpeed;
|
||||
hp -= onSplashDecreaseSpeed * Time.deltaTime;
|
||||
}
|
||||
|
||||
if (col.CompareTag("BalloonTrigger")){
|
||||
if (Input.GetMouseButtonUp(0) && currentTime >= timeToShoot && needABalloon){
|
||||
anim.SetTrigger("Lift");
|
||||
currentTime = 0;
|
||||
needABalloon = false;
|
||||
canShootAgain = false;
|
||||
charging = false;
|
||||
}
|
||||
|
||||
if (Input.GetMouseButton(0) && canShootAgain && needABalloon){
|
||||
charging = true;
|
||||
moving = false;
|
||||
currentTime = Mathf.Clamp(currentTime + Time.deltaTime, 0, timeToShoot);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerExit(Collider col){
|
||||
if (col.CompareTag("BlueSplash")){
|
||||
currentSpeed = speed;
|
||||
}
|
||||
|
||||
if (col.CompareTag("BalloonTrigger")){
|
||||
if(currentTime >= timeToShoot && needABalloon){
|
||||
needABalloon = false;
|
||||
canShootAgain = false;
|
||||
charging = false;
|
||||
}else if (needABalloon){
|
||||
currentTime = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void ReturnToMenu(int winner, int looser)
|
||||
{
|
||||
StartCoroutine(AudioManager.instance.FadeOut("05_globos", 1));
|
||||
if (!scoreDistributed)
|
||||
{
|
||||
StartCoroutine(BetweenScenePass.instance.DistributeScore(
|
||||
BetweenScenePass.Games.Baloons,
|
||||
winner,
|
||||
null));
|
||||
|
||||
int newWinner1 = winner;
|
||||
int i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
newWinner1 = Random.Range(0, 6);
|
||||
i++;
|
||||
if (newWinner1 != winner && newWinner1 != looser)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(BetweenScenePass.instance.DistributeScore(
|
||||
BetweenScenePass.Games.Baloons,
|
||||
newWinner1,
|
||||
null));
|
||||
|
||||
int newWinner2;
|
||||
newWinner2 = winner;
|
||||
i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
newWinner2 = Random.Range(0, 6);
|
||||
i++;
|
||||
if (newWinner2 != winner && newWinner2 != looser && newWinner2 != newWinner1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(BetweenScenePass.instance.DistributeScore(
|
||||
BetweenScenePass.Games.Baloons,
|
||||
newWinner2,
|
||||
scenesTransition,
|
||||
1.5f));
|
||||
scoreDistributed = true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/BalloonFight/BallonPlayerController.cs.meta
Normal file
11
Assets/Scripts/BalloonFight/BallonPlayerController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 4a8a8944b54f7b441bad49c89e47a05c
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
47
Assets/Scripts/BalloonFight/BalloonController.cs
Normal file
47
Assets/Scripts/BalloonFight/BalloonController.cs
Normal file
|
@ -0,0 +1,47 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BalloonController : MonoBehaviour, IPooledObject{
|
||||
|
||||
[SerializeField] float shootForce = 10f;
|
||||
[SerializeField] string nameOfTheSplash = "OrangeSplash";
|
||||
[SerializeField] string enemyTag = "Enemy";
|
||||
Rigidbody rb;
|
||||
[SerializeField, Range(1, 3)] int jumpsToExplode = 3;
|
||||
int currentJump;
|
||||
|
||||
void Awake(){
|
||||
rb = GetComponent<Rigidbody>();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
public void OnObjectSpawn(){
|
||||
currentJump = 1;
|
||||
rb.velocity = Vector3.zero;
|
||||
rb.angularVelocity = Vector3.zero;
|
||||
rb.AddForce(transform.forward * shootForce, ForceMode.Impulse);
|
||||
}
|
||||
|
||||
void OnCollisionEnter(Collision col){
|
||||
if(col.gameObject.CompareTag("Ground")){
|
||||
if(currentJump < jumpsToExplode){
|
||||
GameObject splash = ObjectPooler.instance.SpawnFromPool(nameOfTheSplash, new Vector3(transform.position.x, .15f, transform.position.z), Quaternion.Euler(0, Random.Range(0f, 360f), 0));
|
||||
splash.transform.localScale = new Vector3(1, .15f, 1);
|
||||
AudioManager.instance.PlayOneShot("SFX_globoFalla", true);
|
||||
currentJump++;
|
||||
}else{
|
||||
GameObject splash = ObjectPooler.instance.SpawnFromPool(nameOfTheSplash, new Vector3(transform.position.x, .15f, transform.position.z), Quaternion.Euler(0, Random.Range(0f, 360f), 0));
|
||||
splash.transform.localScale = new Vector3(2, .15f, 2);
|
||||
AudioManager.instance.PlayOneShot("SFX_globoImpacta", true);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
|
||||
if (col.gameObject.CompareTag(enemyTag)){
|
||||
GameObject splash = ObjectPooler.instance.SpawnFromPool(nameOfTheSplash, new Vector3(transform.position.x, .15f, transform.position.z), Quaternion.Euler(0, Random.Range(0f, 360f), 0));
|
||||
splash.transform.localScale = new Vector3(2, .15f, 2);
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/BalloonFight/BalloonController.cs.meta
Normal file
11
Assets/Scripts/BalloonFight/BalloonController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 58409a7c5fda95d4982bfb9333bb7f26
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
238
Assets/Scripts/BalloonFight/BalloonEnemyController.cs
Normal file
238
Assets/Scripts/BalloonFight/BalloonEnemyController.cs
Normal file
|
@ -0,0 +1,238 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.AI;
|
||||
|
||||
public class BalloonEnemyController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] ScenesTransitionController scenesTransition;
|
||||
[SerializeField] GameTutorialControler tutorial;
|
||||
|
||||
[SerializeField] Animator anim = default;
|
||||
[SerializeField] Transform player = default;
|
||||
[SerializeField] Transform basketPos = default;
|
||||
NavMeshAgent agent;
|
||||
|
||||
[Space]
|
||||
[SerializeField] Transform shootPos = default;
|
||||
[SerializeField] Vector2 xPos = new Vector2(1, 10);
|
||||
float maxXPos;
|
||||
[SerializeField] float speed = 6f;
|
||||
[SerializeField] float splashSpeed = 3f;
|
||||
[SerializeField] Vector2 timeToShoot = new Vector2(.25f, 2f);
|
||||
float currentSpeed;
|
||||
float rotationVelocity;
|
||||
[SerializeField, Range(0, .3f)] float turnSmoothTime = .1f;
|
||||
float timeSelected;
|
||||
float currentTime;
|
||||
bool canMove;
|
||||
bool needBalloons;
|
||||
|
||||
[SerializeField, Range(0, 10)] float onSplashDecreaseSpeed = .5f;
|
||||
[SerializeField] float maxHp = 100;
|
||||
[SerializeField] float hp;
|
||||
|
||||
[SerializeField] Color splashColor = Color.red;
|
||||
[System.Serializable]
|
||||
public class BodyMaterials{
|
||||
public Material[] bodyMats;
|
||||
}
|
||||
|
||||
[SerializeField] BodyMaterials[] characterMats;
|
||||
CharacterIdController character;
|
||||
|
||||
[Space]
|
||||
[SerializeField] Canvas canvas = default;
|
||||
[SerializeField] UnityEngine.UI.Image chargingBar = default;
|
||||
[SerializeField] GameObject balloon = default;
|
||||
|
||||
bool isDead;
|
||||
bool scoreDistributed;
|
||||
|
||||
[SerializeField, Range(0, 1f)] float stepsInterval = .35f;
|
||||
float currentStepTime;
|
||||
|
||||
// Start is called before the first frame update
|
||||
void Awake(){
|
||||
character = GetComponent<CharacterIdController>();
|
||||
agent = GetComponent<NavMeshAgent>();
|
||||
currentSpeed = speed;
|
||||
canMove = true;
|
||||
maxXPos = Random.Range(xPos.x, xPos.y);
|
||||
anim = character.SetRandomNpcCustom();
|
||||
|
||||
hp = maxHp;
|
||||
|
||||
foreach (Material bodyMat in characterMats[character.characterId].bodyMats)
|
||||
bodyMat.SetColor("Color_9AC6EC04", splashColor);
|
||||
|
||||
foreach (BodyMaterials body in characterMats)
|
||||
foreach (Material bodyMat in body.bodyMats)
|
||||
bodyMat.SetFloat("Vector1_104BE5AC", Mathf.Lerp(-1, 1.5f, 1 - hp / maxHp));
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (tutorial.gameStarted) {
|
||||
balloon.SetActive(!needBalloons);
|
||||
|
||||
if(canMove && !needBalloons){
|
||||
agent.SetDestination(new Vector3(maxXPos, 0, player.position.z));
|
||||
anim.SetFloat("VelocityY", 1);
|
||||
|
||||
currentStepTime += Time.deltaTime;
|
||||
if (currentStepTime >= stepsInterval){
|
||||
AudioManager.instance.PlayOneShot("SFX_paso" + Random.Range(1, 6), true);
|
||||
currentStepTime = 0;
|
||||
}
|
||||
}
|
||||
else if (needBalloons){
|
||||
anim.SetFloat("VelocityY", 1);
|
||||
agent.SetDestination(new Vector3(10, 0, basketPos.position.z));
|
||||
|
||||
currentStepTime += Time.deltaTime;
|
||||
if (currentStepTime >= stepsInterval){
|
||||
AudioManager.instance.PlayOneShot("SFX_paso" + Random.Range(1, 6), true);
|
||||
currentStepTime = 0;
|
||||
}
|
||||
}
|
||||
|
||||
if ((new Vector3(maxXPos, transform.position.y, player.position.z) - transform.position).sqrMagnitude < agent.stoppingDistance * agent.stoppingDistance && !needBalloons || canMove == false){
|
||||
anim.SetFloat("VelocityY", 0);
|
||||
Vector3 direction = new Vector3(player.position.x - transform.position.x, transform.position.y, player.position.z - transform.position.z).normalized;
|
||||
float targetAngle = Mathf.Atan2(direction.x, direction.z) * Mathf.Rad2Deg;
|
||||
float angle = Mathf.SmoothDampAngle(transform.eulerAngles.y, targetAngle, ref rotationVelocity, turnSmoothTime);
|
||||
|
||||
transform.rotation = Quaternion.Euler(0, angle, 0);
|
||||
|
||||
if(Mathf.Abs(transform.eulerAngles.y - angle) < .5f){
|
||||
if(canMove == false){
|
||||
currentTime = Mathf.Clamp(currentTime + Time.deltaTime, 0, timeSelected);
|
||||
chargingBar.transform.localScale = new Vector3(Mathf.Clamp(currentTime / timeSelected, 0, 1), 1);
|
||||
if (currentTime >= timeSelected && !shooting){
|
||||
StartCoroutine(ShootDelay());
|
||||
}
|
||||
}else{
|
||||
timeSelected = Random.Range(timeToShoot.x, timeToShoot.y);
|
||||
currentTime = 0;
|
||||
chargingBar.transform.localScale = new Vector3(0, 1, 1);
|
||||
canMove = false;
|
||||
maxXPos = Random.Range(xPos.x, xPos.y);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if ((new Vector3(10, transform.position.y, basketPos.position.z) - transform.position).sqrMagnitude < agent.stoppingDistance * agent.stoppingDistance && needBalloons && !gettingABalloon){
|
||||
StartCoroutine(GetABalloon());
|
||||
anim.SetFloat("VelocityY", 0);
|
||||
}
|
||||
|
||||
agent.speed = currentSpeed;
|
||||
|
||||
foreach (Material bodyMat in characterMats[character.characterId].bodyMats)
|
||||
bodyMat.SetFloat("Vector1_104BE5AC", Mathf.Lerp(-1, 1.5f, 1 - hp / maxHp));
|
||||
|
||||
if (hp <= 0 && !isDead)
|
||||
{
|
||||
anim.SetTrigger("Die");
|
||||
isDead = true;
|
||||
ReturnToMenu(GameObject.Find("Player").GetComponent<CharacterIdController>().characterId, GetComponent<CharacterIdController>().characterId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LateUpdate(){
|
||||
canvas.transform.rotation = Quaternion.Euler(45, 0, 0);
|
||||
}
|
||||
|
||||
bool gettingABalloon;
|
||||
IEnumerator GetABalloon(){
|
||||
gettingABalloon = true;
|
||||
anim.SetTrigger("Lift");
|
||||
yield return new WaitForSeconds(.5f);
|
||||
needBalloons = false;
|
||||
gettingABalloon = false;
|
||||
StopCoroutine(GetABalloon());
|
||||
}
|
||||
|
||||
bool shooting;
|
||||
|
||||
IEnumerator ShootDelay(){
|
||||
anim.SetTrigger("Throw");
|
||||
shooting = true;
|
||||
yield return new WaitForSeconds(.7f);
|
||||
chargingBar.transform.localScale = new Vector3(0, 1, 1);
|
||||
Shoot();
|
||||
canMove = true;
|
||||
shooting = false;
|
||||
StopAllCoroutines();
|
||||
}
|
||||
|
||||
void Shoot(){
|
||||
needBalloons = true;
|
||||
ObjectPooler.instance.SpawnFromPool("BlueBalloon", shootPos.position, shootPos.rotation);
|
||||
}
|
||||
|
||||
void OnTriggerStay(Collider col){
|
||||
if (col.CompareTag("OrangeSplash")){
|
||||
hp -= onSplashDecreaseSpeed * Time.deltaTime;
|
||||
currentSpeed = splashSpeed;
|
||||
}
|
||||
}
|
||||
|
||||
void OnTriggerExit(Collider col){
|
||||
if (col.CompareTag("OrangeSplash")){
|
||||
currentSpeed = speed;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void ReturnToMenu(int winner, int looser)
|
||||
{
|
||||
StartCoroutine(AudioManager.instance.FadeOut("05_globos", 1));
|
||||
if (!scoreDistributed)
|
||||
{
|
||||
StartCoroutine(BetweenScenePass.instance.DistributeScore(
|
||||
BetweenScenePass.Games.Baloons,
|
||||
winner,
|
||||
null));
|
||||
|
||||
int newWinner1 = winner;
|
||||
int i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
newWinner1 = Random.Range(0, 6);
|
||||
i++;
|
||||
if (newWinner1 != winner && newWinner1 != looser)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(BetweenScenePass.instance.DistributeScore(
|
||||
BetweenScenePass.Games.Baloons,
|
||||
newWinner1,
|
||||
null));
|
||||
|
||||
int newWinner2;
|
||||
newWinner2 = winner;
|
||||
i = 0;
|
||||
while (i < 100)
|
||||
{
|
||||
newWinner2 = Random.Range(0, 6);
|
||||
i++;
|
||||
if (newWinner2 != winner && newWinner2 != looser && newWinner2 != newWinner1)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
StartCoroutine(BetweenScenePass.instance.DistributeScore(
|
||||
BetweenScenePass.Games.Baloons,
|
||||
newWinner2,
|
||||
scenesTransition,
|
||||
1.5f));
|
||||
scoreDistributed = true;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/BalloonFight/BalloonEnemyController.cs.meta
Normal file
11
Assets/Scripts/BalloonFight/BalloonEnemyController.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: d1c432234f0b2274ba7e881f8c6845b4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
33
Assets/Scripts/BalloonFight/BalloonSplash.cs
Normal file
33
Assets/Scripts/BalloonFight/BalloonSplash.cs
Normal file
|
@ -0,0 +1,33 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class BalloonSplash : MonoBehaviour, IPooledObject{
|
||||
|
||||
[SerializeField] float timeToDisappear = 10f;
|
||||
[SerializeField] float disappearDuration = 1f;
|
||||
float currentTime;
|
||||
|
||||
Animator anim;
|
||||
|
||||
void Awake(){
|
||||
anim = GetComponent<Animator>();
|
||||
}
|
||||
|
||||
// Start is called before the first frame update
|
||||
public void OnObjectSpawn(){
|
||||
currentTime = 0;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
currentTime += Time.deltaTime;
|
||||
if (currentTime >= timeToDisappear - disappearDuration){
|
||||
anim.SetTrigger("Destroy");
|
||||
}
|
||||
}
|
||||
|
||||
public void Disable(){
|
||||
gameObject.SetActive(false);
|
||||
}
|
||||
}
|
11
Assets/Scripts/BalloonFight/BalloonSplash.cs.meta
Normal file
11
Assets/Scripts/BalloonFight/BalloonSplash.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: e3de89a3fb0d3f3498c5c83a04d15828
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Add table
Add a link
Reference in a new issue