예제 #1
0
 private void Start()
 {
     gameManager      = FindObjectOfType <GameManager>();
     capturer         = GetComponentInChildren <Capturer>();
     animator         = GetComponent <Animator>();
     tps              = FindObjectOfType <ThirdPersonCamera>();
     playerController = FindObjectOfType <PlayerControllerRB>();
     audioSource      = GetComponent <AudioSource>();
 }
예제 #2
0
 private void Start()
 {
     Ready     = true;
     BeingUsed = false;
     gm        = FindObjectOfType <GameManager>();
     animatorL = jetpackL.GetComponent <Animator>();
     animatorR = jetpackR.GetComponent <Animator>();
     audioSourceJetpackNoise = GetComponent <AudioSource>();
     playerController        = FindObjectOfType <PlayerControllerRB>();
 }
예제 #3
0
    private void OnTriggerEnter(Collider other)
    {
        PlayerControllerRB pc = other.GetComponent <PlayerControllerRB>();

        if (pc)
        {
            FindObjectOfType <GameManager>().Respawn();
        }
        else
        {
            Minion m = other.GetComponent <Minion>();
            if (m)
            {
                MinionsPool.Instance.Put(m);
            }
        }
    }
예제 #4
0
    public void Shoot()
    {
        RaycastHit hit;

        if (Physics.Raycast(shotPoint.transform.position, shotPoint.transform.forward, out hit, range)) //checks if we hit something
        {
            Debug.Log(hit.transform.name);
            Debug.DrawRay(shotPoint.transform.position, shotPoint.transform.forward, Color.green * 50000);
            PlayerControllerRB player = hit.transform.GetComponent <PlayerControllerRB>();
            if (player != null)
            {
                flash.Play();
                Instantiate(project, shot.position, Quaternion.identity);
                _gm.TakeDamage(damage);
                //bangAudio.Play();
            }
        }
    }
예제 #5
0
    private void Start()
    {
        tpc         = FindObjectOfType <ThirdPersonCamera>();
        pauseCanvas = FindObjectOfType <PauseCanvas>();

        if (pauseCanvas)
        {
            pauseCanvas.gameObject.SetActive(false);
        }

        /* if (pauseCanvas == null)
         * {
         *   PauseCanvas pauseCanvasPrefab = Resources.Load<PauseCanvas>("pauseCanvas");
         *   pauseCanvas = Instantiate(pauseCanvasPrefab);
         *   pauseCanvas.gameObject.name = "[PauseCanvas]";
         *   pauseCanvas.gameObject.SetActive(false);
         * }*/

        player = FindObjectOfType <PlayerControllerRB>();
    }
예제 #6
0
    void Start()
    {
        PlayerPrefs.DeleteAll();

        numOfMice   = 0;
        numOfCatnip = 0;
        totalMice   = 0;


        //Finds the player script
        GameObject laserObject = GameObject.FindWithTag("Laser");

        if (laserObject != null)
        {
            _laser = laserObject.GetComponent <Laser>();
        }
        if (laserObject == null)
        {
            Debug.Log("Cannot find 'Laser' script");
        }

        //Finds the laser script
        GameObject playerObject = GameObject.FindWithTag("Player");

        if (playerObject != null)
        {
            _playerController = playerObject.GetComponent <PlayerControllerRB>();
        }
        if (playerObject == null)
        {
            Debug.Log("Cannot find 'Player' script");
        }

        if (SceneManager.GetActiveScene() == SceneManager.GetSceneByName("Level 3"))
        {
            hbGameObject.SetActive(true);
            Debug.Log("Level 3  loaded");
        }
    }
예제 #7
0
    public void Explode(Vector3 explosionPos)
    {
        Collider[] colliders = Physics.OverlapSphere(explosionPos, explosionRadius);

        for (int i = 0; i < colliders.Length; i++)
        {
            if (colliders[i].gameObject.GetInstanceID() == playerTransform.gameObject.GetInstanceID())
            {
                PlayerControllerRB rb = colliders[i].GetComponent <PlayerControllerRB>();
                if (rb != null)
                {
                    Vector3 dir          = (playerTransform.position - explosionPos).normalized;
                    float   distance     = Vector3.Distance(playerTransform.position, explosionPos);
                    float   appliedForce = 0.2f * explosionForce * (1.0f - Mathf.Clamp01(distance / explosionRadius));

                    PlayerControllerExternalForce force = new PlayerControllerExternalForce
                    {
                        force = appliedForce * dir,
                        mode  = ForceMode.Impulse
                    };

                    // rb.AddExternalForce(force);
                }
            }
            else
            {
                Rigidbody rb = colliders[i].GetComponent <Rigidbody>();
                if (rb != null)
                {
                    rb.AddExplosionForce(explosionForce, explosionPos, explosionRadius, 3.0F);
                }
            }
        }

        gm.audioManager.PlayOneShot(gm.audioManager.poof, transform.position);
        ParticleSystemManager.Instance.Play(ps, _transform);
        MinionsPool.Instance.Put(this);
    }