
物品选择法术(U6)
(内含视频)厌倦了翻书召唤武器吗?无需多言!使用此咒语即可将物品选择器召唤至手中。移除咒语即可消除物品选择器。它始终出现在你的左手上。
查看大图public class ItemSelector : LevelModule
{
public bool bookSpawnedRight;
public bool bookSpawnedLeft;
public GameObject book;
public GameObject bookInstance;
public override void OnLevelLoaded(LevelDefinition levelDefinition)
{
bookSpawnedRight = false;
bookSpawnedLeft = false;
}
public override void Update(LevelDefinition levelDefinition)
{
bookSpawnedRight = CheckForSpell(Player.local.body.handRight, bookSpawnedRight);
bookSpawnedLeft = CheckForSpell(Player.local.body.handLeft, bookSpawnedLeft);
if(bookInstance != null)
{
bookInstance.transform.LookAt(Player.local.head.transform);
bookInstance.transform.Rotate(90f, 0f, 0f);
}
}
bool CheckForSpell(BodyHand hand, bool bookSpawned)
{
if (hand.caster.currentSpell != null && hand.interactor.grabbedHandle == null && !bookSpawned)
{
if (hand.caster.currentSpell.name == "ItemSelectorSpell(Clone)")
{
if(book == null)
{
if (GameObject.Find("ItemStorage") != null)
{
book = GameObject.Find("ItemStorage");
}
}
else if(bookInstance == null)
{
bookSpawned = true;
bookInstance = GameObject.Instantiate(book, Creature.player.body.handLeft.interactor.transform.position - Creature.player.body.handLeft.interactor.transform.right.normalized * 0.35f - Creature.player.body.handLeft.interactor.transform.forward.normalized * 0.2f, Creature.player.body.handLeft.interactor.transform.rotation, Creature.player.body.handLeft.interactor.transform);
}
}
}
if (bookSpawned)
{
if (hand.caster.currentSpell != null)
{
if (hand.caster.currentSpell.name != "ItemSelectorSpell(Clone)")
{
GameObject.Destroy(bookInstance);
bookSpawned = false;
}
}
else
{
GameObject.Destroy(bookInstance);
bookSpawned = false;
}
}
return bookSpawned;
}
public override void OnLevelUnloaded(LevelDefinition levelDefinition)
{
// 当关卡卸载时调用
book = null;
bookInstance = null;
}
}
还没有人评论,去客户端里说两句吧。
评论在新手盒子客户端中发表,这里同步展示。