當前位置: 首頁>>代碼示例>>C#>>正文


C# Agent.GetComponent方法代碼示例

本文整理匯總了C#中Agent.GetComponent方法的典型用法代碼示例。如果您正苦於以下問題:C# Agent.GetComponent方法的具體用法?C# Agent.GetComponent怎麽用?C# Agent.GetComponent使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在Agent的用法示例。


在下文中一共展示了Agent.GetComponent方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Activate

 public void Activate(Agent agent)
 {
     currentAgent = agent;
     AgentRigidbody = currentAgent.GetComponent<Rigidbody2D>();
     AgentAnimator = currentAgent.GetComponent<Animator>();
     Debug.Log("Idle State");
 }
開發者ID:GikeyMe,項目名稱:2D-Platformer,代碼行數:7,代碼來源:IdleState.cs

示例2: Activate

 public void Activate(Agent agent)
 {
     currentAgent = agent;
     AgentRigidbody = currentAgent.GetComponent<Rigidbody2D>();
     AgentAnimator = currentAgent.GetComponent<Animator>();
     player = GameObject.Find("Player");
     Debug.Log("Ranged State");
 }
開發者ID:GikeyMe,項目名稱:2D-Platformer,代碼行數:8,代碼來源:RangedAttackState.cs

示例3: Activate

 public void Activate(Agent agent)
 {
     Debug.Log("PhaseChangeState");
     currentAgent = agent;
     AgentRigidbody = currentAgent.GetComponent<Rigidbody2D>();
     AgentAnimator = currentAgent.GetComponent<Animator>();
     if (currentAgent is Boss || currentAgent is BossThree)
         AgentAnimator.SetBool("Throwing", false);
 }
開發者ID:GikeyMe,項目名稱:2D-Platformer,代碼行數:9,代碼來源:PhaseChangeState.cs

示例4: Activate

 public void Activate(Agent agent)
 {
     currentAgent = agent;
     AgentRigidbody = currentAgent.GetComponent<Rigidbody2D>();
     AgentAnimator = currentAgent.GetComponent<Animator>();
     player = GameObject.Find("Player");
     Debug.Log("Melee State");
     if (currentAgent is Boss || currentAgent is BossThree)
         AgentAnimator.SetBool("Throwing", false);
 }
開發者ID:GikeyMe,項目名稱:2D-Platformer,代碼行數:10,代碼來源:MeleeAttackState.cs

示例5: Activate

 public void Activate(Agent agent)
 {
     currentAgent = agent;
     AgentRigidbody = currentAgent.GetComponent<Rigidbody2D>();
     AgentAnimator = currentAgent.GetComponent<Animator>();
     player = GameObject.Find("Player");
     powerups = GameObject.FindGameObjectsWithTag("BlueDiamond");
     Debug.Log("Seek Power State");
     if (currentAgent is Boss || currentAgent is BossThree)
         AgentAnimator.SetBool("Throwing", false);
 }
開發者ID:GikeyMe,項目名稱:2D-Platformer,代碼行數:11,代碼來源:SeekPowerState.cs

示例6: CanHitAgent

    private bool CanHitAgent(Agent targetAgent)
    {
        if (targetAgent == null)
        {
            return false;
        }

        Vector2 delta = (targetAgent.Position - _agent.Position);

        // Is it within range?
        if (delta.magnitude > fireDistance)
        {
            return false;
        }

        delta = delta.normalized;
        RaycastHit2D hit = Physics2D.Raycast(_agent.Position + delta * (Agent.AgentRadius + 0.2f), delta, fireDistance, _agent.enemies | Level.Instance.buildings);
        if (hit.collider != targetAgent.GetComponent<Collider2D>())
        {
            return false;
        }
        return true;
    }
開發者ID:mfagerlund,項目名稱:LD33,代碼行數:23,代碼來源:Weapon.cs


注:本文中的Agent.GetComponent方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。