Exemplo n.º 1
0
    private void FireProjectile()
    {
        if (_canFireIn > 0)
        {
            return;
        }
        ;
        if (FireProjectileEffect != null)
        {
            var effect = (GameObject)Instantiate(FireProjectileEffect, ProjectileFireLocation.position, ProjectileFireLocation.rotation);
            effect.transform.localScale = new Vector3(isFacingRight ? 1 : -1, 1, 1);
            effect.transform.parent     = transform;
            Destroy(effect, 0.08f);

            SimpleEnemyAI enemy = gameObject.GetComponent <SimpleEnemyAI>();
            if (enemy != null)
            {
                enemy.TakeDamage(Damage, OuchEffect);
            }
        }

        var direction = isFacingRight ? Vector2.right : -Vector2.right;

        var projectile = (Projectile)Instantiate(Projectile, ProjectileFireLocation.position, ProjectileFireLocation.rotation);

        projectile.Initialise(gameObject, direction, controller.Velocity);

        _canFireIn = FireRate;

        SoundManager.Instance.PlayClip3D(PlayerShotShound, transform.position);
    }
Exemplo n.º 2
0
    private void Update()
    {
        SimpleEnemyAI enemyAI = FindObjectOfType <SimpleEnemyAI>();

        if (enemyAI != null && !inFight)
        {
            startFight();
        }
        else if (enemyAI == null && inFight)
        {
            endFight();
        }
    }
Exemplo n.º 3
0
    void Shoot()
    {
        Vector2      mousePosition     = new Vector2(Camera.main.ScreenToWorldPoint(Input.mousePosition).x, Camera.main.ScreenToWorldPoint(Input.mousePosition).y);
        Vector2      firePointPosition = new Vector2(firePoint.position.x, firePoint.position.y);
        RaycastHit2D hit = Physics2D.Raycast(firePointPosition, mousePosition - firePointPosition, 100, whatToHit);

        if (Time.time >= timeToSpawnEffect)
        {
            Effect();
            timeToSpawnEffect = Time.time + 1 / efffectSpawnRate;
        }

        Debug.DrawLine(firePointPosition, (mousePosition - firePointPosition) * 100, Color.cyan);
        if (hit.collider != null)
        {
            Debug.DrawLine(firePointPosition, hit.point, Color.red);
            SimpleEnemyAI enemy = hit.collider.GetComponent <SimpleEnemyAI>();
            if (enemy != null)
            {
                // enemy.TakeDamage(Damage, GameObject instigator);
            }
            //Debug.Log("We hit " + hit.collider.name + " and did " + Damage + " damage");
        }
    }
 public void Awake()
 {
     _director = GameObject.FindObjectOfType<SimpleEnemyAI>();
 }
Exemplo n.º 5
0
 void Start()
 {
     anim = GetComponent <Animator>();
     ai   = GetComponent <SimpleEnemyAI>();
 }
Exemplo n.º 6
0
 public void Awake()
 {
     _director = GameObject.FindObjectOfType <SimpleEnemyAI>();
 }
Exemplo n.º 7
0
 public void AddEnemy(SimpleEnemyAI Enemy)
 {
     _enemies.Add(Enemy);
 }