示例#1
0
    private void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {
            Debug.Log("Bot Bullet touched enemy ");
            EnemyController ectrl = other.gameObject.GetComponent <EnemyController>();
            ectrl.Destroy();
        }
        else if (other.gameObject.CompareTag("Player"))
        {
            Debug.Log("Bot Bullet touched Player ");
            PlayerBotController pBCtrl = other.gameObject.GetComponent <PlayerBotController>();

            if (pBCtrl)
            {
                pBCtrl.Destroy(id);
            }
            else
            {
                PlayerController pc = other.gameObject.GetComponent <PlayerController>();
                if (pc)
                {
                    pc.Destroy(id);
                }
                else
                {
                    Debug.Log("Bullet Bot Controller : Invalid Player tag type was touched");
                }
            }
        }

        Destroy();
    }
示例#2
0
    private void OnCollisionEnter(Collision other)
    {
        if (other.gameObject.CompareTag("Enemy"))
        {
            Debug.Log("Bot Bullet touched enemy ");
            EnemyController ectrl = other.gameObject.GetComponent <EnemyController>();
            ectrl.Destroy();

            GameObject parentObject = GameObjectStateManager.Instance.getParent(id);
            if (parentObject)
            {
                Ship controler = parentObject.GetComponent <Ship>();
                if (controler && !controler.IsPlayer)
                {
                    controler.addRewardOnKill();
                }
            }
        }
        else if (other.gameObject.CompareTag("Player"))
        {
            Debug.Log("Bot Bullet touched Player ");
            PlayerBotController pBCtrl = other.gameObject.GetComponent <PlayerBotController>();

            if (pBCtrl)
            {
                pBCtrl.Destroy(id);
            }
            else
            {
                Ship pc = other.gameObject.GetComponent <Ship>();
                if (pc)
                {
                    pc.Destroy(id);
                }
                else
                {
                    Debug.Log("BulletController : Invalid Player tag type was touched");
                }
            }
        }

        Destroy();
    }