本文整理汇总了C#中Transform.SendMessage方法的典型用法代码示例。如果您正苦于以下问题:C# Transform.SendMessage方法的具体用法?C# Transform.SendMessage怎么用?C# Transform.SendMessage使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Transform
的用法示例。
在下文中一共展示了Transform.SendMessage方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CallItemAction
public int CallItemAction(int id, Transform callee) {
int itemSuccess = 0;
switch (id) {
case 0:
hitBehav = callee.GetComponent<HittableBehaviour>();
if (hitBehav == null) {
Debug.LogWarning("Callee does not contain a HittableBehaviour.");
break;
}
if (hitBehav.health < hitBehav.maxHealth) {
hitBehav.AddHealth(10);
itemSuccess = 1;
}
break;
case 1:
hitBehav = callee.GetComponent<HittableBehaviour>();
if (hitBehav == null) {
Debug.LogWarning("Callee does not contain a HittableBehaviour.");
break;
}
if (hitBehav.health < hitBehav.maxHealth) {
hitBehav.AddHealth(50);
itemSuccess = 1;
}
break;
case 2:
BuffInfo speedBuff;
speedBuff.buffType = "Speed";
speedBuff.buffAmount = 5;
callee.SendMessage("ApplyBuff", speedBuff);
itemSuccess = 1;
break;
case 3:
BuffInfo healthBuff;
healthBuff.buffType = "Health";
healthBuff.buffAmount = 10;
callee.SendMessage("ApplyBuff", healthBuff);
itemSuccess = 1;
break;
case 4:
BuffInfo attackBuff;
attackBuff.buffType = "Attack";
attackBuff.buffAmount = 1;
callee.SendMessage("ApplyBuff", attackBuff);
itemSuccess = 1;
break;
default:
break;
}
return itemSuccess;
}
示例2: ResetOrReDefine
void ResetOrReDefine(Transform child)
{
_stopEffectStruct.isReset = this.isReset();
_stopEffectStruct.isReDefine = this.isReDefine();
_stopEffectStruct.hashcode = string.Format("{0:X}", this.GetHashCode());
child.SendMessage("StopRectTo", _stopEffectStruct, SendMessageOptions.DontRequireReceiver);
}
示例3: activeEffect
public override void activeEffect(Transform player)
{
if(player.GetComponent<PlayerController>()) {
if(preDashAction != null)
preDashAction(player);
player.SendMessage("Dash",effectSize);
}
}
示例4: interactLife
void interactLife(string msg, Transform sendWhere)
{
print (msg);
if(playThis_active!=null) playThis_active.Play();
sendWhere.SendMessage(msg,SendMessageOptions.DontRequireReceiver);
startTime = -1;
}
示例5: ActivateItem
void ActivateItem(Transform obj)
{
if (TriggerCooldown) {
OpenNISessionManager.Instance.StartCooldown(CooldownTime);
}
ActiveItem = obj;
obj.SendMessage("Navigator_Activate", SendMessageOptions.DontRequireReceiver);
SendMessage("Navigator_ActivatedItem", obj, SendMessageOptions.DontRequireReceiver);
}
示例6: Update
// Update is called once per frame
void Update () {
Ray ray = cam.ScreenPointToRay (Input.mousePosition);
if (Input.GetMouseButtonDown (0)) {
RaycastHit hit;
// Cast a ray towards the mouse
if (dragEnabled && Physics.Raycast (ray, out hit, Mathf.Infinity)) {
// If the object is tagged as Draggable, set the appropriate variables
if (hit.transform.tag == "Draggable") {
obj = hit.transform;
obj.SendMessage ("Grab");
obj.SendMessage ("toNormalSize");
obj.GetComponent<SpriteRenderer> ().sortingOrder = currentLayerOrder++;
//if(obj.GetComponent<GrabDrop>().isInBin())
draggedObjects.Add (obj.gameObject);
offset = obj.position - ray.origin;
} else if (hit.transform.tag == "Submit") {
hit.transform.SendMessage ("PressSubmit");
currentLayerOrder = 2;
//PrefabManagerObject.SendMessage ("PrintPrefabString");
PrefabManagerObject.SendMessage("DrawPrefab", "3 0.775919 9.273002 1 2.498859 9.150135 0 0.8207381 9.200403 3 4.373325 9.138773 0 4.49859");
//C.SendMessage ("StopMoving");
dragEnabled = false;
}
}
}
// If the mouse is released, drop an object being held
if (Input.GetMouseButtonUp (0)) {
if (obj != null && drop != null) {
drop.pitch = Random.Range(0.5f, 0.8f);
drop.volume = Random.Range(0.7f, 1);
drop.Play ();
}
obj = null;
}
// If there is an object being dragged, move it to the mouse position
if (obj != null) {
Vector3 orig = ray.origin;
obj.position = new Vector3 (orig.x + offset.x, orig.y + offset.y, 0);
}
}
示例7: defaultCollision
protected override void defaultCollision(Transform projectile, Transform target)
{
if(target.GetComponent<GameActor>())
target.SendMessage("Damage",effectSize);
if(target.rigidbody2D != null) {
Vector3 forceDir = target.position - projectile.position;
Vector3 force = forceDir.normalized*effectSize*10;
target.rigidbody2D.AddForce(force);
}
}
示例8: OnTriggerEnter
void OnTriggerEnter(Collider other)
{
if (other.tag == "Enemy")
{
// the "other" gameObject is just an enemy part (like head, body, ...). "Parent" is the real enemy, with all the logic.
parent = other.transform.parent;
parent.SendMessage("bulletHitEnemy", SendMessageOptions.DontRequireReceiver);
Destroy (gameObject);
}
}
示例9: Fight
/*void NewEnemy (Transform enemy){
if(enemy.tag == "Player"){
target=enemy;
}
}*/
void Fight(Transform enemy)
{
if (! isArcher) enemy.SendMessage ("Damage", damage, SendMessageOptions.DontRequireReceiver);
else {
GameObject temp = Instantiate (arrow, transform.position, Quaternion.identity) as GameObject;
//temp.renderer.material.color = new Color(1,0,0);
//temp.transform.SendMessage ("chooseTarget", enemy, SendMessageOptions.DontRequireReceiver);
temp.GetComponent<ArrowControl>().target = enemy;
temp.GetComponent<ArrowControl>().damage = damage;
}
}
示例10: ContinueMouseTouchRaycast
private void ContinueMouseTouchRaycast(int touchIndex, Transform touchedTransform, RaycastHit hit)
{
//RaycastHit hit = new RaycastHit ();
//if (ShootRaycast (out hit))
//{
TouchData data = new TouchData();
data.touchIndex = touchIndex;
data.touchPosition = hit.point;
if (hit.point != oldHitPoint)
touchedTransform.SendMessage ("OnMouseDraggingMoved", data, SendMessageOptions.DontRequireReceiver);
else
touchedTransform.SendMessage ("OnMouseDragging", data, SendMessageOptions.DontRequireReceiver);
//oldHitPoint = hit.point;
/* }
else //If the user drags the mouse into empty space.
{
touchedTransform.SendMessage ("OnMouseDraggedOff", SendMessageOptions.DontRequireReceiver);
}
*/
oldHitPoint = hit.point;
}
示例11: DoSetup
public void DoSetup(GameRunningState state)
{
firstPhase = (Phase)Instantiate(state.firstPhase);
Debug.Log("Created firstPhase: " + firstPhase.name);
mourning = (Phase)Instantiate(state.mourning);
thePlayer = (PlayerController)Instantiate(state.player);
level = (Transform)Instantiate(state.level);
level.SendMessage("Setup");
messageGUI = (MessageGUI)Instantiate(state.messageGUI);
scoreGUI = (ScoreGUI)Instantiate(state.scoreGUI);
spawner = level.GetComponent<Spawner>();
currentPhase = firstPhase;
ChangePhase(firstPhase);
}
示例12: CharacterShoot
public void CharacterShoot()
{
if (GameManager.Instance._shurikenLaunched == false)
{
AudioManager.audioInstance.PlaySound("ShurikenRelease");
GameManager.Instance._shurikenLaunched = true;
Vector2 character2DPosition = new Vector2(transform.position.x, transform.position.y);
Vector3 mousePosition3D = Camera.main.ScreenToWorldPoint(Input.mousePosition);
Vector2 mousePosition2D = new Vector2(mousePosition3D.x, mousePosition3D.y);
Vector2 shurikenDirection = mousePosition2D - character2DPosition;
shurikenDirection.Normalize();
if (shurikenDirection.x < 0.0f)
{
transform.localScale = new Vector3(-1, 1, 1);
} else
{
transform.localScale = new Vector3(1, 1, 1);
}
ResetParameters();
_characterAnimator.SetBool("Shoot", true);
_thrownShuriken = Instantiate(shurikenPrefab, _shurikenSpawnPoint.position, Quaternion.identity) as Transform;
_thrownShuriken.name = "Shuriken";
_thrownShuriken.SendMessage("SetupShot", shurikenDirection, SendMessageOptions.DontRequireReceiver);
CharacterFollow.characterFollowInstance.ChangeTargetToShuriken();
//currentCharacterState = CharacterState.Shoot;
_isShurikenThrown = true;
}
}
示例13: AttackTarget
public void AttackTarget(Transform tankTurret, Transform target)
{
Vector3 forward = tankTurret.transform.TransformDirection(Vector3.forward);
// we need to make sure that the turret angle is good enough
Vector3 targetDir = target.position - tankTurret.transform.position;
// We are close enough to the target
if (Vector3.Distance(transform.position, target.position) < range) {
// The turret angle is close enough
if (Vector3.Angle(forward, targetDir) < SHOOT_ANGLE_DISTANCE) {
if (Time.time > GetNextFireTime()) {
SetNextFireTime(Time.time + fireRate);
//target.networkView.RPC("ApplyDamage", target.networkView.owner, target.networkView.viewID, damage);
target.SendMessage("ApplyDamage", damage, SendMessageOptions.DontRequireReceiver);
Debug.DrawLine(transform.position, target.position);
}
}
}
}
示例14: Attack
IEnumerator Attack(Transform victim)
{
sleeping = false;
_busy = true;
target = victim;
_attack.enabled = true;
_attack.time = 0;
_attack.weight = 1;
//Wait for half way through the animation
yield return StartCoroutine(WaitForAnimation(_attack, 0.5f));
//Check if still in range
if(victim && (victim.position - _transform.position).sqrMagnitude < _maximumAttackEffectRangeSquared)
{
//Apply the damage
victim.SendMessage("TakeDamage", 1 + Random.value * 5, SendMessageOptions.DontRequireReceiver);
}
//Wait for the end of the animation
yield return StartCoroutine(WaitForAnimation(_attack, 1f));
_attack.weight = 0;
_busy = false;
}
示例15: doDamage
void doDamage(Transform enemy)
{
enemy.SendMessage("Damage",damage,SendMessageOptions.DontRequireReceiver);
float rand = Random.Range (0, 3F);
if (rand < 1) {
randsound=Sound1;
}
if (rand <= 2 && rand >=1) {
randsound=Sound2;
}
if (rand > 2) {
randsound=Sound3;
}
exist = false;
//audio.clip = randsound;
//audio.Play ((ulong)randsound.length);
//Destroy (gameObject);
StartCoroutine( DestroyMe (randsound));
}