資源簡介
一款自制跑酷游戲的一個腳本
代碼片段和文件信息
///?
///?Shop?character.
///?This?script?use?for?create?shop?menu
///?
using?UnityEngine;
using?System.Collections;
using?System.Collections.Generic;
public?class?ShopCharacter?:?MonoBehaviour?{
[System.Serializable]
public?class?CharacterData
{
public?Gameobject?player;
public?string?name;
public?int?price;
public?bool?isUnLock;
}
[System.Serializable]
public?class?Button
{
public?Rect?rect;
public?Texture2D?normal;
public?Texture2D?active;
}
[System.Serializable]
public?class?Label
{
public?GUIText?guiText;
public?string?text;
public?int?fontSize;
public?Color?fontColor;
public?Fontstyle?fontstyle;
public?TextAnchor?alignment;
public?Rect?rect;
}
public?CharacterData[]?players;
public?float?factorSpace;
public?int?coin;
public?Button?btnBuy?btnSelect?btnonselect?btnBack?btnArrowLeft?btnArrowRight?iconCoinBuy?iconCoinCurrent;
public?Label?guiLabelName?guiLabelPrice?guiLabelCoinCurrent;
public?AudioClip?sfxButton;
private?CalOnGUI?calGUI;
private?int?indexSelect;
private?int?selecCorrect;
private?List?point?=?new?List?();
private?Vector3?getMousePos;
[HideInInspector]?public?GUIstyle?guistyleBtnBuy;
[HideInInspector]?public?GUIstyle?guistyleBtnSelect;
[HideInInspector]?public?GUIstyle?guistyleBtnonselect;
[HideInInspector]?public?GUIstyle?guistyleBtnBack;
[HideInInspector]?public?GUIstyle?guistyleBtnArrowLeft;
[HideInInspector]?public?GUIstyle?guistyleBtnArrowRight;
void?Setstyle(){
guistyleBtnBuy.normal.background?=?btnBuy.normal;
guistyleBtnBuy.active.background?=?btnBuy.active;
guistyleBtnSelect.normal.background?=?btnSelect.normal;
guistyleBtnSelect.active.background?=?btnSelect.active;
guistyleBtnBack.normal.background?=?btnBack.normal;
guistyleBtnBack.active.background?=?btnBack.active;
guistyleBtnonselect.normal.background?=?btnonselect.normal;
guistyleBtnonselect.active.background?=?btnonselect.active;
guistyleBtnArrowLeft.normal.background?=?btnArrowLeft.normal;
guistyleBtnArrowLeft.active.background?=?btnArrowLeft.active;
guistyleBtnArrowRight.normal.background?=?btnArrowRight.normal;
guistyleBtnArrowRight.active.background?=?btnArrowRight.active;
}
void?ResetData(){
for?(int?i?=?0;?i?yers.Length;?i++)?{
PlayerPrefs.SetString(“Player_“+i?“False“);
}
}
void?Start(){
//ResetData?();
Setstyle?();
coin?=?GameData.LoadCoin?();
selecCorrect?=?PlayerPrefs.GetInt?(“SelectPlayer“);
Vector3?pos?=?Vector3.zero;
for?(int?i?=?0;?i?yers.Length;?i++)?{
players?[i].player.transform.localPosition?=?new?Vector3?(pos.x?+?(i?*?factorSpace)?0?0);
point.Add?(new?Vector3?(-1?*?(pos.x?+?(i?*?factorSpace))?+?transform.position.x?transform.position.y?transform.position.z));
if?(i?==?0)?{
players?[i].isUnLock?=?true;
}?else?{
Debug.Log?(PlayerPrefs.GetString?(“Player_“?+?i));
if(PlayerPrefs.GetString?(“Player_“?+?i)?==?““){
players?[i].isUnLock?=?false;
- 上一篇:基于c/s模式的簡單聊天程序
- 下一篇:C#高級編程練習題目內附答案
評論
共有 條評論