Пример #1
0
 void OnTriggerEnter2D(Collider2D other)
 {
     //DestroyObject (this);
     //Debug.Log ("boob bay");
     if (other.gameObject.tag == "EnemyMelle")
     {
         hit   = true;
         melle = other.GetComponent <EnemyScriptMelle>();
         if (!spell4)
         {
             melle.TakeDmg(player.Damage);
         }
         if (spell4)
         {
             melle.TakeDmg(player.Damage * 2);
         }
         melle.StunD(0.5f);
         //var shotTransform = Instantiate(boooom) as Transform;
         //shotTransform.position = transform.position;
         if (!massdmg)
         {
             this.renderer.enabled = true;
             DestroyObject(gameObject, 0.2f);
             speed = new Vector2(0, 0);
         }
     }
     if (other.gameObject.tag == "EnemyArcher")
     {
         hit    = true;
         archer = other.GetComponent <ArcherWar>();
         if (!spell4)
         {
             archer.TakeDmg(player.Damage);
         }
         if (spell4)
         {
             archer.TakeDmg(player.Damage * 2);
         }
         archer.StunD(0.5f);
         //var shotTransform = Instantiate(boooom) as Transform;
         //shotTransform.position = transform.position;
         if (!massdmg)
         {
             this.renderer.enabled = true;
             DestroyObject(gameObject, 0.2f);
             speed = new Vector2(0, 0);
         }
     }
     if (other.gameObject.tag == "ground")
     {
         this.renderer.enabled = true;
         hit = true;
         DestroyObject(gameObject, 0.2f);
         speed = new Vector2(0, 0);
         //Destroy(this);
     }
 }
Пример #2
0
    //--------------------------------
    // 3 - Стрельба из другого скрипта
    //--------------------------------

    /// <summary>
    /// Создайте новый снаряд, если это возможно
    /// </summary>
    public void Attack(bool isEnemy)
    {
        if (CanAttack)
        {
            shootCooldown = shootingRate;

            // Создайте новый выстрел
            var shotTransform = Instantiate(shotPrefab) as Transform;

            // Определите положение
            shotTransform.position = transform.position;

            // Свойство врага

            ShotScript shot = shotTransform.gameObject.GetComponent <ShotScript>();
            if (shot != null)
            {
                shot.isEnemyShot = isEnemy;
            }

            // Сделайте так, чтобы выстрел всегда был направлен на него
            MoveScript move = shotTransform.gameObject.GetComponent <MoveScript>();
            ArcherWar  ch   = GetComponent <ArcherWar>();

            if (ch.isFacingRightArcher == true)
            {
                if (move != null)
                {
                    move.direction = this.transform.right;                             // в двухмерном пространстве это будет справа от спрайта
                }
            }
            if (ch.isFacingRightArcher == false)
            {
                if (move != null)
                {
                    move.direction = -this.transform.right;                     // в двухмерном пространстве это будет справа от спрайта
                }
            }
        }
    }
Пример #3
0
 // Use this for initialization
 void Start()
 {
     renderer.enabled = false;
     Gamp = forestGamp.GetComponent<ArcherWar>();
 }
Пример #4
0
 // Use this for initialization
 void Start()
 {
     info = enemy.GetComponent<ArcherWar> ();
     maxHP = (float)info.hp;
     size = this.transform.localScale;
 }
Пример #5
0
 // Use this for initialization
 void Start()
 {
     info  = enemy.GetComponent <ArcherWar> ();
     maxHP = (float)info.hp;
     size  = this.transform.localScale;
 }
Пример #6
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log("Trigger: Player Entered");

        if (other.gameObject.tag == "EnemyMelle")
        {
            EnSCR = other.GetComponent<EnemyScriptMelle> ();
            if(attacked2 || attacked3 || attacked4)
                attacked = false;
            if(attacked)
            {
                if (!critical)
                    EnSCR.TakeDmg(dmg);
                if (critical)
                {
                    EnSCR.critical = true;
                    EnSCR.TakeDmg(dmg*2);
                    critical = false;
                }
                attacked = false;
            }
            if(attacked || attacked3 || attacked4)
                attacked2 = false;
            if(attacked2)
            {
                EnSCR.StunD(0.5f);
                if(EnSCR.turn == 1 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(3000f,400f));
                if(EnSCR.turn == 2 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-400f,3000f));
                if(EnSCR.turn == 3 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-3000f,-400f));
                if(EnSCR.turn == 4 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(400f,-3000f));

                if(EnSCR.turn == 1 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-3000f,400f));
                if(EnSCR.turn == 2 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-400f,-3000f));
                if(EnSCR.turn == 3 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(3000f,-400f));
                if(EnSCR.turn == 4 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(400f,3000f));
                attacked2 = false;
            }
            if(attacked2 || attacked3 || attacked)
                attacked4 = false;
            if(attacked4)
            {
                if (!critical)
                    EnSCR.TakeDmg(dmg*1.7);
                if (critical)
                {
                    EnSCR.critical = true;
                    EnSCR.TakeDmg(dmg*2*1.7);
                    critical = false;
                }
                attacked = false;
            }
            //Debug.Log("WOW!");
        }
        if (other.gameObject.tag == "EnemyArcher")
        {
            ArcherScript = other.GetComponent<ArcherWar> ();
            if(attacked2 || attacked3 || attacked4)
                attacked = false;
            if(attacked)
            {
                if (!critical)
                    ArcherScript.TakeDmg(dmg);
                if (critical)
                {
                    ArcherScript.critical = true;
                    ArcherScript.TakeDmg(dmg*2);
                    critical=false;
                }
                attacked = false;
            }
            if(attacked || attacked3 || attacked4)
                attacked2 = false;
            if(attacked2)
            {
                ArcherScript.StunD(0.5f);
                if(ArcherScript.turnArcher == 1 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(3000f,400f));
                if(ArcherScript.turnArcher == 2 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-400f,3000f));
                if(ArcherScript.turnArcher == 3 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-3000f,-400f));
                if(ArcherScript.turnArcher == 4 && playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(400f,-3000f));

                if(ArcherScript.turnArcher == 1 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-3000f,400f));
                if(ArcherScript.turnArcher == 2 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(-400f,-3000f));
                if(ArcherScript.turnArcher == 3 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(3000f,-400f));
                if(ArcherScript.turnArcher == 4 && !playerSCR.isFacingRight)
                    other.rigidbody2D.AddForce(new Vector2(400f,3000f));
                attacked2 = false;
            }

            if(attacked2 || attacked3 || attacked)
                attacked4 = false;
            if(attacked4)
            {
                if (!critical)
                    ArcherScript.TakeDmg(dmg*2*1.7);
                if (critical)
                {
                    ArcherScript.critical = true;
                    ArcherScript.TakeDmg(dmg*1.7);
                    critical=false;
                }
                attacked4= false;
            }
            //Debug.Log("WOW!");
        }
    }
Пример #7
0
 // Use this for initialization
 void Start()
 {
     renderer.enabled = false;
     Gamp             = forestGamp.GetComponent <ArcherWar>();
 }
Пример #8
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Debug.Log("Trigger: Player Entered");

        if (other.gameObject.tag == "EnemyMelle")
        {
            EnSCR = other.GetComponent <EnemyScriptMelle> ();
            if (attacked2 || attacked3 || attacked4)
            {
                attacked = false;
            }
            if (attacked)
            {
                if (!critical)
                {
                    EnSCR.TakeDmg(dmg);
                }
                if (critical)
                {
                    EnSCR.critical = true;
                    EnSCR.TakeDmg(dmg * 2);
                    critical = false;
                }
                attacked = false;
            }
            if (attacked || attacked3 || attacked4)
            {
                attacked2 = false;
            }
            if (attacked2)
            {
                EnSCR.StunD(0.5f);
                if (EnSCR.turn == 1 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(3000f, 400f));
                }
                if (EnSCR.turn == 2 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-400f, 3000f));
                }
                if (EnSCR.turn == 3 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-3000f, -400f));
                }
                if (EnSCR.turn == 4 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(400f, -3000f));
                }

                if (EnSCR.turn == 1 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-3000f, 400f));
                }
                if (EnSCR.turn == 2 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-400f, -3000f));
                }
                if (EnSCR.turn == 3 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(3000f, -400f));
                }
                if (EnSCR.turn == 4 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(400f, 3000f));
                }
                attacked2 = false;
            }
            if (attacked2 || attacked3 || attacked)
            {
                attacked4 = false;
            }
            if (attacked4)
            {
                if (!critical)
                {
                    EnSCR.TakeDmg(dmg * 1.7);
                }
                if (critical)
                {
                    EnSCR.critical = true;
                    EnSCR.TakeDmg(dmg * 2 * 1.7);
                    critical = false;
                }
                attacked = false;
            }
            //Debug.Log("WOW!");
        }
        if (other.gameObject.tag == "EnemyArcher")
        {
            ArcherScript = other.GetComponent <ArcherWar> ();
            if (attacked2 || attacked3 || attacked4)
            {
                attacked = false;
            }
            if (attacked)
            {
                if (!critical)
                {
                    ArcherScript.TakeDmg(dmg);
                }
                if (critical)
                {
                    ArcherScript.critical = true;
                    ArcherScript.TakeDmg(dmg * 2);
                    critical = false;
                }
                attacked = false;
            }
            if (attacked || attacked3 || attacked4)
            {
                attacked2 = false;
            }
            if (attacked2)
            {
                ArcherScript.StunD(0.5f);
                if (ArcherScript.turnArcher == 1 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(3000f, 400f));
                }
                if (ArcherScript.turnArcher == 2 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-400f, 3000f));
                }
                if (ArcherScript.turnArcher == 3 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-3000f, -400f));
                }
                if (ArcherScript.turnArcher == 4 && playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(400f, -3000f));
                }

                if (ArcherScript.turnArcher == 1 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-3000f, 400f));
                }
                if (ArcherScript.turnArcher == 2 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(-400f, -3000f));
                }
                if (ArcherScript.turnArcher == 3 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(3000f, -400f));
                }
                if (ArcherScript.turnArcher == 4 && !playerSCR.isFacingRight)
                {
                    other.rigidbody2D.AddForce(new Vector2(400f, 3000f));
                }
                attacked2 = false;
            }

            if (attacked2 || attacked3 || attacked)
            {
                attacked4 = false;
            }
            if (attacked4)
            {
                if (!critical)
                {
                    ArcherScript.TakeDmg(dmg * 2 * 1.7);
                }
                if (critical)
                {
                    ArcherScript.critical = true;
                    ArcherScript.TakeDmg(dmg * 1.7);
                    critical = false;
                }
                attacked4 = false;
            }
            //Debug.Log("WOW!");
        }
    }