Archival of the game.
This commit is contained in:
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 6cd30937a5b97c04c91b8238ffc17686
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,68 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
|
||||
public class AntivirusController : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private float posY;
|
||||
[SerializeField] private GameObject AVShot;
|
||||
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
|
||||
|
||||
//Barra de Vida.
|
||||
[SerializeField] private Image barraVida;
|
||||
|
||||
//Combate
|
||||
[SerializeField] private float dañoBalas = 10;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Mov();
|
||||
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
{
|
||||
Disparar();
|
||||
}
|
||||
|
||||
SetHeathBar();
|
||||
|
||||
if (health <= 0)
|
||||
{
|
||||
GameObject gamesystem = GameObject.FindGameObjectWithTag("GameSystem");
|
||||
gamesystem.GetComponent<GameSystem>().EndGame();
|
||||
}
|
||||
}
|
||||
|
||||
private void Mov()
|
||||
{
|
||||
Vector2 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
mousePos.x = Mathf.Clamp(mousePos.x, -8.2f, 8.2f);
|
||||
|
||||
this.transform.position = new Vector2(mousePos.x, posY);
|
||||
|
||||
}
|
||||
|
||||
public void Disparar()
|
||||
{
|
||||
Instantiate(AVShot, this.gameObject.transform.position, AVShot.transform.rotation);
|
||||
}
|
||||
|
||||
private void SetHeathBar()
|
||||
{
|
||||
barraVida.fillAmount = health / maxHealth;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("V-Shot"))
|
||||
{
|
||||
health = health - dañoBalas;
|
||||
Destroy(collision.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1cecaae6e2f4a724b8e96752d8936fac
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,51 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class DefensasSystem : MonoBehaviour
|
||||
{
|
||||
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
|
||||
//Barra de Vida.
|
||||
[SerializeField] private Image barraVida;
|
||||
[SerializeField] private GameObject healthPanel;
|
||||
|
||||
|
||||
//Combate
|
||||
[SerializeField] private float dañoBalas = 10;
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if(health != maxHealth)
|
||||
{
|
||||
healthPanel.gameObject.SetActive(true);
|
||||
SetHealthBar();
|
||||
}
|
||||
|
||||
if(health == 0)
|
||||
{
|
||||
healthPanel.gameObject.SetActive(false);
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void SetHealthBar()
|
||||
{
|
||||
barraVida.fillAmount = health / maxHealth;
|
||||
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if(collision.gameObject.CompareTag("V-Shot") || collision.gameObject.CompareTag("AV-Shot"))
|
||||
{
|
||||
health = health - dañoBalas;
|
||||
Destroy(collision.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 1ddc977a2ebadff4ca43ba6b0b2e822b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,37 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MovimientoBalas : MonoBehaviour {
|
||||
|
||||
public float balaSpeed;
|
||||
[SerializeField] private bool haveMov;
|
||||
[SerializeField] private float maxYValue;
|
||||
[SerializeField] private float minYValue;
|
||||
|
||||
|
||||
void Update ()
|
||||
{
|
||||
if (haveMov)
|
||||
{
|
||||
BalaMove();
|
||||
}
|
||||
|
||||
if(transform.position.y > maxYValue || transform.position.y < minYValue)
|
||||
{
|
||||
DestroyBala();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void BalaMove()
|
||||
{
|
||||
transform.position = new Vector2(transform.position.x, transform.position.y + 1 * balaSpeed);
|
||||
}
|
||||
|
||||
public void DestroyBala()
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 784b539d4d0d5b642b936ded02b23649
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,82 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class VirusController : MonoBehaviour
|
||||
{
|
||||
public float health;
|
||||
public float maxHealth;
|
||||
[SerializeField] private float dañoBalas = 10;
|
||||
|
||||
[SerializeField] private Image barraVida;
|
||||
|
||||
|
||||
//Movimiento y disparo.
|
||||
[SerializeField] private float speed;
|
||||
[SerializeField] private float MinShotTime;
|
||||
[SerializeField] private float MaxShotTime;
|
||||
private Transform target;
|
||||
|
||||
[SerializeField] private GameObject VShot;
|
||||
private bool isShot;
|
||||
float time;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
target = GameObject.FindGameObjectWithTag("AntiVirus").GetComponent<Transform>();
|
||||
isShot = true;
|
||||
Shot();
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
SetHealthBar();
|
||||
|
||||
if (health <= 0)
|
||||
{
|
||||
StopAllCoroutines();
|
||||
GameObject gamesystem = GameObject.FindGameObjectWithTag("GameSystem");
|
||||
gamesystem.GetComponent<GameSystem>().WinGame();
|
||||
}
|
||||
|
||||
Vector2 AVPos = new Vector2(target.position.x, transform.position.y);
|
||||
transform.position = Vector2.MoveTowards(transform.position, AVPos, speed * Time.deltaTime);
|
||||
|
||||
time = Random.Range(MinShotTime, MaxShotTime);
|
||||
}
|
||||
|
||||
private void Shot()
|
||||
{
|
||||
StartCoroutine(Shoting());
|
||||
}
|
||||
|
||||
IEnumerator Shoting()
|
||||
{
|
||||
while (isShot)
|
||||
{
|
||||
yield return new WaitForSeconds(time);
|
||||
Vector3 virusPos = new Vector3(this.gameObject.transform.position.x, this.gameObject.transform.position.y, 0f);
|
||||
|
||||
Instantiate(VShot, virusPos, Quaternion.Euler(0,0,0));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void SetHealthBar()
|
||||
{
|
||||
barraVida.fillAmount = health / maxHealth;
|
||||
}
|
||||
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("AV-Shot"))
|
||||
{
|
||||
Debug.Log("tocado");
|
||||
health = health - dañoBalas;
|
||||
Destroy(collision.gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 0fba2422b514c6c4e9298802e554f60a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,41 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CerrarVentana : MonoBehaviour {
|
||||
|
||||
[SerializeField] private GameObject objetoADestruir;
|
||||
[SerializeField] private GameObject gameSystem;
|
||||
|
||||
public bool isOpen = true;
|
||||
float ram;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
gameSystem = GameObject.FindGameObjectWithTag("GameSystem");
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ram = gameSystem.GetComponent<GameSystem>().ramUsage;
|
||||
}
|
||||
|
||||
|
||||
private void OnMouseDown()
|
||||
{
|
||||
isOpen = false;
|
||||
DestroyVentana();
|
||||
}
|
||||
|
||||
|
||||
public void DestroyVentana()
|
||||
{
|
||||
if (isOpen == false)
|
||||
{
|
||||
Destroy(objetoADestruir);
|
||||
ram = ram - 10;
|
||||
gameSystem.GetComponent<GameSystem>().ramUsage = ram;
|
||||
gameSystem.GetComponent<GameSystem>().ventanasCerradas++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5489bedc93cdee24099a74031114ec4b
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,249 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class DialogosSystem : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject gameSystem;
|
||||
|
||||
[SerializeField] private GameObject dialogosPanel;
|
||||
[SerializeField] private Text dialogoText;
|
||||
[SerializeField] private Text nameText;
|
||||
[SerializeField] private Image hablante;
|
||||
|
||||
|
||||
[SerializeField] private string[] stringsDialogo1;
|
||||
[SerializeField] private int[] hablanteSegunHistoria1;
|
||||
|
||||
[SerializeField] private string[] stringsDialogo2;
|
||||
[SerializeField] private int[] hablanteSegunHistoria2;
|
||||
|
||||
[SerializeField] private string[] stringsDialogo3;
|
||||
[SerializeField] private int[] hablanteSegunHistoria3;
|
||||
|
||||
[SerializeField] private string[] stringsDialogoFail;
|
||||
[SerializeField] private int[] hablanteSegunHistoriaFail;
|
||||
|
||||
[SerializeField] private string[] stringsDialogoWin;
|
||||
[SerializeField] private int[] hablanteSegunHistoriaWin;
|
||||
|
||||
|
||||
[SerializeField] private Sprite[] hablanteSprites;
|
||||
[SerializeField] private string[] hablanteNames;
|
||||
|
||||
//Partes Historia
|
||||
[SerializeField] private bool isDialogos1;
|
||||
int dialogosInt1;
|
||||
[SerializeField] private bool isDialogos2;
|
||||
int dialogosInt2;
|
||||
[SerializeField] private bool isDialogos3;
|
||||
int dialogosInt3;
|
||||
[SerializeField] private bool isDialogosFail;
|
||||
int dialogosIntFail;
|
||||
[SerializeField] private bool isDialogosWin;
|
||||
int dialogosIntWin;
|
||||
|
||||
//GameSystems
|
||||
private int ventanasCerradas;
|
||||
private double time;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
isDialogos1 = true;
|
||||
isDialogos2 = false;
|
||||
isDialogos3 = false;
|
||||
isDialogosFail = false;
|
||||
isDialogosWin = false;
|
||||
|
||||
dialogosInt1 = -1;
|
||||
dialogosInt2 = -1;
|
||||
dialogosInt3 = -1;
|
||||
dialogosIntFail = -1;
|
||||
dialogosIntWin = -1;
|
||||
}
|
||||
|
||||
|
||||
private void Update()
|
||||
{
|
||||
ventanasCerradas = gameSystem.GetComponent<GameSystem>().ventanasCerradas;
|
||||
time = gameSystem.GetComponent<GameSystem>().remTime;
|
||||
|
||||
if (Input.GetMouseButtonDown(1))
|
||||
{
|
||||
if(dialogosPanel.activeSelf == true)
|
||||
{
|
||||
Debug.Log("Siguiente");
|
||||
HistoriaPartDetector();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (time <= 0 && isDialogos2 == true)
|
||||
{
|
||||
gameSystem.GetComponent<GameSystem>().PausaResumeGame();
|
||||
dialogosPanel.SetActive(true);
|
||||
|
||||
isDialogos1 = false;
|
||||
isDialogos2 = false;
|
||||
isDialogos3 = true;
|
||||
|
||||
HistoriaPartDetector();
|
||||
}
|
||||
|
||||
if (ventanasCerradas == 5 && isDialogos1 == true)
|
||||
{
|
||||
gameSystem.GetComponent<GameSystem>().PausaResumeGame();
|
||||
dialogosPanel.SetActive(true);
|
||||
|
||||
isDialogos1 = false;
|
||||
isDialogos2 = true;
|
||||
|
||||
HistoriaPartDetector();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isDialogosFail == false && gameSystem.GetComponent<GameSystem>().fail == true)
|
||||
{
|
||||
dialogosPanel.SetActive(true);
|
||||
|
||||
isDialogos1 = false;
|
||||
isDialogos2 = false;
|
||||
isDialogos3 = false;
|
||||
isDialogosFail = true;
|
||||
|
||||
HistoriaPartDetector();
|
||||
}
|
||||
|
||||
if (isDialogosWin == false && gameSystem.GetComponent<GameSystem>().win == true)
|
||||
{
|
||||
dialogosPanel.SetActive(true);
|
||||
|
||||
isDialogos1 = false;
|
||||
isDialogos2 = false;
|
||||
isDialogos3 = false;
|
||||
isDialogosFail = false;
|
||||
isDialogosWin = true;
|
||||
|
||||
HistoriaPartDetector();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void HistoriaPartDetector()
|
||||
{
|
||||
Debug.Log("Detectando Historia");
|
||||
|
||||
if (isDialogos1 == true)
|
||||
{
|
||||
dialogosInt1++;
|
||||
}
|
||||
if (isDialogos2 == true)
|
||||
{
|
||||
dialogosInt2++;
|
||||
}
|
||||
if (isDialogos3 == true)
|
||||
{
|
||||
dialogosInt3++;
|
||||
}
|
||||
|
||||
if (isDialogosFail == true)
|
||||
{
|
||||
dialogosIntFail++;
|
||||
}
|
||||
if (isDialogosWin == true)
|
||||
{
|
||||
dialogosIntWin++;
|
||||
}
|
||||
|
||||
|
||||
if (isDialogos1 == true && dialogosInt1 < 3)
|
||||
{
|
||||
UpdateHistoria(stringsDialogo1, hablanteSegunHistoria1 ,dialogosInt1);
|
||||
}
|
||||
if(isDialogos1 == true && dialogosInt1 == 3)
|
||||
{
|
||||
dialogosPanel.SetActive(false);
|
||||
|
||||
gameSystem.GetComponent<GameSystem>().StartGame();
|
||||
}
|
||||
|
||||
if(isDialogos2 == true && dialogosInt2 < 2)
|
||||
{
|
||||
Debug.Log(dialogosInt2);
|
||||
UpdateHistoria(stringsDialogo2, hablanteSegunHistoria2, dialogosInt2);
|
||||
}
|
||||
if (isDialogos2 == true && dialogosInt2 == 2)
|
||||
{
|
||||
dialogosPanel.SetActive(false);
|
||||
|
||||
gameSystem.GetComponent<GameSystem>().StartGame();
|
||||
gameSystem.GetComponent<GameSystem>().ramUsage = 2;
|
||||
}
|
||||
|
||||
if (isDialogos3 == true && dialogosInt3 < 2)
|
||||
{
|
||||
UpdateHistoria(stringsDialogo3, hablanteSegunHistoria3, dialogosInt3);
|
||||
}
|
||||
if (isDialogos3 == true && dialogosInt3 == 2)
|
||||
{
|
||||
dialogosPanel.SetActive(false);
|
||||
|
||||
gameSystem.GetComponent<GameSystem>().StartFinalBattle();
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (isDialogosFail == true && dialogosIntFail < 3)
|
||||
{
|
||||
UpdateHistoria(stringsDialogoFail, hablanteSegunHistoriaFail, dialogosIntFail);
|
||||
}
|
||||
if (isDialogosFail == true && dialogosIntFail == 3)
|
||||
{
|
||||
dialogosPanel.SetActive(false);
|
||||
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
|
||||
|
||||
if (isDialogosWin == true && dialogosIntWin < 3)
|
||||
{
|
||||
UpdateHistoria(stringsDialogoWin, hablanteSegunHistoriaWin, dialogosIntWin);
|
||||
}
|
||||
if (isDialogosWin == true && dialogosIntWin == 3)
|
||||
{
|
||||
dialogosPanel.SetActive(false);
|
||||
|
||||
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void UpdateHistoria(string[] stringsDialogo, int[] queHablante,int dialogoNumber)
|
||||
{
|
||||
Debug.Log("actualizando Historia");
|
||||
|
||||
dialogoText.text = stringsDialogo[dialogoNumber];
|
||||
|
||||
if(queHablante[dialogoNumber] == 0)
|
||||
{
|
||||
hablante.sprite = hablanteSprites[0];
|
||||
nameText.text = hablanteNames[0];
|
||||
}
|
||||
if (queHablante[dialogoNumber] == 1)
|
||||
{
|
||||
hablante.sprite = hablanteSprites[1];
|
||||
nameText.text = hablanteNames[1];
|
||||
}
|
||||
if (queHablante[dialogoNumber] == 2)
|
||||
{
|
||||
hablante.sprite = hablanteSprites[2];
|
||||
nameText.text = hablanteNames[2];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 31e0875d68323f24a8fb0c33ef1ca8a4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,205 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class GameSystem : MonoBehaviour {
|
||||
|
||||
//variables de crear ventanas
|
||||
[SerializeField] private GameObject[] ventanasPrefab;
|
||||
[SerializeField] private Vector2 spawnValues;
|
||||
[SerializeField] private float spawnWait;
|
||||
[SerializeField] private float maxSpawnWait;
|
||||
[SerializeField] private float minSpawnWait;
|
||||
|
||||
public bool generate;
|
||||
private int randEnemy;
|
||||
|
||||
//Barra de Ram
|
||||
public float ramUsage = 10f;
|
||||
public float maxRam = 100f;
|
||||
[SerializeField] public Image RamBarra;
|
||||
[SerializeField] private float barVibration;
|
||||
|
||||
|
||||
//StartGame variables
|
||||
[SerializeField] private GameObject dialogoSystem;
|
||||
[SerializeField] private GameObject ramPanel;
|
||||
[SerializeField] private GameObject ventanas;
|
||||
|
||||
public double remTime;
|
||||
public bool haveTimer;
|
||||
[SerializeField] private Text timer;
|
||||
[SerializeField] private GameObject timerPanel;
|
||||
|
||||
//Dialogos Entre partidas
|
||||
public int ventanasCerradas = 0;
|
||||
public bool fail;
|
||||
public bool win;
|
||||
|
||||
//Battalla Final
|
||||
[SerializeField] private GameObject antivirus;
|
||||
[SerializeField] private GameObject virus;
|
||||
[SerializeField] private GameObject defensas;
|
||||
[SerializeField] private GameObject panelBatallaFinal;
|
||||
|
||||
|
||||
private void Start()
|
||||
{
|
||||
RamBarra.GetComponent<Image>();
|
||||
ventanasCerradas = 0;
|
||||
fail = false;
|
||||
win = false;
|
||||
haveTimer = false;
|
||||
}
|
||||
|
||||
void Update ()
|
||||
{
|
||||
spawnWait = Random.Range(minSpawnWait, maxSpawnWait);
|
||||
|
||||
float ram = ramUsage;
|
||||
ramUsage = Random.Range(ramUsage-barVibration, ramUsage+barVibration);
|
||||
SetRamBar();
|
||||
ramUsage = ram;
|
||||
|
||||
if(ramUsage >= maxRam && fail == false)
|
||||
{
|
||||
EndGame();
|
||||
}
|
||||
|
||||
if (haveTimer)
|
||||
{
|
||||
remTime = remTime - Time.deltaTime;
|
||||
timer.text = remTime.ToString();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#region Start/End Game
|
||||
public void StartGame()
|
||||
{
|
||||
Debug.Log("Empieza El juego");
|
||||
|
||||
ventanasCerradas = 0;
|
||||
ramUsage = 2;
|
||||
remTime = 60;
|
||||
haveTimer = true;
|
||||
timerPanel.SetActive(true);
|
||||
|
||||
ramPanel.SetActive(true);
|
||||
generate = true;
|
||||
|
||||
CreateVentana();
|
||||
}
|
||||
|
||||
public void StartFinalBattle()
|
||||
{
|
||||
generate = false;
|
||||
|
||||
ramPanel.SetActive(false);
|
||||
panelBatallaFinal.SetActive(true);
|
||||
defensas.SetActive(true);
|
||||
antivirus.SetActive(true);
|
||||
virus.SetActive(true);
|
||||
}
|
||||
|
||||
|
||||
public void PausaResumeGame()
|
||||
{
|
||||
generate = false;
|
||||
haveTimer = false;
|
||||
timerPanel.SetActive(false);
|
||||
GameObject[] todasVentanas = GameObject.FindGameObjectsWithTag("Ventana");
|
||||
|
||||
int i = 0;
|
||||
while (i < todasVentanas.Length)
|
||||
{
|
||||
Destroy(todasVentanas[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
public void EndGame()
|
||||
{
|
||||
Debug.Log("Perdiste El juego");
|
||||
generate = false;
|
||||
GameObject[] todasVentanas = GameObject.FindGameObjectsWithTag("Ventana");
|
||||
|
||||
int i = 0;
|
||||
while(i < todasVentanas.Length)
|
||||
{
|
||||
Destroy(todasVentanas[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
fail = true;
|
||||
|
||||
ramPanel.SetActive(false);
|
||||
panelBatallaFinal.SetActive(false);
|
||||
defensas.SetActive(false);
|
||||
antivirus.SetActive(false);
|
||||
virus.SetActive(false);
|
||||
|
||||
}
|
||||
|
||||
public void WinGame()
|
||||
{
|
||||
Debug.Log("Ganaste El juego");
|
||||
generate = false;
|
||||
GameObject[] todasVentanas = GameObject.FindGameObjectsWithTag("Ventana");
|
||||
|
||||
int i = 0;
|
||||
while (i < todasVentanas.Length)
|
||||
{
|
||||
Destroy(todasVentanas[i]);
|
||||
i++;
|
||||
}
|
||||
|
||||
panelBatallaFinal.SetActive(false);
|
||||
defensas.SetActive(false);
|
||||
antivirus.SetActive(false);
|
||||
virus.SetActive(false);
|
||||
|
||||
|
||||
win = true;
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
private void SetRamBar()
|
||||
{
|
||||
RamBarra.fillAmount = ramUsage / maxRam;
|
||||
}
|
||||
|
||||
|
||||
#region Crear ventanas
|
||||
|
||||
public void CreateVentana()
|
||||
{
|
||||
StartCoroutine(CreateWindow());
|
||||
}
|
||||
|
||||
IEnumerator CreateWindow()
|
||||
{
|
||||
yield return new WaitForSeconds(spawnWait);
|
||||
|
||||
while (generate)
|
||||
{
|
||||
randEnemy = Random.Range(0, 2);
|
||||
Vector3 SpawnPos = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), Random.Range(-spawnValues.y, spawnValues.y), 0);
|
||||
|
||||
Instantiate(ventanasPrefab[randEnemy], SpawnPos + transform.TransformPoint(0, 0, 0), transform.rotation);
|
||||
ramUsage = ramUsage + 10;
|
||||
yield return new WaitForSeconds(spawnWait);
|
||||
}
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e676ca529b050c54e86cf30f0d5381ec
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MenuSystem : MonoBehaviour {
|
||||
|
||||
public void QuitGame()
|
||||
{
|
||||
Application.Quit();
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 9d4d3bf97ad805b48b27949291439911
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,56 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class MoverVentanas : MonoBehaviour {
|
||||
|
||||
[SerializeField] private float yVariation;
|
||||
[SerializeField] private GameObject interactuaCon;
|
||||
|
||||
public GameObject[] todasLasVentanas;
|
||||
[SerializeField] private bool isSelected;
|
||||
|
||||
private void OnMouseDrag()
|
||||
{
|
||||
Vector2 MousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
|
||||
MousePos.x = Mathf.Clamp(MousePos.x, -5.1f, 5.1f);
|
||||
MousePos.y = Mathf.Clamp(MousePos.y, -3.1f, 4.75f);
|
||||
|
||||
interactuaCon.gameObject.transform.position = new Vector2(MousePos.x, MousePos.y - yVariation);
|
||||
|
||||
interactuaCon.GetComponentInParent<SpriteRenderer>().sortingOrder = 1;
|
||||
|
||||
//isSelected = true;
|
||||
}
|
||||
|
||||
private void OnMouseDown()
|
||||
{
|
||||
SetOrdingLayerTo0();
|
||||
|
||||
/*
|
||||
if (!isSelected)
|
||||
{
|
||||
SetOrdingLayerTo0();
|
||||
}
|
||||
if (isSelected)
|
||||
{
|
||||
isSelected = false;
|
||||
}
|
||||
*/
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void SetOrdingLayerTo0()
|
||||
{
|
||||
int i = 0;
|
||||
todasLasVentanas = GameObject.FindGameObjectsWithTag("Ventana");
|
||||
|
||||
while (i < todasLasVentanas.Length)
|
||||
{
|
||||
todasLasVentanas[i].GetComponent<SpriteRenderer>().sortingOrder = 0;
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ad6a848488d0c5e459e4b61581f6fb1a
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,9 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class VentanasSystem : MonoBehaviour
|
||||
{
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 4d851c1bfe14404439f74eb130ff7e02
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user