SendMessageUpwards() public method

public SendMessageUpwards ( string methodName ) : void
methodName string
return void
Example #1
0
 private void Press(Vector2 screenPos)
 {
     lastGo = RaycastObject(screenPos);
     if (lastGo != null)
     {
         lastGo.SendMessageUpwards("OnPress", SendMessageOptions.DontRequireReceiver);
     }
 }
Example #2
0
 void Attack(GameObject go)
 {
     PlayerAI player = go.GetComponent ("PlayerAI") as PlayerAI;
     this.health -= player.strength;
     if (health <= 0.1) {
         go.SendMessageUpwards("killed", this.gameObject);
         Destroy(this.gameObject);
     }
 }
Example #3
0
    void attackObject(GameObject go, Vector3 direction, float distance)
    {
        timeToChangeMoveDirection = changeInterval;
        moveDirection = direction;

        timeBetweenAttacks -= Time.deltaTime;
        if (distance < 1 && timeBetweenAttacks <= 0) {
            timeBetweenAttacks = 1.0f;
            go.SendMessageUpwards ("Attack", this.gameObject);
        }
    }
Example #4
0
 // Update is called once per frame
 void Update()
 {
     if (!Activated) {
         return;
     }
     Ray ray = new Ray(transform.position, transform.right);
     RaycastHit hit;
     if (Physics.Raycast(ray, out hit, maxDistance)) {
         lineRenderer.SetPosition(1, new Vector3(hit.distance, 0, 0));
         Debug.DrawLine(transform.position, hit.point);
         if (currentTarget != hit.collider.gameObject) {
             currentTarget = hit.collider.gameObject;
             currentTarget.SendMessageUpwards("Hit", killTime, SendMessageOptions.DontRequireReceiver);
             if (currentTarget.transform.tag.Equals("Player")) {
                 audioBeamContact.Play();
             }
         }
     }
 }
Example #5
0
		void DoSendMessage(GameObject go)
		{
			switch (delivery)
			{
				case MessageType.SendMessage:

					switch (functionCall.ParameterType)
					{
						case "None":
							go.SendMessage(functionCall.FunctionName, options);
							return;

						case "int":
							go.SendMessage(functionCall.FunctionName, functionCall.IntParameter.Value, options);
							return;

						case "float":
							go.SendMessage(functionCall.FunctionName, functionCall.FloatParameter.Value, options);
							return;

						case "string":
							go.SendMessage(functionCall.FunctionName, functionCall.StringParameter.Value, options);
							return;

						case "GameObject":
							go.SendMessage(functionCall.FunctionName, functionCall.GameObjectParameter.Value, options);
							return;
					
						case "Object":
							go.SendMessage(functionCall.FunctionName, functionCall.ObjectReferenceParameter, options);
							return;
					}
					return;

				case MessageType.SendMessageUpwards:

					switch (functionCall.ParameterType)
					{
						case "None":
							go.SendMessageUpwards(functionCall.FunctionName, options);
							return;

						case "int":
							go.SendMessageUpwards(functionCall.FunctionName, functionCall.IntParameter.Value, options);
							return;

						case "float":
							go.SendMessageUpwards(functionCall.FunctionName, functionCall.FloatParameter.Value, options);
							return;

						case "string":
							go.SendMessageUpwards(functionCall.FunctionName, functionCall.StringParameter.Value, options);
							return;

						case "GameObject":
							go.SendMessage(functionCall.FunctionName, functionCall.GameObjectParameter.Value, options);
							return;
					
						case "Object":
							go.SendMessageUpwards(functionCall.FunctionName, functionCall.ObjectReferenceParameter, options);
							return;
					}
					return;

				case MessageType.BroadcastMessage:

					switch (functionCall.ParameterType)
					{
						case "None":
							go.BroadcastMessage(functionCall.FunctionName, options);
							return;

						case "int":
							go.BroadcastMessage(functionCall.FunctionName, functionCall.IntParameter.Value, options);
							return;

						case "float":
							go.BroadcastMessage(functionCall.FunctionName, functionCall.FloatParameter.Value, options);
							return;

						case "string":
							go.BroadcastMessage(functionCall.FunctionName, functionCall.StringParameter.Value, options);
							return;

						case "GameObject":
							go.SendMessage(functionCall.FunctionName, functionCall.GameObjectParameter.Value, options);
							return;
					
						case "Object":
							go.BroadcastMessage(functionCall.FunctionName, functionCall.ObjectReferenceParameter, options);
							return;
					}
					return;
			}
		}
Example #6
0
    // Update is called once per frame
    void Update()
    {
        //raycast hits object
        fwd = mainCamera.transform.TransformDirection (Vector3.forward);
        if (gazeTarget == null &&
            Physics.Raycast (mainCamera.transform.position, fwd, out hit, 100) &&
            hit.collider.tag == "GazeAware" &&
            hit.collider != GetComponent<Collider>())
        {
            gazeTarget = hit.collider.gameObject;
            gazeTarget.SendMessageUpwards ("LookedAt");
            gazeTarget.SendMessageUpwards ("AttachGazeController", this);

        }
        else if (gazeTarget != null &&
                 Physics.Raycast (mainCamera.transform.position, fwd, out hit, 100) &&
                 hit.collider.gameObject.name == gazeTarget.name)
        {
            gazeTarget.SendMessageUpwards ("LookedAt");
        }
        //		print ("Gazing " + gazeTarget != null);
    }
Example #7
0
 void sendAction(GameObject target)
 {
     Debug.Log (target.name);
     target.SendMessageUpwards ("Interaction");
 }
Example #8
0
 public void BroadcastUpwards(GameObject sender, GameObject receipient)
 {
     Assert.Test(receipient);
     this.sender = sender;
     receipient.SendMessageUpwards(string.Format(format, name), this, requireReceiver ? SendMessageOptions.RequireReceiver : SendMessageOptions.DontRequireReceiver);
 }