コード例 #1
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Enemy" && playerAttack.isAttacking)
     {
         EnemyAttribute temp = other.gameObject.GetComponent <EnemyAttribute>();
         temp.TakeDamage(damage + playerAttribute.atk);
         playerAttack.isAttacking = false;
     }
 }
コード例 #2
0
 public void OnCollisionEnter(Collision col)
 {
     if (col.gameObject.tag == "Enemy")
     {
         Debug.Log("forward");
         player          = GameManager.player;
         playerAttribute = player.GetComponent <PlayerAttribute>();
         es = SceneManager.GetSceneByName("UI").GetRootGameObjects()[0].transform.GetChild(11).GetComponent <EnemyStatus>();
         EnemyAttribute temp = col.gameObject.GetComponent <EnemyAttribute>();
         if (type == "Firebolt")
         {
             temp.TakeDamage(pa.GetLongRangeDamage(playerAttribute.atk, 0, temp.defence, Mathf.FloorToInt(Vector3.Distance(temp.transform.position, GameManager.player.transform.position))));
         }
         else
         {
             temp.TakeDamage(pa.GetLongRangeDamage(playerAttribute.atk, playerAttribute.Skill[0], temp.defence, Mathf.FloorToInt(Vector3.Distance(temp.transform.position, GameManager.player.transform.position))));
         }
         es.UpdateUI(temp);
     }
     //CollisionHandler.HandleCollision(gameObject, col);
 }
コード例 #3
0
 void Attack()
 {
     if (m_attribute != null)
     {
         if (PlayerManager.instance.GetPlayerAttributes() != null)
         {
             m_attribute.TakeDamage(PlayerManager.instance.GetPlayerAttributes());
         }
     }
     else
     {
         Logs.LogW("Enemy attribute is null");
     }
 }
コード例 #4
0
 void OnTriggerEnter(Collider other)
 {
     //if (other.tag == "Enemy" && playerAttack.isAttacking)
     if (other.tag == "Enemy")
     {
         EnemyAttribute temp = other.gameObject.GetComponent <EnemyAttribute>();
         temp.TakeDamage(playerAttribute.atk / 2);
         es.UpdateUI(temp);
         Destroy(gameObject);
         return;
     }
     if (other.tag != "Player")
     {
         ridigB.velocity   = Vector3.zero;
         ridigB.useGravity = false;
         //ridigB.isKinematic = true;
         isColl = true;
         Destroy(gameObject, 1f);
     }
 }
コード例 #5
0
ファイル: PlayerAttack.cs プロジェクト: TeamNull/FYP
 void AttackByCyclone(int level)
 {
     if (pa.ConsumeMP(50))
     {
         Collider[] hitColliders = Physics.OverlapSphere(new Vector3(transform.position.x, transform.position.y + 1.0f, transform.position.z), 3);
         int        i            = 0;
         while (i < hitColliders.Length)
         {
             if (hitColliders[i].gameObject.tag == "Enemy")
             {
                 EnemyAttribute ea = hitColliders[i].transform.gameObject.GetComponent <EnemyAttribute>();
                 ea.TakeDamage(GetShortRangeDamage(pa.atk, Mathf.FloorToInt(pa.atk * (level / 10)), ea.defence));
                 es.UpdateUI(ea);
             }
             i++;
         }
         timer = 0f;
         GameManager.AudioManager.GetComponent <BGMcontrol>().Playsound("SwordAttack");
         anim.SetTrigger("AttackBySkill0");
     }
 }
コード例 #6
0
ファイル: PlayerAttack.cs プロジェクト: TeamNull/FYP
    //below for warrior
    void Attack()
    {
        Vector3    forward = transform.TransformDirection(Vector3.forward);
        Vector3    origin  = transform.position + new Vector3(0.0f, 1.0f, 0.0f);;
        RaycastHit hit;

        if (Physics.Raycast(origin, forward, out hit, 2))
        {
            //Debug.DrawLine(Camera.main.transform.position, hit.transform.position, Color.red, 0.1f, true);
            //Debug.Log(hit.transform.name);
            if (hit.transform.gameObject.tag == "Enemy")
            {
                EnemyAttribute ea = hit.transform.gameObject.GetComponent <EnemyAttribute>();
                ea.TakeDamage(GetShortRangeDamage(pa.atk, 0, ea.defence));
                es.UpdateUI(ea);
            }
        }
        timer = 0f;
        GameManager.AudioManager.GetComponent <BGMcontrol>().Playsound("SwordAttack");
        anim.SetTrigger("Attack");
    }
コード例 #7
0
    void OnTriggerEnter(Collider other)
    {
        //Debug.Log(other.name+" "+other.tag);
        //if (other.tag == "Enemy" && playerAttack.isAttacking)
        if (other.tag == "Enemy")
        {
            EnemyAttribute temp        = other.gameObject.GetComponent <EnemyAttribute>();
            float          skillDamage = 0;
            switch (arrowType)
            {
            case "Normal":
                skillDamage = 0;
                break;

            case "Triple":
                skillDamage = (skillLevel / 10) / 3;
                break;

            case "Jump":
                skillDamage = skillLevel / 10;
                break;
            }
            temp.TakeDamage(player.GetComponent <PlayerAttack>().GetLongRangeDamage(playerAttribute.atk, Mathf.FloorToInt(playerAttribute.atk * skillDamage), temp.defence, Mathf.FloorToInt(Vector3.Distance(player.transform.position, temp.transform.position))));
            es.UpdateUI(temp);
            Destroy(gameObject);
            return;
        }

        if (other.tag == "Player")
        {
            return;
        }

        ridigB.velocity    = Vector3.zero;
        ridigB.useGravity  = false;
        ridigB.isKinematic = true;
        isColl             = true;
        Destroy(gameObject, 1f);
    }