private void Shoot() { WeaponAI currentWeapon = weaponsList[0]; for (int i = 0; i < weaponsList.Count; i++) { if (weaponsList[i].currentPriority > currentWeapon.currentPriority) { currentWeapon = weaponsList[i]; } } for (int i = 0; i < weaponsList.Count; i++) { weaponsList[i].currentPriority += weaponsList[i].priorityAddOnTurn; } currentWeapon.currentPriority -= currentWeapon.minusPriorityOnShoot; SetRotationOfCanon(currentWeapon); AudioController.INSTANCE.PlayAudio(AudioClipType.COUNTDOWN_321); tankController.currentWeapon.weaponType = currentWeapon.weaponType; tankController.Shoot(); EndTurnAI(); }
public virtual void Awake() { sensesAI = GetComponent <SensesAI>(); Assert.IsNotNull(sensesAI, "Missing sensesAI"); weaponAI = GetComponent <WeaponAI>(); Assert.IsNotNull(weaponAI, "Missing weaponAI"); navMeshAgent = GetComponent <NavMeshAgent>(); Assert.IsNotNull(navMeshAgent, "Missing navMeshAgent"); audioSource = GetComponent <AudioSource>(); Assert.IsNotNull(audioSource, "Missing audioSource"); }
public void Jump() { if (isGround == true) { isGround = false; rb.velocity = Vector2.up * jumpForce * Time.fixedDeltaTime; jumpShoot = Random.Range(0, maxJumpChance); if (jumpShoot == 1 && canShoot == true) { isGround = false; GameObject gunai = GameObject.FindGameObjectWithTag("WeaponAI"); WeaponAI WAI = gunai.GetComponent <WeaponAI>(); WAI.Shoot(); } } }
private void SetRotationOfCanon(WeaponAI weapon) { Quaternion cannonRotation = new Quaternion(); // look into enemy var dir = playerTank.position - tankController.transform.position; var angle = Mathf.Atan2(dir.y, dir.x) * Mathf.Rad2Deg; switch (weapon.weaponType) { case WeaponType.ROCKET: angle += 48; tankController.PowerOfFireProjectile = 0.69f; break; case WeaponType.HOMMING_MISSILE: angle += 50; tankController.PowerOfFireProjectile = 0.8f; break; case WeaponType.BANANA: angle += 60; tankController.PowerOfFireProjectile = 0.85f; break; case WeaponType.LASOR: angle += 43; tankController.PowerOfFireProjectile = 0.9f; break; case WeaponType.POISON_ARROW: break; } cannonRotation = Quaternion.AngleAxis(angle, -Vector3.forward); tankController.canon.DORotateQuaternion(cannonRotation, 2f); }
virtual public void Awake() { owner = GetComponent <WeaponAI>(); Assert.IsNotNull(owner, "Missing owner"); }
private void Update() { liveText = EnemyLives.ToString(); lives.text = liveText; GameObject thePlayer = GameObject.Find("Player"); PlayerController pc = thePlayer.GetComponent <PlayerController>(); dist = Vector2.Distance(pc.transform.position, transform.position); if (dist <= 140) { enemyySpeed = 0; } if (player.transform.position.x <= -200f && transform.position.x <= -200f || player.transform.position.x >= 200f && transform.position.x >= 200f) { enemyySpeed = 0; zonereach = true; } else { zonereach = false; } if (pc.transform.position.y <= 700) { enemyySpeed = 0; } if (pc.transform.position.y > 700) { enemyySpeed = enemySpeed; } if (dist >= 140 && zonereach == false) { enemyySpeed = enemySpeed; } if (pc.transform.position.x > transform.position.x && hit == false && isGround == true) { transform.rotation = new Quaternion(0, 0, 0, 0); rb.velocity = transform.right * enemyySpeed; } if (pc.transform.position.x < transform.position.x && hit == false && isGround == true) { transform.rotation = new Quaternion(0, 180, 0, 0); rb.velocity = transform.right * enemyySpeed; } if (pc.transform.position.y <= transform.position.y && canShoot == true) { canShoot = false; GameObject gunai = GameObject.FindGameObjectWithTag("WeaponAI"); WeaponAI WAI = gunai.GetComponent <WeaponAI>(); WAI.Shoot(); } if (transform.position.y <= -1100) { Die(); } }