- Home /
How do you make your game have moves count down to end the game?
I've been looking everywhere to find out how to make my bejeweled game have 40 moves total, every move would count down until you hit zero and the game would end with your total score. does anyone know how to do something like this?
You haven't included enough information for an accurate answer. How are you moving your character? Where is the script? What constitutes a move? The actual code to do what you want is only a few lines, but it is highly dependent on the code you have to move your object.
Im using a game$$anonymous$$anager script like this:
using UnityEngine; using System.Collections;
public class Game$$anonymous$$anager : $$anonymous$$onoBehaviour {
public static Game$$anonymous$$anager instance; public GameObject[] playingObjectPrefabs; public GameObject[] horizontalPrefabs; public GameObject[] verticalPrefabs; public GameObject universalPlayingObjectPrefab; public GameObject []jellyPrefab;
internal int numberOfColumns;
internal int numberOfRows;
public float gapBetweenObjects = .7f;
public float swappingTime = .8f;
public float objectFallingDuration = .5f;
internal float initialObjectFallingDuration;
internal bool isBusy = false;
public int totalNoOfJ$$anonymous$$s = 0;
public iTween.EaseType objectfallingEase;
internal Text$$anonymous$$esh scoreText;
internal Text$$anonymous$$esh jellyText;
int score;
internal static int numberOfItemsPoppedInaRow = 0;
void Awake()
{
instance = this;
}
void Start ()
{
scoreText = GameObject.Find("Score Text").GetComponent<Text$$anonymous$$esh>();
jellyText = GameObject.Find("Jelly Text").GetComponent<Text$$anonymous$$esh>();
initialObjectFallingDuration = objectFallingDuration;
numberOfColumns = LevelStructure.instance.numberOfColumns;
numberOfRows = LevelStructure.instance.numberOfRows;
numberOfItemsPoppedInaRow = 0;
scoreText.text = "Score : " + score.ToString();
jellyText.text = "Jelly : " + totalNoOfJ$$anonymous$$s.ToString();
}
internal void AddScore()
{
int temp = 10 * numberOfItemsPoppedInaRow * (numberOfItemsPoppedInaRow / 5 + 1);
// print(temp);
score += temp;
scoreText.text = "Score : " + score.ToString();
}
}
But I don't know how to have a move counter and end the game with a total score.
move counter
and end the game with a GUI score at the end.
Answer by poncho · Jan 26, 2014 at 07:37 AM
Yes, the script where you manage the game, needs a turns count, you need to take one of those turn in each move you do, and after your turns count reaches 0 then change your game status to game over or something like that.
Your answer
Follow this Question
Related Questions
Check Coordinate if its increasing by value over time 1 Answer
Making a bubble level (not a game but work tool) 1 Answer
How can i make score keep updating after bool condition has been met on looping objects? 1 Answer
Restricting axis of movement not working at all! 1 Answer
The name 'Joystick' does not denote a valid type ('not found') 2 Answers