Esempio n. 1
0
    IEnumerator SmashBehaviour()
    {
        float travelDistance    = 0;
        float maxTravelDistance = 1f;

        while (travelDistance < maxTravelDistance)
        {
            travelDistance     += Mathf.Abs(direction.x * speed * Time.deltaTime);
            transform.position += new Vector3(direction.x * speed * Time.deltaTime, 0, 0);
            yield return(null);
        }

        yield return(new WaitForSeconds(0.5f));

        speed = 30f;

        Vector3 targetPos = new Vector3(-direction.x * sprRend.sprite.bounds.size.y * 0.5f, transform.position.y, transform.position.z);

        while (transform.position != targetPos)
        {
            transform.position = Vector3.MoveTowards(transform.position, targetPos, speed * Time.deltaTime);
            yield return(new WaitForEndOfFrame());
        }
        AudioManager.PlayOneShot(soundEffect);
        BattleBox.ShakeBox(0.5f, 0.10f, 0.10f);

        StartCoroutine(FadeOut());
    }
Esempio n. 2
0
        static void RunGame()
        {
            Console.Clear();
            ShowMenu();
            var key = ReadOption();

            switch (key.Key)
            {
            case ConsoleKey.D1:
                Console.Clear();
                var battleBox = new BattleBox();
                battleBox.GenerateRobots();
                battleBox.GenerateObstacles(4);
                StartGame(battleBox);
                break;

            case ConsoleKey.D2:
                Console.WriteLine("Presione [ENTER] para salir...");
                Console.ReadLine();
                break;

            default:
                RunGame();
                break;
            }
        }
Esempio n. 3
0
        static void StartGame(BattleBox battleBox)
        {
            Console.Clear();
            battleBox.DrawAll();
            Console.ForegroundColor = ConsoleColor.White;
            Console.SetCursorPosition(0, Helpers.ConstantHelpers.MAP.MAX_Y * 2 + 2);
            Console.WriteLine("Presione [ESC] para salir...");
            Console.WriteLine("Presione [+] para agregar robot...");
            Console.WriteLine("Presione [->] para simular el siguiente movimiento...");
            Console.WriteLine("=== Log ===");
            var key2 = Console.ReadKey();

            switch (key2.Key)
            {
            case ConsoleKey.OemPlus:
                Console.Clear();
                Console.WriteLine("INFORMACION DEL ROBOT");
                Console.Write("Ingrese el nombre:");
                var name = Console.ReadLine();
                Console.Write("Ingrese el peso: ");
                float.TryParse(Console.ReadLine(), out float weight);
                Console.Write("Ingrese el tamaño: ");
                float.TryParse(Console.ReadLine(), out float size);
                Console.Write("Ingrese el # de vidas: ");
                int.TryParse(Console.ReadLine(), out int lifes);
                Console.Write("Ingrese el color (red/yellow/green/blue/gray/magenta/cyan/darkred/darkblue/darkyellow/darkcyan/darkmagenta/darkgreen): ");
                var color = Console.ReadLine().ToColor();
                var rand  = new Random();
                Console.Write($"Ingrese la posición X [de 0 a {ConstantHelpers.MAP.MAX_X - 1}] (vacío para que se genere aleatoriamente): ");
                var r1 = int.TryParse(Console.ReadLine(), out int posX);
                posX = r1 && posX < ConstantHelpers.MAP.MAX_X && posX >= 0 ? posX : rand.Next(0, ConstantHelpers.MAP.MAX_X);
                Console.Write($"Ingrese la posición Y [de 0 a {ConstantHelpers.MAP.MAX_Y - 1}] (vacío para que se genere aleatoriamente): ");
                var r2 = int.TryParse(Console.ReadLine(), out int posY);
                posY = r2 && posY < ConstantHelpers.MAP.MAX_Y && posY >= 0 ? posY : rand.Next(0, ConstantHelpers.MAP.MAX_Y);
                battleBox.GenerateRobot(name, weight, size, lifes, color, posX, posY);
                Console.WriteLine("Robot Agregado...");
                Console.WriteLine("Presione una tecla para regresar al juego");
                Console.ReadKey();
                StartGame(battleBox);
                break;

            case ConsoleKey.RightArrow:
                battleBox.MoveAll();
                battleBox.CheckForCollisions();
                StartGame(battleBox);
                break;

            case ConsoleKey.Escape:
                return;

            default:
                StartGame(battleBox);
                break;
            }
        }
Esempio n. 4
0
 private void Awake()
 {
     instance = this;
     startPos = transform.position;
 }