现在的位置: 首页 > 综合 > 正文

【打发时间之US脚本】读书笔记1

2018年05月06日 ⁄ 综合 ⁄ 共 750字 ⁄ 字号 评论关闭

一、基本语法

1.US概念:C++和Java的杂交语言,以C的风格来创建它(EPIC的人都是人才啊,这都能想出来)

2.具有标识符和关键字,标识符和C、C++风格一样,重点:所有修饰符大小写不敏感(C++用习惯了,改不了了)

3.具有表达式和操作符

4.注释风格和C++一样

// A line comment

/* A block comment */

(=。=官方人员还真的是简略,几句话就介绍完基本语法,上边是我的精简版,学过C++的基本一下都懂)

二、实例

1.环境配置

注意:Start with specified game 中选项一定记得要把自己创建的文件名添加到前面

2.代码

说明:创建实例,当玩家受到伤害,血量不足时候进行生命回复

MyGameInfo.uc

class MyGameInfo extends UTGame;

defaultproperties
{
	DefaultPawnClass=class'UnrealScript_01.UTPawn_SuperRegen'
}

UTPawn_SuperRegen.uc

class UTPawn_SuperRegen extends UTPawn;

var Int RegenPerSecond;

simulated function PostBeginPlay()
{
	super.PostBeginPlay();

	SetTimer(1.0,true);
}

function Timer()
{
	if (Controller.IsA('PlayerController') && !IsInPain() && Health < SuperHealthMax )
	{
		Health = Min( Health + RegenPerSecond, SuperHealthMax );
	}
}

defaultproperties
{
	RegenPerSecond=10
}

抱歉!评论已关闭.