本文整理汇总了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;
}
示例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;
}
示例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;
}
示例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;
}
示例5: SwitchBalls
public void SwitchBalls(int targetIndex)
{
BallPrefab = Prefabs[targetIndex];
foreach(var ball in FindObjectsOfType<Ball>()) {
ball.GetComponent<MeshRenderer>().material = BallPrefab.GetComponent<Renderer>().sharedMaterial;
}
}
示例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;
}
示例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;
}
示例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();
}
}
}