bool flyUp()
        {
            bool isUp = false;

            if (!isStepGravityEnable)
            {
                // Asegurarse que el boss mira hacia el player.
                boss.putLookingToPlayer();
                // Cambiamos el estado al mismo que el de salto.
                boss.onlyChangeToJumpState();
                boss.setIsTouchFloor(false);
                // Desactivamos la gravedad.
                boss.enableGravity(false);
                isStepGravityEnable = true;
            }

            isUp = (boss.transform.position.y >= ceilingMargin + UserInterfaceGraphics.getHeightCamera());
            if (isUp)
            {
                // Paramos y reseteamos las variables utilizadas.
                boss.setVelocity(0, 0);
                isStepGravityEnable = false;
            }
            else
            {
                // Lanzamos impulso ascendente hacia el aliado.
                boss.setVelocity(boss.transform.localScale.x * factorImpulseX, factorImpulseY);
            }

            return(isUp);
        }
    // Use this for initialization
    void Start()
    {
        gamecamera = GameObject.FindGameObjectWithTag("MainCamera");

        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
    }
Beispiel #3
0
    // Use this for initialization
    void Start()
    {
        gamecamera             = GameObject.FindGameObjectWithTag("MainCamera");
        cameraFollow           = (CameraFollow)gamecamera.GetComponent("CameraFollow");
        pauseMenu              = (PauseMenu)gamecamera.GetComponent("PauseMenu");
        goPlayer               = GameObject.FindGameObjectWithTag("Player");
        anim                   = gameObject.GetComponent <Animator>();
        rb2d                   = gameObject.GetComponent <Rigidbody2D>();
        currentTimeInAssault   = 0f;
        countJumpUntilAssault  = 0;
        isInAssault            = false;
        firstMovementToAssault = false;
        isTouchFloor           = true;
        isLaunchPowerUp        = false;
        //------------- Colisiones a ignorar.
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY, UserInterfaceGraphics.LAYER_ENEMY, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY_SHOOT, UserInterfaceGraphics.LAYER_ENEMY, true);
        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
        //------------- Creo la sombra del enemigo.
        shadow = GameObject.Instantiate <GameObject>(shadowPrefabs);
        ShadowCharacter sc = (ShadowCharacter)shadow.GetComponent("ShadowCharacter");

        sc.characterToFollow = gameObject;
    }
Beispiel #4
0
    // Use this for initialization
    void Start()
    {
        gamecamera    = GameObject.FindGameObjectWithTag("MainCamera");
        cameraFollow  = (CameraFollow)gamecamera.GetComponent("CameraFollow");
        isBlockCamera = true;
        isActive      = false;

        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
    }
    void Start()
    {
        isInit            = true;
        numberLevel       = 0;
        currentPointLevel = 0;
        notificateNewLevel();

        gamecamera = GameObject.FindGameObjectWithTag("MainCamera");
        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
    }
    // Use this for initialization
    void Start()
    {
        isCalledEnemies   = false;
        unlockCamera      = false;
        isEnd             = false;
        numEnemiesCreated = 0;
        gamecamera        = GameObject.FindGameObjectWithTag("MainCamera");
        blockCamera       = (BlockCamera)gameObject.GetComponent("BlockCamera");
        enemiesCreated    = new System.Collections.Generic.List <GameObject>();

        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
    }
    void Start()
    {
        // Lo típico.
        gamecamera            = GameObject.FindGameObjectWithTag("MainCamera");
        cameraFollow          = (CameraFollow)gamecamera.GetComponent("CameraFollow");
        pauseMenu             = (PauseMenu)gamecamera.GetComponent("PauseMenu");
        goPlayer              = GameObject.FindGameObjectWithTag("Player");
        player                = (Player)goPlayer.GetComponent("Player");
        anim                  = gameObject.GetComponent <Animator>();
        rb2d                  = gameObject.GetComponent <Rigidbody2D>();
        isTouchFloor          = true;
        currentTimeLaunchMine = 0f;
        //------------- Colisiones a ignorar.
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY, UserInterfaceGraphics.LAYER_ENEMY, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY_SHOOT, UserInterfaceGraphics.LAYER_ENEMY, true);
        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
        //------------- Creo la sombra del enemigo.
        shadow = GameObject.Instantiate <GameObject>(shadowPrefabs);
        ShadowCharacter sc = (ShadowCharacter)shadow.GetComponent("ShadowCharacter");

        sc.characterToFollow = gameObject;

        // Creamos estrategias e inicializamos variables asociadas a las mismas.
        strategies = new Strategy[] { new StopStrategy(1f, this), new StopStrategy(0.5f, this),
                                      new JumpStrategy(-1f, this), new CallEnemiesStrategy(-1f, this),
                                      new FlyTypeZ(-1f, this), new AssaultStrategy(-1, this), new StopStrategy(2f, this) };
        indexCurrentStrategy = 0;
        isIn23      = true;
        isIn13      = false;
        currentJump = 0;
        maxLife     = currentLife;
        // Como al inicio estamos en idle (y no en RUN o JUMP), activo las manos, desactivo el boss.
        enableHands(true);
        isActive = false;
        // No está parpadeando en rojo al inicio.
        currentTimeBlink = 0;
        isInRedColor     = false;
        isBlinkInRed     = false;
        // Desactivo colisiones que no necesito.
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_BOSS, UserInterfaceGraphics.LAYER_ENEMY, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_BOSS, UserInterfaceGraphics.LAYER_ENEMY_SHOOT, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_BOSS, UserInterfaceGraphics.LAYER_POWER_UP, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_BOSS_HANDS, UserInterfaceGraphics.LAYER_ENEMY, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_BOSS_HANDS, UserInterfaceGraphics.LAYER_ENEMY_SHOOT, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_BOSS_HANDS, UserInterfaceGraphics.LAYER_POWER_UP, true);
    }
    void checkActions()
    {
        // Comprobar si se ha pulsado en un "botón" de la pantalla mediante el teclado.
        bool isKeyboard = Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W) ||
                          Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.X);
        float axisV = (isKeyboard)? 0 : UserInterfaceGraphics.getAxisVerticalForMenus();

        if (Input.GetKeyDown(KeyCode.UpArrow) || Input.GetKeyDown(KeyCode.W) || (axisV == 1f))
        {
            // Si hemos pulsado arriba, seleccionamos opción de arriba.
            decrementCurrentOption();
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow) || Input.GetKeyDown(KeyCode.S) || Input.GetKeyDown(KeyCode.X) || (axisV == -1f))
        {
            // Si hemos pulsado abajo, seleccionamos opción de abajo.
            incrementCurrentOption();
        }
        else if (Input.GetKeyDown(KeyCode.F) || Input.GetKeyDown(KeyCode.J) || Input.GetKeyDown(KeyCode.K) ||
                 Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return) || Input.GetKeyDown(KeyCode.JoystickButton0))
        {
            // Si ha pulsado la F, J, K, el espacio o la tecla enter, confirmar la opción seleccionada.
            launchCurrentOption();
        }

        // Cambiar de color las opciones no seleccionadas y esconder las flecha no activas (si hay flechas en el menú).
        bool areArrows = (arrowImageTextsMenuPause != null) && (arrowImageTextsMenuPause.Length == textsMenuPause.Length);

        for (int i = 0; i < textsMenuPause.Length; i++)
        {
            tmMenuPause[i].color = new Color(rgbaColorUnselected[0], rgbaColorUnselected[1], rgbaColorUnselected[2]);
            if (areArrows)
            {
                SpriteRenderer sr = srArrowMenuPause[i];
                sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, 0f);
            }
        }
        // Cambiar de color la opción seleccionada y mostrar la flecha indicada (si hay flechas en el menú).
        tmMenuPause[currentOption].color = new Color(RGBA_COLOR_SELECTED[0], RGBA_COLOR_SELECTED[1], RGBA_COLOR_SELECTED[2]);
        if (areArrows)
        {
            SpriteRenderer sr = srArrowMenuPause[currentOption];
            sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, 1f);
        }
    }
Beispiel #9
0
    // Use this for initialization
    void Start()
    {
        gamecamera       = GameObject.FindGameObjectWithTag("MainCamera");
        cameraFollow     = (CameraFollow)gamecamera.GetComponent("CameraFollow");
        pauseMenu        = (PauseMenu)gamecamera.GetComponent("PauseMenu");
        goPlayer         = GameObject.FindGameObjectWithTag("Player");
        player           = (Player)goPlayer.GetComponent("Player");
        anim             = gameObject.GetComponent <Animator>();
        rb2d             = gameObject.GetComponent <Rigidbody2D>();
        isLookingToRight = true;
        isInAttackMode   = false;
        timeToAttack     = 0;
        timeInAttack     = TIME_IN_ATTACK;
        //------------- Colisiones a ignorar.
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY, UserInterfaceGraphics.LAYER_ENEMY, true);
        Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY_SHOOT, UserInterfaceGraphics.LAYER_ENEMY, true);
        //------------- Calcular ancho de la cámara.
        widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
        //------------- Creo la sombra del enemigo.
        shadow = GameObject.Instantiate <GameObject>(shadowPrefabs);
        ShadowCharacter sc = (ShadowCharacter)shadow.GetComponent("ShadowCharacter");

        sc.characterToFollow = gameObject;
    }
Beispiel #10
0
 // Use this for initialization
 void Start()
 {
     Player.score          = 0;
     Player.timeGame       = 1000;
     gamecamera            = GameObject.FindGameObjectWithTag("MainCamera");
     cameraFollow          = (CameraFollow)gamecamera.GetComponent("CameraFollow");
     pauseMenu             = (PauseMenu)gamecamera.GetComponent("PauseMenu");
     rb2d                  = gameObject.GetComponent <Rigidbody2D>();
     anim                  = gameObject.GetComponent <Animator>();
     currentLife           = maxLife;
     timerAttack           = 0;
     timeMatrix            = 0;
     timeToRefleshTimeGame = 0;
     timeToShowGo          = 0;
     isLookingToRight      = true;
     goAlertArrow.GetComponent <Renderer>().enabled = false;
     activeBlinkHurt  = false;
     currentTimeBlink = 0;
     //------------- Calcular ancho de la cámara.
     widthCamera = UserInterfaceGraphics.getWidthCamera() / 2;
     // Para cuando muere el player y vuelve a iniciarse el juego.
     Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY_SHOOT, UserInterfaceGraphics.LAYER_PLAYER, false);
     Physics2D.IgnoreLayerCollision(UserInterfaceGraphics.LAYER_ENEMY, UserInterfaceGraphics.LAYER_PLAYER, false);
 }