void Shoot()
    {
        timer = 0f;

        gunAudio.Play();
        gunLight.enabled = true;

        gunParticles.Stop();
        gunParticles.Play();

        gunLine.enabled = true;
        gunLine.SetPosition(0, transform.position);

        shootRay.origin    = transform.position;
        shootRay.direction = transform.forward;

        if (Physics.Raycast(shootRay, out shootHit, range, shootableMask))
        {
            GhostHealth ghostHP = shootHit.collider.GetComponent <GhostHealth> ();

            if (ghostHP != null)
            {
                ghostHP.TakeDamage(damage, shootHit.point);
            }

            gunLine.SetPosition(1, shootHit.point);
        }
        else
        {
            gunLine.SetPosition(1, shootRay.origin + shootRay.direction * range);
        }
    }
Esempio n. 2
0
    private void Awake()
    {
        rigidbody = GetComponent <Rigidbody2D>();
        animator  = GetComponent <Animator>();
        renderer  = GetComponent <SpriteRenderer>();

        environment = GameObject.FindObjectOfType <Environment>();
        player      = GameObject.FindObjectOfType <PlayerMovement>();
        health      = GetComponent <GhostHealth>();

        eyes        = transform.GetChild(0);
        eyePosition = eyes.localPosition;

        regularPattern    = regularMovement.GetMovementPattern();
        vulnerablePattern = vulnerableMovement.GetMovementPattern();
    }
Esempio n. 3
0
    // Update is called once per frame
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            bulletAnt--;

            if (bulletAnt <= 0)
            {
                GameManager.OnGhostMiss();
            }

            Vector3 mousePos = Input.mousePosition;
            mousePos.z = Camera.main.transform.position.z;

            if (Physics.Raycast(Camera.main.ScreenToWorldPoint(mousePos), Camera.main.transform.forward, out hit, Mathf.Infinity))
            {
                if (hit.transform.tag == "Ghost")
                {
                    health = hit.transform.GetComponent <GhostHealth>();
                    health.KillGhost();
                }
            }
        }
    }
Esempio n. 4
0
 private void Awake()
 {
     m_health      = GetComponent <GhostHealth>();
     m_rigidbody   = GetComponent <Rigidbody2D>();
     m_audioSource = OurUtility.GetOrAddComponent <AudioSource>(gameObject);
 }
    // FIXME: I shouldn't run update, there should be a band progression event
    private void Update()
    {
        var level     = bandProgression.BandLevel;
        var levelText = "";

        if (level != 0)
        {
            levelText = string.Format("Band Level: {0}\n ({1}x Bonus Damage)", level, GhostHealth.DamageMultiplierForBandLevel(level));
        }
        bandLevelText.text = levelText;
    }