void Awake() { drop = GetComponent <BossDrop>(); goldAmount = Random.Range(0, goldMax); GenerateGold(); scoreObject = GameObject.FindGameObjectWithTag("Score"); scorePoints = scoreObject.GetComponent <Score>(); healthPoints = startingHealth; player = GameObject.FindGameObjectWithTag("Player"); experience = player.GetComponent <Experience>(); anim = GetComponent <Animator> (); enemyAudio = GetComponent <AudioSource> (); //hitParticles = GetComponentInChildren <ParticleSystem> (); //capsuleCollider = GetComponent <CapsuleCollider> (); //bullet = GetComponent<BulletMoveFoward>(); //col.GetComponent<Collider2D>(); playerHealth = player.GetComponent <PlayerHealth>(); sprite = GetComponent <SpriteRenderer>(); move = GetComponent <EnemyMovement>(); tiro = player.GetComponent <Tiro>(); cameraShake = Camera.main.transform.parent.GetComponent <CameraFollow>(); }
// Update is called once per frame void Update() { nave.Move(); if (tiro != null) { tiro.Move(); } if (Input.GetKeyDown(KeyCode.LeftArrow) || Input.GetKeyDown(KeyCode.A)) { nave.TurnLeft(); } if (Input.GetKeyDown(KeyCode.RightArrow) || Input.GetKeyDown(KeyCode.D)) { nave.TurnRight(); } if (Input.GetKeyDown(KeyCode.Space)) { tiro = ScriptableObject.CreateInstance <Tiro>(); tiro.Init(); tiro.posx = nave.posx; } }
private void AddTiro(Vector2 mousePosition, Vector2 posicaoNave) { posicaoNave.Y += 20; Tiro tiro = new Tiro(posicaoNave); tiro.Imagem = imgTiro; mousePosition.X = mousePosition.X + imgMira.Width / 2; mousePosition.Y = (mousePosition.Y + imgMira.Height / 2) - 5; Vector2 movement = mousePosition - posicaoNave; if (movement != Vector2.Zero) { movement.Normalize(); } tiro.direcao = movement; tiro.rotation = (float)Math.Atan2(movement.Y, movement.X); // Posição do tiro na tela tiro.RecDst = new Rectangle( (int)tiro.Posicao.X, (int)tiro.Posicao.Y, tiro.Imagem.Width, tiro.Imagem.Height); // Área de colisão tiro.AreaColisao.Add(new Rectangle( tiro.RecDst.X, tiro.RecDst.Y, tiro.RecDst.Width, tiro.RecDst.Height)); nave.tiros.Enqueue(tiro); }
private void Cliente_OnTiroRecebido(Tiro t) { Invoke(new Action(delegate() { tJogador.TiroRecebido(t.X, t.Y); })); }
void Shoot() { //Debug.Log("targetEnemy.tag: "+targetEnemy.tag); //if (targetEnemy.CompareTag("Enemy2")) { //} GameObject tiroObject = (GameObject)Instantiate(tiroPrefab, initTiro.position, initTiro.rotation); Tiro tiro = tiroObject.GetComponent <Tiro>(); if (tiro != null) { tiro.Procurar(target); } if (targetEnemy != null) { targetEnemy.TakeDamage(1); } if (targetEnemy2 != null) { targetEnemy2.TakeDamage(1); } }
void Awake() { rb = GetComponent <Rigidbody2D>(); _currentLife = _maxLife; anim = GetComponent <Animator>(); shoot = defaultShoot; }
private bool AbateuAviao(int i, double tempo, Tiro tiro) { Vetor posicaoTiro = tiro.PosicaoEm(tempo); Console.WriteLine(" {0}: {1} {2}", i, posicaoTiro, (posicaoAviao - posicaoTiro).Mag()); return((tiro.PosicaoEm(tempo) - posicaoAviao).Mag() < 7); }
private void Cliente_OnTiroRecebido(Tiro t) { Invoke(new Action(() => { Console.WriteLine("tomou tiro"); tirosRecebidos.Add(t); })); }
// Update is called once per frame void Update() { if (_currentLife <= 0) { if (Input.GetKeyDown(KeyCode.Return)) { SceneManager.LoadScene("HighScore"); } return; } else { transform.Rotate(transform.forward * -Input.GetAxisRaw("Horizontal") * Time.deltaTime * rotateSpeed * 100); rb.AddForce(transform.up * Input.GetAxisRaw("Vertical") * Time.deltaTime * moveSpeed * 100); rb.velocity = Vector2.ClampMagnitude(rb.velocity, maxSpeed); if (shootReady && Input.GetKeyDown(KeyCode.Space)) { foreach (Transform weapon in weapons) { shootReady = false; Instantiate(shoot, weapon.position, weapon.rotation); StartCoroutine(ShootAwait()); } } Vector3 pos = transform.position; if (transform.position.x > GameBounds.instance.BoundX) { pos.x = -GameBounds.instance.BoundX; } if (transform.position.y > GameBounds.instance.BoundY) { pos.y = -GameBounds.instance.BoundY; } if (transform.position.x < -GameBounds.instance.BoundX) { pos.x = GameBounds.instance.BoundX; } if (transform.position.y < -GameBounds.instance.BoundY) { pos.y = GameBounds.instance.BoundY; } transform.position = pos; } if (isTiroEspecial) { if (tiroEspecialTempoAtual <= 0) { isTiroEspecial = false; tiroEspecialUI.gameObject.SetActive(false); shoot = defaultShoot; } else { tiroEspecialTempoAtual -= Time.deltaTime; tiroEspecialTimerUI.fillAmount = 1f - (tiroEspecialTempoAtual / tiroEspecialDuracao); } } }
void Awake() { player = GameObject.FindGameObjectWithTag("Player"); shopObject = GameObject.FindGameObjectWithTag("Shop"); shop = shopObject.GetComponent <Shop>(); text = GetComponent <Text> (); score = 0; tiro = player.GetComponent <Tiro>(); }
public void ResultadoTiro(Tiro t, ResultadoDeTiro r) { StatusCelula s = StatusCelula.Agua; if (r == ResultadoDeTiro.Acertou || r == ResultadoDeTiro.Afundou) { s = StatusCelula.Navio; } celulas[t.X, t.Y] = s; }
private void Cliente_OnResultadoDeTiro(Tiro t, ResultadoDeTiro resultado) { if (resultado == ResultadoDeTiro.Ganhou) { MessageBox.Show(this, "Você ganhou!", "UHUL :)", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); cliente = null; PosicionarNavios(); } tInimigo.ResultadoTiro(t, resultado); }
void shoot() { //Cria um novo tiro baseado no objeto de referência Tiro tiro = Tiro.Instantiate(this.tiroPrefab); //Obtém a posição atual da nave Vector2 posicao = (Vector2)this.transform.position; //Define a posição atual do tiro tiro.SetarPosicao(posicao); tiro.SetarDirecao(true); }
private void Cliente_OnResultadoDeTiro(Tiro t, ResultadoDeTiro resultado) { Invoke(new Action(() => { Console.WriteLine("Atirô"); tirosDados.Add(new Tiro(tiroX, tiroY), resultado); tiroX = tiroY = -1; pictureBox1.Invalidate(); pictureBox2.Invalidate(); podeAtirar = false; })); }
void Shoot() { Debug.Log("ATIROU"); GameObject tiroObject = (GameObject)Instantiate(tiroPrefab, initTiro.position, initTiro.rotation); Tiro tiro = tiroObject.GetComponent <Tiro>(); if (tiro != null) { tiro.Procurar(target); } }
public override void Ataque() { base.Ataque(); if (Input.GetButtonDown("A") && !isShooting) { if (canShootNormal) { sourceAudio.clip = soundEffects[0]; sourceAudio.Play(); coolDownAtaqueNormal += delayAtaqueNormal; Tiro tiro1 = (Tiro)Instantiate(projetilNormal, transform.position, Quaternion.identity); tiro1.direcao = direcao; } } if (Input.GetButtonDown("X") && !isShooting) { if (canShootEspecial) { isShooting = true; shootingTimer = shootingCD; sourceAudio.clip = soundEffects[1]; sourceAudio.Play(); animator.SetBool("shooting", true); coolDownAtaqueEspecial += delayAtaqueEspecial; //Vector3 misselPos = new Vector3(transform.position.x, transform.position.y, transform.position.z - 3f); Missel missel1 = (Missel)Instantiate(projetilEspecial, transform.position, Quaternion.identity); missel1.direcao = direcao; } } if (Input.GetButtonDown("Y")) { Debug.Log("God Mode"); speed = 4f; hp = 50; danoAtaqueNormal = 10; delayAtaqueEspecial = 0; } animator.SetBool("shooting", isShooting); }
private void CriarTiro(float offsetX, float offsetY) { //Cria um novo tiro baseado no objeto de referência Tiro tiro = Tiro.Instantiate(this.tiroPrefab); //Obtém a posição atual da nave Vector2 posicao = (Vector2)this.transform.position; posicao.x = posicao.x + offsetX; posicao.y = posicao.y + offsetY; //Define a posição atual do tiro tiro.SetarPosicao(posicao); tiro.SetarDirecao(false); }
public void OnTriggerEnter2D(Collider2D collider) { if (collider.gameObject.CompareTag("TiroJogador")) { Tiro tiro = collider.gameObject.GetComponent <Tiro>(); this.vidas -= tiro.GetDano(); Destroy(collider.gameObject); if (this.vidas <= 0) { Destroy(this.gameObject); ControladorPontuacao.IncrementarPontuacao(1); } } }
public void TestTiro() { Tiro tiro = new Tiro(new Vetor(0, 0, 0), 0, 0.5 * Math.PI / 180, 0); double t = 0; while (t < 80) { Console.WriteLine( "{0:f2} ==> Posicao: {1}", t, tiro.PosicaoEm(t)); t += 0.5; } }
private bool AbateuAviao2(int i, double tempo, Tiro tiro) { Vetor posicaoTiro = tiro.PosicaoEm(tempo); Vetor posicaoTiroAnterior = tiro.PosicaoEm(tempoAnterior); Console.WriteLine(" {0}: {1} {2}", i, posicaoTiro, (posicaoAviao - posicaoTiro).Mag()); for (double t = tempoAnterior; t < tempo; t += 3 / Tiro.VELOCIDADEMEDIA) { if ((aviao.PosicaoEm(t) - tiro.PosicaoEm(t)).Mag() < 2) { return(true); } } return(false); }
private void OnTriggerEnter2D(Collider2D collision) { if (collision.GetComponent <Attack>()) { shoot = collision.GetComponent <Attack>().TiroEspecial; tiroEspecialDuracao = collision.GetComponent <Attack>().DuracaoEfeito; tiroEspecialTempoAtual = tiroEspecialDuracao; tiroEspecialTimerUI.fillAmount = 0; tiroEspecialUI.gameObject.SetActive(true); isTiroEspecial = true; collision.GetComponent <Attack>().Coletado(); } if (collision.GetComponent <Poison>()) { TakeDamage(); collision.GetComponent <Poison>().Coletado(); } }
void Awake() { slimeExplode = GetComponent <SlimeExplode>(); player = GameObject.FindGameObjectWithTag("Player"); anim = GetComponent <Animator>(); enemyAudio = GetComponent <AudioSource>(); experience = player.GetComponent <Experience>(); //hitParticles = GetComponentInChildren <ParticleSystem> (); //capsuleCollider = GetComponent <CapsuleCollider> (); //bullet = GetComponent<BulletMoveFoward>(); //col.GetComponent<Collider2D>(); playerHealth = player.GetComponent <PlayerHealth>(); sprite = GetComponent <SpriteRenderer>(); move = GetComponent <ChasePlayer>(); isDead = false; tiro = player.GetComponent <Tiro>(); }
void Awake() { pause = restartHUD.GetComponent <PauseMenu>(); rigidPlayer = GetComponent <Rigidbody2D>(); shopObject = GameObject.FindGameObjectWithTag("Shop"); shop = shopObject.GetComponent <Shop>(); experience = GetComponent <Experience>(); player = GameObject.FindGameObjectWithTag("Weapon"); weapon = player.GetComponentInChildren <Weapon>(); tiro = GetComponent <Tiro>(); playerCollider = this.gameObject.GetComponent <BoxCollider2D>(); anim = GetComponent <Animator> (); playerAudio = GetComponent <AudioSource> (); playerMovement = GetComponent <PlayerMovement> (); //playerShooting = GetComponentInChildren <PlayerShooting> (); currentHealth = startingHealth; maxHealth = startingHealth; damageable = true; Energy(); }
void Update() { if (onlySpin) { if (spitter) { zRotation = Time.deltaTime / 60 * 360 * (zRotationsPerMinute * spinOrientation); transform.RotateAround(transform.position, transform.forward, zRotation); } else { zRotation = Time.deltaTime / 60 * 360 * zRotationsPerMinute; transform.RotateAround(transform.position, transform.forward, zRotation); } } else { tiro = player.GetComponent <Tiro>(); if (tiro.isReloading) { if (player.GetComponent <SpriteRenderer>().flipX) { float zDegreesPerFrame = Time.deltaTime / 60 * 360 * -zRotationsPerMinute; transform.RotateAround(transform.position, transform.forward, zDegreesPerFrame); } else { float zDegreesPerFrame = Time.deltaTime / 60 * 360 * zRotationsPerMinute; transform.RotateAround(transform.position, transform.forward, zDegreesPerFrame); } } else { this.transform.rotation = controle.rotation; } } }
private void TiroColidiuBandeira(Bandeira band, Tiro t) { string aux = string.Format("T|{0}|{1}", band.GetBandeira, t.GetId); int tam = aux.Length + 5; string msg = string.Format("15{0}{1}", tam.ToString("000"), aux); this.frm_Inicio.EnviaMsgTcp(msg); }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); playSpell = GetComponent <AudioSource>(); tiro = player.GetComponent <Tiro>(); }
private void CampoBatalha_KeyDown(object sender, KeyEventArgs e) { if (e.KeyCode == Keys.Escape) Application.Exit(); if (e.KeyCode == Keys.Space && !endPartida && podeAtirar && !PossoAtirar()) { newTiro = new Tiro(this.player.xAtual, this.player.yAtual, this.player.tamX, LARGURA, this.player.proxDirecao, Tiro.id_Tiro); Tiro.id_Tiro += 1; podeAtirar = false; tm_Bala.Start(); EnviaMsgTiro(newTiro); } }
public void SetarPrefabTiro(Tiro tiroPrefab) { this.tiroPrefab = tiroPrefab; }
// Use this for initialization void Start() { player = GameObject.FindGameObjectWithTag("Player"); tiro = player.GetComponent <Tiro>(); image = GetComponent <Image>(); }
// private void AtualizarBoss() { // foreach (Nave b in bossEnemies.ToList()) { if (b.Posicao.X > -120) { if (b.tiros.ToList().Count > 0) { AtualizaTirosInimigos(b); } Vector2 nPos1 = new Vector2(b.Posicao.X, b.Posicao.Y); Vector2 nVel1 = new Vector2(b.Velocidade.X, b.Velocidade.Y); nPos1.X -= b.Aceleracao; // Novas posições e velocidade b.Posicao = nPos1; // Posição da nave na tela b.RecDst = new Rectangle( (int)b.Posicao.X, (int)b.Posicao.Y, b.Imagem.Width / b.ImagemQtd, b.Imagem.Height); ////////////////////////////////////BOSS ATIRA//////////////////////////// if (tempoTiroInimigo > intervaloTiroInimigo) { Vector2 posicao = new Vector2(b.Posicao.X + 50, b.Posicao.Y + 80); Tiro tiro = new Tiro(posicao); tiro.Imagem = imgTiroInimigo; Vector2 movement = nave.Posicao - posicao; if (movement != Vector2.Zero) { movement.Normalize(); } tiro.direcao = movement; tiro.rotation = (float)Math.Atan2(movement.Y, movement.X); // Posição do tiro na tela tiro.RecDst = new Rectangle( (int)tiro.Posicao.X, (int)tiro.Posicao.Y, tiro.Imagem.Width, tiro.Imagem.Height); // Área de colisão tiro.AreaColisao.Add(new Rectangle( tiro.RecDst.X, tiro.RecDst.Y, tiro.RecDst.Width, tiro.RecDst.Height)); b.tiros.Enqueue(tiro); tempoTiroInimigo = 0; } } // Define nova posição da imagem b.RecSrc = new Rectangle( b.ImagemNum * imgBoss.Width / b.ImagemQtd, 0, imgBoss.Width / b.ImagemQtd, imgBoss.Height); b.AreaColisao[0] = new Rectangle( b.RecDst.X + 25, b.RecDst.Y + 10, b.RecDst.Width - 40, b.RecDst.Height - 40); if (b.Posicao.X < -119) { bossEnemies.Remove(b); } if (b.Life <= 0) { AddExplosao(b.Posicao); bossEnemies.Remove(b); placar += 10; } if (b.VerificarColisao(nave.AreaColisao[0])) { AddExplosao(b.Posicao); vidas--; } } if (bossEnemies.ToList().Count < bossCount && tempoBoss > intervaloBoss) { AddBossEnemy(); tempoBoss = 0; } }
//---------------- MENSSAGENS DE COLISÕES DOS TIROS ----------- /// <summary> /// Ouve a colisão do tiro com um obstaculo. /// </summary> /// <param name="obs"></param> /// <param name="t"></param> private void EnviaMsgColisaoObstaculo(Obstaculo obs, Tiro t) { string aux = string.Format("T|BL{0}{1}{2}|{3}", obs.GetColuna, obs.GetFileira, obs.GetBloco.ToString("00"), t.GetId); int qtd = aux.Length + 5; string msg = string.Format("15{0}{1}", qtd.ToString("000"), aux); this.frm_Inicio.EnviaMsgTcp(msg); }
/// <summary> /// Envia MSG que foi disparada um tiro. /// </summary> /// <param name="t"></param> private void EnviaMsgTiro(Tiro t) { float[] posTiro = this.player.ConvertDispositivoNormal(t.GetX, t.GetY);//converto para coordenadas normalizadas. string aux = string.Format("{0}|{1}|{2}|{3}", posTiro[0], posTiro[1], t.GetDirecao, t.GetId); int qtd = aux.Length + 5; string msg = string.Format("13{0}{1}", qtd.ToString("000"), aux); this.frm_Inicio.EnviaMsgTcp(msg); }
private void TiroColidiuPowerUp(Tiro t) { string aux = string.Format("T|PU|{0}", t.GetId); int tam = aux.Length + 5; string msg = string.Format("15{0}{1}", tam.ToString("000"), aux); this.frm_Inicio.EnviaMsgTcp(msg); }
/// <summary> /// Desenha o tiro disparado pelo outro jogador. /// </summary> /// <param name="dados">Dados referentes a posição do tiro do outro jogador.</param> public void TiroDisparadoOutroJogador(string[] dados) { //vetor de dados sempre tem que ser um vetor com 4 posição. float[] posTiros = this.player.ConvertNormalDispositivo(float.Parse(dados[0]), float.Parse(dados[1])); Tiro newTiro = new Tiro(posTiros, this.player.tamX, this.pb.Size.Width, char.Parse(dados[2]), int.Parse(dados[3])); newTiro.PodeIr(); this.tirosInimigos.Add(newTiro); }
// Use this for initialization void Start() { playerTiro = gameObject.GetComponent <Tiro> (); }
/// <summary> /// Ouve a colisão do tiro com o player remoto. /// </summary> /// <param name="t"></param> private void TiroColidiuPlayerMsg(Tiro t) { string aux = ""; if (this.qualPlayer == 0) aux = string.Format("T|J2|{0}", t.GetId); else if (this.qualPlayer == 1) aux = string.Format("T|J1|{0}", t.GetId); int qtd = aux.Length + 5; string msg = string.Format("15{0}{1}", qtd.ToString("000"), aux); this.frm_Inicio.EnviaMsgTcp(msg); }