Exemple #1
0
    public void OnTriggerEnter(Collider other)
    {
        if (isHit)
        {
            return;
        }


        string     info = "";
        GameObject obj  = other.gameObject;

        switch (obj.tag)
        {
        case nameof(Tag.Player):
            isHit = true;
            info  = "船只撞击->" + other.gameObject.name;
            CharacterInfo cInfo = obj.GetComponent <CharacterInfo>();
            cInfo.BeShoot(cardInfo.Atk);
            break;

        case nameof(Tag.Support):
            isHit = true;
            info  = "船只撞击->" + other.gameObject.name;
            SupportInfo sInfo = obj.GetComponent <SupportInfo>();
            sInfo.BeShoot(cardInfo.Atk);
            break;
        }
        if (info != "")
        {
            Debug.LogError(info);
        }
        if (isHit)
        {
            PoolDestroy();
        }
    }
Exemple #2
0
    public void TrrigerLogic(Collider coll)
    {
        if (isHit)
        {
            return;
        }

        string     info = "";
        GameObject obj  = coll.gameObject;

        switch (obj.tag)
        {
        case nameof(Tag.Enemy):
            if (myTag != Tag.Player)
            {
                return;
            }
            else
            {
                targetTag = Tag.Enemy;
                isHit     = true;
                //info += obj.tag + "/" + obj.name;
                CharacterInfo cInfo = obj.GetComponent <CharacterInfo>();
                cInfo.BeShoot(Atk);
            }
            break;

        case nameof(Tag.Player):
            if (myTag != Tag.Player)
            {
                targetTag = Tag.Player;
                isHit     = true;
                //info += obj.tag + "/" + obj.name;
                CharacterInfo cInfo = obj.GetComponent <CharacterInfo>();
                cInfo.BeShoot(Atk);
            }
            else
            {
                return;
            }
            break;

        case nameof(Tag.Support):
            if (myTag != Tag.Player)
            {
                targetTag = Tag.Player;
                isHit     = true;
                //info += obj.tag + "/" + obj.name;
                SupportInfo sInfo = obj.GetComponent <SupportInfo>();
                sInfo.BeShoot(Atk);
            }
            else
            {
                return;
            }
            //info += myTag + "子弹射中Support";
            break;

        case nameof(Tag.Bullet):
            //info += " 子弹都能射中?";
            break;

        case nameof(Tag.Boat):
            if (myTag != Tag.Player)
            {
                return;
            }
            else
            {
                targetTag = Tag.Boat;
                isHit     = true;
                BoatInfo bInfo = obj.GetComponent <BoatInfo>();
                bInfo.BeShoot(Atk);
            }
            break;

        default:
            info += "未判断的Tag->" + obj.tag + "/" + obj.name;
            break;
        }
        if (info != "")
        {
            Debug.LogError(info);
        }
        if (isHit)
        {
            PoolDestroy();
        }
    }