资源简介
一款自制跑酷游戏的一个脚本
代码片段和文件信息
///
/// 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 < players.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 < players.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#高级编程练习题目内附答案
相关资源
- unity3d 连接外置摄像头
-
Js to CSharp sc
ript converter - unity上传文件7牛云存储服务器
- 鱼类游动代码
- unity旋转,缩放,移动控制脚本
- unity旧粒子系统转换为新粒子系统
- MoveCamera.cs
- Unity3D场景中对模型旋转放大缩小脚本
- unity3d实现物体透明渐变效果
- 使用C#在Unity中制作VR游戏
- Unity项目对齐地面功能
- Unity5实战使用C#和Unity开发多平台游戏
- 可视化调节曲线运动Unity插件
- SwitchClick.cs
- c# 排序算法诠释排序过程
- Unity\“I18N.West\“
- c#开发,unity环境,计算器,支持四则
- unity3D简易计算器C#脚本代码
- LitJson.dll C# 与 unity 可用的Json处理插
- Unity3d使用Meth实现温度云图
- 简易unity屏幕特效代码shader+C#
- Unity不用Dll直接读取BMP图片并转为Te
- Unity保存录音实际长度并分段上传服务
- AssetStudio.v0.13.25 unity引擎解包工具
- Unity Excel插件 EPPlus 3.5+4.x
- unity3d BitmapToTexture2D
- c#、unity3d实现远程视频通话源码NN视频
- unity ugui 日历demo
- Unity粒子系统升级到2018新粒子系统
- C# 心跳包服务端,客户端
评论
共有 条评论