Пример #1
0
    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();
    }
Пример #2
0
 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");
 }
Пример #3
0
 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();
         }
     }
 }
Пример #4
0
    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);
    }
Пример #5
0
 virtual public void Awake()
 {
     owner = GetComponent <WeaponAI>();
     Assert.IsNotNull(owner, "Missing owner");
 }
Пример #6
0
    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();
        }
    }