Beispiel #1
0
 public void TakeDamage(int attackAmount, ContactPoint contactPoint, ProjectileType projectileType)
 {
     if (isDead)
     {
         return;
     }
     audioSource.Stop();
     audioSource.Play();
     if (projectileType.Equals(ProjectileType.Kill))
     {
         currentHealth -= attackAmount;
         hitParticlesDamage.transform.position = contactPoint.point;
         hitParticlesDamage.Play();
         if (currentHealth <= 0)
         {
             Death();
         }
     }
     else if (projectileType.Equals(ProjectileType.Heal))
     {
         // Turn back to human
         state = EnemyState.Human;
         hitParticlesHeal.transform.position = contactPoint.point;
         hitParticlesHeal.Play();
         // Debug.Log("It's now a human");
     }
 }
Beispiel #2
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("Player"))
     {
         if (projectileType.Equals(ProjectileType.Kill))
         {
             // hud.UpdateAmmo(amount);
         }
         else if (projectileType.Equals(ProjectileType.Heal))
         {
             // hud.UpdateAntidotes(amount);
         }
         Destroy(gameObject, 0.3f);
     }
 }
 /// <summary>
 /// Gets the projectile sprite for the given projectile type
 /// </summary>
 /// <param name="type">the projectile type</param>
 /// <returns>the projectile sprite for the type</returns>
 public static Texture2D GetProjectileSprite(ProjectileType type)
 {
     if (type.Equals(ProjectileType.TeddyBear))
     {
         return teddyBearProjectileSprite;
     }
     // defaults to frenchFriesSprite
     return frenchFriesSprite;
 }
    public void Shoot()
    {
        if (Time.time > m_nextShot && ShootingDistanceIsGreaterThanZero())
        {
            m_nextShot = Time.time + ResetShootCooldown();
            //playerMovement.p_Movement.SetFacingDirection((shootDirection-this.transform.position).x);
            playerController.p_controller.shot.Play();
            ShootProjectile(shootDirection, currentAmmoType);
            if (currentAmmoType.Equals(ProjectileType.AREA))
            {
                Vector3 v  = shootDirection;
                Vector3 v2 = Quaternion.AngleAxis(45, Vector3.forward) * v;
                Vector3 v3 = Quaternion.AngleAxis(-45, Vector3.forward) * v;

                ShootProjectile((shootDirection + v2).normalized, currentAmmoType);
                ShootProjectile((shootDirection + v3).normalized, currentAmmoType);
            }
        }
    }
        public override void OnItemLoaded(Item item)
        {
            base.OnItemLoaded(item);

            ProjectileType selectedType = GetSelectedType(projectileType);

            if (selectedType.Equals(ProjectileType.Pierce) || selectedType.Equals(ProjectileType.Blunt))
            {
                item.gameObject.AddComponent <Projectiles.BasicProjectile>();
            }
            else if (selectedType.Equals(ProjectileType.Explosive))
            {
                item.gameObject.AddComponent <Projectiles.ExplosiveProjectile>();
            }
            else
            {
                item.gameObject.AddComponent <Projectiles.BasicProjectile>();
            }
        }
Beispiel #6
0
    private void CheckMouseInput()
    {
        if (Input.GetKeyDown(KeyCode.Alpha1))
        {
            // Debug.Log("Main Projectile");
            projectileType = ProjectileType.Kill;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha2))
        {
            // Debug.Log("Healing Projectile");
            projectileType = ProjectileType.Heal;
        }
        else if (Input.GetKeyDown(KeyCode.Alpha3))
        {
            // Debug.Log("Dragging Projectile");
            projectileType = ProjectileType.Drag;
        }

        if (Input.GetKeyDown(KeyCode.Mouse0))
        {
            audioSource.Stop();
            audioSource.PlayOneShot(shotAudio);
            if (hud.ammoLeft > 0 || hud.antidotesLeft > 0)
            {
                playerAnim.SetTrigger("Shoot");
            }
            // Shoot a projectile
            if (projectileType.Equals(ProjectileType.Kill) && hud.ammoLeft > 0)
            {
                GameObject projectileTemp = Instantiate(projectile, weapon.transform.position, weapon.transform.rotation);
                projectileTemp.GetComponent <Projectile>().ProjectileType = projectileType;
                // hud.UpdateAmmo(-1);
            }
            else if (projectileType.Equals(ProjectileType.Heal) && hud.antidotesLeft > 0)
            {
                GameObject projectileTemp = Instantiate(projectile, weapon.transform.position, weapon.transform.rotation);
                projectileTemp.GetComponent <Projectile>().ProjectileType = projectileType;
                // hud.UpdateAntidotes(-1);
            }
        }
    }
Beispiel #7
0
 public override void OnItemLoaded(Item item)
 {
     base.OnItemLoaded(item);
     selectedType = (ProjectileType)weaponTypeEnums.GetValue(projectileType);
     if (selectedType.Equals(ProjectileType.Pierce))
     {
         item.gameObject.AddComponent <ItemSimpleProjectile>();
     }
     // TODO: Add additional projectile types in future versions
     //else if (selectedType.Equals(ProjectileType.Explosive)) item.gameObject.AddComponent<Weapons.SimpleExplosive>();
     //else if (selectedType.Equals(ProjectileType.Energy)) item.gameObject.AddComponent<Weapons.PlasmaBolt>();
 }
Beispiel #8
0
 /// <summary>
 /// Gets the projectile sprite for the given projectile type
 /// </summary>
 /// <param name="type">the projectile type</param>
 /// <returns>the projectile sprite for the type</returns>
 public static Texture2D GetProjectileSprite(ProjectileType type)
 {
     // replace with code to return correct projectile sprite based on projectile type
     if (type.Equals(ProjectileType.FrenchFries))
     {
         return(frenchFriesSprite);
     }
     else
     {
         return(teddyBearProjectileSprite);
     }
 }
 /// <summary>
 /// Gets the projectile sprite for the given projectile type
 /// </summary>
 /// <param name="type">the projectile type</param>
 /// <returns>the projectile sprite for the type</returns>
 public static Texture2D GetProjectileSprite(ProjectileType type)
 {
     if (type.Equals(ProjectileType.TeddyBear))
     {
         return teddyBearProjectileSprite;
     }
     // defaults to frenchFriesSprite
     return frenchFriesSprite;
 }