/// <summary> /// Luo zombin /// </summary> /// <param name="x">zombin x-koordinaatit</param> /// <param name="y">zombin y-koordinaatit</param> /// <returns></returns> Zombi LuoZombi(double x, double y, List <Vector> polku) { Zombi zombi = new Zombi(25.0, 25.0, new Color[] { Color.Green, Color.Red }); zombi.Shape = Shape.Circle; zombi.X = x; zombi.Y = y; zombi.Restitution = 0.0; zombi.Tag = "zombi"; zombi.Image = LoadImage("zombi"); zombi.CanRotate = false; zombiLaskuri.Value += 1; Add(zombi, 1); PathFollowerBrain polkuAivo = new PathFollowerBrain(50); polkuAivo.Path = polku; FollowerBrain seuraajaAivo = new FollowerBrain(pelaaja); seuraajaAivo.Speed = 100; seuraajaAivo.DistanceFar = 400; seuraajaAivo.DistanceClose = 50; seuraajaAivo.FarBrain = polkuAivo; seuraajaAivo.StopWhenTargetClose = false; zombi.Brain = seuraajaAivo; return(zombi); }
public void DisableZombi(int nZombi) { Zombi z = dicZombis[nZombi]; z.myTransform.gameObject.SetActive(false); zombiList.Remove(dicZombis[z.ID]); zombi_desactivado_ID.Add(z.ID); }
void ReciclarZombi(int id) { Zombi zombiT = dicZombis[id]; zombiT.vida = vidaZombi; zombiT.myTransform.gameObject.transform.position = SpawnAleatorio(); zombiT.myTransform.gameObject.SetActive(true); zombiList.Add(zombiT); }
private void OnCollisionEnter(Collision collision) { if (collision.transform.tag == "Zombi") { Zombi transform = gameObject.AddComponent <Zombi>(); transform.datos = (DatoZombis)gameObject.GetComponent <Ciudadano>().datoNPC; Destroy(gameObject.GetComponent <Ciudadano>()); Juego.enemy++; Juego.cyti--; } }
void OnCollisionEnter(Collision collision) //si colisiona con el zombi se convierte en zombi { if (collision.transform.name == "Zombi") { Zombi datZom = this.gameObject.AddComponent <Zombi>(); //le adiere el componente zombi datZom.utilZom = (DatosZom)this.gameObject.GetComponent <Ciudadano>().utilCiud; //hace un cast para conservar la edad del ciudadano en la del zombi gameObject.GetComponent <Renderer>().material.color = collision.transform.GetComponent <Renderer>().material.color; //le da color del zombi que lo toco transform.name = "Zombi"; //le da nombre para que el ciudadano pueda identificarlo y activar su comportamiento Destroy(this.gameObject.GetComponent <Ciudadano>()); //destruye el componente de tipo ciudadano para dejarlo solo con el de zombi } }
public void ZombiDamage(int nZombi) { Zombi zombiBuscado = dicZombis[nZombi]; if (zombiBuscado.vida - fuerzaJugador > 0) { zombiBuscado.Damage(fuerzaJugador); } else { DisableZombi(zombiBuscado); } }
/// <summary> /// Hoidellaan ammuksen osuminen /// </summary> /// <param name="ammus">ammus</param> /// <param name="kohde">zombi</param> public void AmmusOsuiZombiin(PhysicsObject ammus, Zombi kohde) { if (kohde.Tag.ToString() == "zombi") { pelaajanPisteet.Value += 1; zombiLaskuri.Value -= 1; kohde.OtaVastaanOsuma(); if (zombiLaskuri.Value == 0) { GameOver(); } } ammus.Destroy(); }
private void OnZombiDied(Zombi zombi) { zombi.Died -= OnZombiDied; _waveSize--; if (_waveSize == 0 && _currentWaveIndex >= _waves.Count) { GameWon?.Invoke(); } else if (_waveSize == 0) { WaveEnded?.Invoke(); } }
private void OnCollisionEnter(Collision collision) { if (collision.transform.tag == "Zombi") { Zombi transform = gameObject.AddComponent <Zombi>(); transform.datos = (DatoZombis)gameObject.GetComponent <Ciudadano>().datoNPC; Destroy(gameObject.GetComponent <Ciudadano>()); Juego.zombis++; Juego.cyti--; } else if (collision.transform.tag == "Ninja") { Ninja transform = gameObject.AddComponent <Ninja>(); transform.datoNinya = (DatosNinja)gameObject.GetComponent <Ciudadano>().datoNPC; Destroy(gameObject.GetComponent <Ciudadano>()); Juego.ninjas++; Juego.cyti--; } }
public void SpawnNextWave() { if (_currentWaveIndex >= _waves.Count) { return; } foreach (var sp in _spawnPoints) { for (int i = 0; i < _waves[_currentWaveIndex]; i++) { Zombi z = Instantiate(_zombiPrefab, sp).GetComponent <Zombi>(); z.Died += OnZombiDied; z.GetComponent <ZombiController>().Target = Player; } } _waveSize = _waves[_currentWaveIndex] * _spawnPoints.Count; NextWaveSpawned?.Invoke(_currentWaveIndex); _currentWaveIndex++; }
GameObject CrearZombi(int id) { Zombi newInstance = new Zombi(); dicZombis.Add(id, newInstance); zombiList.Add(newInstance); newInstance.vida = vidaZombi; newInstance.ID = id; newInstance.velocidadMovimiento = Random.Range(1.5f, 2.5f); GameObject newZombi = new GameObject(id.ToString()); newInstance.myTransform = newZombi.transform; newZombi.transform.position = SpawnAleatorio(); newZombi.transform.SetParent(Horda.transform); newZombi.transform.tag = "Enemigo"; BoxCollider2D collider = newZombi.AddComponent <BoxCollider2D>(); collider.isTrigger = true; SpriteRenderer renderer = newZombi.AddComponent <SpriteRenderer>(); newInstance.zombi_sprite = renderer.sprite = zombie_sprite1; return(newZombi); }
private void Start() { _mover = GetComponent <ZombiMover>(); _zombi = GetComponent <Zombi>(); }
/// <summary> /// Hoidellaan zombin osuminen pelaajaan. /// </summary> /// <param name="pelaaja">PhysicsObject pelaaja</param> /// <param name="kohde">Zombi zombi</param> public void ZombiOsuuPelaajaan(PhysicsObject pelaaja, Zombi kohde) { pelaaja.Destroy(); pelaajaKuoli = true; GameOver(); }