Example #1
0
    // Spawn coroutine for miss mode
    private IEnumerator MissSpawn()
    {
        AM.Play("electric1");
        while (drillWaves[levelPick].amountSpawned <= 5000)
        {
            int posPick = Random.Range(0, drillWaves[levelPick].spawnPoints.pointList.Count);
            GM.totalSpawned++;

            // Instantiates effect
            for (int i = 0; i < drillWaves[levelPick].spawnPoints.pointList.Count; i++)
            {
                // Checks if child count is 0 to only spawn the effect once
                if (drillWaves[levelPick].spawnPoints.pointList[i].transform.childCount == 0)
                {
                    Instantiate(flamePrefab, drillWaves[levelPick].spawnPoints.pointList[i].transform);
                }
            }

            // Instantiates picked enemy at picked position using the parents rotation
            Instantiate(drillWaves[levelPick].enemyPrefab, drillWaves[levelPick].spawnPoints.pointList[posPick].transform.position, drillWaves[levelPick].spawnPoints.pointList[posPick].transform.rotation);
            drillWaves[levelPick].amountSpawned++;

            // Breaks out of coroutine if the game is over or spawned enemies exceed 5000
            if (GM.gameIsOver || drillWaves[levelPick].amountSpawned == 5000)
            {
                GM.SetGameOver();
                yield break;
            }

            yield return(new WaitForSeconds(1.2f));
        }
        AM.Play("electric2");
        yield break;
    }
Example #2
0
    private void Start()
    {
        menus[0].SetActive(true);
        menus[1].SetActive(false);
        loadingPanel.SetActive(false);
        SetStartingWordLength();

        AM.Play("water");
    }
Example #3
0
 // Handle collision with Screen shake when hitting ground
 private void OnCollisionEnter2D(Collision2D other)
 {
     if (other.gameObject.CompareTag("Ground") && isLongFall)
     {
         StartCoroutine(screenShake.Shake(0.10f, 0.1f));
         Instantiate(medParticle, groundCheck.transform);
         AM.Play("ExplosionSmall");
         isLongFall = false;
     }
 }
    private void Start()
    {
        timeCounter = 0;
        movement    = 0;
        SetInitValues();

        Invoke("SelfDestruct", 20f);

        AM.Play("BeeHive");
    }
Example #5
0
    // Handles typing of every single letter
    public void TypeLetter(char letter)
    {
        if (hasActiveWord)
        {
            if (activeWord.GetNextLetter() == letter)
            {
                activeWord.TypeLetter();
                AM.Play("thud_bright");
            }
            else
            {
                GM.ShakeScreen();
                AM.Play("alarm");
                interfaceController.ShowMissText();
                GM.ReduceScore();

                // Increments typing errors on gameManager
                GM.typingErrors++;

                if (GM.gameMode == GameMode.Miss)
                {
                    GM.Invoke("SetGameOver", 0.5f);
                }
            }
        }
        else
        {
            foreach (Word word in words)
            {
                if (word.GetNextLetter() == letter)
                {
                    AM.Play("thud_bright");
                    activeWord    = word;
                    hasActiveWord = true;
                    word.TypeLetter();
                    break;
                }
            }
        }

        // Resets when you typed the last letter
        if (hasActiveWord && activeWord.WordTyped())
        {
            hasActiveWord = false;
            startChars.Remove(activeWord.word[0]);
            words.Remove(activeWord);

            AM.Play("generic_spell7");
            GM.IncrementScore();
        }
    }
    // Triggers from animation when player is hit
    public void HitPlayer()
    {
        GM.DamagePlayer();

        hasSwung = true;

        DestroyComponents();

        // Play sound effect on hitting player
        switch (enemyType)
        {
        case EnemyType.WOLF:
            if (GetRand(2) == 0)
            {
                AM.Play("warg_attack1");
            }
            else
            {
                AM.Play("warg_attack2");
            }
            break;

        case EnemyType.SKELETON:
            AM.Play("ice8");
            break;

        default:
            break;
        }
    }
Example #7
0
    private void Start()
    {
        pointsPerKill       = 100;
        minusPointsPerMiss  = 50;
        gameIsPaused        = false;
        gameIsOver          = false;
        totalSpawned        = 0;
        totalDefeated       = 0;
        typingErrors        = 0;
        currentScore        = 0;
        hasActiveProjectile = false;

        AM.Play("fear3");
        AM.Play("ambience_wind");
    }
    // Triggers on Destroy, either by hitting player or being defeated
    private void OnDestroy()
    {
        AM.Play("earthquake1");

        GM.hasActiveProjectile = false;

        preSpawnHandler.TrySetOnRails();
    }
Example #9
0
 void Update()
 {
     if (Input.GetMouseButtonDown(0) && Time.time > nextSwing)
     {
         audioManager.Play("PlayerAttack");
         nextSwing = Time.time + swingRate;
         Swing();
     }
 }
 private void OnCollisionEnter2D(Collision2D other)
 {
     // Activate particles and screen shake when colliding with the ground
     if (other.gameObject.CompareTag("Ground"))
     {
         StartCoroutine(screenShake.Shake(0.15f, 0.4f));
         AM.Play("ExplosionBig");
         gameObject.GetComponent <BoxCollider2D>().enabled = false;
         Instantiate(hvyParticle, transform);
         Invoke("DestroyBlock", blockDestructionDelay);
     }
     // Kill player on collision
     else if (other.gameObject.CompareTag("Player"))
     {
         PlayerMovement playerScript = other.gameObject.GetComponent <PlayerMovement>();
         AM.Play("LoseTwo");
         playerScript.Die();
     }
 }
Example #11
0
    // Checks grounded state of fruit
    private void CheckGroundedState()
    {
        // counts up when fruit is grounded
        if (isGrounded)
        {
            groundedTimer += Time.deltaTime;
        }

        // Calls GM to end the game if fruit was on the ground for X seconds
        if (groundedTimer >= maxGroundedTime)
        {
            AM.Play("LoseTwo");
            GM.GameOver();
        }
    }
Example #12
0
    // Apply damage to this entity. A knockback force can be given to apply knockback to this entity.
    // This will do no damage if the entity is invincible, and will apply invincible frames
    // for all entities.
    // If health is 0, the OnKill method is called and can be handled based on the entity.
    public void Damage(float amount, Vector2 knockback)
    {
        if (invincible)
        {
            return;
        }

        if (health == 0)
        {
            return;
        }

        audioManager.Play("Damage");

        amount /= defense;
        health  = Mathf.Max(health - amount, 0);

        if (knockback != Vector2.zero)
        {
            ApplyKnockback(knockback);
        }

        if (!(this is Player))
        {
            GameObject points = Instantiate(damagePopup, transform.position, Quaternion.identity);
            points.transform.GetComponent <TextMesh>().text = Mathf.Max(Mathf.RoundToInt(amount), 1).ToString();
        }

        if (health == 0)
        {
            OnKill();
            return;
        }

        invincible = true;

        if (invincibleRoutine != null)
        {
            StopCoroutine(invincibleRoutine);
        }

        invincibleRoutine = StartCoroutine(InvincibleWait());
    }
Example #13
0
    private void OnTriggerEnter2D(Collider2D other)
    {
        //Checks if the tag of the bush and fruit are a match
        if
        (
            gameObject.CompareTag("CherryBush") && other.gameObject.CompareTag("Cherry") ||
            gameObject.CompareTag("AvocadoBush") && other.gameObject.CompareTag("Avocado") ||
            gameObject.CompareTag("EggplantBush") && other.gameObject.CompareTag("Eggplant")
        )
        {
            // Gets wether or not the triggering item was thrown by the player
            bool itemWasHeld = other.gameObject.GetComponent <ItemParameters>().GetHeldStatus();

            // Gets velocity of item to determine weather or not it is falling
            float itemVelocity = other.gameObject.GetComponent <Rigidbody2D>().velocity.y;

            // Checks if the item is a fruit
            if (itemWasHeld && itemVelocity < 0)
            {
                AcceptItem(other.gameObject);
                AM.Play("Collect");
            }
        }
    }
 // Starts spawning coroutine
 public void StartSpawn()
 {
     StartCoroutine("Spawn", waves[0]);
     AM.Play("electric1");
 }