예제 #1
0
    private void OnTriggerStay2D(Collider2D collision)
    {
        AttackRange attckRange = collision.gameObject.GetComponent <AttackRange>();

        if (attckRange != null && candamage == true)
        {
            UnitStatus ustatus = collision.gameObject.GetComponent <UnitStatus>();
            if (ustatus.unitCheck != unitStatus.unitCheck)
            {
                candamage = false;
                ustatus.AddDamage(unitStatus.unitPower);
                StartCoroutine("Span");
            }
        }

        UnitStatus status = GetComponent <UnitStatus>();

        if (status != null)
        {
            if (collision.gameObject.tag == "Base" && candamage == true && status.unitCheck == false)
            {
                candamage = false;
                BaseStatus baseStatus = collision.gameObject.GetComponent <BaseStatus>();
                if (baseStatus != null)
                {
                    baseStatus.damage(unitStatus.unitPower);
                    StartCoroutine("Span");
                }
            }

            /*
             * else if (collision.gameObject.name == "EnemyBase" && candamage == true && status.unitCheck == true)
             * {
             *  candamage = false;
             *  BaseStatus baseStatus = collision.gameObject.GetComponent<BaseStatus>();
             *  baseStatus.damage(unitStatus.unitPower);
             *  StartCoroutine("Span");
             * }
             */
        }
    }