public void ReplaceValues(Unidade un) { this.agent = un.agent; this.dinossauro = un.dinossauro; this.dino = un.dino; this.agentTransform = un.agentTransform; }
public void CopyAttr(Dinossauro dino) { this.custo = dino.custo; this.vida = dino.vida; this.ataque = dino.ataque; this.velocidadeAtaque = dino.velocidadeAtaque; this.velocidade_deslocamento = dino.velocidade_deslocamento; this.alcance_ataque = dino.alcance_ataque; this.custoAttrVida = dino.custoAttrVida; this.custoAttrAtaque = dino.custoAttrAtaque; this.custoAttrVelocidadeAtaque = dino.custoAttrVelocidadeAtaque; this.custoAttrVelocidadeDeslocamento = dino.custoAttrVelocidadeDeslocamento; this.abilityCost = dino.abilityCost; this.dinoType = dino.dinoType; this.MAX_VIDA = dino.MAX_VIDA; this.MAX_ATAQUE = dino.MAX_ATAQUE; this.MAX_VELOCIDADE_ATAQUE = dino.MAX_VELOCIDADE_ATAQUE; this.MAX_VELOCIDADE_DESLOCAMENTO = dino.MAX_VELOCIDADE_DESLOCAMENTO; this.MAX_ALCANCE_ATAQUE = dino.MAX_ALCANCE_ATAQUE; this.habilidadeOn = dino.habilidadeOn; }
static void Main(string[] args) { TiranossauroRex tiranossauroRex = null; Velociraptor velociraptor = new(); Dinossauro dinossauro = tiranossauroRex ?? velociraptor; Console.WriteLine(""); }
public override bool Atacar(GroupController gp) { int nDinos = 0; //attack implemented by alex-sama Gc = gp; Dinossauro dTarget = null; int menorVida = -1; foreach (Dinossauro d in gp.DinosDinossauro) { if (d != null) { nDinos++; } if (d != null && (d.Vida < menorVida || menorVida == -1)) { dTarget = d; menorVida = d.Vida; } } logg.dinossauroID = this.GetInstanceID(); // logg.attachedObj = this; logg.acao = "ATAQUE"; if (menorVida != -1) { if (habilidadeOn) { //Atack * number of enemy dinosaurs dTarget.Vida = dTarget.Vida - (ataque * nDinos - (Random.Range(0, ataque / 2))); Debug.Log(GetInstanceID() + "Attacked with " + ataque + " dmg. Target was " + dTarget + "which is now with " + dTarget.Vida + "life"); return(true); } else { dTarget.Vida = dTarget.Vida - ataque; string msg; msg = (GetInstanceID() + "Attacked with " + ataque + " dmg. Target was " + dTarget + "which is now with " + dTarget.Vida + "life"); Debug.Log(msg); logg.msg = msg; logg.writeLog(); return(true); } } else { string msg; msg = (GetInstanceID() + "Attacked but there were no target"); Debug.Log(msg); logg.msg = msg; return(false); } }
void OnTriggerEnter(Collider collider) { Dinossauro dino = collider.GetComponent <Dinossauro> (); if (dino != null) { dino.Dano(); } Destroy(gameObject); colidiu = true; rb.useGravity = true; }
public override bool Atacar(GroupController gp) { Gc = gp; Dinossauro dTarget = null; int menorVida = -1; //Habilidade on = Ataque em área if (habilidadeOn) { foreach (Dinossauro d in gp.DinosDinossauro) { if (d != null) { d.Vida = d.Vida - (ataque - Random.Range(0, (ataque / 2))); } } return(true); } //se não, single else { logg.dinossauroID = this.GetInstanceID(); // logg.attachedObj = this; logg.acao = "ATAQUE"; foreach (Dinossauro d in gp.DinosDinossauro) { if (d != null && (d.Vida < menorVida || menorVida == -1)) { dTarget = d; menorVida = d.Vida; } } if (menorVida != -1) { dTarget.Vida = dTarget.Vida - (ataque - Random.Range(1, ataque / 2)); string msg; msg = (GetInstanceID() + "Attacked with " + ataque + " dmg. Target was " + dTarget + "which is now with " + dTarget.Vida + "life"); Debug.Log(msg); logg.msg = msg; logg.writeLog(); return(true); } else { string msg; msg = (GetInstanceID() + "Attacked but there were no target"); Debug.Log(msg); logg.msg = msg; return(false); } } }
void Start() { dino = dinossauro.GetComponent <Dinossauro>(); agentTransform = agent.GetComponent <Transform>(); if (dinossauro != null) { dinossauro.transform.SetParent(this.transform); } if (agentTransform != null) { agent.transform.SetParent(this.transform); } }
IEnumerator AttackWithDinosaur(Dinossauro dino, GroupController gp) { bool thereAreTargets = true; while (thereAreTargets && dino != null && gp != null) { dino.gameObject.GetComponent <Animator>().SetTrigger("ataque"); yield return(new WaitForSeconds((float)dino.VelocidadeAtaque)); thereAreTargets = dino.Atacar(gp); } yield return(null); }
public bool Atacar(Unidade uni) { if (uni == null) { return(false); } Dinossauro dinoInimigo = uni.dino; if (this.Distance(uni) < this.dino.Alcance_ataque) { dinoInimigo.Vida -= dino.Ataque; } return(true); }
public override bool Atacar(GroupController gp) { Gc = gp; Dinossauro dTarget = null; int menorVida = -1; foreach (Dinossauro d in gp.DinosDinossauro) { if (d != null && (d.Vida < menorVida || menorVida == -1)) { //Apatasaur ability only will work one time per group; if (Gc != oldGroup) { oldGroup = Gc; if (habilidadeOn) { Habilidade(); } } dTarget = d; menorVida = d.Vida; } } logg.dinossauroID = this.GetInstanceID(); logg.acao = "ATAQUE"; string msg = ""; if (menorVida != -1) { dTarget.Vida = dTarget.Vida - (ataque - Random.Range(0, ataque / 2)); msg = (GetInstanceID() + "Attacked with " + ataque + " dmg. Target was " + dTarget + "which is now with " + dTarget.Vida + "life"); Debug.Log(msg); logg.msg = msg; logg.writeLog(); return(true); } else { msg = (GetInstanceID() + "Attacked but there were no target"); Debug.Log(msg); logg.msg = msg; return(false); } }
/*RETORNA UM GAMEOBJECT COM A UNIDADE ATTACHED */ public GameObject createUnidade(int dinoNumber, GameObject base_inimiga) { // agente GameObject agente = Instantiate(agenteRef); //agente.AddComponent<AgentBehaviour>(); agente.GetComponent <AgentBehaviour>().Base_inimiga = base_inimiga; agente.name = "agente" + dinoNumber; //dinossauro GameObject dino = this.CreateDinoRef(dinoNumber); dino.name = "dino" + this.id + " " + dinoNumber; //tamanho do collider Dinossauro d = dino.GetComponent <Dinossauro>(); agente.GetComponent <RectTransform>().localScale = new Vector3(d.NSlot / 2f, d.NSlot / 2f, d.NSlot / 2f); //unidade // Unidade uni = new Unidade(agente,dino, this.id); //gameobject da unidade GameObject gb = new GameObject(); gb.SetActive(false); gb.AddComponent <Unidade>(); gb.GetComponent <Unidade>().setUnidade(agente, dino, this.id); //ReplaceValues(uni); gb.name = "unidadePlayer" + this.id; this.unidades.Add(gb); agente.SetActive(true); dino.SetActive(true); return(gb); }
public override bool Atacar(GroupController gp) { Gc = gp; Dinossauro dTarget = null; int menorVida = -1; foreach (Dinossauro d in gp.DinosDinossauro) { if (d != null && (d.Vida < menorVida || menorVida == -1)) { dTarget = d; menorVida = d.Vida; } } logg.dinossauroID = GetInstanceID(); logg.acao = "ATAQUE"; if (menorVida != -1) { dTarget.Vida = dTarget.Vida - (ataque - Random.Range(0, ataque / 2)); string msg; msg = (GetInstanceID() + "Attacked with " + ataque + " dmg. Target was " + dTarget + "which is now with " + dTarget.Vida + "life"); Debug.Log(msg); logg.msg = msg; logg.writeLog(); return(true); } else { string msg; msg = (GetInstanceID() + "Attacked but there were no target"); Debug.Log(msg); logg.msg = msg; return(false); } }
public void SpawnarInimigo <Y>(float distanciaInimigoPlayer, int indexPlayer)//aqui o int indexplayer é o valor q sera usado no array { if (!typeof(Y).IsSubclassOf(typeof(Inimigo)) || (indexPlayer < 0 || indexPlayer >= players.Length)) { return; } Vector3 iniPos = players[indexPlayer].transform.position; Vector3 position = iniPos; position.x += distanciaInimigoPlayer; position.y += distanciaInimigoPlayer; position.z = -1f; if (listaInimigos.Count > 0) { if (typeof(Y) == typeof(Dinossauro)) { if (listaInimigos.OfType <Dinossauro>().Any()) { int index = listaInimigos.FindLastIndex(x => x.GetType() == typeof(Dinossauro)); Dinossauro D = (Dinossauro)listaInimigos[index]; listaInimigos.RemoveAt(index); D.transform.position = position;//aqui o segundo position é o vector 3 de cima D.SetActive(true); } } else if (typeof(Y) == typeof(Robo)) { if (listaInimigos.OfType <Robo>().Any()) { int index = listaInimigos.FindLastIndex(x => x.GetType() == typeof(Robo)); Robo D = (Robo)listaInimigos[index]; //aqui tem q fazer a referencia para poder tirar da lista listaInimigos.RemoveAt(index); //aqui se colocar o listInimigos antes do Robo D, não podera achalo na lista pois ele não estará la //o listaInimigos.RemoveAt(index) ja sabe q tem q tirar o robo da lista pois esta no if do robo position.x += D.distanciaPlayer; position.y += D.distanciaPlayer; D.transform.position = position; D.SetActive(true); } } else if (typeof(Y) == typeof(Zumbi)) { if (listaInimigos.OfType <Zumbi>().Any()) { int index = listaInimigos.FindLastIndex(x => x.GetType() == typeof(Zumbi)); Zumbi D = (Zumbi)listaInimigos[index]; listaInimigos.RemoveAt(index); position.x += D.distanciaPlayer; position.y += D.distanciaPlayer; D.transform.position = position; D.SetActive(true); } } else if (typeof(Y) == typeof(Abobora)) { if (listaInimigos.OfType <Abobora>().Any()) { int index = listaInimigos.FindLastIndex(x => x.GetType() == typeof(Abobora)); Abobora D = (Abobora)listaInimigos[index]; listaInimigos.RemoveAt(index); position.x += D.distanciaPlayer; position.y += D.distanciaPlayer; D.transform.position = position; D.SetActive(true); } } } else { if (typeof(Y) == typeof(Dinossauro)) { Dinossauro inimigo = Instantiate(InimigoDinossauroPrefab, position, Quaternion.identity).GetComponent <Dinossauro>(); //inimigo.init(); } if (typeof(Y) == typeof(Robo)) { Robo inimigo = Instantiate(InimigoRoboPrefab, position, Quaternion.identity).GetComponent <Robo>(); // inimigo.init(); } if (typeof(Y) == typeof(Zumbi)) { Zumbi inimigo = Instantiate(InimigoZumbiPrefab, position, Quaternion.identity).GetComponent <Zumbi>(); // inimigo.init(); } if (typeof(Y) == typeof(Abobora)) { Abobora inimigo = Instantiate(InimigoAboboraPrefab, position, Quaternion.identity).GetComponent <Abobora>(); // inimigo.init(); } } }