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


C# Ball.GetComponent方法代码示例

本文整理汇总了C#中Ball.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# Ball.GetComponent方法的具体用法?C# Ball.GetComponent怎么用?C# Ball.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Ball的用法示例。


在下文中一共展示了Ball.GetComponent方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetCurrentBallPosition

 public static Vector2 GetCurrentBallPosition(Ball ball)
 {
     float ballRadius = ball.GetComponent<CircleCollider2D>().radius;
     float ballXPosition = ball.transform.position.x;
     float GridX = Mathf.Round( (ballXPosition+1)/2 );
     float GridY = Mathf.Round(( ball.transform.position.y )/(ballRadius*2));
     Vector2 ballPosition = new Vector2 ((int)GridX-1,(int)GridY-1);
     return ballPosition;
 }
开发者ID:eranshac,项目名称:UniversityProjectShared,代码行数:9,代码来源:GameGrid.cs

示例2: OnEnter

    public override void OnEnter()
    {
        m_ball = Game.GetInstance().GetBall();
        m_paddle = Game.GetInstance().GetPaddleLeft();

        // make ball as child of paddle
        var ballTransform = m_ball.GetComponent<Transform>();
        var paddleTransform = m_paddle.GetComponent<Transform>();
        m_ballOriTransParent = ballTransform.parent;
        ballTransform.parent = paddleTransform;
    }
开发者ID:tkokof,项目名称:ExamPong,代码行数:11,代码来源:GameStart.cs

示例3: fleePower

	public IEnumerator fleePower (Ball ball, float duration) {

		enemies = FindObjectsOfType(typeof(Enemy)) as Enemy[];
		foreach (Enemy enemy in enemies) {
			if (enemy.destination == ball.transform) StartCoroutine( enemy.Flee( ball.transform, powerDuration ) );
		}

		ball.GetComponent<Renderer>().material = GetComponent<Renderer>().material;
		active = true;

		yield return new WaitForSeconds(duration);

		if (ball) {
			ball.GetComponent<Renderer>().material = ball.normMaterial;
			ball.powerup = null;
		}
		Destroy(gameObject);

		yield return null;

	}
开发者ID:matze150,项目名称:ballyrinth,代码行数:21,代码来源:Powerup.cs

示例4: colorFade

    void colorFade(Ball ball, bool chosen)
    {
        if (chosen)
        {
            originalColor = ball.color;
            Renderer rend = ball.GetComponent<Renderer>();
            Material highlighted = Resources.Load("Black") as Material;

            rend.material = highlighted;
        }
        else
            ball.color = originalColor;
    }
开发者ID:darinav,项目名称:Total_Balls,代码行数:13,代码来源:BallMover.cs

示例5: SwitchBalls

 public void SwitchBalls(int targetIndex)
 {
     BallPrefab = Prefabs[targetIndex];
     foreach(var ball in FindObjectsOfType<Ball>()) {
         ball.GetComponent<MeshRenderer>().material = BallPrefab.GetComponent<Renderer>().sharedMaterial;
     }
 }
开发者ID:Dethrail,项目名称:pinball,代码行数:7,代码来源:Game.cs

示例6: OnKeeperSave

    void OnKeeperSave(Ball ball)
    {
        Rigidbody rigBall = ball.GetComponent<Rigidbody>();

        bool deflect = true;

        if (ball.transform.position.y > 1.5f)
        {
            RpcSetAnimTrigger("StandSave");
        } 
        else if (rigBall.velocity.magnitude > 12)
        {
            RpcSetAnimTrigger("Sliding");
        } 
        else
        {
            RpcSetAnimTrigger("Shooting");
            deflect = false;
        }

        if (deflect)
            rigBall.AddForce(transform.localScale.x * Random.Range(4, 10), Random.Range(2, 5), Random.Range(-10, 10));
        else
            rigBall.AddForce(transform.localScale.x * Random.Range(50, 60), Random.Range(15, 25), Random.Range(-2, 2));

        KickLock = Time.time + 0.2f;
    }
开发者ID:SayAllenthing,项目名称:Soccer-Game,代码行数:27,代码来源:ActorSync.cs

示例7: Start

    // Use this for initialization
    void Start()
    {
        ball = GameObject.FindObjectOfType<Ball>();
        paddle = GameObject.FindObjectOfType<Paddle>();
        life = GameObject.FindObjectOfType<Life>();
        levelManager = GameObject.FindObjectOfType<LevelManager>();
        bonusSprite = gameObject.GetComponent<SpriteRenderer>();
        isVisible = true;

        if (!Brick.destroyMode)
            ball.GetComponent<SpriteRenderer>().color = Color.white;
    }
开发者ID:Qhoros,项目名称:Unity,代码行数:13,代码来源:Bonus.cs

示例8: Awake

    // Use this for initialization
    void Awake()
    {
        //set variables
        manager = this;

        //set object links
        ball = GameObject.Find("Ball").GetComponent<Ball>();
        score = GameObject.Find("Score").GetComponent<Score>();
        backgroundSlider = GameObject.Find("Scripts").GetComponent<BG_Slider> ();
        backgroundSound = GameObject.Find("Scripts").GetComponent<AudioSource>();
        menuUI = GameObject.Find("MenuUI Canvas").GetComponent<MenuUIManager>();
        coinCounterUI = GameObject.Find("CoinCounter").GetComponent<Text> ();

        if(GameObject.Find("AdColonyAdManager") != null) {
            adColonyAdManager = GameObject.Find("AdColonyAdManager").GetComponent<AdColonyManager>();
            adColonyAdManager.setGameManager(manager);
        }

        //Check if scene loaded into from the "store"
        //If coming back from the "Store" TextureSwapData exists, set the ball material to the new picked material
        if (GameObject.Find ("TextureSwapData") != null) {

            TextureSwapData textureData = GameObject.Find ("TextureSwapData").GetComponent<TextureSwapData> ();
            ball.GetComponent<Renderer>().sharedMaterial = textureData.pickedMaterial;
            Destroy (textureData.gameObject);
        }
        else {
            Debug.Log("Loaded into scene from somewhere other than the Store, not swaping ball texture");
        }

        //get reference to the AppManager
        if(GameObject.Find("AppManager") != null){
            appManager = GameObject.Find("AppManager").GetComponent<AppManager>();

            //only loads the saved data the first time called
            if(appManager.gameManagerNeedsUpdating){
                appManager.gameManagerNeedsUpdating = false;

                coinsCollected = appManager.loadedCoins;
                menuUI.setHighScoreOnLoad(appManager.loadedHighScore);
                ball.GetComponent<Renderer>().sharedMaterial = appManager.loadedMaterial;

                CoinUIUpdated();
            }
        }
    }
开发者ID:CovalentGaming,项目名称:Super-Dash,代码行数:47,代码来源:GameManager.cs


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