//比较运算符
//> < <= >= == !=
//int hp = 100;
//boll res = hp>0;
//print(res);
int hp = 100;
//hp = hp +10;
//hp += 10;
//print(hp);
//hp -=100;//hp = hp-100;
//print(hp);
//比较运算符
//> < <= >= == !=
//int hp = 100;
//boll res = hp>0;
//print(res);
int hp = 100;
//hp = hp +10;
//hp += 10;
//print(hp);
//hp -=100;//hp = hp-100;
//print(hp);
public GameObject cemeraMain;
public Camera mainCamer;
void Start()
{
//print(transform.Find("GameObject(1)/GameObject2"));
//print(transform.Find("GameObject(2)"));
//GameObject mainCameraGo = GameObject.Find("Main Camera");
//print(maincamera):
GameObject Player = GameObject.FindWithTag("Player"):
print(Player);
}
int ADD(int a,int b){ int res = a+b; return res; } print(res)
int i = 0;
格式:
int a = 90 ;
int b = 10 ;
int res = a+b
bool布尔类型 a = false or true;
char字符类型 a = 'XXX'
string a = "XXX"(可中文)
网址:www.cnblogsf.com/tonney/archive/2011/03/18/1987577.html
<30000 sbyte
<20000000 short
>20000000 int
float小数
写法:
(1)
int a;
a=100;
a=b
(2)
int a =100;
a=b
print(b)
日志输出: Debug.log("XXX");(警告)
Debug.logError("XXX");(严重)
print("XXX");(普通
int[] hps = new int[8]{2,2,3,4,1,2,3,4}
console.Win
int boss1 = 14;
int boss2 = 0;
if (boss1 <= 50 && boss2 <= 50)
{
print("游戏结束");
}
else
{
print("游戏继续");
}
第三排是这节课的关键
方法(method)
返回值 方法名(参数){
方法体}
for (int i = 1; i <= 10; i++)(i++=i+1=2 循环输出10次)
{print("创建一个敌人"+i)} //循环体
QQR[2] = 80 (更改相应位置的数字)
int[] QQR = new int[10];(创建一个新的随机数的10位数数组)
int[] QQR = new int[5] {105,333,928,231,123}(创建一个新的指定数的数组)
数组:存储多个数据
类型[] 数组名 = {数组值(需要和数组名里的变量数量一样)}
int qqr = 1
int qqr1 = 1
int qqr2 = 1
int qqr3 = 1
int qqr4 = 1
int QQR = qqr,qqr1,qqr2,qqr3,qqr4
int[] QQR = { 100, 90, 80, 10, 50 };(数组长度为5 位数0-4)
hps[1] //查找数组值第几位的数字
http://www.cnblogs.com/tonney/archive/2011/03/18/1987577.html
CreateEnemy(new Vetor3(1, 1, 1));
CreateEnemy(new Vetor3(3, 4, 5));
//定义方法
void Test()
{
print("Test方法被调用了");
}
void CreateEnemy ( Vetor3 pos)
{
print('创建敌人');
print('设置敌人位置'+pos);
print('设置敌人初始属性');
}
定义枚举类型
enum RoleType{
Mag,
Soldier,
Wizard
}
void Start (){
//调用方法
Test()
}
//定义方法
void Test(){
print('Test方法被调用了'); //方法体
}
返回值 方法名 (参数){
方法体
}