Beispiel #1
0
 private void OnCollisionEnter2D(Collision2D other)
 {
     Debug.Log("Choco con " + name);
     if (other.collider.tag == "Bos" || other.collider.tag == "meemperra")
     {
         MovimientoBos.pantalla = true;
         NotificationCenter.DefaultCenter().PostNotification(this, "LineaBomas");
     }
     else
     {
         if (other.collider.tag == "Bombas")
         {
             Destroy(gameObject);
         }
         NotificationCenter.DefaultCenter().PostNotification(this, "Pared", name);
     }
 }
Beispiel #2
0
    //IEnumerator OnTriggerEnter2D(Collider2D collider){
    void OnTriggerEnter2D(Collider2D collider)
    {
        //Debug.Log("Tocado");
        if (collider.tag == "Player")
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "IncrementarPuntos", puntosGanados);
            NotificationCenter.DefaultCenter().PostNotification(this, "PillaGuitarra", puntosGanados);

            //AudioSource.PlayClipAtPoint(itemSoundClip,  Camera.main.GetComponent<Transform>().position,itemSoundVolume);
            //GetComponent<AudioSource>().Play ();
            Guitarra = true;
            animator.SetBool("ConGuitarra", Guitarra);
            Invoke("Autodestruccion", 4f);
            gameObject.GetComponent <Collider2D>().enabled = false;
        }
        //Destroy(gameObject);
    }
Beispiel #3
0
    private void Start()
    {
        gunSound = GetComponent <AudioSource>();
        GameObject BulletParent = new GameObject("BulletParent");
        int        numOfTargets = 10;

        targetList = new GameObject[numOfTargets];

        for (int i = 0; i < numOfTargets; i++)
        {
            GameObject newTarget = Instantiate(GameStatus.UISO.Bullet, BulletParent.transform);
            newTarget.SetActive(false);
            targetList[i] = newTarget;
        }

        NotificationCenter.DefaultCenter().AddObserver(this, "StartGame");
    }
    void countDown()
    {
        //print(timeremain);


        if (timeremain <= 0)
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "EnNada");
            _button.onClick.Invoke();
            //reset time
            CancelInvoke("countDown");
            timeremain = 3;
            //print("reset time");
        }

        timeremain--;
    }
Beispiel #5
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.gameObject.tag == "Player")
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeHaMuerto");
        }

        if (other.gameObject.tag == "Bala")
        {
            //Le bajo uno la salud
            DecrementarSalud();

            //Inicio la variable del animator y hago la animacion del disparo (para que se vaya).
            anim.SetTrigger("disparo");

            //Si salud es cero quiere decir que ha muerto.
            if (salud == 0)
            {
                DecrementarVida();

                NotificationCenter.DefaultCenter().PostNotification(this, "IncrementarPuntos", puntosGanados);
                NotificationCenter.DefaultCenter().PostNotification(this, "Estadisticas", 1);

                //Si tiene una vida antes de decrementarle una vida (su vida es 0).
                if (vidas == 0)
                {
                    Destroy(coll);
                    Destroy(dis);

                    audio_dis.Play();

                    //Inicio la variable del Animator morir, para que el Boss explote.
                    anim.SetTrigger("morir");
                }
                else
                {
                    //Si tiene mas de una vida no dejo que se mueva.
                    entrar       = false;
                    rig.velocity = new Vector2(velocidad, 0);

                    //Invoco la funcion Morir a los dos segundos (dejandole tiempo para que se vaya).
                    Invoke("Morir", 1);
                }
            }
        }
    }
Beispiel #6
0
    void breakdownTileScore(string tileType, int arrayLength)
    {
        if (tileType == "Potion")
        {
            player.currentHealth += arrayLength * player.strength * 1;
            if (player.currentHealth > player.maxHealth)
            {
                player.currentHealth = player.maxHealth;
            }
        }
        else if (tileType == "Armor")
        {
            player.armor += arrayLength * 15;
            float armorToAdd = (float)arrayLength * (player.salvageMultiplier * 7.0f + 1.15f);
            if ((player.currentSalvage += armorToAdd) > player.maxSalvage)
            {
                player.currentSalvage -= player.maxSalvage;
                NotificationCenter.DefaultCenter().PostNotification(this, "ArmorUp");
            }
        }
        else if (tileType == "EnemyWeapon")
        {
            //Count the number of enemies

            //Count the number of weapons

            //Calculate damage

            //Subtract damage from enemy health

            //Calculate number of dead enemies

            //Add xp equivalent to number of enemies killed.
            float xpToAdd = (float)arrayLength * (player.xpMultiplier * 3.0f + 1.15f);
            if ((player.currentXP += xpToAdd) > player.maxXP)
            {
                player.currentXP -= player.maxXP;
                NotificationCenter.DefaultCenter().PostNotification(this, "LevelUp");
            }
        }
        else if (tileType == "Time")
        {
            float timeToAdd = (float)arrayLength * player.timeMultiplier * .3f;
            NotificationCenter.DefaultCenter().PostNotification(this, "AddTime", timeToAdd);
        }
    }
    IEnumerator OnTriggerEnter2D(Collider2D collider)
    {
        if (collider.gameObject.tag == "Player")
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "ReceiveDamage", transform.position);
            yield return(0);

            PoolManager.Pools ["fx"].Spawn(effect.transform, collider.transform.position, effect.transform.rotation);
            Camera.main.gameObject.GetComponent <FollowTarget>().offset.x           = 0;
            collider.gameObject.GetComponent <RigidBody2DUnidirectional>().maxSpeed = 0f;
            collider.gameObject.SetActive(false);
            yield return(new WaitForSeconds(3.5f));

            NotificationCenter.DefaultCenter().PostNotification(this, "OnDead");
            //PlayerStatus.playerStatus.DisableRenderers();
        }
    }
    void OnMouseOver()
    {
        if (Input.GetMouseButtonDown(0))
        {
            vida             = vida - 2;
            life.fillAmount -= 0.02f;
            pow.SetActive(true);

            //Debug.Log("vida - 1");
        }
        if (vida == 0)
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "AnotherEnemy");
            NotificationCenter.DefaultCenter().PostNotification(this, "SetCountText");
            Destroy(gameObject);
        }
    }
Beispiel #9
0
 public int Close_LED(string side, int nindex)
 {
     SetDetectString("@_@");
     CheckAndConnect();
     if (!IsOpen)
     {
         return(-1);
     }
     if (side == "Left")
     {
         byte[] data = { (byte)'C', (byte)'l',    (byte)'o',  (byte)'s', (byte)'e', (byte)' ', (byte)'t',
                         (byte)'h', (byte)'e',    (byte)' ',  (byte)'L', (byte)'e', (byte)'f', (byte)'t',(byte)' ',  (byte)'L', (byte)'E', (byte)'D',
                         (byte)':', (byte)nindex, (byte)'\r', (byte)'\n' };
         Write(data, 0, 22);
         if (WaitForString(200) != -1)
         {
             string str = ReadString().ToLower();
             if (str.IndexOf("close the left led") != -1)
             {
                 if (str.IndexOf("finish") != -1)
                 {
                     NotificationCenter.DefaultCenter().Notification2Log(0,
                                                                         "Pulsar 2 :Close the LEFT LED:" + nindex.ToString() + "  " + " Success" + "\r\n");
                     return(0);
                 }
                 else
                 {
                     NotificationCenter.DefaultCenter().Notification2Log(0,
                                                                         "Pulsar 2 :Close the LEFT LED:" + nindex.ToString() + "  " + " Faild" + "\r\n");
                     return(-1);
                 }
             }
         }
         else
         {
             NotificationCenter.DefaultCenter().Notification2Statue(0,
                                                                    "Pulsar 2 :Close the LEFT LED:" + nindex.ToString() + " TimeOut!");
             return(-1);
         }
     }
     else
     {
         //todo add right
     }
     return(-1);
 }
    public void CambiarIdioma(string idioma)
    {
        IdiomaActual = idioma;
        NotificationCenter.DefaultCenter().PostNotification(this, "CambiarIdioma_");

        if (EsEscenaMenu)
        {
            if (idioma == "Español")
            {
                toggleEspañol.isOn = true;
            }
            else if (idioma == "Ingles")
            {
                toggleIngles.isOn = true;
            }
        }
    }
Beispiel #11
0
    // Use this for initialization
    IEnumerator Start()
    {
        GameObject.Find("OverHeadCamera").GetComponent <OverHeadCameraController>().target = this.transform;

        if (GameObject.Find("Message") != null)
        {
            messageText = GameObject.Find("Message").GetComponent <Text>();
        }

        messageText.text = "3";
        yield return(new WaitForSeconds(1));

        messageText.text = "2";
        yield return(new WaitForSeconds(1));

        messageText.text = "1";
        yield return(new WaitForSeconds(1));

        messageText.text = "GO!";
        GetComponent <CarController>().canMove = true;

        NotificationCenter.DefaultCenter().AddObserver(this, "OnCarEnter");
        NotificationCenter.DefaultCenter().AddObserver(this, "OnCarScore");

        if (GameObject.Find("ScoreText") != null)
        {
            scoreText = GameObject.Find("ScoreText").GetComponent <Text>();
        }
        if (GameObject.Find("TimerText") != null)
        {
            timerText = GameObject.Find("TimerText").GetComponent <Text>();
        }
        if (GameObject.Find("Message") != null)
        {
            messageText = GameObject.Find("Message").GetComponent <Text>();
        }

        singlePlayer = new SinglePlayer();
        singlePlayer.SetNotificationInterface(this);

        yield return(new WaitForSeconds(1));

        messageText.text = "";
        StartCoroutine(Run());
    }
Beispiel #12
0
 void badgesAction()
 {
     if (Social.localUser.authenticated)
     {
         ((PlayGamesPlatform)Social.Active).ShowAchievementsUI();
     }
     else
     {
         Social.localUser.Authenticate((bool success) => {
             if (success)
             {
                 NotificationCenter.DefaultCenter().PostNotification(this, "Again");
                 NotificationCenter.DefaultCenter().PostNotification(this, "UpdateGoogle");
                 ((PlayGamesPlatform)Social.Active).ShowAchievementsUI();
             }
         });
     }
 }
Beispiel #13
0
 void rankingAction()
 {
     if (Social.localUser.authenticated)
     {
         ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI("CgkI0oKVh6oBEAIQAA");
     }
     else
     {
         Social.localUser.Authenticate((bool success) => {
             if (success)
             {
                 NotificationCenter.DefaultCenter().PostNotification(this, "Again");
                 NotificationCenter.DefaultCenter().PostNotification(this, "UpdateGoogle");
                 ((PlayGamesPlatform)Social.Active).ShowLeaderboardUI("CgkI0oKVh6oBEAIQAA");
             }
         });
     }
 }
Beispiel #14
0
    void OnCollisionEnter2D(Collision2D collision)
    {
        Destructores.Murio = false; //se resetea para permitir que vuelva avisar cuando el personaje muera
        SegundoSalto.aux3  = false; //Reseta este booleano para permitir que se vuelva a resetear la condicion de sumar puntaje

        if (collision.gameObject.tag == "Pies")
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "PermisivoSalto"); //Permitimos que se resetee el salto con esta notificacion
        }
        if (collision.gameObject.name == "BlueBodyPlay")                                 //Si el objeto colisiono y el objeto con el que colisiono tiene como nombre "BlueBodyPlay"
        {
            if (!MovimientoBases.nosuma)
            {
                NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeGanaPuntos");//Avisamos que el jugador gano los puntos que se encuentan actualmente en @textopuntos.text
                MovimientoBases.nosuma = true;
            }
        }
    }
Beispiel #15
0
 public void WrongAnswer()
 {
     try
     {
         foreach (GameObject element in FalsoS)
         {
             element.gameObject.SetActive(true);
         }
         incorrectSign.gameObject.SetActive(true);
         NotificationCenter.DefaultCenter().PostNotification(this, "ReducirPuntos", puntosPerdidos);
         Debug.Log("Respuesta Incorrecta, ha perdido 5 puntos Pase a la Siguiente Pregunta");
         NotificationCenter.DefaultCenter().PostNotification(this, "GameOver", Intentos);
     }
     catch (System.NullReferenceException ex)
     {
         Debug.Log("ERROR DE VARIABLE NOINSTANCIADAOREFERENCIADA" + ex);
     }
 }
Beispiel #16
0
 public void UpdateBalance(Action <decimal> callback)
 {
     // ViewManager.ShowWaitTip("正在请求更新余额");
     if (string.IsNullOrEmpty(mAddress))
     {
         Debug.Log("UpdateBalance mAddress is null");
         return;
     }
     StartCoroutine(Wallet.GetBalance(mAddress, (balance) => {
         mBalance = balance;
         if (callback != null)
         {
             callback(balance);
         }
         NotificationCenter.DefaultCenter().PostNotification("RefreshBalance");
         // ViewManager.CloseWaitTip();
     }));
 }
Beispiel #17
0
    void OnMouseDown()
    {
        //detiene el audio de la camara y luego reproduce el del boton jugar
        //Camera.main.GetComponent<AudioSource>().Stop();
        GetComponent <AudioSource>().Play();

        objeto.SetActive(true);
        //El if es para evitar que salga una notificacion diciendo que no encuentra la notificacion
        if (activo == true)
        {
            NotificationCenter.DefaultCenter().PostNotification(this, cargarInfo);
        }
        //NotificationCenter.DefaultCenter().PostNotification(this, "cargarInfo");
        else
        {
            activo = true;
        }
    }
Beispiel #18
0
    // Update is called once per frame
    void Update()
    {
        if (int.Parse(puntuacion.text) != numAct)
        {
            numAct = int.Parse(puntuacion.text);
            mod    = int.Parse(puntuacion.text) % 3;
        }

        if (mod == 0 && !entra)
        {
            entra   = true;
            nomorir = true;
            camara.SetActive(true);
            NotificationCenter.DefaultCenter().PostNotification(this, "SystemPaticule", true);

            print("Entro en la funcion Activar camara");
        }
    }
Beispiel #19
0
    void OnTriggerEnter2D(Collider2D other)
    {
        //Llama a la funcion IncrementarPuntos, para que incremente 1 punto y siempre que haya un Gameobject con el tag Boss.
        if (!haColisionado && other.gameObject.tag == "Finish")
        {
            if (GameObject.FindGameObjectWithTag("Boss") == false)
            {
                haColisionado = true;

                NotificationCenter.DefaultCenter().PostNotification(this, "IncrementarPuntos", puntosGanados);
                NotificationCenter.DefaultCenter().PostNotification(this, "Estadisticas", 3);
            }

            rig.isKinematic = false;

            Invoke("Parar", 0.2f);
        }
    }
Beispiel #20
0
    /// <summary>
    /// El metodo PerderVidaTiempo es un metodo que notifica a la clase Vida que se ha acabado el tiempo y realiza la animacion del jugador donde ha muerto.
    /// <paramref name="Notification">Tipo de parametro Notification<paramref/>
    /// </summary>
    public void PerderVidaTiempo(Notification Notification)
    {
        float Tiempo = (float)Notification.data;

        if (Tiempo <= 0)
        {
            Animator.SetBool("Die", true);
            AudioSource.Play();
            NotificationCenter.DefaultCenter().PostNotification(this, "PerderVida", PerderVida);
            Speed = 0f;

            Invoke("Respawn", 2.0f);
        }
        else
        {
            Debug.Log("El tiempo no llego a Cero.");
        }
    }
Beispiel #21
0
 // Update is called once per frame
 void Update()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (corrriendo)
         {
             if (enSuelo) ///obtiene el click izquierdo el el toque de una pantalla tactill
             {
                 GetComponent <Rigidbody2D>().AddForce(new Vector2(0, Fuerzasalto));
             }
         }
         else
         {
             corrriendo = true;
             NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeEmpiezaACorrer");
         }
     }
 }
    void OnTriggerEnter2D(Collider2D other)
    {
        entra = true;
        if (other.tag == "Player")
        {
            mainCamara.GetComponent <AudioSource>().Stop();
            GetComponent <AudioSource>().Play();
            ActivarColores.nomorir = false;
            NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeHaMuerto");
            NotificationCenter.DefaultCenter().PostNotification(this, "Desactivar2");

            other.gameObject.SetActive(false);
        }
        else
        {
            Destroy(other.gameObject);
        }
    }
Beispiel #23
0
 void OnCollisionEnter2D(Collision2D coll)
 {
     if (coll.gameObject.tag == "Enemy")
     {
         if (!hitted)
         {
             hitted  = true;
             timeHit = Time.time;
             lives  -= 1;
             NotificationCenter.DefaultCenter().PostNotification(this, "playerHitted");
             calculateAttackDirection(coll.transform);
         }
     }
     else
     {
         movement = idle;
     }
 }
Beispiel #24
0
    void OnTriggerEnter2D(Collider2D other)
    {
        if (other.tag == "Player")
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeMuere");
            //BUSAR TAMBIEN EL MARiachi
            //GameObject personaje = GameObject.Find ("Personaje");
            personajes = GameObject.FindGameObjectsWithTag("Player");
            //Debug.Log (personajes);
            //Destroy(personaje);
            foreach (GameObject personaje in personajes)
            {
                personaje.SetActive(false);
            }
            //Debug.Log ("me he cargado a alguien");
            //Si lo destruimos la camara no tiene a quien seguir y chifla,
            //Por eso mejor se desactiva del juego.
            //FIN DEL JUEGO.MARCADORES ETC
            //				} else if (other.tag == "Justin") {
            //						GameObject personaje = GameObject.Find ("JustinBerenjena");
            //
            //						Destroy(personaje);
            //						//personaje.SetActive (false);
        }
        else if (other.tag == "Justin")
        {
            personajes = GameObject.FindGameObjectsWithTag("Justin");
            foreach (GameObject personaje in personajes)
            {
                personaje.SetActive(false);
            }
            personajes = GameObject.FindGameObjectsWithTag("Player");
            foreach (GameObject personaje in personajes)
            {
                personaje.SetActive(false);
            }

            NotificationCenter.DefaultCenter().PostNotification(this, "JustinMuere");
        }
        else
        {
            Destroy(other.gameObject);
        }
    }
Beispiel #25
0
        public override int StopTest(object arg)
        {
            if (arg == null)
            {
                return(0);
            }
            int id = (int)arg;

            int start_index = id;
            int stop_index  = id + 1;

            if (id < 0)
            {
                start_index = 0;
                stop_index  = m_ModuleCount;
            }
            for (int index = start_index; index < stop_index; index++)
            {
                try
                {
                    if (m_TestThread[index] != null)
                    {
                        m_ScriptEngine[index].DoString("TestCancel();");

                        //m_TestThread[id].Abort();
                        //让出时间给子线程执行  lxl
                        System.Threading.Thread.Sleep(100);
                        m_testStop = true;
                        //m_SyncEvent[id].Reset();
                    }
#if false
                    DictionaryEx dic = new DictionaryEx();
                    dic["id"]    = index;
                    dic["state"] = 2;
                    NotificationCenter.DefaultCenter().PostNotification(tmMarcos.kOnTestFinish, dic);
#endif
                }
                catch (ThreadAbortException e)
                {
                    //System.Windows.Forms.MessageBox.Show(e.Message);
                }
            }
            return(0);
        }
Beispiel #26
0
    /////////////////////////////////
    //Unity-Related
    /////////////////////////////////
    // Use this for initialization
    void Start()
    {
        NotificationCenter.DefaultCenter().AddObserver(this, "Pause");
        NotificationCenter.DefaultCenter().AddObserver(this, "Unpause");
        NotificationCenter.DefaultCenter().AddObserver(this, "LevelUp");

        //Set up initial values (initalization above not working correctly.
        level                  = 1;
        itemLevel              = 1;
        currentXP              = 0;
        currentSalvage         = 0;
        strengthMultiplier     = 1;
        agilityMultiplier      = 1;
        intelligenceMultiplier = 1;
        xpMultiplier           = 1;
        salvageMultiplier      = 1;

        //Set up character
        if (charType == eCharTypes.Strength)
        {
            strength     = 25;
            agility      = 20;
            intelligence = 18;
        }
        else if (charType == eCharTypes.Agility)
        {
            strength     = 20;
            agility      = 25;
            intelligence = 18;
        }
        else if (charType == eCharTypes.Intelligence)
        {
            strength     = 18;
            agility      = 20;
            intelligence = 25;
        }

        updateStats();

        currentHealth = maxHealth;
        currentMana   = maxMana;

        InvokeRepeating("Regen", 0f, 1f);
    }
Beispiel #27
0
 void updateState()
 {
     if (Input.GetMouseButtonDown(0))
     {
         if (run)
         {
             if (enSuelo || !doubleJumpUsed)
             {
                 GetComponent <Rigidbody2D>().velocity = new Vector2(GetComponent <Rigidbody2D>().velocity.x, fuerzaSalto);
                 doubleJumpUsed = true;
             }
         }
         else
         {
             run = true;
             NotificationCenter.DefaultCenter().PostNotification(this, "pjStartRun");
         }
     }
 }
Beispiel #28
0
    // metodo especial para detectar colisiones
    void OnTriggerEnter2D(Collider2D other)
    {
        // destruimos el objeto con el que hemos colisonado porque sabemos su collider
        // si es el jugador
        if (other.tag == "Player")
        {
            // muerte, por hacer
            NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeHaMuerto");

            //Debug.Break ();

            //GameObject personaje = GameObject.Find("Personaje");
            personaje.SetActive(false);
        }
        else
        {
            Destroy(other.gameObject);
        }
    }
Beispiel #29
0
    void OnTriggerEnter(Collider col)
    {
        //GetComponent<BoxCollider>().enabled = false; // disable the box collider so that we cannot re enter this one

        // if we have visted the map, then dont post a message to generate a map piece again
        if (!hasBeenVisited)
        {
            NotificationCenter.DefaultCenter().PostNotification(this, "UserGenerateMapPiece", this.gameObject);
            NotificationCenter.DefaultCenter().PostNotification(this, "OnCarScore");
            hasBeenVisited = true;
        }

        Vector2 myPosition = new Vector2();

        myPosition.Set(this.transform.position.x, this.transform.position.z);

        // always post that the car has entered though
        NotificationCenter.DefaultCenter().PostNotification(this, "OnCarEnter", myPosition - previousPosition);
    }
Beispiel #30
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.gameObject.tag == "Player")
        {
            if (this.gameObject.tag == "Item" || this.gameObject.tag == "Astronauta")
            {
                AudioSource.PlayClipAtPoint(cogerItemClip, Camera.main.transform.position, volumen);
                NotificationCenter.DefaultCenter().PostNotification(this, "IncrementarPuntuacion", puntuacionIncrementar);
            }
            else if (this.gameObject.tag == "Cometa")
            {
                NotificationCenter.DefaultCenter().PostNotification(this, "PersonajeHaMuerto");
                GameObject personaje = GameObject.Find("DinoRino");
                personaje.SetActive(false);
            }
        }

        Destroy(this.gameObject);
    }