Example #1
0
 private void SetPoints()
 {
     animator.SetTrigger(runningSanta);
     points += (level * 100);
     SumScore.Add(level * 100);
     level += 1;
 }
Example #2
0
    void fire()
    {
        bool quota = false;

        enemyArray = GameObject.FindGameObjectsWithTag("enemy");
        EnemyAStar enStar;

        foreach (GameObject enemy in enemyArray)
        {
            enStar = (EnemyAStar)enemy.GetComponent(typeof(EnemyAStar));
            Vector2 enPos = enStar.fetchGridPosition();
            if (!quota)
            {
                foreach (Vector2 fireGrid in killZone)
                {
                    if (fireGrid == enPos)
                    {
                        quota = true;
                        //temporarily we will just reset the hasTarget bool when fire occurs, but later we need to do checks agains enemy health
                        EnemyHealth targetHP  = (EnemyHealth)enemy.GetComponent(typeof(EnemyHealth));
                        float       currentHP = targetHP.blast(10);
                        if (currentHP <= 0)
                        {
                            hasTarget = false;
                            Destroy(enemy);
                            GameObject  temp = GameObject.FindGameObjectsWithTag("GameMgr")[0];
                            GameManager gm   = (GameManager)temp.GetComponent(typeof(GameManager));
                            gm.credits += 25;
                            SumScore.Add(5);
                        }
                    }
                }
            }
        }
    }
Example #3
0
    void OnTriggerEnter2D(Collider2D col)
    {
        if (col.tag == "Boss" || col.tag == "Crit")
        {
            Target enemy = col.GetComponent <Target>();
            if (enemy != null)
            {
                cam.GetComponent <CameraShake>().shakecamera();
                enemy.TakeDamage(damage);
                SumScore.Add(5);
            }
        }

        if (col.tag == "Enemy")
        {
            TargetEnemy enemy = col.GetComponent <TargetEnemy>();
            if (enemy != null)
            {
                cam.GetComponent <CameraShake>().shakecamera();
                enemy.TakeDamage(damage);
                SumScore.Add(5);
            }
        }

        if (col.tag == "EnemyBullet")
        {
            SumScore.Add(1);
        }

        Destroy(gameObject);
    }
Example #4
0
    public void Black()
    {
        GetComponent <Renderer>().material.color = Color.black;

        SumScore.Add(1);
        SumScore.HighScore += 1;
    }
    void Update()
    {
        enemyArray = GameObject.FindGameObjectsWithTag("enemy");
        //find a target
        EnemyAStar enStar;

        foreach (GameObject enemy in enemyArray) //check everybody in array
        {
            enStar = (EnemyAStar)enemy.GetComponent(typeof(EnemyAStar));
            Vector2 enPos = enStar.fetchGridPosition();
            if (enPos == triggerZone)
            {
                foreach (Vector2 fireGrid in killZone)
                { //are they within range
                    if (fireGrid == enPos)
                    {
                        Destroy(enemy);
                        blewup = true;
                        SumScore.Add(5);
                    }
                }
            }
        }

        if (blewup == true)
        {
            //this.GetComponent<Renderer>().material.color = Color.white;
            this.GetComponent <TurnToWall> ().removeTile();
            //Destroy(this);
        }
    }
Example #6
0
    // Start is called before the first frame update
    private void OnTriggerEnter(Collider other)
    {
        Destroy(this.gameObject);

        SumScore.Add(10);

        SumScore.SaveHighScore();
    }
Example #7
0
 // Update is called once per frame
 private void Update()
 {
     if (playerTransf.position.x > (spawnerEmX - qtdeTilesNaTela * tileInicialLen))
     {
         GeradorTiles();
         LimpadorDeTiles();
     }
     SumScore.Add(Mathf.RoundToInt(Time.deltaTime * 10));
 }
Example #8
0
 void Update()
 {
     if (timed)
     {
         // Use Time.deltaTime to create a steady addition of points.
         // This example would add 100 points per second
         SumScore.Add(Mathf.RoundToInt(Time.deltaTime * 100));
     }
 }
Example #9
0
 public void TakeDamage(float amount)
 {
     health -= amount;
     if (health <= 0f)
     {
         SumScore.Add(pointsToAdd: 1);
         Die();
     }
 }
Example #10
0
    public void TakeDamage(int amount)
    {
        health -= amount;
        SumScore.Add(amount);

        if (health <= 0)
        {
            Die();
        }
    }
Example #11
0
    private void ClearMatch(Vector2[] paths)                       // 1
    {
        List <GameObject> matchingTiles = new List <GameObject>(); // 2

        for (int i = 0; i < paths.Length; i++)                     // 3
        {
            matchingTiles.AddRange(FindMatch(paths[i]));
        }
        if (matchingTiles.Count >= 3)                     // 4
        {
            for (int i = 0; i < matchingTiles.Count; i++) // 5
            {
                matchingTiles[i].GetComponent <SpriteRenderer>().sprite = null;
                if (matchingTiles.Count == 3)
                {
                    SumScore.Add(matchingTiles.Count);
                    SFXManager.instance.PlaySFX(Clip.Clear4);
                    Instantiate(whiteParticles, transform.position, Quaternion.identity);
                }
                if (matchingTiles.Count == 4)
                {
                    SumScore.Add(matchingTiles.Count);
                    SFXManager.instance.PlaySFX(Clip.Clear5);
                    Instantiate(whiteParticles, transform.position, Quaternion.identity);
                }
                if (matchingTiles.Count == 5)
                {
                    SumScore.Add(matchingTiles.Count);
                    BoardManager.instance.GetComponent <AudioSource>().volume = 0;
                    SFXManager.instance.PlaySFX(Clip.Clear6);

                    StartCoroutine(ShadowWaveNas());
                    Instantiate(whiteParticles, transform.position, Quaternion.identity);
                    StartCoroutine(HasNasSampleStoppedPlaying());
                }
                if (matchingTiles.Count >= 6)
                {
                    SumScore.Add(matchingTiles.Count);
                    BoardManager.instance.GetComponent <AudioSource>().volume = 0;

                    int index = Random.Range(0, samples.Length);
                    sampleClip       = samples[index];
                    audioSource.clip = sampleClip;
                    audioSource.Play();

                    StartCoroutine(TriggerWave(matchingTiles.Count));
                    StartCoroutine(ShadowWave());
                    StartCoroutine(FlipWaveY());
                    StartCoroutine(HasSoulSampleStoppedPlaying());
                }
            }
            matchFound = true;             // 6
        }
    }
Example #12
0
    void Update()
    {
        if (timed)
        {
            // Use Time.deltaTime to create a steady addition of points.
            // This example would add 100 points per second
            SumScore.Add(Mathf.RoundToInt(Time.deltaTime * 1));
        }


        //if (Input.GetKeyDown(KeyCode.P))
        //    AddPoints(1);
    }
Example #13
0
 void OnTriggerEnter(Collider other)
 {
     if (other.name == "disparo(Clone)")
     {
         currentHealth -= 100;
         //Debug.Log("Vida enemigo" + currentHealth);
         if (currentHealth <= 0)
         {
             explosion.Play();
             tie.SetActive(false);
             ShipsManager.contShips--;
             SumScore.Add(100);
             Invoke("Death", 1);
         }
     }
 }
    void Start()
    {
        sR = GetComponent <SpriteRenderer> ();

        //If got out
        if (tempRemLife != remLife)
        {
            SoundManager.PlaySound(fx_OhNo);
            policeMen_Animator.SetBool("Out", true);
            Invoke("OutMethod", 1f);
            tempRemLife = remLife;


            if (remLife == 3)
            {
                sR.sprite = sprite_remLife [0];
            }
            if (remLife == 2)
            {
                sR.sprite = sprite_remLife [0];
            }
            if (remLife == 1)
            {
                sR.sprite = sprite_remLife [1];
            }
        }
        else
        {
            SumScore.Add(1);
            SumScore.SaveHighScore();
            SoundManager.PlaySound(fx_Yeayi);
            OutMethod();
        }



        //policeman Gameover animation and randomScene Start
        if (remLife > 0)
        {
            Invoke("RandomScene", 1.3f);
        }
        else
        {
            policeMen_Animator.SetBool("GameOver", true);
        }
    }
Example #15
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "gundam" || other.tag == "Boss")
        {
            currentHealth = 0;
            healthBar.SetHealth(currentHealth);
        }

        if (other.tag == "health")
        {
            currentHealth += pickHealthValue;
            healthBar.SetHealth(currentHealth);
        }

        if (other.tag == "star")
        {
            SumScore.Add(1);
        }

        if (other.tag == "pickup" && girlCalled == false && robotCalled == false && alienCalled == false)
        {
            girl.GetComponent <SmoothFollow>().enabled   = true;
            girl.GetComponent <NPC>().enabled            = true;
            girl.GetComponent <SmoothFallback>().enabled = false;
            girlCalled = true;
        }

        if (other.tag == "pickup2" && girlCalled == true && robotCalled == false && alienCalled == false)
        {
            robot.GetComponent <SmoothFollow>().enabled   = true;
            robot.GetComponent <NPC>().enabled            = true;
            robot.GetComponent <SmoothFallback>().enabled = false;
            robotCalled = true;
            girlCalled  = true;
        }

        if (other.tag == "pickup3" && girlCalled == true && robotCalled == true && alienCalled == false)
        {
            alien.GetComponent <SmoothFollow>().enabled   = true;
            alien.GetComponent <NPC>().enabled            = true;
            alien.GetComponent <SmoothFallback>().enabled = false;
            alienCalled = true;
            robotCalled = true;
            girlCalled  = true;
        }
    }
    // Use this for initialization
    void Start()
    {
        LeanTween.alpha(fadeSprite, 0, 0.2f);
        playAgainText.GetComponent <Renderer>().sortingLayerName = "TopMenuTextContent";
        SumScore.Add(SceneManagerScript.Points);

        tapGesture = new TapGestureRecognizer();
        tapGesture.AllowSimultaneousExecutionWithAllGestures();
        tapGesture.StateUpdated += TapGesture_StateUpdated;
        FingersScript.Instance.AddGesture(tapGesture);
        if (SceneManagerScript.GameOver)
        {
            GameOver();
        }
        else
        {
            StartingView();
        }
    }
Example #17
0
 public IEnumerator TriggerWave(int clearedCount)
 {
     for (int x = 0; x < BoardManager.instance.xSize; x++)
     {
         for (int y = 0; y < BoardManager.instance.ySize; y++)
         {
             if (BoardManager.instance.tiles[x, y].GetComponent <SpriteRenderer>().sprite == render.sprite)
             {
                 BoardManager.instance.tiles[x, y].GetComponent <SpriteRenderer>().sprite = null;
                 Instantiate(whiteParticles, BoardManager.instance.tiles[x, y].transform.position, Quaternion.identity);
                 StartCoroutine(BoardManager.instance.FindNullTiles());
                 SFXManager.instance.PlaySFX(Clip.Scratch);
                 SumScore.Add(clearedCount);
                 yield return(StartCoroutine(HalfSecondDelay()));
             }
         }
     }
     StopCoroutine(BoardManager.instance.FindNullTiles());
     StartCoroutine(BoardManager.instance.FindNullTiles());
 }
Example #18
0
    // Update is called once per frame
    void Update()
    {
        if (Time.time < startAnimacao)
        {
            controller.Move(Vector3.right * 0 * Time.deltaTime);
            return;
        }

        vetorMovimento = Vector3.zero;

        bool chao = controller.isGrounded;

        Debug.Log(chao);
        if (controller.isGrounded)
        {
            onTheGround = true;
            if (Input.GetButton("Jump") && onTheGround)
            {
                onTheGround        = false;
                velocidadeVertical = velocidadePulo;
                transform.Translate(Vector3.up * velocidadePulo * Time.deltaTime);
            }
            //velocidadeVertical = 0.0f;
        }
        else
        {
            onTheGround         = false;
            velocidadeVertical -= gravidade * Time.deltaTime;
        }


        //Mover direita ou esquerda
        vetorMovimento.z = Input.GetAxisRaw("Horizontal") * (-velocidadeDirecionada);
        vetorMovimento.y = velocidadeVertical;
        vetorMovimento.x = velocidade;
        controller.Move(vetorMovimento * velocidade * Time.deltaTime);

        SumScore.Add(Mathf.RoundToInt(Time.deltaTime * 10 * velocidade));

        checaPontuacao(SumScore.Score);
    }
Example #19
0
 void OnCollisionEnter(Collision collision)
 {
     // other object is close
     if (collision.collider.tag == "apple")
     {
         audioSource.Play();
         SumScore.Add(10);
         Destroy(apple);
         SpawnApple();
     }
     if (collision.collider.tag == "strawberry")
     {
         audioSource.Play();
         SumScore.Add(10);
         Destroy(strawberry);
     }
     if (collision.collider.tag == "kiwi")
     {
         audioSource.Play();
         SumScore.Add(10);
         Destroy(kiwi);
     }
 }
Example #20
0
    void Start()
    {
        SumScore.Reset(); // Ensure score is 0 when object loads
        if (initialScore != 0)
        {
            SumScore.Add(initialScore);  // Set initial score
        }
        if (storeHighScore)
        {
            if (PlayerPrefs.HasKey("sumHS"))
            {
                // Set high score value and tell manager
                SumScore.HighScore = PlayerPrefs.GetInt("sumHS");
                UpdatedHS();
            }
            else
            {
                SumScore.HighScore = 0;
            }
        }

        Updated(); // Set initial score in UI
    }
Example #21
0
    void OnCollisionEnter(Collision collision)
    {
        audience = new GameObject[] { audience1, audience2, audience3, audience4, audience5, audience6, audience7, audience8 };      //, audience9, audience10}
        score    = 0;
        ContactPoint contact = collision.contacts[0];
        Vector3      pos     = contact.point;

        point_x = pos.x;
        point_y = pos.y;
        //TODO assign Points x,y and Origin x,y
        float dist = Mathf.Sqrt(((point_y - origin_y) * (point_y - origin_y)) + ((point_x - origin_x) * (point_x - origin_x)));

        if (dist <= outer_b_r)
        {
            if (dist <= inner_b_r)
            {
                score = 50;
            }
            else
            {
                score = 25;
            }
        }
        else
        {
            float angle = (Mathf.Atan2((point_y - origin_y), (point_x - origin_x)) * 180) / Mathf.PI;
            if ((point_y < origin_y))
            {
                angle += 360;
            }
            angle += 9;
            int index   = ((int)(angle / 18)) % 20;
            int section = val_scores[index];
            Debug.Log("ANGLE IS -------- : " + angle);

            if (dist <= inner_single_r)
            {
                score = section;
            }
            else if (dist <= triple_r)
            {
                score = 3 * section;
            }
            else if (dist <= outer_single_r)
            {
                score = section;
            }
            else if (dist <= double_r)
            {
                score = 2 * section;
            }
            else
            {
                score = 0;
            }
        }
        if (dist <= t_radius)
        {
            collision.collider.GetComponent <Rigidbody>().velocity        = Vector3.zero;
            collision.collider.GetComponent <Rigidbody>().angularVelocity = Vector3.zero;
            collision.collider.GetComponent <Rigidbody>().isKinematic     = true;
            this.gameObject.GetComponent <AudioSource> ().Play();
        }
        //scoreboard.GetComponent<SumScore>().Add(score);
        SumScore.IncrementDartCount();
        if (SumScore.Score - score > 0)
        {
            SumScore.Subtract(score);
            if (score != 0)
            {
                foreach (GameObject aud in audience)
                {
                    aud.GetComponent <Animation> ().Play("applause");
                }
            }
        }
        else if (SumScore.Score - score == 0)
        {
            SumScore.Subtract(score);
            SumScore.SaveHighScore(SumScore.DartScore);
            SumScore.Reset();
            SumScore.Add(101);
            foreach (GameObject aud in audience)
            {
                aud.GetComponent <Animation> ().Play("celebration");
            }
        }
        else
        {
            SumScore.Subtract(0);
            Debug.Log("Last dart score must be equal to remaining score");
        }
    }
Example #22
0
 /// <summary>
 /// Example of how to subtract points from a game object.
 /// </summary>
 /// <remarks>Can call from button in inspector</remarks>
 /// <param name="points">Number of points to subtract from score</param>
 public void SubtractPoints(int points)
 {
     SumScore.Add(-points);
     // NOTE - You can also use SumScore.Subtract(points) if you like typing
 }
Example #23
0
 public void AddPoints(int points)
 {
     SumScore.Add(points);
     CheckHighScore();
 }
Example #24
0
 /// <summary>
 /// Example of how to add points from a game object.
 /// </summary>
 /// <remarks>Can call from button in inspector</remarks>
 /// <param name="points">Number of points to add (negative to subtract)</param>
 public void AddPoints(int points)
 {
     SumScore.Add(points);
     GetComponent <AudioSource>().Play();
 }
Example #25
0
File: Enemy.cs Project: pecavi/TFG
    // Update is called once per frame
    void Update()
    {
        keepPos();

        if (!destroyed && Time.timeScale == 1)
        {
            healthBar.UpdateBar(currentHealth, maxHealth);
            if (currentHealth <= 0)
            {
                arma.Stop();
                GetComponent <Rigidbody>().isKinematic = true;
                GetComponent <Collider>().isTrigger    = true;
                SumScore.Add(100);
                destroyed = true;
                explosion.transform.position = transform.position;
                explosion.SetActive(true);

                anim.SetBool("attack", false);
                anim.SetBool("enemyDead", true);
                Invoke("destroy", 3);
            }
            else
            {
                if (objetivo != null)
                {
                    if (distancia(transform.position, objetivo.transform.position) > d)
                    {
                        anim.SetBool("attack", false);
                        if (!anim.GetCurrentAnimatorStateInfo(0).IsName(attackClip))
                        {
                            arma.Stop();
                            //rotate to look at the player
                            var lookPos  = objetivo.transform.position - transform.position;
                            var rotation = Quaternion.LookRotation(lookPos);
                            transform.rotation = Quaternion.Slerp(transform.rotation, rotation, rotationSpeed);


                            //move towards the player
                            transform.position = transform.position + transform.forward * (speed);
                        }
                    }
                    else
                    {
                        anim.SetBool("attack", true);
                        //arma.time = 0;
                        Invoke("attack", 1);
                    }

                    if (anim.GetCurrentAnimatorStateInfo(0).IsName(attackClip))
                    {
                        //rotate to look at the player
                        var lookPos  = objetivo.transform.position - transform.position;
                        var rotation = Quaternion.LookRotation(lookPos);
                        transform.rotation = Quaternion.Slerp(transform.rotation, rotation, Time.deltaTime);
                    }
                }
                else
                {
                    arma.Stop();
                    anim.SetBool("attack", false);
                    anim.SetBool("playerDead", true);
                }
            }
        }
        else
        {
            arma.Stop();
        }
    }
Example #26
0
 public void AddPoints(int points)
 {
     SumScore.Add(points);
 }
    /// /////////////////////////////////////////////////////////////////////////////////

    public void ClickAnswer(int no)
    {
        if (!quizOn)
        {
            return;
        }
        quizOn = false;
        QuizData item = quizList[quizIndex];

        // Is answer collect?
        if (item.correct == no)
        {
            // Display good Effect
            Instantiate(goodEffect);
            // Display soul trail effect
            GameObject go = Instantiate(soulEffect) as GameObject;
            go.GetComponent <SoulEffect>().posX = -1f;
            // Display Happy Effect
            StartCoroutine(DelayActoin(0.6f, () =>
            {
                go = Instantiate(happyEffect, new Vector3(-0.7f, 1f, 0f), Quaternion.identity) as GameObject;
            }));
            // Display Actor's motion
            friendAnimator.CrossFade("Good", 0.2f);
            enemyAnimator.CrossFade("Bad", 0.2f);
            SumScore.Add(10);
            SumScore.SaveHighScore();
        }
        else
        {
            // Display Bad Effect
            Instantiate(badEffect);
            // Display soul trail effect
            GameObject go = Instantiate(soulEffect) as GameObject;
            go.GetComponent <SoulEffect>().posX = 1f;
            // Display Happy Effect
            StartCoroutine(DelayActoin(0.6f, () =>
            {
                go = Instantiate(happyEffect, new Vector3(0.7f, 1f, 0f), Quaternion.identity) as GameObject;
                friendHpMan.DoDamageHp(30);
            }));
            // Display Actor's motion
            friendAnimator.CrossFade("Bad", 0.2f);
            enemyAnimator.CrossFade("Good", 0.2f);
            SumScore.SaveHighScore();

            // Add to result data.
            string questionKey = "question" + wrongCnt.ToString();
            string correctKey  = "correct" + wrongCnt.ToString();
            string questionVal = item.question;
            string correctVal  = answerLabels[item.correct].text;

            Debug.Log("Save : " + questionKey);
            Debug.Log("Save : " + questionVal);

            PlayerPrefs.SetString(questionKey, questionVal);
            PlayerPrefs.SetString(correctKey, correctVal);

            wrongCnt++;
        }

        StartCoroutine(DelayActoin(3f, () =>
        {
            DrawQuiz();
        }));
    }
Example #28
0
 public void SubtractPoints(int points)
 {
     SumScore.Add(-points);
 }