Esempio n. 1
0
 public void Attack()
 {
     if (touch)
     {
         if (target.gameObject.tag == "animal")
         {
             print("Hit animal");
             EnemyControler Ec = target.gameObject.GetComponent <EnemyControler>();
             if (Ec != null)
             {
                 Ec.animalChangeHealth(damage);
             }
             else
             {
                 Debug.LogError("Animal doesn't have script");
             }
         }
         else if (target.gameObject.tag == "slime")
         {
             slime sl = target.gameObject.GetComponent <slime>();
             sl.slimeChangeHealth(damage);
             Debug.Log("Hit Slime");
         }
         Debug.Log("Damage: " + damage);
     }
 }
    void OnEnemyContact(EnemyControler enemyControler)
    {
        Debug.Log(effect);
        switch (effect)
        {
        case EFFECT_SLOW:
            enemyControler.Slow();
            break;

        case EFFECT_BIRD:
            enemyControler.Bird();
            break;

        case EFFECT_EXPLOSION_CIRCLE:
            enemyControler.Explosion();
            break;

        case EFFECT_IMMORTAL:
            enemyControler.Immortal();
            break;

        case EFFECT_LIFE_UP:
            enemyControler.LifeUp();
            break;

        case EFFECT_INSTANT_KILL:
            enemyControler.InstatKill();
            break;

        case EFFECT_EXPLOSION_LINES:
            enemyControler.Explosion();
            break;
        }
    }
    void Shoot()
    {
        muzzleFlash.Play();

        currentAmmo--;

        RaycastHit hit;

        if (Physics.Raycast(head.transform.position, head.transform.forward, out hit, range))
        {
            Debug.Log(hit.transform.name);

            EnemyControler target  = hit.transform.GetComponent <EnemyControler>();
            BossControler  target2 = hit.transform.GetComponent <BossControler>();

            if (target != null)
            {
                target.TakeDamageEnemy(damage);
            }

            else
            {
                target2.TakeDamageEnemy(damageB);
            }

            GameObject impactGO = Instantiate(impactEffect, hit.point, Quaternion.LookRotation(hit.normal));
            Destroy(impactGO, 0.5f);
        }
    }
Esempio n. 4
0
 void OnEnable()
 {
     playerScript = PlayerScript.player;
     player       = PlayerScript.player.transform.gameObject; //cache the player gameobject
     CommonStartup();                                         // run the common startup from CoreActorScript
     //find out what I am
     IdentifyType();
     //get my variables
     myDamage        = loader.enemyDamage * myModifier; // figure out what my damage is *** consider moving all modifiers to this level
     mySpecialDamage = myDamage * 2;                    //*** revisit this set
     maxHealth       = loader.enemyHealth * myModifier; // figure out the health *** consider moving all modifiers to this level
     curHealth       = maxHealth;                       // current health is maxhealth
     if (listOfChildrenDisabled.Count > 0)
     {
         TransferBetweenLists(listOfChildrenDisabled.Count); // if there are any disabled children enable all of them this is revive logic
     }
     if (!myHead.activeSelf)                                 // if my head is not active, set it active, again this is revive logic
     {
         myHead.SetActive(true);
     }
     heDead           = false;                                              // make sur the heDead bool is false
     scoreValue       = loader.gameIteration;
     activeBlocking   = true;                                               // default active blocking to true
     myHeadsTransform = myHead.transform;                                   // cache the myHead transorm
     myControler      = myTransform.parent.GetComponent <EnemyControler>(); // cache my controler's script
     if (!anim.isInitialized)
     {
         anim.Rebind();           // rebind the animator in case it cached any prior state this is revive logic
     }
     inRange             = false; //reset range flag for revive logic
     projectileTransform = myProjectile.transform;
     myHead.SetActive(true);
     myHealPower = 10 * loader.gameIteration;
 }
    public void OnTriggerEnter2D(Collider2D col)
    {
        int layer = col.gameObject.layer;

        if (layer == LayerMask.NameToLayer("Enemy"))
        {
            EnemyControler enemyController = col.gameObject.GetComponent <EnemyControler>();
            OnEnemyContact(enemyController);
        }
        else if (layer == LayerMask.NameToLayer("Player"))
        {
            PlayerCar playerControler = col.gameObject.GetComponent <PlayerCar>();
            OnPlayerContact(playerControler);
        }
    }
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "Ground" || collision.gameObject.tag == "Box")
        {
            isGrounded = true;
            EnemyControler.MoveAgain();
        }

        /*if (collision.gameObject.tag == "Box")
         * {
         *  if(PlayerHealth.health == 3)
         *  {
         *      EnemyControler.Wait();
         *  }
         * }*/
    }
Esempio n. 7
0
 private void OnCollisionEnter2D(Collision2D collision)
 {
     if (collision.gameObject.tag == "animal")
     {
         print("Hit animal!!!");
         EnemyControler Ec = collision.gameObject.GetComponent <EnemyControler>();
         if (Ec != null)
         {
             Ec.animalChangeHealth(-1);
         }
     }
     else if (collision.gameObject.tag == "slime")
     {
         slime sl = collision.gameObject.GetComponent <slime>();
         sl.slimeChangeHealth(-1);
         Debug.Log("Hit Slime");
     }
     Destroy(this.gameObject);
 }
Esempio n. 8
0
 public void SetMissile(Collider2D target, float speed, Sprite sprite, DiceStatus diceStatus)
 {
     this.diceStatus = diceStatus;
     GetComponent <SpriteRenderer>().sprite = sprite;
     this.target  = target;
     targetObject = target.GetComponent <EnemyControler>();
     StartCoroutine(Shoot(target, speed));
     this.attackType = diceStatus.attackType;
     explosion.SetExplode(attackType);
     if (diceStatus.animator == null)
     {
         animator.runtimeAnimatorController = null;
         hasAnimation = false;
     }
     else
     {
         animator.runtimeAnimatorController = diceStatus.animator;
         hasAnimation = true;
     }
     //   Debug.Log("탄 설정");
 }
Esempio n. 9
0
    public void Spawn()
    {
        Debug("Wave #" + waveNumber);
        int amountOfMobsToSpawn = waveNumber;

        for (int i = 0; i < amountOfMobsToSpawn; i++)
        {
            Enums.ColorSelector colorSelector;
            EnemyControler      enemy;
            mobID++;

            switch (mobID % 4)
            {
            case 0: enemy = enemyBlue;     colorSelector = Enums.ColorSelector.Blue;      break;

            case 1: enemy = enemyGreen;    colorSelector = Enums.ColorSelector.Green;     break;

            case 2: enemy = enemyYellow;   colorSelector = Enums.ColorSelector.Yellow;    break;

            case 3: enemy = enemyRed;      colorSelector = Enums.ColorSelector.Red;       break;

            default: enemy = null;          colorSelector = Enums.ColorSelector.Red;       break;
            }

            if (enemy != null)
            {
                newEnemy               = Instantiate(enemy, spawnLocation.position, spawnLocation.rotation) as EnemyControler;
                newEnemy.MobID         = mobID;
                newEnemy.Wave          = this;
                newEnemy.colorSelector = colorSelector;
                Debug("Spawned : " + newEnemy.ToString());
                remainingMobs.Add(newEnemy.MobID, newEnemy);
            }
            else
            {
                print("Error occured : x %4 was neither 0, 1, 2 or 3 ???");
            }
        }
    }
    public void  EnemyKnockBack(GameObject enemy)
    {
        jump = true;
        float          enemyPosx = enemy.transform.position.x;
        EnemyControler enemyctr  = enemy.GetComponent <EnemyControler>();
        float          side      = Mathf.Sign(enemyPosx - transform.position.x);

        rb2d.AddForce(Vector2.left * side * jumpPower, ForceMode2D.Impulse); // Fisica del SALTO para atras
        movement = false;
        Invoke("EnableMovement", 1f);
        Color colour = new Color(19f, 111f, 60f);

        sprt.color = Color.red;


        if (enemyctr.tipoDeEnemigo == 1)
        {
            // healhtbar.SendMessage("RecibirDanho", 4f);
            RecibirDanho(4f);
            EfecuarEnvenamientoPorUnTiempo(6f);
        }
        RecibirDanho(2f);
        //healhtbar.SendMessage("RecibirDanho", 2f);
    }
Esempio n. 11
0
 public void RemoveEnemyFromList(EnemyControler enemyControler)
 {
     spawnedEnemies.Remove(enemyControler);
 }
Esempio n. 12
0
 public void CrowdEffect(EnemyControler controler, AttackType attackType)
 {
     controler.Debuff(attackType.diffusion, attackType.range, EnemyStat.speed);
 }