unity3d开源Ultimate MMORPG插件技术文档渣翻译第3页

来源:互联网 发布:淘宝一件代发赚钱吗 编辑:程序博客网 时间:2024/04/30 05:17

 一直想弄个MMORPG ,发现了这个牛逼的插件,但我是小白,苦于网上没教程,就尝试下翻译技术文档,我技术渣英文渣,只求抛砖引玉引大神出来,有错欢迎指出来,我共享翻译文档,希望大神更正,我会在更正错误的地方打括号留下大神的名字重新上传翻译文档(:D)。

翻译文档链接:http://yunpan.cn/cQC2J4GVzQcDf(提取码:777a)

UlitimateMMORPG插件链接http://pan.baidu.com/s/1sjBPMaT

                       http://yunpan.cn/cQCWyhfcTPXrG(提取码:3b42)

Csdn博客地址:http://blog.csdn.net/rightandwill





Page3

You can use simple mathematical operations in code and do anythingyou want with  them. To declare thevariable, write its type and then its name. All lines ends with «;» symbol. Youcan comment some useful information using «//».

你可以通过他们使用最简单的数学运算符在代码中做你任何想做的事。只需要声明变量,写明类型和它的名字。所有行的末尾要加;符号。你可以使用//来注释一些有用的信息。

C# code:

int x;

x=2;

int y=3; // Itis a comment. Look, you can declare and bind a value at one time

      //这是一个注释。看,你可以一次性地声明和绑定一个值

int a, b; //You can declare a few variables of one type at the same time

      //您可以在同一时间声明一种类型的变量

a = (x * y)/2 -6; // Calculate anything you want

//计算你想要的任何东西

 But what will we do with our variables andcalculations? If you try to write a

C# script withthe previous text, the error will appeared. It will so because we need

a function,where the calculations will happen.

   但是我将用变量和计算做什么?如果你试着用上述文本写一份C#脚本,将会发生错误。之所以是这样是因为我们需要一个用以计算的函数。

 Function is a place in thescript, where all events will happen. Unity has a few main functions that youneed to know:

所有的事件都在函数中发生。Unity有一些你需要知道的主函数。

1)     Awake — called one time beforethe game starts (all objects already initialized);

在游戏开始前被执行一次(所有物体已经被初始化)

2) Start —called one time after Awake and before Update functions;

         在函数Update前Awake后执行

3) Update —called every frame. For instance can be used for translating a GameObject

somewhere;

          每一帧都被执行。例如可用于改变某处GameObject的位置;

4) OnGUI —called every frame. Using for graphic (buttons, labels, windows and etc.).

每一帧都被执行。用于图形(按钮、标签、窗口等)。

 So, we will use «Awake»function for our calculations. Every function is declared in the way like this:<type> <name> «() {  }». Thetype of our function will be «void» because it returns nothing. Create new C#script in Unity and called it as you want. Then delete green comments and twofunctions - Start and Update. And then write this between «{» and «}»:

   所以,我们将用Awake函数来计算。每个函数将会以如下方式申明:: <类型> <名字> «() {  }»。我们使用的函数类型是void型的,因为它返回空值。在Unity中创建一个c#脚本并取一个你喜欢的名字。然后删除绿色注释和2个函数-Start和Update。然后在两个括号之间写下如下代码:

C# code:

int x;    //Don’t copy «C# code:» 别复制c#code

void  Awake(){

 x=5-2;

 Debug.Log(«The result is:»+x);    // Method for debugging. It willwrite the

                               // result in theconsole调试方法。它的结果将被写在//console中。

}

If you writethis script right (you can just copy&past it), add this script to the MainCamera and press «Play» button, you will see the result in the consolewindow!You see, methods do something with variables.

如果你正确地写出了此脚本(你可以只是复制粘贴),把这个脚本添加到主摄像机上,然后按下Play键,你将在控制台中看到结果。你看,我们使用变量做了点事。

 

«If» Statement       If语句

   Veryoften the action depends on variable. Or variable depends on another variable.(e.g. if health more than 0, the Player will be alive. In other way he willdie).To make this possible, «If» Statement exists.

    行为经常依赖于变量。或者变量依赖于另一个变量。(比如如果生命大于0,玩家会活着。否则玩家将死亡)。要尽可能地使用if语句。

   


0 0
原创粉丝点击