コード例 #1
0
 private void OnTriggerExit(Collider other)
 {
     if (other.gameObject.CompareTag("LadoDeCima") || other.gameObject.CompareTag("LadoDeBaixo") || other.gameObject.CompareTag("LadoDireito") || other.gameObject.CompareTag("LadoEsquerdo"))
     {
         direcao = Direcoes.Nenhuma;//aqui poderia mandar para uma possivel parte do swith?**
     }
 }
コード例 #2
0
 public Passante(float vel, Pontes pon)
 {
     if (vel < 0)
     {
         direcao = Direcoes.ParaEsquerda;
     }
     velocidade = vel;
     ponte      = pon;
 }
コード例 #3
0
 public void Mover(Direcoes argdirecao)
 {
     direcao = argdirecao;
     switch (argdirecao)
     {
     case Direcoes.Esquerda: Posicao = new Point(Posicao.X - 2, Posicao.Y); break;
         /*case Direcoes.Direita: Posicao = new Point(Posicao.X + 2, Posicao.Y); break;*/
     }
 }
コード例 #4
0
        public void Mover(Direcoes argdirecao)
        {
            direcao = argdirecao;
            switch (argdirecao)
            {
            case Direcoes.Cima: Posicao = new Point(Posicao.X, Posicao.Y - 10); break;

            case Direcoes.Baixo: Posicao = new Point(Posicao.X, Posicao.Y + 10); break;
            }
        }
コード例 #5
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.gameObject.CompareTag("LadoDeCima"))
     {
         direcao = Direcoes.Baixo; //aqui manda entrar no switch da direção? no Direcoes.Baixo?
     }
     else
     if (other.gameObject.CompareTag("LadoDeBaixo"))
     {
         direcao = Direcoes.Cima;
     }
     else
     if (other.gameObject.CompareTag("LadoDireito"))
     {
         direcao = Direcoes.Esquerda;
     }
     else
     if (other.gameObject.CompareTag("LadoEsquerdo"))
     {
         direcao = Direcoes.Direita;
     }
 }
コード例 #6
0
ファイル: Player.cs プロジェクト: wilterson/star-warrier
        public void Mover(Direcoes argDirecao)
        {
            direcao = argDirecao;
            switch (direcao)
            {
            case Direcoes.Cima:
                posicao.Y -= 4;
                if (posicao.Y < 0)
                {
                    posicao.Y = 0;
                }
                break;

            case Direcoes.Baixo:
                posicao.Y += 4;
                if (posicao.Y > Constantes.SCREEN_HEIGHT - Constantes.PLAYER_HEIGHT)
                {
                    posicao.Y = Constantes.SCREEN_HEIGHT - Constantes.PLAYER_HEIGHT;
                }
                break;

            case Direcoes.Esquerda:
                posicao.X -= 4;
                if (posicao.X < 0)
                {
                    posicao.X = 0;
                }
                break;

            case Direcoes.Direita:
                posicao.X += 4;
                if (posicao.X > Constantes.SCREEN_WIDTH - Constantes.PLAYER_WIDTH)
                {
                    posicao.X = Constantes.SCREEN_WIDTH - Constantes.PLAYER_WIDTH;
                }
                break;
            }
        }
コード例 #7
0
ファイル: Agente.cs プロジェクト: bernardobrezende/dengueSim
        public void Mover(Direcoes p)
        {
            int x = 0;
            int y = 0;
            switch (p)
            {
                case Direcoes.N: x = 0; y = -1;
                    break;
                case Direcoes.NE: x = 1; y = -1;
                    break;
                case Direcoes.E: x = 1; y = 0;
                    break;
                case Direcoes.SE: x = 1; y = 1;
                    break;
                case Direcoes.S: x = 0; y = 1;
                    break;
                case Direcoes.SO: x = -1; y = 1;
                    break;
                case Direcoes.O: x = -1; y = 0;
                    break;
                case Direcoes.NO: x = -1; y = -1;
                    break;
            }

            int proxX = Posicao.Coluna + x;
            int proxY = Posicao.Linha + y;

            Mover(ambiente[proxY, proxX]);
        }
コード例 #8
0
    // Update is called once per frame
    void Update()
    {
        if (Game.Data.bullet)
        {
            if (Game.Data.tempoRestante > 0)
            {
                Game.Data.tempoRestante -= Time.deltaTime;

                // Acabou de entrar no bullet
                if (!last_value)
                {
                    texto1.enabled = true;
                    texto2.enabled = true;
                    texto3.enabled = true;

                    swipeUp    = false;
                    swipeRight = false;
                    swipeDown  = false;
                    swipeLeft  = false;


                    int ran = Random.Range(0, 4);
                    switch (ran)
                    {
                    case 0:
                        dir1          = Direcoes.Cima;
                        texto1.sprite = dirCimaAzul;
                        texto1.SetNativeSize();
                        break;

                    case 1:
                        dir1          = Direcoes.Direita;
                        texto1.sprite = dirDireitaAzul;
                        texto1.SetNativeSize();
                        break;

                    case 2:
                        dir1          = Direcoes.Baixo;
                        texto1.sprite = dirBaixoAzul;
                        texto1.SetNativeSize();
                        break;

                    case 3:
                        dir1          = Direcoes.Esquerda;
                        texto1.sprite = diresquerdaAzul;
                        texto1.SetNativeSize();
                        break;
                    }
                    ran = Random.Range(0, 4);
                    switch (ran)
                    {
                    case 0:
                        dir2          = Direcoes.Cima;
                        texto2.sprite = dirCimaAzul;
                        texto2.SetNativeSize();
                        break;

                    case 1:
                        dir2          = Direcoes.Direita;
                        texto2.sprite = dirDireitaAzul;
                        texto2.SetNativeSize();
                        break;

                    case 2:
                        dir2          = Direcoes.Baixo;
                        texto2.sprite = dirBaixoAzul;
                        texto2.SetNativeSize();
                        break;

                    case 3:
                        dir2          = Direcoes.Esquerda;
                        texto2.sprite = diresquerdaAzul;
                        texto2.SetNativeSize();
                        break;
                    }
                    ran = Random.Range(0, 4);
                    switch (ran)
                    {
                    case 0:
                        dir3          = Direcoes.Cima;
                        texto3.sprite = dirCimaAzul;
                        texto3.SetNativeSize();
                        break;

                    case 1:
                        dir3          = Direcoes.Direita;
                        texto3.sprite = dirDireitaAzul;
                        texto3.SetNativeSize();
                        break;

                    case 2:
                        dir3          = Direcoes.Baixo;
                        texto3.sprite = dirBaixoAzul;
                        texto3.SetNativeSize();
                        break;

                    case 3:
                        dir3          = Direcoes.Esquerda;
                        texto3.sprite = diresquerdaAzul;
                        texto3.SetNativeSize();
                        break;
                    }
                    direcao_atual = 0;
                }
                else
                {
                    swipeUp    = false;
                    swipeRight = false;
                    swipeDown  = false;
                    swipeLeft  = false;


                    if (Input.touchCount > 0)
                    {
                        foreach (Touch touch in Input.touches)
                        {
                            switch (touch.phase)
                            {
                            case TouchPhase.Began:
                                /* this is a new touch */
                                isSwipe         = true;
                                fingerStartTime = Time.time;
                                fingerStartPos  = touch.position;
                                break;

                            case TouchPhase.Canceled:
                                /* The touch is being canceled */
                                isSwipe = false;
                                break;

                            case TouchPhase.Ended:

                                float gestureTime = Time.time - fingerStartTime;
                                float gestureDist = (touch.position - fingerStartPos).magnitude;

                                if (isSwipe && gestureTime < maxSwipeTime && gestureDist > minSwipeDist)
                                {
                                    Vector2 direction = touch.position - fingerStartPos;
                                    Vector2 swipeType = Vector2.zero;

                                    if (Mathf.Abs(direction.x) > Mathf.Abs(direction.y))
                                    {
                                        // the swipe is horizontal:
                                        swipeType = Vector2.right * Mathf.Sign(direction.x);
                                    }
                                    else
                                    {
                                        // the swipe is vertical:
                                        swipeType = Vector2.up * Mathf.Sign(direction.y);
                                    }

                                    if (swipeType.x != 0.0f)
                                    {
                                        if (swipeType.x > 0.0f)
                                        {
                                            // MOVE RIGHT
                                            swipeRight = true;
                                        }
                                        else
                                        {
                                            // MOVE LEFT
                                            swipeLeft = true;
                                        }
                                    }

                                    if (swipeType.y != 0.0f)
                                    {
                                        if (swipeType.y > 0.0f)
                                        {
                                            // MOVE UP
                                            swipeUp = true;
                                        }
                                        else
                                        {
                                            // MOVE DOWN
                                            swipeDown = true;
                                        }
                                    }
                                }

                                break;
                            }
                        }
                    }

                    switch (direcao_atual)
                    {
                    case 0:

                        switch (dir1)
                        {
                        case Direcoes.Cima:
                            if (Input.GetKeyDown(KeyCode.UpArrow))
                            {
                                direcao_atual++;
                                texto1.sprite = dirCimaVerde;
                                texto1.SetNativeSize();
                            }

                            if (swipeUp == true)
                            {
                                direcao_atual++;
                                texto1.sprite = dirCimaVerde;
                                texto1.SetNativeSize();
                            }
                            else if (swipeLeft || swipeRight || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Direita:
                            if (Input.GetKeyDown(KeyCode.RightArrow))
                            {
                                direcao_atual++;
                                texto1.sprite = dirDireitaVerde;
                                texto1.SetNativeSize();
                            }

                            if (swipeRight == true)
                            {
                                direcao_atual++;
                                texto1.sprite = dirDireitaVerde;
                                texto1.SetNativeSize();
                            }
                            else if (swipeLeft || swipeUp || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Baixo:
                            if (Input.GetKeyDown(KeyCode.DownArrow))
                            {
                                direcao_atual++;
                                texto1.sprite = dirBaixoVerde;
                                texto1.SetNativeSize();
                            }

                            if (swipeDown == true)
                            {
                                direcao_atual++;
                                texto1.sprite = dirBaixoVerde;
                                texto1.SetNativeSize();
                            }
                            else if (swipeLeft || swipeRight || swipeUp)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Esquerda:
                            if (Input.GetKeyDown(KeyCode.LeftArrow))
                            {
                                direcao_atual++;
                                texto1.sprite = diresquerdaVerde;
                                texto1.SetNativeSize();
                            }

                            if (swipeLeft == true)
                            {
                                direcao_atual++;
                                texto1.sprite = diresquerdaVerde;
                                texto1.SetNativeSize();
                            }
                            else if (swipeUp || swipeRight || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;
                        }

                        break;

                    case 1:

                        switch (dir2)
                        {
                        case Direcoes.Cima:
                            if (Input.GetKeyDown(KeyCode.UpArrow))
                            {
                                direcao_atual++;
                                texto2.sprite = dirCimaVerde;
                                texto2.SetNativeSize();
                            }

                            if (swipeUp == true)
                            {
                                direcao_atual++;
                                texto2.sprite = dirCimaVerde;
                                texto2.SetNativeSize();
                            }
                            else if (swipeLeft || swipeRight || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Direita:
                            if (Input.GetKeyDown(KeyCode.RightArrow))
                            {
                                direcao_atual++;
                                texto2.sprite = dirDireitaVerde;
                                texto2.SetNativeSize();
                            }

                            if (swipeRight == true)
                            {
                                direcao_atual++;
                                texto2.sprite = dirDireitaVerde;
                                texto2.SetNativeSize();
                            }
                            else if (swipeLeft || swipeUp || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Baixo:
                            if (Input.GetKeyDown(KeyCode.DownArrow))
                            {
                                direcao_atual++;
                                texto2.sprite = dirBaixoVerde;
                                texto2.SetNativeSize();
                            }

                            if (swipeDown == true)
                            {
                                direcao_atual++;
                                texto2.sprite = dirBaixoVerde;
                                texto2.SetNativeSize();
                            }
                            else if (swipeLeft || swipeRight || swipeUp)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Esquerda:
                            if (Input.GetKeyDown(KeyCode.LeftArrow))
                            {
                                direcao_atual++;
                                texto2.sprite = diresquerdaVerde;
                                texto2.SetNativeSize();
                            }

                            if (swipeLeft == true)
                            {
                                direcao_atual++;
                                texto2.sprite = diresquerdaVerde;
                                texto2.SetNativeSize();
                            }
                            else if (swipeUp || swipeRight || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;
                        }

                        break;

                    case 2:

                        switch (dir3)
                        {
                        case Direcoes.Cima:
                            if (Input.GetKeyDown(KeyCode.UpArrow))
                            {
                                direcao_atual++;
                                texto3.sprite = dirCimaVerde;
                                texto3.SetNativeSize();
                            }

                            if (swipeUp == true)
                            {
                                direcao_atual++;
                                texto3.sprite = dirCimaVerde;
                                texto3.SetNativeSize();
                            }
                            else if (swipeLeft || swipeRight || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Direita:
                            if (Input.GetKeyDown(KeyCode.RightArrow))
                            {
                                direcao_atual++;
                                texto3.sprite = dirDireitaVerde;
                                texto3.SetNativeSize();
                            }

                            if (swipeRight == true)
                            {
                                direcao_atual++;
                                texto3.sprite = dirDireitaVerde;
                                texto3.SetNativeSize();
                            }
                            else if (swipeLeft || swipeUp || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Baixo:
                            if (Input.GetKeyDown(KeyCode.DownArrow))
                            {
                                direcao_atual++;
                                texto3.sprite = dirBaixoVerde;
                                texto3.SetNativeSize();
                            }

                            if (swipeDown == true)
                            {
                                direcao_atual++;
                                texto3.sprite = dirBaixoVerde;
                                texto3.SetNativeSize();
                            }
                            else if (swipeLeft || swipeRight || swipeUp)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;

                        case Direcoes.Esquerda:
                            if (Input.GetKeyDown(KeyCode.LeftArrow))
                            {
                                direcao_atual++;
                                texto3.sprite = diresquerdaVerde;
                                texto3.SetNativeSize();
                            }

                            if (swipeLeft == true)
                            {
                                direcao_atual++;
                                texto3.sprite = diresquerdaVerde;
                                texto3.SetNativeSize();
                            }
                            else if (swipeUp || swipeRight || swipeDown)
                            {
                                Game.Data.tempoRestante = -0.1f;
                            }

                            break;
                        }

                        break;

                    case 3:

                        if (SoundController.Data != null)
                        {
                            int ran = Random.Range(0, 3);
                            switch (ran)
                            {
                            case 0:
                                SoundController.Data.AudioSources["espada_som_1"].Play();
                                break;

                            case 1:
                                SoundController.Data.AudioSources["espada_som_2"].Play();
                                break;

                            case 2:
                                SoundController.Data.AudioSources["espada_som_3"].Play();
                                break;
                            }
                        }

                        robot_destrroy_script destroy = Game.Data.Mecha.target.GetComponent <robot_destrroy_script>();
                        if (destroy != null)
                        {
                            destroy.Explode();
                            Game.Data.bullet = false;
                            texto1.enabled   = false;
                            texto2.enabled   = false;
                            texto3.enabled   = false;
                        }
                        else
                        {
                            Destroy(Game.Data.Mecha.target.gameObject);
                            Game.Data.Mecha.target = null;
                            Game.Data.bullet       = false;
                            texto1.enabled         = false;
                            texto2.enabled         = false;
                            texto3.enabled         = false;
                        }
                        break;
                    }
                }
            }
            else
            {
                Game.Flash();
                Game.Data.Mecha.health      -= 1;
                Game.Data.Mecha.recovery     = true;
                Game.Data.Mecha.timeRecovery = 2;
                Game.Data.Mecha.combo        = 0;
                Game.Data.shake = 0.8f;

                Game.Data.bullet = false;
                texto1.enabled   = false;
                texto2.enabled   = false;
                texto3.enabled   = false;
            }
        }

        last_value = Game.Data.bullet;
    }
コード例 #9
0
        private void Resolver()
        {
            Movimentos = new PilhaLista <Movimento>();
            int  novoI;
            int  novoJ;
            int  atualJ  = 0;
            int  atualI  = 0;
            bool moveuSe = false;

            for (int d = 0; d < Direcoes.GetLength(0); d++)
            {
                moveuSe = false;

                if (!Movimentos.EstaVazia)
                {
                    atualI = Movimentos.OTopo().Coordenada[0, 0];
                    atualJ = Movimentos.OTopo().Coordenada[0, 1];
                    novoI  = atualI + Direcoes[d, 1];
                    novoJ  = atualJ + Direcoes[d, 2];
                }
                else
                {
                    novoI = Inicio[0, 0] + Direcoes[d, 1];
                    novoJ = Inicio[0, 1] + Direcoes[d, 2];
                }

                if (Matriz[novoI, novoJ].ToString().Equals(" "))
                {
                    if (!Movimentos.EstaVazia)
                    {
                        Mover(novoI, novoJ, ref atualI, ref atualJ, d);
                        moveuSe = true;
                        d       = -1;
                    }
                    else
                    {
                        atualI = Inicio[0, 0];
                        atualJ = Inicio[0, 1];
                        Mover(novoI, novoJ, ref atualI, ref atualJ, d);
                        moveuSe = true;
                        d       = -1;
                    }
                }
                else
                if (Matriz[novoI, novoJ].ToString().Equals("S"))
                {
                    SalvarCaminho(novoI, novoJ);
                    break;
                }
                else if (d == 7 && moveuSe == false)
                {
                    if (Movimentos.EstaVazia)
                    {
                        todosOsCaminhosEncontrados = true;
                        return;
                    }

                    Movimento atual = Movimentos.Desempilhar();

                    if (!Movimentos.EstaVazia)
                    {
                        Movimento ant = Movimentos.OTopo();
                        atualI = ant.Coordenada[0, 0];
                        atualJ = ant.Coordenada[0, 1];
                        d      = -1;
                    }
                }
            }
        }
コード例 #10
0
        /// <summary>
        /// Retorna as coordenadas da direção que deve consultado a portir de um ponto de coordenada.
        /// </summary>
        /// <param name="coordenadas">Coordenadas a portir de onde deve olhar.</param>
        /// <param name="direcao">Direção para procurar as coordenadas.</param>
        /// <returns>Coordenada encontrada.</returns>
        public static Coordenadas GetCoordenadasPorDirecao(Coordenadas coordenadas, Direcoes direcao)
        {
            switch (direcao)
            {
            case Direcoes.NENHUMA:
                return(new Coordenadas
                {
                    X = coordenadas.X,
                    Y = coordenadas.Y
                });

            case Direcoes.CIMA:
                return(new Coordenadas
                {
                    X = coordenadas.X,
                    Y = coordenadas.Y - 1
                });

            case Direcoes.CIMAx2:
                return(new Coordenadas
                {
                    X = coordenadas.X,
                    Y = coordenadas.Y - 2
                });

            case Direcoes.BAIXO:
                return(new Coordenadas
                {
                    X = coordenadas.X,
                    Y = coordenadas.Y + 1
                });

            case Direcoes.BAIXOx2:
                return(new Coordenadas
                {
                    X = coordenadas.X,
                    Y = coordenadas.Y + 2
                });

            case Direcoes.ESQUERDA:
                return(new Coordenadas
                {
                    X = coordenadas.X - 1,
                    Y = coordenadas.Y
                });

            case Direcoes.ESQUERDAx2:
                return(new Coordenadas
                {
                    X = coordenadas.X - 2,
                    Y = coordenadas.Y
                });

            case Direcoes.DIREITA:
                return(new Coordenadas
                {
                    X = coordenadas.X + 1,
                    Y = coordenadas.Y
                });

            case Direcoes.DIREITAx2:
                return(new Coordenadas
                {
                    X = coordenadas.X + 2,
                    Y = coordenadas.Y
                });

            default:
                return(null);
            }
        }
コード例 #11
0
        public Vetor(Direcoes pDirecao, int pIntensidade)
        {
            Direcao = pDirecao;

            Intensidade = pIntensidade;
        }