本文整理汇总了C#中PlayerControl.AddPickup方法的典型用法代码示例。如果您正苦于以下问题:C# PlayerControl.AddPickup方法的具体用法?C# PlayerControl.AddPickup怎么用?C# PlayerControl.AddPickup使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PlayerControl
的用法示例。
在下文中一共展示了PlayerControl.AddPickup方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CollectPickup
public virtual void CollectPickup(PlayerControl player)
{
// does player already own me?
if (player.Pickups.Contains(this))
{
// just update my state
this.Player = player;
gameObject.SetOwner(player.gameObject);
transform.SetParent(player.transform);
transform.localPosition = Vector3.zero;
}
else
{
// Show pickup message
if (GameBrain.Instance.State == PlayState.GameOn && PlayerHudCanvas.Instance != null)
PlayerHudCanvas.Instance.ShowPickupText(this.GetPickupName(), player.gameObject, player.PlayerIndex);
// check if player already has one of these
var duplicate = player.Pickups.Find(x => x.GetPickupName() == this.GetPickupName() && x != this);
if (duplicate != null)
{
// already got one, take ammo etc and destroy
var ammo = GetAmmoCount();
if (ammo > 0)
{
duplicate.AddAmmo(ammo);
}
Destroy(gameObject);
}
else
{
// pick it up
this.Player = player;
player.AddPickup(this);
gameObject.SetOwner(player.gameObject);
transform.SetParent(player.transform);
transform.localPosition = Vector3.zero;
OnPlayerPickup.Invoke();
}
// play pickup sound
if (PickupSound != null)
Helper.PlaySoundEffect(PickupSound);
}
}