本文整理汇总了C#中BoxCollider.GetComponent方法的典型用法代码示例。如果您正苦于以下问题:C# BoxCollider.GetComponent方法的具体用法?C# BoxCollider.GetComponent怎么用?C# BoxCollider.GetComponent使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类BoxCollider
的用法示例。
在下文中一共展示了BoxCollider.GetComponent方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Setup
protected virtual void Setup()
{
controller = new Controller(this);
t = transform;
rb = rigidbody;
go = gameObject;
sprite = GetComponentInChildren<tk2dSprite>();
anim = GetComponentInChildren<tk2dSpriteAnimator>();
bc = GetComponent<BoxCollider>();
name = name + gameObject.GetInstanceID();
botDetector = GameObject.Find(name + "/downDetector").GetComponent<BoxCollider>();
leftDetector = GameObject.Find(name + "/leftDetector").GetComponent<BoxCollider>();
rightDetector = GameObject.Find(name + "/rightDetector").GetComponent<BoxCollider>();
topDetector = GameObject.Find(name + "/topDetector").GetComponent<BoxCollider>();
botDScript = botDetector.GetComponent<FitzDetectBox>();
leftDScript = leftDetector.GetComponent<FitzDetectBox>();
rightDScript = rightDetector.GetComponent<FitzDetectBox>();
topDScript = topDetector.GetComponent<FitzDetectBox>();
Debug.Log ("My right detector is " + rightDetector.gameObject.GetInstanceID());
dummy = GameObject.Find(name + "/dummy");
bc.size = new Vector3(sprite.CurrentSprite.colliderVertices[1].x * 2, sprite.CurrentSprite.colliderVertices[1].y * 2, 10);
Debug.Log ("Fitting detectors for " + gameObject.GetInstanceID());
FitDetectors();
}
示例2: DetectorEnter
public override void DetectorEnter(BoxCollider detector, BoxCollider colEntering)
{
base.DetectorEnter (detector, colEntering);
Doc docScript = colEntering.GetComponent<Doc>();
if (docScript){ //what happens when what I hit is Doc?
if(currentMotor == mondo){ //Am I mario or what
if (velocity.y > 0 && docScript.Dangerous){
Debug.Log("Get hurt!");
}
else if (detector == botDetector && docScript.JumpedOn(controller.getRun) && velocity.y < 0){ //where did I hit? Do I jump? If I jump, do I rebound (JumpedOn gives me this result; see Doc.cs)
velocity = new Vector2(velocity.x, controller.getJump? mondo.jExtraHeight : mondo.jHeight);
}
else if ((detector == rightDetector || detector == leftDetector)){
if (docScript.Dangerous){ //should the shell hurt me?
Debug.Log("Get hurt!");
Dying = true;
}
else if (!controller.getRun){ //should I kick the shell?
docScript.Kicked();
pMeter = 0;
velocity = new Vector2(0, velocity.y);
}
else { //or I guess I should hold on to it
ballHolding = docScript.transform;
docScript.Held = true;
Debug.Log("Hold that ball");
}
}
else if (!docScript.Dangerous && controller.getRun){
ballHolding = docScript.transform;
docScript.Held = true;
Debug.Log("Holding ball now");
}
}
else if (currentMotor == pinky){
//TODO : hurt Doc; he always gets hurt if I touch him, unless I'm spitting him out.
if ((detector == topDetector || detector == botDetector) && !meteor){
//TODO: Hurt self because I'm not going fast enough to be a weapon
Dying = true;
return;
}
if (((detector == rightDetector && FacingRight) || (detector == leftDetector && !FacingRight)) && agape){
docScript.Inhaled();
mouthFull = true;
inMouth = docScript.gameObject;
agape = false;
anim.Play(PinkyIdle);
}
}
} //end if docscript
else if (detector == botDetector){
Checkpoint checkScript = colEntering.GetComponent<Checkpoint>();
if (checkScript != null){
checkScript.Enter ();
Debug.Log ("There's a checkpoint script.");
}
}
else if (detector == topDetector && currentMotor == mondo){
BrickBlock brickScript = colEntering.GetComponent<BrickBlock>();
if (brickScript){
brickScript.SendMessage("Explode");
}
}
if (colEntering.gameObject.layer == LayerMask.NameToLayer("normalCollision") && (detector == leftDetector || detector == rightDetector) && charging){
EndCharge ();
}
int layer = colEntering.gameObject.layer;
if (layer == 31 && colEntering.tag == "spike"){
Debug.Log ("OUCH");
Dying = true;
}
}