Indonesia Unity3D Game Developing
Would you like to react to this message? Create an account in a few clicks or log in to continue.
Search
 
 

Display results as :
 


Rechercher Advanced Search

Latest topics
» Game Mewarnai Tutorial
#ASK Skor di quiz game EmptyThu Mar 23, 2017 10:21 am by kamil

» [ASK HELP] Slide informasi di augmented reality
#ASK Skor di quiz game EmptyTue Jan 03, 2017 8:58 pm by Briyan_ap

» ASK cara klik dan memunculkan informasi
#ASK Skor di quiz game EmptyTue Jan 03, 2017 8:54 pm by Briyan_ap

» [Ask] mengubah game PC menjadi game Android
#ASK Skor di quiz game EmptyTue Jan 03, 2017 10:57 am by NiethaChan

» Virtualisasi suatu Gedung mengunakan unity3D + google seketchUP
#ASK Skor di quiz game EmptySat Dec 31, 2016 1:06 am by zeepank

» Minta Tolong, slideshow ngga muncul saat object di klik
#ASK Skor di quiz game EmptyTue Dec 27, 2016 12:53 pm by Briyan_ap

» tolong dong lagi bikin button rotate tp button ga keluar
#ASK Skor di quiz game EmptyWed Dec 21, 2016 1:15 pm by Lita Misae

» algoritma Minimax/negascout buat checkers
#ASK Skor di quiz game EmptyWed Nov 30, 2016 1:51 am by ardiansa

» screenshot
#ASK Skor di quiz game EmptyWed Nov 16, 2016 10:15 pm by azhari

Statistic

#ASK Skor di quiz game

Go down

#ASK Skor di quiz game Empty #ASK Skor di quiz game

Post  mrjoners366 Sat Oct 08, 2016 12:30 pm

halo agan agan sekalian ane orang baru di unity ini
ane mau nanya cara buat skor di quiz game ane
ini script nya

Code:
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using System.Collections.Generic;
using System.Linq;



public class GameManager : MonoBehaviour {


    public Question[] questions;
    private static List<Question> unansweredQuestions;

    private Question currentQuestion;

    [SerializeField]
    private Text factText;

    [SerializeField]
    private Text TrueAnswerText;
    [SerializeField]
    private Text FalseAnswerText;


    [SerializeField]
    private Animator animator;

    [SerializeField
    private float TimeBetweenQuestions = 1f;

    void Start()
    {
        if (unansweredQuestions == null || unansweredQuestions.Count == 0)
        {
            unansweredQuestions = questions.ToList<Question>();
        }
        SetCurrentQuestion();
    }

    void SetCurrentQuestion()
    {
        int randomQuestionIndex = Random.Range(0, unansweredQuestions.Count);
        currentQuestion = unansweredQuestions[randomQuestionIndex];

        factText.text = currentQuestion.fact;

       if (currentQuestion.isTrue)
       {
            TrueAnswerText.text = "Hebat";
            FalseAnswerText.text = "Maaf";
       }else
        {
            TrueAnswerText.text = "Maaf";
            FalseAnswerText.text = "Hebat";
        }
    }
 
   void CallGameOverScene()
   {
       SceneManager.LoadScene("GameOverScene");
        Application.LoadLevel("GameOverScene");
   }


    IEnumerator TransitionToNextQuestion()
    {
        unansweredQuestions.Remove(currentQuestion);

        yield return new WaitForSeconds(TimeBetweenQuestions);

        SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
    }

    public void UserSelectTrue()
    {
        animator.SetTrigger("Benar");
        if (currentQuestion.isTrue)
        {
            Debug.Log("Hebat!");
            StartCoroutine(TransitionToNextQuestion());
        }
        else
        {
            Debug.Log("Maaf");
            CallGameOverScene();
        }


    }

    public void UserSelectFalse()
    {[/font]
        animator.SetTrigger("Salah");
        if (!currentQuestion.isTrue)
        {
            Debug.Log("Hebat!");
            StartCoroutine(TransitionToNextQuestion());
        }
        else
        {[/font]
            Debug.Log("Maaf");
            CallGameOverScene();
        }
    }
}

jadi tiap kali user game jawaban nya bener + skor nya 3
ini game nya tentang bener atau salah gan 
Thx sebelumnya Wink
mrjoners366
mrjoners366
Unity3D Newbie
Unity3D Newbie

Posts : 1
Points : 3
Reputation : 0
Join date : 2016-10-08

Back to top Go down

Back to top

- Similar topics

 
Permissions in this forum:
You cannot reply to topics in this forum