本文整理汇总了C#中Collider.GetInstanceID方法的典型用法代码示例。如果您正苦于以下问题:C# Collider.GetInstanceID方法的具体用法?C# Collider.GetInstanceID怎么用?C# Collider.GetInstanceID使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Collider
的用法示例。
在下文中一共展示了Collider.GetInstanceID方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnTriggerExit
//upon exiting the collision status
void OnTriggerExit(Collider col)
{
char side;
collisionSides.TryGetValue (col.GetInstanceID (), out side);
collisionSides.Remove (col.GetInstanceID ());
if(side == 'r')
Collision_Right = false;
if(side == 'l')
Collision_Left = false;
if(side == 'u')
Collision_Up = false;
if(side == 'd')
Collision_Down = false;
if (col.gameObject.tag == "floor")
{
// if(maxDiff.z >= 0)
Collision_Below = false;
}
//Debug.Log ("collision exit");
}
示例2: OnTriggerEnter
//our ball has landed in the water, lets call the ball bowling pit
void OnTriggerEnter(Collider col)
{
PoolBall pb = col.GetComponent<PoolBall>();
if (col.CompareTag("Ball"))
{
GameManager.Rules.PotBall(pb, m_RefTrigger.PocketIndex);
Pools.StorageRack.Add(pb);
if (PocketTrigger.pocketTriggerBallList.Contains(col.GetInstanceID()))
PocketTrigger.pocketTriggerBallList.Remove(col.GetInstanceID());
}
}
示例3: OnTriggerEnter
public void OnTriggerEnter(Collider collider)
{
if (collider.tag.Equals("Enemy") && tag.Equals("Player Atk"))
{
if (!m_targetDatas.ContainsKey(collider.GetInstanceID()))
m_targetDatas.Add(collider.GetInstanceID(), collider.GetComponent<BaseData>());
}
else if (collider.tag.Equals("Player") && tag.Equals("Enemy Atk"))
{
if (!m_targetDatas.ContainsKey(collider.GetInstanceID()))
m_targetDatas.Add(collider.GetInstanceID(), PlayerData.GetInstance());
}
}
示例4: OnTriggerStay
void OnTriggerStay(Collider other)
{
if (other.GetInstanceID() == Pinky.GetComponent<Collider>().GetInstanceID())
{
target.position = Pinky.position;
}
}
示例5: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if(other.transform.CompareTag("Planet")){
/* If the planet has been already destroyed do nothing. */
if(((PlanetScript) other.GetComponent("PlanetScript")).isDestroyed())
return;
/* Set the status of the planet to 0 => Planet destroyed. */
((PlanetScript) other.GetComponent("PlanetScript")).setDestroyed();
/* Update the score. */
GameObject.Find("Controller").GetComponent<ControllerScript>().updateScore(-other.rigidbody.mass
* other.GetComponent<PlanetScript>().getPlanetPoints());
foreach(GameObject star in GameObject.FindGameObjectsWithTag("Star")){
star.GetComponent<StarScript>().removeOrbitantPlanet(other.GetInstanceID());
star.GetComponent<StarScript>().updateMultiplier();
}
Debug.Log("Score:" + GameObject.Find("Controller").GetComponent<ControllerScript>().getScore());
/* Get the Detonator script component */
Detonator det = (Detonator) other.GetComponent("Detonator");
/* Call Explode method defined in Detonator script. Simply show an explosion. */
det.Explode();
/* Play an explosion sound. */
other.GetComponent<AudioSource>().Play();
/*Adds the planet mass to the star mass*/
rigidbody.mass += other.rigidbody.mass;
/* Destroy the rigidboy of the collided planet. In this way it is no more subject to forces
and has no speed. */
Destroy(other.rigidbody);
/* Hide the collided planet. */
other.transform.position = transform.position;
/* Destroy the game object of the planet. */
Destroy(other.gameObject, 3);
}
}
示例6: OnTriggerStay
public void OnTriggerStay(Collider collider)
{
int id = collider.GetInstanceID();
if (m_targetDatas.ContainsKey(id))
{
m_targetDatas[id].Damaged(fireAtk * Time.deltaTime);
}
}
示例7: Broadcast
protected virtual IEnumerator Broadcast(Collider other)
{
while (other)
{
Messenger.Broadcast(m_message.ToLower() + other.GetInstanceID(), other.name);
yield return new WaitForSeconds(m_timer);
}
}
示例8: OnTriggerExit
public void OnTriggerExit(Collider collider)
{
int id = collider.GetInstanceID();
if (m_targetDatas.ContainsKey(id))
{
m_targetDatas.Remove(id);
}
}
示例9: OnTriggerEnter
void OnTriggerEnter(Collider other) {
touchBendingPlayerListener tempPlayerVars = other.GetComponent<touchBendingPlayerListener>();
// register touch only if collider has the touchBendingPlayerListener script attached and enabled
if( tempPlayerVars != null && tempPlayerVars.enabled) {
// no other touch event registered
if (!touched) {
//register gameobject ID
Player_ID = other.GetInstanceID();
Destroy(myRenderer.material);
PlayerVars = tempPlayerVars;
Player_Direction = PlayerVars.Player_Direction;
Player_Speed = PlayerVars.Player_Speed;
intialTouchForce = Player_Speed;
// instantiate mat
myRenderer.material = touchBendingMaterial;
myRenderer.material.SetVector("_TouchBendingPosition", new Vector4(myTransform.position.x, myTransform.position.y, myTransform.position.z, 0f) );
axis = PlayerVars.Player_Direction;
// rotate by 90
axis = Quaternion.Euler(0,90,0) * axis;
timer = 0.0f;
touched = true;
left = false;
targetTouchBending = 1.0f;
touchBending = targetTouchBending;
finished = false;
}
else {
/// 2nd+ touch: we simply drop the first registered collision
if ( doubletouched == true ) {
SwapTouchBending ();
}
//register gameobject ID
Player1_ID = other.GetInstanceID();
PlayerVars1 = tempPlayerVars;
Player_Direction1 = PlayerVars1.Player_Direction;
Player_Speed1 = PlayerVars1.Player_Speed;
intialTouchForce1 = Player_Speed1;
axis1 = Player_Direction1;
// rotate by 90
axis1 = Quaternion.Euler(0,90,0) * axis1;
timer1 = 0.0f;
left1 = false;
targetTouchBending1 = 1.0f;
touchBending1 = targetTouchBending1;
finished1 = false;
lerptime = duration - timer;
doubletouched = true;
}
}
}
示例10: OnTriggerEnter
void OnTriggerEnter(Collider col)
{
if ((mask.value & 1 << col.gameObject.layer) == 1 << col.gameObject.layer)
{
GameObject toAdd = CreateEffect(col.transform);
toAdd.transform.SetParent(col.transform);
toAdd.transform.localRotation = Quaternion.Euler(new Vector3(90f, 0f, 0f));
effects.Add(col.GetInstanceID(), toAdd);
}
}
示例11: OnTriggerEnter
void OnTriggerEnter(Collider mob)
{
if (mob.gameObject.CompareTag("Creep"))
{
for (int i = 0; i < 100; i++)
{
if (targetStack[i] != null && targetStack[i].GetInstanceID() == mob.GetInstanceID()) return;
}
StackPush(mob.gameObject);
}
}
示例12: OnTriggerEnter
protected override void OnTriggerEnter(Collider other)
{
var direction = other.transform.position - transform.position;
var ray = new Ray(transform.position, direction);
RaycastHit firstRayHit;
if (TriggerEntered != null && Physics.Raycast(ray, out firstRayHit) && firstRayHit.collider.GetInstanceID() == other.GetInstanceID())
{
Debug.Log("firstRayHit.collider: " + firstRayHit.collider + "other.collider: " + other);
TriggerEntered(other.gameObject);
}
}
示例13: OnTriggerStay
void OnTriggerStay(Collider csi)
{
int id=csi.GetInstanceID();
//if(id!=this.GetInstanceID())
{
DefBoxCtl dbc=csi.GetComponent<DefBoxCtl>();
Vector3 v3=(transform.parent.localPosition-csi.transform.parent.localPosition);
dbc.f.CombineF(-v3.normalized*10f);
// Debug.Log(csi.name);
}
}
示例14: AOE
protected void AOE(Collider collider)
{
int id = collider.GetInstanceID();
if (!m_targets.ContainsKey(id))
{
BaseData data = collider.GetComponent<BaseData>();
if (data != null)
m_targets.Add(collider.GetInstanceID(), data);
else
{
Debug.LogError("BaseData is not found!");
}
}
if (m_targets[id].curLife > 0)
{
m_targets[id].Damaged((atk + PlayerData.GetInstance().GetAttributeValue(fuckRPGLib.GameCode.BasicAttributeName.Intelligence) * 5) * Time.deltaTime);
if (m_targets[id].curLife <= 0)
{
PlayerData.GetInstance().GainExp(m_targets[id].valueExp);
PlayerData.GetInstance().gold += m_targets[id].valueGold;
}
}
}
示例15: OnTriggerExit
void OnTriggerExit(Collider col)
{
if ((mask.value & 1 << col.gameObject.layer) == 1 << col.gameObject.layer)
{
int id = col.GetInstanceID();
if (effects.ContainsKey(id))
{
GameObject toRemove = effects[id];
effects.Remove(id);
Destroy(toRemove);
}
}
}