SendMessage() public method

public SendMessage ( string methodName ) : void
methodName string
return void
    void Update()
    {
        curTime += Time.deltaTime;
        if(curTime > destroyTime){
            Object.Destroy(gameObject);
        }

        Collider[] enemyArray =	Physics.OverlapSphere(transform.position, radius, mask);

        if(enemyArray.Length > 0) {
            for(int i = 0; i < enemyArray.Length; i++) {
                targetEnemy = enemyArray[i].gameObject;

                if(targetEnemy.transform.name.IndexOf("Enemy_Car") != -1) {
                    targetEnemy.SendMessage("InfectCollision", 100);
                }
                else {
                    targetEnemy.SendMessage("BulletCollision", bulletDamage);
                }

                GameObject instance = Instantiate(explosion, transform.position, transform.rotation) as GameObject;
                //instance.SendMessage("igniteFire");
                //if(instance.rigidbody){
                //	instance.SendMessage("igniteFire");
                //}

                Object.Destroy(gameObject);
            }
        }
    }
	public static void DeliverMessages(GameObject hitObject, ref GameObject [] tgtList, string m, string sp, float fp, string tgFltr, bool msgBmp)
	{
		foreach(GameObject o in tgtList)
		{
			if(o.tag == tgFltr || tgFltr == "")
			{
				Debug.Log (" DELIVERING MESSAGE!!");

				if(sp != null)
					o.SendMessage(m,sp,SendMessageOptions.DontRequireReceiver);

				if(fp != null)
					o.SendMessage(m,fp,SendMessageOptions.DontRequireReceiver);
			}
		}
		
		if(msgBmp)
		{
			if(hitObject.tag == tgFltr || tgFltr == "")
			{
				Debug.Log (" DELIVERING MESSAGE!!");

				if(sp != null)
					hitObject.SendMessage(m,sp,SendMessageOptions.DontRequireReceiver);
				
				if(fp != null)
					hitObject.SendMessage(m,fp,SendMessageOptions.DontRequireReceiver);
			}
		}
	}
Example #3
0
    void Update()
    {
        if (Input.touchCount > 0)
        {
            ray = Camera.main.ScreenPointToRay(Input.GetTouch(0).position);

                touchPos = ray.origin;
                if (Physics.Raycast(ray, out rHit, 100, enemyMask))
                {
                    reciever = rHit.collider.gameObject;
                    switch (Input.GetTouch(0).phase)
                    {
                        case TouchPhase.Began:
                            reciever.SendMessage("touchStart", SendMessageOptions.DontRequireReceiver);
                            break;
                        case TouchPhase.Ended:
                            reciever.SendMessage("touchUp", SendMessageOptions.DontRequireReceiver);
                            break;
                        case TouchPhase.Canceled:
                            reciever.SendMessage("touchExit", SendMessageOptions.DontRequireReceiver);
                            break;
                    }
                    Debug.Log("raycast hit with enemy");
                    Debug.DrawRay(ray.origin, ray.direction);
                }

        }
    }
 void Fire()
 {
     TempBall = Instantiate(Ball, transform.Find("Barrel").transform.position, transform.rotation) as GameObject;
     TempBall.transform.parent = transform;
     TempBall.SendMessage("SetLifeSpan", LifeSpan);
     TempBall.SendMessage("SetBallSpeed", BallSpeed);
     TempBall.SendMessage("SetLeft", Left);
     TempBall.SendMessage("SetBounce", BounceHeight);
     switch (SpeedCase)
     {
         case 0:
             {
                 BroadcastMessage("SetTime", 4);
                 break;
             }
         case 1:
             {
                 BroadcastMessage("SetTime", 1);
                 break;
             }
         case 2:
             {
                 BroadcastMessage("SetTime", 2);
                 break;
             }
         case 3:
             {
                 BroadcastMessage("SetTime", 3);
                 break;
             }
     }
 }
Example #5
0
    IEnumerator DropItem(GameObject character)
    {
        character.SendMessage("Freeze", true);

        character.SendMessage("Freeze", false);
        yield return null;
    }
Example #6
0
	// Use this for initialization
	void Start ()
    {
        // Create gravity field and gravity effect
        gravityField_ = Instantiate(Resources.Load("GravityField")) as GameObject;
        inGravityEffect_ = Instantiate(Resources.Load(tag + "InGravityEffect")) as GameObject;
        outGravityEffect_ = Instantiate(Resources.Load(tag + "OutGravityEffect")) as GameObject;

        inGravityEffect_.transform.position = gameObject.transform.position;
        inGravityEffect_.transform.parent = gameObject.transform;
        outGravityEffect_.transform.position = gameObject.transform.position;
        outGravityEffect_.transform.parent = gameObject.transform;

        // Get a game Controller
        gameController_ = GameObject.FindGameObjectWithTag("GameController");

        if (forceDirection_ < 0.0f)
        {
            inGravityEffect_.SendMessage("Play");
            outGravityEffect_.SendMessage("Stop");
        }
        else
        {
            inGravityEffect_.SendMessage("Stop");
            outGravityEffect_.SendMessage("Play");
        }

        inGravityForthEffect_ = Instantiate(Resources.Load("GravityInForthAnimation")) as GameObject;
        outGravityForthEffect_ = Instantiate(Resources.Load("GravityOutForthAnimation")) as GameObject;

        inGravityForthEffect_.transform.parent = gravityField_.transform;
        inGravityForthEffect_.transform.position = gravityField_.transform.position;
        outGravityForthEffect_.transform.parent = gravityField_.transform;
        outGravityForthEffect_.transform.position = gravityField_.transform.position;
    }
    // Use this for initialization
    void Start()
    {
        stageManager = GameObject.Find ("StageManager");

        stageManager.SendMessage ("EnemySetUp");
        stageManager.SendMessage ("StageSetUp");
    }
Example #8
0
    IEnumerator GrabItem(GameObject character)
    {
        character.SendMessage("Freeze", true);
        transform.parent = character.transform;

        character.SendMessage("Freeze", false);
        yield return null;
    }
	// Use this for initialization
	void Start () {
        //Instantiate a self-propelled lazer shot at the turret's position
        lazerTemp = Instantiate(lazerObject, Vector3.zero, Quaternion.identity) as GameObject;
        //Set the range the missile can travel before being destroyed
        lazerTemp.SendMessage("SetRange", range);
        //Send this gameObject to the missile for sending back successful hits to the player firing the shot
        lazerTemp.SendMessage("SetPlayer", player);
        spawnPosition = Vector3.zero;
	}
Example #10
0
 void OnMouseDown()
 {
     if(GUIUtility.hotControl == 0){
             GameObject g = new GameObject();
             g.AddComponent<GUI_DetalleStory>();
             g.SendMessage("setUserStory", cubous.getUS());
             g.SendMessage("Mostrar");
         }
 }
Example #11
0
    void doTaskDetailWindow(int windowID)
    {
        GUIComponents.labelDetail(new Rect(20,30,310,20),"Tarea: ",t.getTitulo());
        GUI.contentColor = Color.yellow;
        GUI.Label(new Rect(20,55,310,20),"Descripción:");
        int offset = 18*((int)(t.getDescripcion().Length/50)+1);
        if (offset > 53){
            offset = 53;
        }
        GUI.contentColor = Color.white;
        GUI.Label(new Rect(40,75,290,offset),t.getDescripcion());
        GUIComponents.labelDetail(new Rect(20,80+offset,310,20),"Responsable: ",t.getResponsable());
        GUIComponents.labelDetail(new Rect(20,105+offset,310,20),"Tiempo estimado: ",t.getT_Estimado().ToString());
        GUIComponents.labelDetail(new Rect(20,130+offset,310,20),"Tiempo restante: ",(t.getT_Estimado()-t.getT_Total()).ToString());
        GUIComponents.labelDetail(new Rect(20,155+offset,310,20),"Tiempo total: ",t.getT_Total().ToString());
        GUIComponents.labelDetail(new Rect(20,180+offset,310,20),"Prioridad: ",t.getPrioridad().ToString());
        GUIComponents.labelDetail(new Rect(20,205+offset,310,20),"Estado: ",t.getEstado());

        if (t.getEstado ().Equals ("ON TEST"))
                if (GUI.Button (new Rect (maxWidth / 2 - 90, 235 + offset, 185, 20), "Administrar Tests")) {
                        if (Application.isWebPlayer) {
                                GameObject g = new GameObject ();
                                UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent (g, "Assets/Game/Scripts/ScriptsPanelesVS/GUI_DetalleTarea.cs (69,9)", "GUI_Mensaje");
                                g.SendMessage ("setMensaje", "Esta funcionalidad no esta disponible en la version Web");
                                g.SendMessage ("setAnterior", this);
                                g.SendMessage ("Mostrar");
                                openWindow = false;
                        } else {
                                offset += 30;
                                GameObject g = new GameObject ();
                                UnityEngineInternal.APIUpdaterRuntimeServices.AddComponent (g, "Assets/Game/Scripts/ScriptsPanelesVS/GUI_DetalleTarea.cs (77,9)", "GUI_Testing");
                                g.SendMessage ("setTask", t);
                                g.SendMessage ("setAnterior", this);
                                g.SendMessage ("Mostrar");
                                openWindow = false;
                        }
                }
        puntos=GUIComponents.labelTextField(new Rect(20,maxHeight-60,120,20),puntos,"Story Points: ",30);

        //GUIComponents.labelTextField(new Rect(20,225+offset,310,20)," ","Cargar Puntos :",4);

        if (GUI.Button(new Rect (maxWidth / 2 - 130, maxHeight - 30, 100, 20),"Cargar Puntos")){
            t.setT_Total(t.getT_Total()+System.Convert.ToInt32(puntos));
            MultiPlayer.Instance.cambiarTTotalTask(t);
        }

        if (GUI.Button (new Rect (maxWidth/2+20,maxHeight-30,110,20), "Cerrar")) {
            openWindow = false;
            try {
                this.ant.Mostrar ();
                Destroy (this);
            } catch {
                Debug.Log ("No tiene anterior porque viene del taskboard");
            }
        }
    }
Example #12
0
	IEnumerator slowDown(GameObject go) {

		go.SendMessage ("SlowDown", gameObject);
		changeColor (new Color(.5f, .5f, 1f), go.transform);
		while (true) {
			yield return new WaitForSeconds (1f);
			go.SendMessage ("UnSlowDown", gameObject);
			changeColor (Color.white, go.transform);
			Destroy (gameObject);
		}
	}
	IEnumerator HoldPlayer(GameObject player){
		player.SendMessage("Freeze");
		player.SendMessage("BubbleCatch");
		FindObjectOfType<ScreenShake> ().jiggleCam (0.1f, 2f);
		FindObjectOfType<LauncherLogic>().PauseLauncher();
		FindObjectOfType<BeatMatcher> ().TriggerInXBeats (this, 4);
		while (true) {
			yield return new WaitForEndOfFrame();
			player.transform.position = transform.position;
		}
	}
    private void NpcStopped(GameObject npc)
    {
        npcIsWaitingForFood = true;
        firstInLine = npc;

        npc.GetComponent<SoundCheck>().State = 1;
        npc.SendMessage("MoveChanged", false, SendMessageOptions.RequireReceiver);
        npc.SendMessage("ShowSpeechBubble", true, SendMessageOptions.RequireReceiver);
        soundManager.SendMessage("TriggerGuiSound", GuiSoundMode.SPEEECHBUBBLE, SendMessageOptions.RequireReceiver);
        npc.SendMessage("TriggerSound",SendMessageOptions.RequireReceiver);
        StartCoroutine(WaitForChitChat());
    }
    private void Send(GameObject go, string functionName, object obj = null)
    {
        if (go == null) return;
        if (string.IsNullOrEmpty(functionName)) return;

        if (obj != null)
        {
            go.SendMessage(functionName, obj);
        }
        else
        {
            go.SendMessage(functionName);
        }
    }
Example #16
0
 void OnInstantiatedSonarPoint(GameObject target)
 {
     // すでにソナー内にいるかチェックする
     Vector3 pos = new Vector3(transform.position.x, 0.0f, transform.position.z);
     Vector3 target_pos = new Vector3( target.transform.position.x, 0.0f, target.transform.position.z );
     float dist = Vector3.Distance(pos, target_pos);
     Debug.Log("OnInstantiatedSonarPoint[" + target.transform.parent.gameObject.name + "]: dist=" + dist + ", radius=" + radius);
     if (dist <= radius)
     {
         target.SendMessage("OnSonarInside");
     }
     else {
         target.SendMessage("OnSonarOutside");
     }
 }
Example #17
0
    private IEnumerator BeginPullingObject(GameObject other)
    {
        other.SendMessage("HaltGravity", SendMessageOptions.DontRequireReceiver);
        while (Vector3.Distance(casterTransform.position, other.transform.position) > 1f)
        {
            Vector3 towardsDirection = other.transform.position - casterTransform.position;
            other.transform.position -= towardsDirection.normalized * grappleSpeed * Time.deltaTime;
            this.transform.position = other.transform.position + casterVerticalOffset;
            yield return null;
        }
        other.SendMessage("ResumeGravity", SendMessageOptions.DontRequireReceiver);

        Destroy(this.gameObject);
        yield break;
    }
Example #18
0
 void Update()
 {
     RaycastHit hit;
     Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
     if (Physics.Raycast(ray, out hit))
     {
         if (hit.transform.tag == "Agent" && Input.GetMouseButtonDown(0))
         {
             selectedUnit = hit.transform.gameObject;
             if (selectedUnits.Contains(selectedUnit))
             {
                 selectedUnit.SendMessage("Deselect", 1);
                 selectedUnits.Remove(selectedUnit);
             }
             else
             {
                 selectedUnit.SendMessage("Select", 1);
                 selectedUnits.Add(selectedUnit);
             }
         }
         else if (Input.GetMouseButtonDown(0))
         {
             if (Time.time - lastClickTime < catchTime)
             {
                 //double click
                 foreach (GameObject g in selectedUnits)
                 {
                     g.SendMessage("DoubleClick", 1);
                 }
             }
             lastClickTime = Time.time;
             foreach (GameObject g in selectedUnits)
             {
                 g.SendMessage("Destination", hit.point);
             }
         }
         /*
         if (hit.transform.tag == "Ground" && Input.GetMouseButtonDown(0))
         {
             foreach (GameObject g in selectedUnits)
             {
                 g.SendMessage("Deselect", 1);
             }
             selectedUnits.Clear();
         }
         */
     }
 }
    // Update is called once per frame
    void Update()
    {
        Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;
        if (Physics.Raycast(ray, out hit))
        {
            if (currentHit != hit.transform.gameObject)
            {

                if (currentHit != null)
                {
                    currentHit.SendMessage("UnPointed", SendMessageOptions.DontRequireReceiver);
                }

                currentHit = hit.transform.gameObject;
                currentHit.SendMessage("Pointed", SendMessageOptions.DontRequireReceiver);

            }

            Debug.DrawLine(ray.origin, hit.point);
        } else {
            if (currentHit != null)
            {
                currentHit.SendMessage("UnPointed", SendMessageOptions.DontRequireReceiver);
                currentHit = null;
            }

        }
    }
    // Use this for initialization
    void Start()
    {
        redshirt = GameObject.Find ("R-SHIRT");
        blueshirt = GameObject.Find ("B-SHIRT");

        Collider[] thingsHit = Physics.OverlapSphere (transform.position, radius);
        foreach (Collider other in thingsHit) {
            if (other.CompareTag ("Player") || other.CompareTag ("Player 2")) {
                float dist = Vector3.Distance (transform.position, other.transform.position);
                float percent = radius / dist;
                waterScore = percent * waterAmount;
                //print(waterScore);
                other.gameObject.SendMessage("getWet", waterScore);
                other.gameObject.SendMessage("GotHit");

                    if (other.CompareTag ("Player 2") && other.GetComponent<BP1Mov>().bubbleshield == false){
                        redshirt.SendMessage("Hit", waterScore);
                    }

                    if (other.CompareTag ("Player") && other.GetComponent<BP1Mov>().bubbleshield == false){
                        blueshirt.SendMessage("Hit", waterScore);
                    }

            }
        }
    }
 private void AlterHealth(GameObject go)
 {
     float multiplier = GetComponent<ParticleSystemMultiplier>().multiplier;
     short damage = (short)((range * multiplier - Vector3.Distance(transform.position, go.transform.position)) * explosionDamage);
     damage = (short) -damage;
     go.SendMessage("CmdAlterHealth", damage, SendMessageOptions.DontRequireReceiver);
 }
 public void SetScriptCommand(GameObject doingObject, string scriptCommand, string[] arrayOfParameter)
 {
     ScriptParameter scriptParameter;
     scriptParameter.ScriptCommand = scriptCommand;
     scriptParameter.ArrayOfParameter = arrayOfParameter;
     doingObject.SendMessage("ReceiveScriptFlag", scriptParameter);
 }
Example #23
0
    public void doLockdown()
    {
        if(triggerLockdown == true) {

            if (Input.GetMouseButtonDown(0)) {
                Debug.Log ("Left Clicked LD");
                triggerLockdown = false;
                ray = _camera.ScreenPointToRay(Input.mousePosition);

                //If we hit...
                if(Physics.Raycast (ray, out hit, Mathf.Infinity))
                {
                    //Tell the system what we clicked something if in debug

                    Collider[] lockdownArray = Physics.OverlapSphere(hit.point, radius, mask);

                    if(lockdownArray.Length > 0) {
                        Debug.Log("lockedown 1");
                        for(int i = 0; i < lockdownArray.Length; i++) {
                            targetEnemy = lockdownArray[i].gameObject;
                            targetEnemy.SendMessage("setLockdown", true);
                        }
                    }

                    //Run the Clicked() function on the clicked object
                    //hit.transform.gameObject.SendMessage("RightClicked", hit.point, SendMessageOptions.DontRequireReceiver);
                }

            }
        }
    }
 public void take()
 {
     myAppleTree.SendMessage("eatApple");
     player = GameObject.FindGameObjectWithTag("Player");
     player.SendMessage("take");
     Destroy(this.gameObject);
 }
    public void AttackUnit(GameObject unit)
    {
        gameObject.SendMessage("CheckLegalMove", attackCost);
        UpdatedTameStatusIfCurrentlySelected();

        if (PlayerFunctionalityAndStats.isLegalMove)
        {
            UpdateCurrentlySelectedSpecies();
            unit.SendMessage("UpdateInteractSpecies");
            MinigameMenu.previousInteractUnit = unit;
            if(!networking || (CharacterManager.aTurn == 1 && Network.isServer) || (CharacterManager.aTurn == 3 && Network.isClient))
                GameObject.Find("MiniGameManager").SendMessage("BeginMiniGame", attackPoints);
            // Play SFX
            audio.PlayOneShot(soundAttack); //THE SOUND ATTACK WILL COME FROM THE UNIT THAT WE INSTANTIATE IN THIS ROUTINE

            //Removing Mana
            if (gameObject.tag == "Player1")
            {
                CharacterManager.bird1.SendMessage("RemoveMana", attackCost);
            }
            else if (gameObject.tag == "Player2")
            {
                CharacterManager.bird2.SendMessage("RemoveMana", attackCost);
            }

        }
        else
        {
            if (!PlayerFunctionalityAndStats.isLegalMove)
                GameObject.Find("GUI Hot Seat").SendMessage("showText", "Insufficient Mana");
            else
                GameObject.Find("GUI Hot Seat").SendMessage("showText", "Can't Attack Again");
        }
    }
Example #26
0
    /// <summary>
    /// Starts the conversation with another game object.
    /// </summary>
    /// <param name="obj">Object.</param>
    public void StartConversation(GameObject obj, string reply = null)
    {
        // cannot start another conversation if we have an active one
        if (activeConversation != null) {
            return;
        }
        ConversationSet conversationSet = obj.GetComponent<ConversationSet>();
        if (conversationSet != null) {
            activeConversation = conversationSet.GetActiveConversation();
            if (reply != null && reply != "") {
                activeConversation.headerText = reply;
            }

            // disable rigidbody while in conversation
            if (_state != null) {
                _state.state = State.DISABLED;
            }

            obj.SendMessage(eventName, SendMessageOptions.DontRequireReceiver);

            if (uiPrefab != null) {
                // TODO: finish this
                _uiShown = Instantiate(uiPrefab) as GameObject;
                _buttons = _uiShown.GetComponentsInChildren<Button>();
                for (int i = 0; i < _buttons.Length; ++i) {
                    //				Button.ButtonClickedEvent ev = new Button.ButtonClickedEvent();
                    //				ev.AddListener(
                    //				_buttons[i].onClick += OnResponseClick;
                }
                Button button;
            }
        }
    }
	/**
	 * This method receives a gameObject and checks for collision.
	 * It checks to see if the lesion gameObjects are water disolvable, increments the collected lesion's count on HUD and destroys the objects disolved.
	 * \param other is the currently colliding gameObject.
	 */		
	void OnParticleCollision(GameObject other) 
	{		
        Rigidbody body = other.rigidbody;
        if (body) 
		{		
			if (body.name == "ObstacleSphere2")
			{
				Destroy(GameObject.Find("ObstacleSphere2"));
				TrainingController.sessionLesions = TrainingController.sessionLesions + 1;
				ObstaclesSet.SendMessage("TurnOnLesions", 2);			
				lesionTag = GameObject.Find("LesionTag2");
				lesionTag.SendMessage("DestroyTag", true);            	
			}			
			else if (body.name == "ObstacleSphere4")
			{				
				TrainingController.sessionLesions = TrainingController.sessionLesions + 1;					
				Destroy(GameObject.Find("ObstacleSphere4"));				
			}
			
=======
	void OnParticleCollision(GameObject other) 
	{
		
        Rigidbody body = other.rigidbody;
        if (body) 
		{		
			Destroy(GameObject.Find("ObstacleSphere2"));
			TrainingController.sessionLesions = TrainingController.sessionLesions + 1;
			ObstaclesSet.SendMessage("TurnOnLesions", 2);			
			lesionTag = GameObject.Find("LesionTag2");
			lesionTag.SendMessage("DestroyTag", true);            
>>>>>>> 9f1edfb2b5abdad31c478054209af1964fca0dc9
		}
    }
}
 /// <summary>
 /// This method decides if the state should transition to another on its list
 /// NPC is a reference to the object that is controlled by this class
 /// </summary>
 public override void Reason(GameObject player, GameObject npc)
 {
     if(Vector3.Distance(player.transform.position,
                         npc.transform.position) > 30){
         npc.SendMessage("OnHandlePerformTransition", Transition.LostPlayer, SendMessageOptions.RequireReceiver);
     }
 }
    // Old PlayerCollisions Code prior to Raycast Change
    //    // Boolean to determine if door is open. On start, the door should be closed hence the 'false' initialization
    //    bool doorIsOpen = false;
    //    
    //    // Counter/Timer to determine how long door remains open upon trigger
    //    float doorTimer = 0.0f;
    //    
    //    // public float allowing me to adjust how long door must be open in the Inspector
    //    public float doorOpenTime = 3.0f;
    //    
    //    //Audio
    //    public AudioClip doorOpenSound;
    //    public AudioClip doorShutSound;
    //
    //    // Use this for initialization
    //    void Start () {
    //    
    //    }
    void Update()
    {
        RaycastHit hit;

        if (Physics.Raycast (transform.position, transform.forward, out hit, 3))
        {
            if (hit.collider.gameObject.tag=="playerDoor")
            {
                currentDoor = hit.collider.gameObject;
                currentDoor.SendMessage("DoorCheck");
            }
        }

                                // Old PlayerCollisions Code prior to Raycast Change
        //		if(doorIsOpen)
        //		{
        //			doorTimer+= Time.deltaTime;
        //
        //			if (doorTimer > doorOpenTime)
        //			{
        //				//ShutDoor(currentDoor);
        //				Door(doorShutSound, false,"doorshut", currentDoor);
        //				doorTimer = 0.0f;
        //			}
        //		}
    }
 /// <summary>
 /// Trigger this event and send the message.
 /// </summary>
 /// <param name="actor">the actor to send the message to.</param>
 public override void Trigger(GameObject actor)
 {
     if (actor != null)
     {
         actor.SendMessage(MethodName, Parameter, SendMessageOptions);
     }
 }