示例#1
0
    void Shoot()
    {
        timer = 0f;
        gunAudio.Play();
        gunLight.enabled = true;
        gunParticles.Stop();
        gunParticles.Play();

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            EnemyLife enemyHealth = shootHit.collider.GetComponent <EnemyLife> ();

            if (enemyHealth != null)
            {
                enemyHealth.TakeDamage(damagePerShot, shootHit.point);
            }
            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
示例#2
0
 void Awake()
 {
     player       = GameObject.FindGameObjectWithTag("Player").transform;
     playerHealth = player.GetComponent <PlayerLife> ();
     enemyHealth  = GetComponent <EnemyLife> ();
     nav          = GetComponent <NavMeshAgent> ();
 }
示例#3
0
    protected void UpdateTargetAndFire()
    {
        if (!TargetInRange())
        {
            TargetLost();
            target = null;
        }

        if (target == null)
        {
            GetTarget();
            if (target != null)
            {
                TargetFound();
            }
        }

        if (target != null && CanFire())
        {
            Fire();
        }

        if (target == null)
        {
            UpdateNoTarget();
        }
    }
示例#4
0
 void Awake()
 {
     player      = GameObject.FindGameObjectWithTag("Player");
     PlayerLife  = player.GetComponent <PlayerLife> ();
     enemyHealth = GetComponent <EnemyLife> ();
     anim        = GetComponent <Animator> ();
 }
示例#5
0
    public void Start()
    {
        this.raycastEnemy = GetComponent <RaycastEnemy>();

        this.myTransform = gameObject.transform;

        this.canAttack = GetComponent <EnemyCanAttack>();

        this.enemyStateMachine = GetComponent <EnemyStateMachine>();

        this.enemyStateMachine.setStateMachineEnemy(StateMachineEnemy.Move);

        this.target = GameObject.Find("Jumba").transform;

        this.controllerHitSequence = target.GetComponent <ControllerHitSequence>();

        this.interfaceHitCombo = target.GetComponent <InterfaceHitCombo>();

        this.controllerHit = target.GetComponent <ControllerHitPlayer>();

        this.strikeForce = target.GetComponent <StrikeForce>();

        this.enemyLife = GetComponent <EnemyLife>();

        this.characterController = GetComponent <CharacterController>();

        this.enemyAnimation = GetComponent <EnemyAnimator>();
    }
 // private AudioSource aud;
 private void Start()
 {
     enemyHurt = GetComponentInParent <EnemyHurt>();
     enemyLife = GetComponentInParent <EnemyLife>();
     enemiIA   = GetComponentInParent <EnemiIA>();
     // aud = GetComponent<AudioSource>();
 }
示例#7
0
 void Start()
 {
     poolPoint = GameObject.FindGameObjectWithTag("PoolPoint").GetComponent <BulletPooler>(); //Point pooler
     spriteRendererComponent = transform.Find("EnemySprite").GetComponent <SpriteRenderer>(); //Enemy sprite
     lifeScript = GetComponent <EnemyLife>();                                                 //Get life script
     maxLife    = lifeScript.GetLife();                                                       //get maximum life
 }
示例#8
0
    // Use this for initialization
    void Start()
    {
        Transform[] enemyTypes        = { enemy1, enemy2, enemy3 };
        int         numberOfEnemyType = enemyTypes.Length;
        float       step = (xMax - xMin) / numberOfEnemies;

        for (int i = 0; i < numberOfEnemies; i++)
        {
            Transform obj = enemyTypes [Random.Range(0, numberOfEnemyType)];

            Transform   enemy        = GameObject.Instantiate(obj, parentTransform);
            EnemyAttack attackScript = enemy.gameObject.AddComponent <EnemyAttack> ();
            attackScript.target = target;

            EnemyLife lifeScript = enemy.gameObject.AddComponent <EnemyLife> ();
            lifeScript.maxHealth = maxHealth;

            enemy.localScale = new Vector3(0.5f, 0.5f, 0.5f);

            enemy.transform.Translate(new Vector3(
                                          Random.Range(i - 1, i + 1) * step + xMin,
                                          y,
                                          0));
        }
    }
示例#9
0
    // Update is called once per frame
    void Update()
    {
        float deltaTime = Time.deltaTime;

        lastAttackTime += deltaTime;

        if (lastAttackTime > 1f && attacking)
        {
            attacking = false;
        }

        if (Input.GetKey(KeyCode.Space) && !attacking)
        {
            attacking      = true;
            lastAttackTime = 0f;
            animator.SetBool("isAttacking", true);
            animator.CrossFade("Attack1H", 1);

            int childCount = enemies.childCount;
            for (int i = 0; i < childCount; i++)
            {
                Transform enemy    = enemies.GetChild(i);
                float     distance = Vector3.Distance(enemy.transform.position, transform.position);
                if (distance < attackDistance)
                {
                    EnemyLife script = enemy.gameObject.GetComponent <EnemyLife> ();
                    script.attacked(attackStrength);
                }
            }
        }
    }
示例#10
0
 void Start()
 {
     poolPoint = GameObject.FindGameObjectWithTag("PoolPoint").GetComponent <BulletPooler>();                 //Point pooler
     StartCoroutine("AddRotation");                                                                           //Add rotation
     spriteRendererComponent = GetComponentInChildren <SpriteRenderer>();
     lifeScript       = GetComponent <EnemyLife>();                                                           //Get life script
     enemySpawnSystem = GameObject.FindGameObjectWithTag("GameController").GetComponent <EnemySpawnSystem>(); //Find the enemySpawnSystem
 }
 void Start()
 {
     player = ProceduralMap.pla;
     camera = player.transform.GetComponentInChildren <Camera>();
     ef     = transform.transform.GetComponent <EnemyLife>();
     loadingBar.transform.localScale = new Vector3(1, 1, 1);
     billboard.cam = camera;
 }
示例#12
0
    private void Start()
    {
        life = GetComponent <EnemyLife>();
        move = GetComponent <EnemyMove>();

        life.damageMultiplier = 2;
        move.moveMultiplier   = 0.60f;
    }
示例#13
0
	void Start()
	{
		originalVel = rotVel;

		enemyLife = GetComponent<EnemyLife>();

		if(enemyLife == null)
			enemyLife = transform.parent.GetComponent<EnemyLife>();
	}
示例#14
0
    void Awake()
    {
        GameObject player = GameObject.FindGameObjectWithTag("Player");

        playerTransform = player.transform;
        playerLife      = player.GetComponent <PlayerLife>();
        enemyLife       = GetComponent <EnemyLife>();
        nav             = GetComponent <UnityEngine.AI.NavMeshAgent>();
    }
	protected virtual void Start()
	{
		enemyLife = GetComponent<EnemyLife> ();
	
		myAnimator = transform.GetComponentInChildren<Animator> ();

		if(myAnimator != null)
			originalAnimatorSpeed = myAnimator.speed;
	}
示例#16
0
 void HitAnEnemy(EnemyLife enemyLife)
 {
     if(!enemyLifesHit.Contains(enemyLife)){
         enemyLifesHit.Add(enemyLife);
         enemyLife.TakeDamage(damage);
         if(destroyOnHitEnemy){
             Destroy(gameObject);
         }
     }
 }
示例#17
0
    private void Start()
    {
        thisEnemyLife = GetComponentInChildren <EnemyLife>();
        if (thisEnemyLife == null)
        {
            instatiateEnemyLifeInChild();
        }

        thisEnemyLife.OnEnemyDead += deathRoutine;
    }
示例#18
0
    private void instatiateEnemyLifeInChild()
    {
        System.Type[] EnemyLife =
        {
            typeof(EnemyLife)
        };         //componentes

        Instantiate(new GameObject("EnemyLife", EnemyLife), this.transform);
        thisEnemyLife = GetComponentInChildren <EnemyLife>();        //reload
    }
示例#19
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        EnemyLife life = other.gameObject.GetComponent <EnemyLife>();

        if (life != null)
        {
            GameObject.Destroy(gameObject);
            life.Damage(EnemyLife.RED, damage);
        }
    }
示例#20
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.gameObject.tag == "Player")
     {
         playerLife.CurrentLife--;
     }
     if (other.gameObject.tag == "Weapon")
     {
         EnemyLife en = GetComponent <EnemyLife>();
         en.currentLife--;
     }
 }
示例#21
0
    void MaybeUpdateTarget(Collider collider)
    {
        float distance = (collider.transform.position - transform.position).magnitude;

        if (distance > range)
        {
            return;
        }

        if (target == null || distance < (target.transform.position - transform.position).magnitude)
        {
            target = collider.gameObject.GetComponent <EnemyLife>();
        }
    }
示例#22
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        //Collide with bullet
        if (collision.gameObject.tag == "Bullet" && !invulnerable)
        {
            Bullet bullet = collision.gameObject.GetComponent <Bullet> ();

            if (bullet.hasTouched == false)
            {
                bullet.hasTouched = true;
                EnemyLife enemyLife = GetComponent <EnemyLife> ();
                Debug.Log("bullet touch");

                PollutedBullet tmpbullet = collision.gameObject.GetComponent <PollutedBullet> ();
                if (tmpbullet != null)
                {
                    tmpbullet.applyBulletEffect(this.gameObject);
                }
                else if (enemyLife)
                {
                    enemyLife.damageLife();
                }
                Destroy(collision.gameObject);
            }
        }

        //Polute and link when collide
        if (collision.gameObject.tag == "Player" && !invulnerable)
        {
            invulnerable = true;
            ghostTime    = Time.time;

            //GetComponent<MoveToPlayer> ().angularSpeed += 1.0f;
            Color grey = new Color();
            grey   = Color.gray;
            grey.a = 0.25f;
            foreach (SpriteRenderer elem in gameObject.GetComponentsInChildren <SpriteRenderer> ())
            {
                elem.color = grey;
            }
            EnemyPolute polute = GetComponent <EnemyPolute> ();
            if (polute != null)
            {
                //Debug.Log ("polute");
                polute.polute();
                Destroy(polute);
            }
        }
    }
示例#23
0
 private void Start()
 {
     myEnemyLife = GetComponent <EnemyLife>();
     if (myEnemyLife != null)
     {
         myEnemyLife.SetEnemy(this);
     }
     myMovingBackAndForth = GetComponent <MovingBackAndForth>();
     myMovingBackAndForth.SetEnemy(this);
     myEnemyHitBox = GetComponentInChildren <EnemyHitBox>();
     if (myEnemyHitBox != null)
     {
         myEnemyHitBox.SetEnemy(this);
     }
 }
示例#24
0
    // Use this for initialization
    void Awake()
    {
        enemyBullet = Resources.Load("enemyBullet") as GameObject;
        enemyLife   = GetComponent <EnemyLife>();
        bossPhase   = -1;
        wave        = GameController.gameControl.enemySpawner.GetCurrentWave();
        phase       = (Phase)wave.phase;

        bulletsShot = new ArrayList();

        if (wave.isBoss || wave.isMidBoss)
        {
            phase            = gameObject.AddComponent <Phase> ();
            phase.endOfPhase = true;
        }
    }
示例#25
0
    private void Start()
    {
        enemyLife      = GetComponentInChildren <EnemyLife>();
        rbEnemy        = GetComponent <Rigidbody>();
        enemieType     = GetComponent <EnemieType>();
        changeMaterial = GetComponentInChildren <ChangeMaterial>();


        if (ChangeMaterialParentBeach != null && ChangeMaterialParentBeach.name == "meshenemigoplaya")
        {
            changeMaterialBeach = GetComponentInChildren <ChangeMaterialBeach>();
        }
        else
        {
            changeMaterialBeach = null;
        }
    }
示例#26
0
    void OnTriggerEnter(Collider collision)
    {
        new WaitForSeconds(0.1f);
        if (collision.tag == "Enemy")
        {
            EnemyLife life = collision.GetComponent <EnemyLife>();
            life.recibirDaño(daño);
            Destroy(this.gameObject);
        }

        if (collision.tag == "Breakable")
        {
            Destruction destr = collision.GetComponent <Destruction>();
            destr.Destruir();
            Destroy(this.gameObject);
        }
    }
示例#27
0
    private void Shoot()
    {
        timer = 0f;

        shootRay.origin    = cam.transform.position;
        shootRay.direction = cam.transform.forward * range;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            EnemyLife enemyLife = shootHit.collider.GetComponent <EnemyLife>();

            if (enemyLife != null && enemyLife.IsAlive())
            {
                enemyLife.TakeHit();
                audioSource.Play();
            }
        }
    }
示例#28
0
    void OnTriggerEnter(Collider collision)
    {
        if (ataque)
        {
            if (collision.tag == "Enemy")
            {
                EnemyLife life = collision.GetComponent <EnemyLife>();
                life.recibirDaño(100);
                ataque = false;
            }

            if (collision.tag == "Breakable")
            {
                Destruction destr = collision.GetComponent <Destruction>();
                destr.Destruir();
                ataque = false;
            }
        }
    }
示例#29
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Weapon")
        {
            EnemyLife en = GetComponent <EnemyLife>();
            en.currentLife--;

            var destroy = GetComponentInParent <Earth_Enemy2>();
            if (destroy != null)
            {
                destroy.Destroy();
            }
        }
        if (other.gameObject.tag == "Player")
        {
            if (playerLife != null)
            {
                playerLife.CurrentLife--;
            }
        }
    }
示例#30
0
    // Update is called once per frame
    void Update()
    {
        if (target != null)
        {
            transform.position = Vector3.SmoothDamp(transform.position, target.transform.position, ref velocity, 0.05f);

            relative        = target.transform.position - transform.position;
            distanceToEnemy = relative.magnitude;

            // If it has reached its target then display the take damage effect, decrease the enemy's life and destroy the bullet
            if (distanceToEnemy < 0.1)
            {
                enemyLifeScript = target.GetComponent <EnemyLife> ();
                if (tower != null && (tower.GetComponent <Weapon>().TakeDamageEnemyEffect != null || tower.GetComponent <MultiShotWeapon>().TakeDamageEnemyEffect != null))
                {
                    Weapon weapon;
                    if (tower.GetComponent <Weapon>().TakeDamageEnemyEffect != null)
                    {
                        weapon = tower.GetComponent <Weapon>();
                    }
                    else
                    {
                        weapon = tower.GetComponent <MultiShotWeapon>();
                    }

                    weapon.effect = (GameObject)Instantiate(weapon.TakeDamageEnemyEffect, target.transform.position, target.transform.rotation);
                    weapon.effect.transform.parent = tower.transform;
                }

                enemyLifeScript.TakeDamage(1);

                Destroy(gameObject);
            }
        }
        else
        {
            Destroy(gameObject);
        }
    }
    void OnTriggerEnter(Collider collider)
    {
        if (tag != "Shooting" && collider.gameObject.tag == "Enemy")
        {
            EnemyLife enemyLife = collider.gameObject.GetComponent <EnemyLife>();
            ScoreScript.scoreValue += enemyLife.getPoints();
            Destroy(collider.gameObject);
        }

        if (collider.gameObject.tag == "Bullet")
        {
            if (tag == "Shooting")
            {
                shootingLife--;
                if (shootingLife == 0)
                {
                    Destroy(this.gameObject);
                }

                Destroy(collider.gameObject);
            }
        }
    }
示例#32
0
    private void OnTriggerEnter(Collider other)
    {
        if (PlayerController.attack == true && other.gameObject.tag == "Enemy" && !other.gameObject.GetComponent <EnemyLife>().death)
        {
            live       = other.gameObject.GetComponent <EnemyLife>();
            live.life -= damage;
            popupController.CreatePopupText(damage, other.gameObject.GetComponent <Transform>().transform);

            my_audioSource.clip = enemyHitSound[Random.Range(0, enemyHitSound.Length)];
            my_audioSource.Play();

            live.BloodSplat();

            if (BeatStrike.beatAttack && !other.gameObject.GetComponent <EnemyLife>().death)
            {
                GameObject particalEffect = Instantiate(particle, this.transform.position, Quaternion.identity);
            }
            if (testFight.knockBack)
            {
                Rigidbody rb = other.GetComponent <Rigidbody>();

                Vector3 direction = other.transform.position - transform.position;
                direction.y = 0;

                rb.transform.position += direction.normalized * knockBackStrenght;
            }
            if (testFight.disturbAttack)
            {
                EnemyController enemy = other.GetComponent <EnemyController>();
                enemy.hit = true;
            }
        }
        else
        {
            return;
        }
    }
示例#33
0
    void Start()
    {
        if (boss == null)
        {
            this.boss = GameObject.Find("createBoss").GetComponent <InstantiateBoss>().prefabBoss;
        }

        EnemyLife _enemyLife = this.boss.GetComponent <EnemyLife>();

        if (_enemyLife != null)
        {
            this.lifeTotal = _enemyLife.life;
        }
        else
        {
            if (boss.name.Equals("BossRobot"))
            {
                this.lifeTotal = GameObject.Find("BossRobot(Clone)").GetComponent <RobotLife>().getLife();
            }
            else if (boss.name.Equals("SwordBoss"))
            {
                this.lifeTotal = GameObject.Find("SwordBoss(Clone)").GetComponent <SwordBossLife>().getCurrentLife();
            }
            else if (boss.name.Equals("DragonScene"))
            {
                this.lifeTotal = this.boss.FindChild("Dragon").FindChild("Head").GetChild(0).GetComponent <DragonLife>().life;
            }
            else if (boss.name.Equals("Exterminator"))
            {
                this.lifeTotal = this.boss.GetChild(0).GetComponent <ExterminatorLife>().maxLife;
            }
        }

        this.startAnimation = true;

        myScale.localScale = new Vector3(MAX_SCALE_X - 0.9f, MAX_SCALE_Y, MAX_SCALE_Z);
    }
示例#34
0
	protected virtual void Start()
	{
		enemyLife = GetComponent<EnemyLife> ();
	}