// Use this for initialization
 void Start()
 {
     self         = GetComponent <MoveTowardsPlayer>();
     self.enabled = false;
     player       = FindObjectOfType <BasePlayerStats>();
     animator     = GetComponent <Animator>();
 }
Example #2
0
 void TurnOnSlow()
 {
     if (slowOn)
     {
         GameObject[] activeEnemies;
         activeEnemies = GameObject.FindGameObjectsWithTag("Enemy");
         foreach (GameObject activeEnemy in activeEnemies)
         {
             if (activeEnemy)
             {
                 MoveTowardsPlayer mtp = activeEnemy.GetComponent <MoveTowardsPlayer> ();
                 if (mtp)
                 {
                     //mtp.attackWait *= 2.5f;
                     mtp.attackForceHigh *= 0.5f;
                     mtp.attackForceLow  *= 0.5f;
                 }
             }
         }
     }
     else
     {
         CancelInvoke();
     }
 }
Example #3
0
 private void Awake()
 {
     fieldOfView                   = Instantiate(fieldOfViewPrefab);
     fieldOfView.zombie            = gameObject;
     fieldOfView.OnRaycastHit     += ZombieRaycastHit;
     fieldOfView.OnPlayerNotFound += PlayerNotFound;
     moveTowardsPlayer             = GetComponent <MoveTowardsPlayer>();
     fieldOfView.viewDistance      = 20f;
 }
 private void Awake()
 {
     fieldOfView                   = Instantiate(fieldOfViewPrefab);
     fieldOfView.zombie            = gameObject;
     fieldOfView.OnRaycastHit     += SoldierRaycastHit;
     fieldOfView.OnPlayerNotFound += PlayerNotFound;
     fieldOfView.viewDistance      = 30f;
     soldierStateManager           = GetComponent <EnemySoldierStateManager>();
     moveTowardsPlayer             = GetComponent <MoveTowardsPlayer>();
 }
Example #5
0
    private Transform m_playerTransform;        // Player Transform

    // Use this for initialization
    void Start()
    {
        timer            = 0;
        m_projectilePool = new ObjectPool(projectile, 10, limitedFire);

        m_movementComp = GetComponent <MoveTowardsPlayer>();
        m_animator     = GetComponent <Animator>();

        m_playerTransform = GameObject.FindGameObjectWithTag("Player").transform;
    }
 public void Awake()
 {
     if (soldierState == EnemySoldierState.Pacing)
     {
         GetComponent <PaceInCircle>().enabled = true;
     }
     hitManager.OnHitWithBullet += EnemySoldierHitWithBullet;
     healthManager     = GetComponent <ZombieHealthManager>();
     moveTowardsPlayer = GetComponent <MoveTowardsPlayer>();
     rigidBody         = transform.GetComponent <Rigidbody2D>();
 }
Example #7
0
 public void StartGame()
 {
     hasGameStarted = true;
     titleScreen.gameObject.SetActive(false);
     scoreText.gameObject.SetActive(true);
     playerControllerScript = GameObject.Find("Player").GetComponentInChildren <PlayerController>();
     moveTowards            = GameObject.Find("Ground").GetComponent <MoveTowardsPlayer>();
     StartCoroutine(SpawnObjects());
     StartCoroutine(SpawnPowerup());
     StartCoroutine(KeepScore());
 }
 public void Awake()
 {
     if (zombieState == ZombieState.Pacing)
     {
         GetComponent <PaceInCircle>().enabled = true;
     }
     hitManager.OnHitWithBullet += ZombieHitWithBullet;
     healthManager     = GetComponent <ZombieHealthManager>();
     moveTowardsPlayer = GetComponent <MoveTowardsPlayer>();
     rigidBody         = transform.GetComponent <Rigidbody2D>();
     audioManager      = FindObjectOfType <AudioManager>();
 }
 public void LevelUp(float oldLevel)
 {
     enemyLevel           = ++oldLevel;
     lerpFromRedToWhite   = true;
     health              += 100f;
     transform.localScale = new Vector3(enemyLevel * 0.35f, enemyLevel * 0.35f, 1f);
     mtp                  = GetComponent <MoveTowardsPlayer> ();
     mtp.attackWait      += 0.25f;
     mtp.attackForceHigh -= 75f;
     mtp.attackForceLow  -= 25f;
     GetComponent <AudioSource> ().PlayOneShot(warning, 0.4f);
 }
Example #10
0
    void Start()
    {
        rand  = new System.Random();
        timer = Random.Range(0, 1);

        playerScript      = player.GetComponent <Player>();
        blackScreen       = GameObject.Find("BlackScreen");
        twitterScript     = GameObject.Find("UI/TwitterScriptObject").GetComponent <TwitterScript>();
        moveTowardsPlayer = GetComponent <MoveTowardsPlayer>();
        originalRotation  = transform.eulerAngles.z;

        audioSource  = transform.Find("CameraSound").GetComponent <AudioSource>();
        cameraSounds = Resources.LoadAll <AudioClip>("Sounds");
    }
Example #11
0
    private void OnEnable()
    {
        if (rigidBody2D == null)
        {
            rigidBody2D = GetComponent <Rigidbody2D>();
        }
        if (coll2D == null)
        {
            coll2D = GetComponent <Collider2D>();
        }
        if (moveTowardsScript == null)
        {
            moveTowardsScript = GetComponent <MoveTowardsPlayer>();
        }

        coll2D.enabled            = true;
        moveTowardsScript.enabled = true;

        Animator.Play(IdleAnimation.name);
    }
Example #12
0
 void Start()
 {
     rigidBody2D       = GetComponent <Rigidbody2D>();
     coll2D            = GetComponent <Collider2D>();
     moveTowardsScript = GetComponent <MoveTowardsPlayer>();
 }
Example #13
0
    IEnumerator PickUp(Collider2D player)
    {
        activated = true;
        Destroy(Instantiate(powerupVFX [selection], Vector3.zero, Quaternion.identity), 4f);
        GetComponent <AudioSource> ().PlayOneShot(powerup);
        GetComponent <AudioSource> ().PlayOneShot(pickup);

        gameObject.GetComponent <SpriteRenderer> ().enabled   = false;
        gameObject.GetComponent <CircleCollider2D> ().enabled = false;

        lerpFromRedToPurple = true;
        if (selection == 0 || selection == 1 || selection == 2)
        {
            //fast bpms
            //stop music if player dies w powerup in gc

            /*gc.beat.Stop ();
            *  gc.beat.clip = fastBeat;
            *  gc.beat.volume += 0.2f;
            *  gc.beat.Play ();*/
            gc.ekg.clip   = fastEKG;
            gc.ekg.pitch += 0.2f;
            gc.ekg.Play();

            //increase score multiplier
            gc.powerupScoreMultiplier *= 2.5f;
        }
        if (selection == 0)
        {
            /*use if setting base shot round 2.1875f
             * pillayer.GetComponent<LookAtMouse> ().shot.transform.localScale = new Vector3
             *      (pillayer.GetComponent<LookAtMouse> ().shot.transform.localScale.x * 0.6f,
             *              pillayer.GetComponent<LookAtMouse> ().shot.transform.localScale.y * 2f,
             *      0f);*/
            pillayer = GameObject.FindGameObjectWithTag("Player");
            pillayer.GetComponent <LookAtMouse> ().shot.transform.localScale = new Vector3(2.18f, 2.18f, 0f);
            AudioSource audioSource = pillayer.GetComponent <AudioSource> ();
            audioSource.pitch   = 0.65f;
            audioSource.volume *= 1.7f;
            lam.is2x            = true;
            gc.healthHit       *= 2;
            es.spawnWaitMin    -= 1.5f;
            es.spawnWaitMax    -= 1.5f;
            StartCoroutine(TimerText(selection));
            powerupName.GetComponent <Text>().text = "Shots 2x powerful";
            yield return(new WaitForSeconds(effectTimer[selection]));

            pillayer.GetComponent <LookAtMouse> ().shot.transform.localScale = new Vector3(1f, 3f, 0f);
            lam.is2x            = false;
            es.spawnWaitMin    += 1.5f;
            es.spawnWaitMax    += 1.5f;
            gc.healthHit       /= 2;
            audioSource.pitch   = 1f;
            audioSource.volume /= 1.7f;
        }
        else if (selection == 1)
        {
            lam.shotWaitTime *= 0.3f;
            lam.GetComponent <AudioSource> ().pitch = 1.15f;
            lam.holdToShoot  = true;
            es.spawnWaitMin -= 1f;
            es.spawnWaitMax -= 2.5f;
            powerupName.GetComponent <Text>().text = "Hold Mouse to Shoot";
            StartCoroutine(TimerText(selection));
            yield return(new WaitForSeconds(effectTimer[selection]));

            es.spawnWaitMin += 1f;
            es.spawnWaitMax += 2.5f;
            if (lam)
            {
                lam.holdToShoot   = false;
                lam.shotWaitTime /= 0.3f;
                lam.GetComponent <AudioSource> ().pitch = 1f;
            }
        }
        else if (selection == 2)
        {
            InvokeRepeating("TurnOnSlow", 0f, 1f);
            slowOn = true;

            powerupName.GetComponent <Text>().text = "Slow Enemies";
            StartCoroutine(TimerText(selection));
            es.spawnWaitMin -= 0.75f;
            es.spawnWaitMax -= 0.75f;
            yield return(new WaitForSeconds(effectTimer[selection]));

            slowOn           = false;
            es.spawnWaitMin += 0.75f;
            es.spawnWaitMax += 0.75f;
            GameObject[] activeEnemies = GameObject.FindGameObjectsWithTag("Enemy");
            foreach (GameObject activeEnemy in activeEnemies)
            {
                if (activeEnemy)
                {
                    MoveTowardsPlayer mtp = activeEnemy.GetComponent <MoveTowardsPlayer> ();
                    if (mtp)
                    {
                        //mtp.attackWait /= 2.5f;
                        mtp.attackForceHigh /= 0.5f;
                        mtp.attackForceLow  /= 0.5f;
                    }
                }
            }
        }
        else if (selection == 3)
        {
            shieldRing.SetActive(true);
            shieldRing.transform.parent.GetComponent <PolygonCollider2D> ().enabled = false;
            GameObject.Find("PowerupCanvas").transform.GetChild(2).gameObject.SetActive(true);
            //show white shield logo on bottom left
            //Set it such that the powerupLastActiveTime is also set properly
            //add fake wait time if needed
            //make arrangements in shield.cs & destroyoncontact.cs
        }
        if (selection == 0 || selection == 1 || selection == 2)
        {
            //revert bpms

            /*gc.beat.Stop ();
            *  gc.beat.clip = slowBeat;
            *  gc.beat.volume -= 0.2f;
            *  gc.beat.Play ();*/
            gc.ekg.clip   = slowEKG;
            gc.ekg.pitch -= 0.1f;
            gc.ekg.Play();

            //revert score multiplier
            gc.powerupScoreMultiplier /= 2.5f;
        }
        powerupName.GetComponent <Text>().text = "";
        lerpFromRedToPurple = false;
        lerpFromPurpleToRed = true;

        gc.powerupLastActive = Time.time;
        Destroy(gameObject, 3f);
    }
 void Awake()
 {
     towardsPlayer = this.GetComponent<MoveTowardsPlayer>();
     awayFromPlayer = this.GetComponent<MoveAwayFromPlayer>();
     StartCoroutine(TowardsPlayer());
 }
 void Awake()
 {
     towardsPlayer  = this.GetComponent <MoveTowardsPlayer>();
     awayFromPlayer = this.GetComponent <MoveAwayFromPlayer>();
     StartCoroutine(TowardsPlayer());
 }