本文整理汇总了C#中Player.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Player.GetComponent方法的具体用法?C# Player.GetComponent怎么用?C# Player.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Player
的用法示例。
在下文中一共展示了Player.GetComponent方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnCollisionEnter
// When a player collides, he joins the bromstick
public void OnCollisionEnter(Collision collision)
{
Player player = collision.transform.GetComponent<Player>();
if (inUse || player == null || !player.isMine) {
return;
}
// freeze player
driver = player;
driver.transform.eulerAngles = new Vector3(0, 0, 0);
driver.transform.SetParent(transform);
driver.freeze();
driver.GetComponent<Rigidbody>().useGravity = false;
driver.GetComponent<Rigidbody>().isKinematic = true;
driver.GetComponent<Collider>().enabled = false;
driver.isFlying = true;
driver.transform.position = playerPos.position;
player.transform.FindChild ("Main Camera").gameObject.SetActive(false);
controller.enabled = true;
camera.SetActive(true);
Instance = this;
}
示例2: EndGame
public void EndGame(Player winner)
{
if (!isEnding)
{
isEnding = true;
EndPlaque.GetComponent<BoxCollider2D>().enabled = true;
Text text = GameObject.FindGameObjectWithTag("UI").GetComponentInChildren<Text>();
GameObject goal = GameObject.FindGameObjectWithTag("Goal");
goal.SetActive(false);
setWinnerText(winner);
remporte.GetComponent<Image>().enabled = true;
text.text = "";
foreach(Player player in playerManager.players)
{
player.setInGame(false);
player.setTurn(false);
}
audioManager.PlaySound(winner.Victoire);
winner.GetComponent<Animator>().SetBool("Idle2Walk", false);
winner.GetComponent<Animator>().SetBool("Idle2Walk2", false);
winner.GetComponent<Animator>().SetBool("Idle2Throw", false);
winner.GetComponent<Animator>().SetBool("WalkToThrow", false);
winner.GetComponent<Animator>().SetTrigger("Win");
}
}
示例3: PlayerState_Normal
public PlayerState_Normal(Player p)
{
player = p;
rigidbody = player.GetComponent<Rigidbody2D> ();
fireDelayTimer = new CountdownTimer();
fireArm = player.gameObject.GetComponentInChildren<FireArm>();
animator = player.GetComponent<Animator>();
}
示例4: Start
// Use this for initialization
void Start ()
{
player = GetComponent<Player>();
if (player.GetComponent<PlayerHealth>().ReturnWinCount() > 0)
{
Debug.Log("win count in showwins" + player.GetComponent<PlayerHealth>().ReturnWinCount());
gameObject.SetActive(true);
}
}
示例5: Activated
GameObject owner; // The owner of this trap
#endregion Fields
#region Methods
/**
* Activate function
*
* Arguments
* - Player player - The player that activated the trap
*/
public override void Activated(Player p)
{
if (owner != null && owner.GetComponent<Player>() == p) // Owner activated us
return;
else if (owner == null)
return;
else { // Other players. Activate trap */
p.GetComponent<PhotonView>().RPC("Stun", p.GetComponent<PhotonView>().owner, 1);
p.GetComponent<PhotonView>().RPC("DisplayStunAnim", PhotonTargets.All, null);
GetComponent<PhotonView>().RPC("Destroy", PhotonTargets.All, null);
}
}
示例6: Start
// Use this for initialization
void Start ()
{
m_inventory = GameObject.Find ("Inventory").GetComponent<Inventory> ();
//m_amount = 1;
m_toolTip = m_inventory.GetComponent<ToolTip> ();
m_playerObj = GameObject.Find ("Berserker");
m_player = m_playerObj.GetComponent<Player> ();
m_attack = m_player.GetComponent<Player> ().m_attack;
m_defence = m_player.GetComponent<Player> ().m_defence;
m_health = m_player.GetComponent<Player> ().m_health;
}
示例7: PickedUp
//include setters for manually setting stats
void PickedUp(Player player)
{
switch (gemType)
{
case 1:
gem = new StrengthGem();
break;
case 2:
gem = new AgilityGem();
break;
case 3:
gem = new IntelligenceGem();
break;
case 4:
gem = new HealthGem();
break;
case 5:
gem = new ManaGem();
break;
case 6:
Debug.Log("Would be skill Gem");
//insert skill gem here when done
break;
}
gem.setOwner(player);
gem.Initialize(quality); //MUST CALL. think of this as running the Start() function, but Gem does not inherit from monobehaviour. Its its own man, taking orders from no base class.
Debug.Log(gem.getDescription());
//Set stats for gem before adding to play
player.GetComponent<GemManager>().addGem(gem);
Destroy(gameObject);
}
示例8: PlayerState_Dead
public PlayerState_Dead(Player p)
{
player = p;
player.GetComponent<Animator>().SetBool ("Dead", true);
player.transform.GetChild (1).gameObject.GetComponent<SpriteRenderer>().enabled = false;
CircleCollider2D[] colliders = player.GetComponents<CircleCollider2D>();
for (int i = 0; i < colliders.Length; ++i)
{
colliders[i].enabled = false;
}
player.GetComponent<Rigidbody2D>().velocity = new Vector2(0.0f, 0.0f);
}
示例9: Start
// Use this for initialization
void Start()
{
player = FindObjectOfType(typeof(Player)) as Player;
playerDest = player.GetComponent<Destroyable>();
colorize = GetComponent<Colorize>();
maxHealth = playerDest.health;
}
示例10: Start
void Start()
{
InitGame();
player = GameObject.FindWithTag("Player").GetComponent<Player>();
player.GetComponent<Player>().ContinueMoving();
LocationManager.instance.EnterLocation += new LocationManager.LocationHandler(ProposeEnteringLocation);
}
示例11: init
public virtual void init()
{
player = GameManager.Player;
ActiveSpecialAbilities activeAbilities = player.GetComponent<ActiveSpecialAbilities> ();
activeAbilities.onReload += onReload;
activeAbilities.onBulletHit += onBulletHit;
activeAbilities.onDamageTaken += onDamageTaken;
activeAbilities.onItemPickup += onItemPickup;
}
示例12: Interact
public override void Interact(Player player)
{
ClearAtt();
Done = true;
player.transform.rotation = Quaternion.identity;
player.transform.position = Spawn;
player.GetComponent<Rigidbody>().isKinematic = false;
player.path = null;
}
示例13: OnCollisionEnter
// When a player collides, he joins the bromstick
public void OnCollisionEnter(Collision collision)
{
Player player = collision.transform.GetComponent<Player>();
if (inUse || player == null || !player.isMine) {
return;
}
driver = player;
driver.transform.eulerAngles = new Vector3(0, 180f, 0);
driver.transform.SetParent(transform);
driver.freeze();
driver.GetComponent<Rigidbody>().useGravity = false;
driver.GetComponent<Collider>().enabled = false;
driver.isFlying = true;
driver.transform.position = playerPos.position;
Instance = this;
}
示例14: Start
// Use this for initialization
void Start()
{
player = GameObject.FindGameObjectWithTag ("Player").GetComponent<Player>();
if (player.warpId >= 0)
{
Vector3 position = warps [player.warpId].transform.position;
//position.y += 0.1f;
player.transform.position = position;
}
player.GetComponent<NavMeshAgent> ().enabled = true;
}
示例15: Start
// Use this for initialization
void Start()
{
playerDetector = GetComponent<CapsuleCollider>();
player = GameObject.FindGameObjectWithTag("Player").GetComponent<Player>();
playerControls = player.GetComponent<TwinStickController>();
curChargeUp = chargeUpTime;
curLaserTime = laserTime;
laserParticlesInScene = new GameObject[towers.Length];
}