当前位置: 首页>>代码示例>>C#>>正文


C# Player.GetComponent方法代码示例

本文整理汇总了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;
    }
开发者ID:hefanzhou,项目名称:hogwarts,代码行数:27,代码来源:Broomstick.cs

示例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");
     }
 }
开发者ID:tommylavoie,项目名称:WonderJamA2015,代码行数:25,代码来源:TurnManager.cs

示例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>();
    }
开发者ID:David-Hanna,项目名称:IvGGameJam,代码行数:9,代码来源:PlayerState_Normal.cs

示例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);
     }
 }
开发者ID:gamesketches,项目名称:ButtonMashClumpPrototype,代码行数:10,代码来源:ShowWins.cs

示例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);
        }
    }
开发者ID:RandomTroll18,项目名称:deco3801-nodayoff,代码行数:24,代码来源:ScoutTrapScript.cs

示例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;

	}
开发者ID:fsanta328,项目名称:Garden-of-Eden,代码行数:13,代码来源:ItemData.cs

示例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);
    }
开发者ID:DevelopersGuild,项目名称:Castle-Bashers,代码行数:34,代码来源:DroppedGem.cs

示例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);
	}
开发者ID:David-Hanna,项目名称:IvGGameJam,代码行数:16,代码来源:PlayerState_Dead.cs

示例9: Start

 // Use this for initialization
 void Start()
 {
     player = FindObjectOfType(typeof(Player)) as Player;
     playerDest = player.GetComponent<Destroyable>();
     colorize = GetComponent<Colorize>();
     maxHealth = playerDest.health;
 }
开发者ID:Kuirak,项目名称:HardcoreRambot,代码行数:8,代码来源:CameraHeartBeat.cs

示例10: Start

 void Start()
 {
     InitGame();
     player = GameObject.FindWithTag("Player").GetComponent<Player>();
     player.GetComponent<Player>().ContinueMoving();
     LocationManager.instance.EnterLocation += new LocationManager.LocationHandler(ProposeEnteringLocation);
 }
开发者ID:oguretsss,项目名称:par,代码行数:7,代码来源:GameManager.cs

示例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;
 }
开发者ID:reqnux,项目名称:reqnux_TillDeath,代码行数:9,代码来源:SpecialAbility.cs

示例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;
 }
开发者ID:Dyhr,项目名称:GGJ16-TheEverydayMorningRoutineOfAnOrdinaryMan,代码行数:9,代码来源:Bed.cs

示例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;
    }
开发者ID:firehot,项目名称:hogwarts,代码行数:21,代码来源:Broomstick.cs

示例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;
 }
开发者ID:rvagner42,项目名称:RushUltime,代码行数:12,代码来源:WarpPosition.cs

示例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];
    }
开发者ID:SeiZon,项目名称:Fade,代码行数:12,代码来源:TowerActivator.cs


注:本文中的Player.GetComponent方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。