源码的一些记录
常用方法
获取房间名字:
获取区域名字:
显示层级
| 游戏运行期渲染容器(Futile Container) |
Rained 编辑器层级 / 对应游戏元素 |
遮挡顺序(由低到高) |
说明 |
Background |
Layer 3(背景层) |
1 (最底层) |
远景、云雾、背景大板、不与玩家互动的极深背景 |
Midground |
Layer 2 / 部分 Layer 1 |
2 |
背景实体、管道、中景装饰物、普通场景结构 |
Items |
动态生成物体 |
3 |
矛、果子、投掷物等可捡拾物品 |
Shadows |
阴影渲染层 |
4 |
各种物体或生物投射的黑影 |
Foreground |
Layer 1(最表层) & 玩家 |
5 |
玩家(蛞蝓猫)、普通生物 |
Shortcuts |
管道高亮层 |
6 |
管道口闪烁、捷径指示灯等极其显眼的UI和高亮 |
HUD |
UI界面层 |
7 (最顶层) |
饱食度、雨期倒计时等屏幕最前方的UI |
ProjectedCircle
位于命名空间CoralBrain,绘制五块卵石内部区域背景中的动态圆圈投影。
构造方法签名:
| ProjectedCircle(Room room, IOwnProjectedCircles owner, int index, float size)
|
要求传入一个Room对象,一个实现了IOwnProjectedCircles接口的对象、初始坐标和尺寸。
其中,Room对象表示当前所在房间,IOwnProjectedCircles接口的定义如下:
IOwnProjectedCircles接口的定义
| public interface IOwnProjectedCircles
{
Vector2 CircleCenter(int index, float timeStacker);
Room HostingCircleFromRoom();
bool CanHostCircle();
}
|
ExplosiveSpear
Spear的子类,工匠所使用的爆炸矛。
以下用于有关在指定坐标实例化对象的参考。
| //计算伤害发生的位置
Vector2 vector2 = base.firstChunk.pos + this.rotation * (this.pivotAtTip ? 0f : 15f);
//在当前房间内实例化伤害对象
this.room.AddObject(new Explosion.ExplosionLight(vector2, 40f, 1f, 2, this.explodeColor));
//【视觉】在爆炸中心生成八个向外随机方向扩散的粒子(火星)
for (int k = 0; k < 8; k++)
{
Vector2 a = Custom.RNV();
this.room.AddObject(new Spark(vector2 + a * (UnityEngine.Random.value * 10f), a * Mathf.Lerp(6f, 18f, UnityEngine.Random.value), this.explodeColor, null, 4, 18));
}
//【视觉】在当前房间添加冲击波视觉效果
this.room.AddObject(new ShockWave(vector2, 30f, 0.035f, 2, false));
//【听觉】播放爆炸音效
this.room.PlaySound(SoundID.Fire_Spear_Pop, vector2, this.abstractPhysicalObject);
//【视觉/逻辑】对爆炸矛的末端布条施加一个推力,使布料飞走
for (int l = 0; l < this.rag.GetLength(0); l++)
{
this.rag[l, 2] += (Custom.DirVec(vector2, this.rag[l, 0]) + Custom.RNV() - this.rotation) * (UnityEngine.Random.value * 5f);
this.rag[l, 0] += (Custom.DirVec(vector2, this.rag[l, 0]) + Custom.RNV() - this.rotation) * (UnityEngine.Random.value * 5f);
}
//【逻辑】如果长矛脱手且未扎入物体,则对长矛施加后坐力,改变它的状态
if (base.mode == Weapon.Mode.Free && this.stuckInObject == null)
{
if (base.firstChunk.vel.y < 0f)
{
BodyChunk firstChunk = base.firstChunk;
firstChunk.vel.y = firstChunk.vel.y * 0.5f;
}
base.firstChunk.vel -= (Custom.RNV() + this.rotation) * (UnityEngine.Random.value * ((base.firstChunk.ContactPoint.y < 0) ? 5f : 15f));
//使长矛随机翻滚
this.SetRandomSpin();
}
//【逻辑】实例化局内音效,通知房间内的生物AI
this.room.InGameNoise(new InGameNoise(vector2, 800f, this, 1f));
|