Programación Orientada a Objetos (Tower defense - kingdom rush)
Moderator: julianmartinez16
-
JAntonio
- Posts: 13
- Joined: Tue Jan 22, 2019 2:05 pm
Post
by JAntonio » Tue Mar 05, 2019 7:24 pm
SPRINT 6 Marzo 1 - Marzo 8
QUE HICIMOS HOY?
-Base de los enemigos
-Terminar aliados
-Programar aparición de enemigos y aliados
-Programar detección de enemigos
-Programar disparo a enemigos
QUE HAREMOS HASTA EL PRÓXIMO POST?
- destrucción de la bala
- vida de enemigos
-vida de aliados

Jesus Antonio Buitrago Duque
Pdoo2
-
000287377
- Posts: 12
- Joined: Tue Jan 22, 2019 2:06 pm
Post
by 000287377 » Tue Mar 05, 2019 9:18 pm
Daniel Garcia Negrette
Pdoo 2
-
000287377
- Posts: 12
- Joined: Tue Jan 22, 2019 2:06 pm
Post
by 000287377 » Wed Mar 13, 2019 6:31 pm
SPRINT 7 Marzo 12 - Marzo 19
QUE HICIMOS HOY?
- Ver vídeos explicativos sobre el uso de animaciones 2d a unity
- Sprites de vida y tiempos de uso de habilidades
- Programar aparición de enemigos y aliados
QUE HAREMOS HASTA EL PRÓXIMO POST?
- Implementar animaciones ya terminadas en Unity.
Daniel Garcia Negrette
Pdoo 2
-
JAntonio
- Posts: 13
- Joined: Tue Jan 22, 2019 2:05 pm
Post
by JAntonio » Mon Apr 01, 2019 6:36 pm
SPRINT 8 Marzo 19 - Marzo 26
QUE HICIMOS HOY?
- Ver vídeos explicativos sobre el uso de botones para cambios de escenario
- Reducción de vida visible en el juego
-
QUE HAREMOS HASTA EL PRÓXIMO POST?
-Aplicar tiempos de vida de las balas
-Aplicar tiempos de velocidad de ataque
-Orden de tags y nombres
Que problemas tuvimos?
-Se nos boro la ultima bebercio de proyecto
-tuvimos que repetir el movimiento y spawn de enemigos
Jesus Antonio Buitrago Duque
Pdoo2
-
000287377
- Posts: 12
- Joined: Tue Jan 22, 2019 2:06 pm
Post
by 000287377 » Mon Apr 01, 2019 11:47 pm
SPRINT 8 Marzo 26 - Abril 2
QUE HICIMOS HOY?
- Controlar animaciones del juego por medio del animator.
- Programar diferentes cambios de animaciones por medio de colisiones.
QUE HAREMOS HASTA EL PRÓXIMO POST?
- Hacer la presentación pp y montarla a slideshare.
- Revisar el funcionamiento del juego.
Que problemas tuvimos?
- No sabemos como hacer el cambio de animaciones.
- No sabemos como hacer que los clones tengan los mismo parámetros que los principales.
Daniel Garcia Negrette
Pdoo 2
-
JAntonio
- Posts: 13
- Joined: Tue Jan 22, 2019 2:05 pm
Post
by JAntonio » Fri Apr 05, 2019 10:59 am
SPRINT 9 Abril 2 - Abril 9
QUE HICIMOS HOY?
- Correcciones del código del spawn
- Ponerle tiempo de vida a las balas
- Corregimos los tags y nombres de los elementos del juego
QUE HAREMOS HASTA EL PRÓXIMO POST?
- Evitar que la bala se genere al interior del enemigo
- Aplicar listas para reconocimiento de los enemigos
- Corregir la vida de las unidades
- Que la detección se de en todas las copias deforma adecuada
Que problemas tuvimos?
- Cuando una tropa recibe daño todas sus copias también daño todos los enemigos
- La detección de los enemigos no se da de forma correcta
- Una gran dificultad para coincidir en los orarios disponibles para reunirnos
- la semana pasada en medio del trabajo a un miembro del equipo se le fue la luz

Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Vidah : MonoBehaviour
{
Transform mtransform;
Torresh humano;
// Start is called before the first frame update
void Start()
{
mtransform = GetComponent<Transform>();
humano = GetComponentInParent<Torresh>();
}
// Update is called once per frame
void Update()
{
mtransform.localScale = new Vector3(Torresh.vidah, 1 , 0f);
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Vida : MonoBehaviour
{
Transform mtransform;
Torres demonio;
// Start is called before the first frame update
void Start()
{
mtransform = GetComponent<Transform>();
demonio = GetComponentInParent<Torres>();
}
// Update is called once per frame
void Update()
{
transform.localScale = new Vector3(Torres.vida, 1, 0f);
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Torresh : MonoBehaviour
{
public GameObject enemigoh ;
public GameObject punto;
private float distancia_umbral;
private bool estaActivo;
public static float vidah;
public float damage;
public float attackspeed;
float t = 0;
public bool EstaActivo { get => estaActivo; set => estaActivo = value; }
// Start is called before the first frame update
void Start()
{
enemigoh = GameObject.FindGameObjectWithTag("Volador");
attackspeed = 2;
distancia_umbral = 4;
vidah = 100;
damage = 10;
}
// Update is called once per frame
void Update()
{
t += Time.deltaTime;
float distancia = (enemigoh.transform.position - this.transform.position).magnitude;
if (distancia <= distancia_umbral)
{
Debug.DrawLine(this.transform.position, enemigoh.transform.position, Color.green);
Disparar();
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Volador")
{
vidah -= damage;
if (vidah <= 0)
{
Destroy(gameObject);
}
}
}
public void Disparar()
{
if (t > 1 / attackspeed)
{
GameObject balaR = Instantiate(GameObject.Find("Bala2"), punto.transform.position, Quaternion.identity);
Bala2 bala = balaR.GetComponent<Bala2>();
bala.disparado = true;
bala.ActivarBala(this);
t = 0;
}
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Torres : MonoBehaviour
{
public GameObject enemigo;
public GameObject punto;
private float distancia_umbral;
private bool estaActiv;
public static float vida;
public float damage;
public float attackspeed;
float t = 0;
public bool EstaActivo { get => estaActiv; set => estaActiv = value; }
// Start is called before the first frame update
void Start()
{
enemigo = GameObject.FindGameObjectWithTag("Jugador");
attackspeed = 2;
distancia_umbral = 4;
vida = 100;
damage = 10;
}
// Update is called once per frame
void Update()
{
t += Time.deltaTime;
float distancia = (enemigo.transform.position - this.transform.position).magnitude;
if (distancia <= distancia_umbral)
{
Disparar();
Debug.DrawLine(this.transform.position, enemigo.transform.position, Color.green);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Jugador")
{
vida -= damage;
if (vida <= 0)
{
Destroy(gameObject);
}
}
}
public void Disparar()
{
if (t > 1 / attackspeed)
{
GameObject balaR = Instantiate(GameObject.Find("Bala"), punto.transform.position, Quaternion.identity);
Bala bala = balaR.GetComponent<Bala>();
bala.disparado = true;
bala.ActivarBala(this);
t = 0;
}
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bala2 : MonoBehaviour
{
private GameObject bala;
private float velocidad;
float t = 0;
public bool disparado = false;
float tiempodevida;
// Start is called before the first frame update
void Start()
{
velocidad = 2;
tiempodevida = 4;
}
// Update is called once per frame
void Update()
{
Vector3 direccion;
if (bala != null)
{
direccion = bala.transform.position - this.transform.position;
this.transform.position += velocidad * direccion * Time.deltaTime;
}
if (disparado == true)
{
t += Time.deltaTime;
if (t > tiempodevida) { Destroy(gameObject); }
}
}
public void ActivarBala(Torresh torre)
{
bala = torre.enemigoh;
}
private void OnCollisionEnter2D(Collision2D collision)
{
float t = Time.deltaTime;
if (collision.gameObject.tag == "Volador" || t >= 5)
{
Destroy(gameObject);
}
}
}
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Bala : MonoBehaviour
{
private GameObject bala;
private float velocidad;
float t = 0;
public bool disparado = false;
float tiempodevida;
// Start is called before the first frame update
void Start()
{
velocidad = 2;
tiempodevida = 4;
}
// Update is called once per frame
void Update()
{
Vector3 direccion;
if (bala != null)
{
direccion = bala.transform.position - this.transform.position;
this.transform.position += velocidad * direccion * Time.deltaTime;
}
if (disparado == true)
{
t += Time.deltaTime;
if (t > tiempodevida) { Destroy(gameObject); }
}
}
public void ActivarBala(Torres torre)
{
bala = torre.enemigo;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Jugador")
{
Destroy(gameObject);
}
}
}
Jesus Antonio Buitrago Duque
Pdoo2
-
JAntonio
- Posts: 13
- Joined: Tue Jan 22, 2019 2:05 pm
Post
by JAntonio » Sat Apr 06, 2019 11:15 am
Problemas con el docente frente ala respuesta de dudas
06 Abril
¿Que hicimos hoy?.
- Evitar que la bala se genere al interior del enemigo.
- Aplicar listas para reconocimiento de los enemigos.
- Corregir la vida de las unidades.
- Que la detección se de en todas las copias deforma adecuada.
¿QUE HAREMOS HASTA EL PRÓXIMO POST?
- Aplicar los códigos a todos los personajes.
- Pantalla de victoria.
- Pantalla de derrota.
¿Que problemas tuvimos?
- Una gran dificultad para coincidir en los orarios disponibles para reunirnos
- Al intentar usar un puling de objetos nos saltan errores con los demás códigos
Negrette
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VidaHumano : MonoBehaviour
{
private Transform mtransform;
private Humanos humano;
// Start is called before the first frame update
void Start()
{
mtransform = GetComponent<Transform>();
humano = GetComponentInParent<Humanos>();
}
// Update is called once per frame
void Update()
{
transform.localScale = new Vector3(humano.Vida, 1, 0f);
}
}
Jesus Antonio
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class VidaDemonio : MonoBehaviour
{
private Transform mtransform;
private Demonios demonio;
// Start is called before the first frame update
void Start()
{
mtransform = GetComponent<Transform>();
demonio = GetComponentInParent<Demonios>();
}
// Update is called once per frame
void Update()
{
transform.localScale = new Vector3(demonio.Vida, 1, 0f);
}
}
Jesus Antonio
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Spawn : MonoBehaviour
{
public GameObject unidadACopiar;
public GameObject punto;
public float attackspeed;
private ArrayList enemigosActivos;
private float t = 0;
private int limiteDeCopias;
private int contadorDeCopias;
public ArrayList EnemigosActivos
{
get
{
return enemigosActivos;
}
}
// Start is called before the first frame update
void Start()
{
attackspeed = 1;
enemigosActivos = new ArrayList();
limiteDeCopias = 5;
}
// Update is called once per frame
void Update()
{
t += Time.deltaTime;
Clonar();
foreach (GameObject enemigoI in EnemigosActivos)
{
if (enemigoI ==null)
{
enemigosActivos.Remove(enemigoI);
}
}
}
public void Clonar()
{
if (t > 1 / attackspeed && contadorDeCopias < limiteDeCopias)
{
GameObject spawnR = Instantiate(unidadACopiar, punto.transform.position, Quaternion.identity);
enemigosActivos.Add(spawnR);
contadorDeCopias += 1;
t = 0;
}
}
}
Negrette
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Humanos : MonoBehaviour
{
public GameObject puntoDeCreacionDeBala;
private Spawn spawnDeDemonio;
private float distancia_umbral;
private float vida;
private float danoRecivido;
private float velocidadDeAtaque;
private float tiempo;
public float Vida { get => vida; set => vida = value; }
// Start is called before the first frame update
void Start()
{
velocidadDeAtaque = 2;
distancia_umbral = 4;
vida = 100;
danoRecivido = 10;
spawnDeDemonio = GameObject.Find("SpawnDemonio").GetComponent<Spawn>();
}
// Update is called once per frame
void Update()
{
tiempo += Time.deltaTime;
foreach (GameObject enemigoI in spawnDeDemonio.EnemigosActivos)
{
float distancia = (enemigoI.transform.position - this.transform.position).magnitude;
if (distancia <= distancia_umbral)
{
Debug.DrawLine(this.transform.position, enemigoI.transform.position, Color.green);
Disparar(enemigoI);
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Bala Demonio")
{
vida -= danoRecivido;
if (vida <= 0)
{
Destroy(gameObject);
}
}
}
public void Disparar(GameObject objetivo)
{
if (tiempo > 1 / velocidadDeAtaque)
{
GameObject balaR = Instantiate(GameObject.Find("Bala Humano"), puntoDeCreacionDeBala.transform.position, Quaternion.identity);
BalaHumano bala = balaR.GetComponent<BalaHumano>();
bala.disparado = true;
bala.ActivarBala(objetivo);
tiempo = 0;
}
}
}
Jesus Antonio
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Demonios : MonoBehaviour
{
public GameObject puntoDeCreacionDeBala;
private Spawn spawnDeHumanos;
private float distancia_umbral;
private float vida;
private float danoRecivido;
private float velocidadDeAtaque;
private float tiempo;
public float Vida { get => vida; set => vida = value; }
// Start is called before the first frame update
void Start()
{
velocidadDeAtaque = 2;
distancia_umbral = 4;
vida = 100;
danoRecivido = 10;
spawnDeHumanos = GameObject.Find("SpawnHumano").GetComponent<Spawn>();
}
// Update is called once per frame
void Update()
{
tiempo += Time.deltaTime;
foreach (GameObject enemigoI in spawnDeHumanos.EnemigosActivos)
{
float distancia = (enemigoI.transform.position - this.transform.position).magnitude;
if (distancia <= distancia_umbral)
{
Debug.DrawLine(this.transform.position, enemigoI.transform.position, Color.green);
Disparar(enemigoI);
}
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Bala Humano")
{
vida -= danoRecivido;
if (vida <= 0)
{
Destroy(gameObject);
}
}
}
public void Disparar(GameObject objetivo)
{
if (tiempo > 1 / velocidadDeAtaque)
{
GameObject balaR = Instantiate(GameObject.Find("Bala Demonio"), puntoDeCreacionDeBala.transform.position, Quaternion.identity);
BalaDemonio bala = balaR.GetComponent<BalaDemonio>();
bala.disparado = true;
bala.ActivarBala(objetivo);
tiempo = 0;
}
}
}
Negrette
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BalaHumano : MonoBehaviour
{
private GameObject bala;
private float velocidad;
private float tiempo;
public bool disparado;
private float tiempodevida;
// Start is called before the first frame update
void Start()
{
velocidad = 2;
tiempodevida = 4;
}
// Update is called once per frame
void Update()
{
Vector3 direccion;
if (bala != null)
{
direccion = bala.transform.position - this.transform.position;
this.transform.position += velocidad * direccion * Time.deltaTime;
}
if (disparado == true)
{
tiempo += Time.deltaTime;
if (tiempo > tiempodevida) { Destroy(gameObject); }
}
}
public void ActivarBala(GameObject objetivo)
{
bala = objetivo;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Demonio")
{
Destroy(gameObject);
}
}
}
Jesus Antonio
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BalaDemonio : MonoBehaviour
{
private GameObject bala;
private float velocidad;
private float tiempo;
public bool disparado;
private float tiempodevida;
// Start is called before the first frame update
void Start()
{
velocidad = 2;
tiempodevida = 4;
}
// Update is called once per frame
void Update()
{
Vector3 direccion;
if (bala != null)
{
direccion = bala.transform.position - this.transform.position;
this.transform.position += velocidad * direccion * Time.deltaTime;
}
if (disparado == true)
{
tiempo += Time.deltaTime;
if (tiempo > tiempodevida) { Destroy(gameObject); }
}
}
public void ActivarBala(GameObject objetivo)
{
bala = objetivo;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Humano")
{
Destroy(gameObject);
}
}
}
Last edited by
JAntonio on Sun Apr 14, 2019 4:35 pm, edited 3 times in total.
Jesus Antonio Buitrago Duque
Pdoo2
-
xacarana
- Site Admin
- Posts: 1213
- Joined: Fri Jan 15, 2016 6:13 pm
Post
by xacarana » Tue Apr 09, 2019 2:45 pm
Andrés Bedoya Tobón
Profesor
"I only smile in the dark, I only smile when it's complicated" Raybiez
-
000287377
- Posts: 12
- Joined: Tue Jan 22, 2019 2:06 pm
Post
by 000287377 » Thu Apr 11, 2019 1:30 pm
09 Abril
¿Que hicimos hoy?
- Aplicar los códigos a todos los personajes.
- Pantalla de victoria.
- Pantalla de derrota.
¿Que haremos hasta el próximo post?
- Programar los cambios de animación.
- Programar la salida y entrada a las escenas.
¿Que problemas tuvimos?
- Uno de los integrantes debido a la carga académica no pudo reunirse.
- Evento familiar.
Implementamos el código que reconoce a los enemigos en todos los personajes (Modificado por Negrette).
Code: Select all
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class BalaHumano : MonoBehaviour
{
private GameObject bala;
private float velocidad;
private float tiempo;
public bool disparado;
private float tiempodevida;
// Start is called before the first frame update
void Start()
{
velocidad = 2;
tiempodevida = 4;
}
// Update is called once per frame
void Update()
{
Vector3 direccion;
if (bala != null)
{
direccion = bala.transform.position - this.transform.position;
this.transform.position += velocidad * direccion * Time.deltaTime;
}
if (disparado == true)
{
tiempo += Time.deltaTime;
if (tiempo > tiempodevida) { Destroy(gameObject); }
}
}
public void ActivarBala(GameObject objetivo)
{
bala = objetivo;
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (collision.gameObject.tag == "Humano")
{
Destroy(gameObject);
}
}
}

Last edited by
000287377 on Tue Apr 23, 2019 12:20 pm, edited 1 time in total.
Daniel Garcia Negrette
Pdoo 2
-
xacarana
- Site Admin
- Posts: 1213
- Joined: Fri Jan 15, 2016 6:13 pm
Post
by xacarana » Fri Apr 12, 2019 10:33 am
Avance con imágenes y pulir la redacción y autoría.
Andrés Bedoya Tobón
Profesor
"I only smile in the dark, I only smile when it's complicated" Raybiez