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


C# Transform.SendMessage方法代码示例

本文整理汇总了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;
 }
开发者ID:jakedeichert,项目名称:ggj2016,代码行数:51,代码来源:ItemDispatcher.cs

示例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);
 }
开发者ID:joeytsao,项目名称:Game_JIC,代码行数:7,代码来源:MUI_LayoutMoveTo.cs

示例3: activeEffect

 public override void activeEffect(Transform player)
 {
     if(player.GetComponent<PlayerController>()) {
         if(preDashAction != null)
             preDashAction(player);
         player.SendMessage("Dash",effectSize);
     }
 }
开发者ID:EternalGB,项目名称:platforming-combat-roguelike,代码行数:8,代码来源:Dash.cs

示例4: interactLife

    void interactLife(string msg, Transform sendWhere)
    {
        print (msg);
        if(playThis_active!=null) playThis_active.Play();

        sendWhere.SendMessage(msg,SendMessageOptions.DontRequireReceiver);
        startTime = -1;
    }
开发者ID:yenv672,项目名称:thesis,代码行数:8,代码来源:look_action.cs

示例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);
 }
开发者ID:CodeStrumpet,项目名称:anticlockwise-experiments,代码行数:9,代码来源:Navigator.cs

示例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);
		}

	}
开发者ID:dustinbayer,项目名称:FactoryWorker,代码行数:45,代码来源:DragObjects.cs

示例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);
     }
 }
开发者ID:EternalGB,项目名称:platforming-combat-roguelike,代码行数:10,代码来源:GrenadeToss.cs

示例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);
     }
 }
开发者ID:marcocuccu,项目名称:Defence,代码行数:10,代码来源:BulletLogic.cs

示例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;
     }
 }
开发者ID:GullinBustin,项目名称:UnityTutorial,代码行数:16,代码来源:CruzadoControler.cs

示例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;
    }
开发者ID:WondermSwift,项目名称:unity_moba_sandbox,代码行数:22,代码来源:RaycastMouseBetter.cs

示例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);
 }
开发者ID:iamseb,项目名称:RGJ05LoveWars,代码行数:14,代码来源:MissionManager.cs

示例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;
        }
    }
开发者ID:kishoreven1729,项目名称:ShurikenUnity,代码行数:41,代码来源:CharacterControl.cs

示例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);
                }
            }
        }
    }
开发者ID:mjparinas,项目名称:MTG,代码行数:21,代码来源:TowerController.cs

示例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;
 }
开发者ID:Drewbie,项目名称:Homeworld,代码行数:21,代码来源:MovementStateMachine3.cs

示例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));
    }
开发者ID:GullinBustin,项目名称:UnityTutorial,代码行数:21,代码来源:ArrowControl.cs


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