C# Game Programming Cookbook for Unity 3D / Программирование игр на Unity 3D C#. Книга готовых решений.: 10.2 Внутригровой пользовательский интерфейс

Оглавление
Английский оригинал Перевод на русский

Сожалеем, но текст оригинала доступен только зарегистрированным пользователям.

using UnityEngine;
using System.Collections;
public class BaseUIDataManager : MonoBehavior
{
// the actual UI drawing is done by a script deriving from this one
public int player_score;
public int player_lives;
public int player_highscore;
public string gamePrefsName= "DefaultGame"; // DO NOT FORGET TO SET
// THIS IN THE EDITOR!!
public void UpdateScoreP1( int aScore )
{
player_score=aScore; if( player_score>player_highscore )
player_highscore = player_score;
}
public void UpdateLivesP1( int alifeNum )
{ player_lives = alifeNum;
}
public void UpdateScore( int aScore )
{ player_score = aScore;
}
public void UpdateLives( int alifeNum )
{ player_lives = alifeNum;
}
public void LoadHighScore()
{ // grab high score from prefs if( PlayerPrefs.HasKey( gamePrefsName+"_highScore" ) )
{
player_highscore = PlayerPrefs.GetInt
( gamePrefsName+"_highScore" );
}
}
public void SaveHighScore()
{
// as we know that the game is over, let’s save out the high
// score too
PlayerPrefs.SetInt ( gamePrefsName+"_highScore", player_
highscore );
}
}

ilia1395 25.10.14 в 20:25

0
Минутку...