예제 #1
0
    override public void update()
    {
        base.update();

        mButtonPlay.update();

        exitButton.update();
        logo.update();

        if (mButtonPlay.isMouseOver())

        {
        }



        if (mButtonPlay.clicked())
        {
            CGame.inst().setState(new CPlatformGameState());


            return;
        }

        if (exitButton.clicked())
        {
            Application.Quit();
        }
    }
예제 #2
0
    public static void update()
    {
        shadow.update();
        text.update();
        characterPortrait.update();

        if (dialogs.Count > 0 && CKeyboard.firstPress(CKeyboard.ENTER))
        {
            if (dialogs[currentDialog].hasNextDialog())
            {
                text.setText(dialogs[currentDialog].goToNextDialog());
            }
            else if (currentDialog < dialogs.Count - 1)
            {
                currentDialog++;

                if (dialogs[currentDialog].hasPortrait())
                {
                    if (dialogs[currentDialog - 1].getPortrait() != dialogs[currentDialog].getPortrait())
                    {
                        characterPortrait.setFrames(Resources.LoadAll <Sprite>(dialogs[currentDialog].getPortrait()));
                        //characterPortrait.gotoAndPlay(1);
                        //characterPortrait.proceedAnimation();
                        characterPortrait.setVisible(true);
                    }
                }
                else
                {
                    characterPortrait.setVisible(false);
                }

                text.setText(dialogs[currentDialog].getCurrentDialog());
            }
            else
            {
                dialogs.Clear();
                text.setText("");
                shadow.setVisible(false);
                text.setVisible(false);
                currentDialog = 0;

                characterPortrait.setVisible(false);
            }
        }
    }
예제 #3
0
    override public void update()
    {
        base.update();
        //CSpriteManager.update();
        CMouse.update();
        if (current_state == STATE_PAUSE)
        {
            if (nextScreenClick())
            {
                screenDim.setImage(null);
                backMenuBttn.setImage(null);
                btnNextScreen.setImage(null);
                current_state = STATE_PLAYING;
            }
            if (backToMenuClick())
            {
                SoundList.instance.stopMusic();
                SoundList.instance.playMenuMusic();
                CGame.inst().setState(new CMenuState());
                return;
            }


            return;
        }
        mBoard.update();
        monster.update();
        building.update();
        screenDim.update();
        mTimer.update();
        optionsBttn.update();
        skills.update();
        backMenuBttn.update();
        tryAgainBttn.update();
        btnNextScreen.update();
        timeLeft.setText("TIME: " + (int)(CurrentStageData.currentTimer.getTimeLeft()));
        timeLeft.update();
        scoreText.setText("SCORE: " + (CurrentStageData.score * 10));
        scoreText.update();
        switch (current_state)
        {
        case STATE_PLAYING:
            if (optionsClick())
            {
                current_state = STATE_PAUSE;
                backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                screenDim.setX(0);
                screenDim.setY(0);
                btnNextScreen.setImage(Resources.Load <Sprite>("Sprites/Buttons/Button_Continue"));
                btnNextScreen.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 150);
                return;
            }
            if (mBoard.current_state == 0)
            {
                if (CurrentStageData.currentKaiju.scale >= 100)
                {
                    current_state = STATE_WIN;
                    SoundList.instance.stopMusic();
                    monster.setState(4);
                    building.setState(1);
                }
                else
                {
                    screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                    screenDim.setX(0);
                    screenDim.setY(0);

                    current_state = STATE_LOSE;

                    backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                    backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                    tryAgainBttn.setImage(Resources.Load <Sprite>("Sprites/tryAgainButton"));
                    tryAgainBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 100);
                    monster.setState(2);
                }
            }
            break;

        case STATE_WIN:
            CGameConstants.HIGH_SCORE = CurrentStageData.score;
            //System.IO.File.WriteAllText("score.txt", CurrentStageData.score.ToString());
            tryAgainInfo.TargetScore = CurrentStageData.score;
            if (!building.building.isEnded())
            {
                CurrentStageData.cameraShake();
            }
            else
            {
                screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                screenDim.setX(0);
                screenDim.setY(0);
                backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                tryAgainBttn.setImage(Resources.Load <Sprite>("Sprites/tryAgainButton"));
                tryAgainBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 100);

                if (backToMenuClick())
                {
                    CurrentStageData.clearData();
                    SoundList.instance.stopMusic();
                    SoundList.instance.playMenuMusic();
                    CGame.inst().setState(new CMenuState());
                    return;
                }
                if (tryAgainClick())
                {
                    CurrentStageData.clearData();
                    CGame.inst().setState(new CSurvivalState(tryAgainInfo));
                    return;
                }


                if (Camera.main.transform.position.x > 360)
                {
                    Camera.main.transform.Translate(new Vector3(-15, 0, 0));
                }
                if (Camera.main.transform.position.x < 360)
                {
                    Camera.main.transform.Translate(new Vector3(15, 0, 0));
                }
            }
            break;

        case STATE_LOSE:
            if (backToMenuClick())
            {
                CurrentStageData.clearData();
                SoundList.instance.stopMusic();
                SoundList.instance.playMenuMusic();
                CGame.inst().setState(new CMenuState());
                return;
            }
            if (tryAgainClick())
            {
                CurrentStageData.clearData();
                CGame.inst().setState(new CSurvivalState(tryAgainInfo));
                return;
            }
            break;
        }
    }
예제 #4
0
    override public void update()
    {
        int tileWidth  = CGame.inst().getMap().getTileWidth();
        int tileHeight = CGame.inst().getMap().getTileHeight();

        //Debug.Log ("test left : " + CKeyboard.pressed (CKeyboard.LEFT) + CKeyboard.pressed (CKeyboard.UP) + CKeyboard.pressed (CKeyboard.SPACE));
        //Debug.Log ("test right: " + CKeyboard.pressed (CKeyboard.RIGHT) + CKeyboard.pressed (CKeyboard.UP) + CKeyboard.pressed (CKeyboard.SPACE));

        // Guardar la posicion anterior del objeto.
        setOldYPosition();

        base.update();

        if (CKeyboard.firstPress(KeyCode.E))
        {
            this.selectNextPower();
        }
        else if (CKeyboard.firstPress(KeyCode.Q))
        {
            this.selectPreviousPower();
        }

        if (getState() == STATE_STAND)
        {
            // En stand no deberia pasar nunca que quede metido en una pared.
            // Si estamos en una pared, corregirnos.
            if (isWallLeft(getX(), getY()))
            {
                // Reposicionar el personaje contra la pared.
                setX(((mLeftX + 1) * tileWidth) - this.getLeftOffsetBoundingBox());
            }
            if (isWallRight(getX(), getY()))
            {
                // Reposicionar el personaje contra la pared.
                setX((((mRightX) * tileWidth) - getWidth()) + this.getRightOffsetBoundingBox());
            }


            // Si en el pixel de abajo del jugador no hay piso, caemos.
            if (!isFloor(getX(), getY() + 1))
            {
                setState(STATE_FALLING);
                return;
            }

            if (CKeyboard.firstPress(CKeyboard.SPACE))
            {
                setState(STATE_PRE_JUMPING);
                return;
            }

            if (CKeyboard.pressed(CKeyboard.KEY_A) && !isWallLeft(getX() - 1, getY()))
            {
                setState(STATE_WALKING);
                return;
            }

            if (CKeyboard.pressed(CKeyboard.KEY_D) && !isWallRight(getX() + 1, getY()))
            {
                setState(STATE_WALKING);
                return;
            }
        }
        else if (getState() == STATE_WALKING)
        {
            if (isWallLeft(getX(), getY()))
            {
                // Reposicionar el personaje contra la pared.
                setX(((mLeftX + 1) * tileWidth) - this.getLeftOffsetBoundingBox());
            }
            if (isWallRight(getX(), getY()))
            {
                // Reposicionar el personaje contra la pared.
                setX((((mRightX) * tileWidth) - getWidth()) + this.getRightOffsetBoundingBox());
            }

            if (CKeyboard.firstPress(CKeyboard.SPACE))
            {
                setState(STATE_PRE_JUMPING);
                return;
            }

            // Si en el pixel de abajo del jugador no hay piso, caemos.
            if (!isFloor(getX(), getY() + 1))
            {
                setState(STATE_FALLING);
                return;
            }

            if (!(CKeyboard.pressed(CKeyboard.KEY_A) || CKeyboard.pressed(CKeyboard.KEY_D)))
            {
                setState(STATE_STAND);
                return;
            }
            else
            {
                if (CKeyboard.pressed(CKeyboard.KEY_A))
                {
                    // Chequear pared a la izquierda.
                    // Si hay pared a la izquierda vamos a stand.
                    if (isWallLeft(getX(), getY()))
                    {
                        // Reposicionar el personaje contra la pared.
                        //setX((((int) getX ()/tileWidth)+1)*tileWidth);
                        setX(((mLeftX + 1) * tileWidth) - this.getLeftOffsetBoundingBox());

                        // Carlos version.
                        //setX (getX()+tileWidth/(getWidth()-1));

                        setState(STATE_STAND);
                        return;
                    }
                    else
                    {
                        // No hay pared, se puede mover.
                        setVelX(-400);
                        setFlip(true);
                    }
                }
                else
                {
                    // Chequear pared a la derecha.
                    // Si hay pared a la derecha vamos a stand.
                    if (isWallRight(getX(), getY()))
                    {
                        // Reposicionar el personaje contra la pared.
                        setX((((mRightX) * tileWidth) - getWidth()) + this.getRightOffsetBoundingBox());

                        setState(STATE_STAND);
                        return;
                    }
                    else
                    {
                        // No hay pared, se puede mover.
                        setVelX(400);
                        setFlip(false);
                    }
                }
            }
        }
        else if (getState() == STATE_PRE_JUMPING)
        {
            controlMoveHorizontal();

            if (!isFloor(getX(), getY() + 1) && getAccelY() == 0)
            {
                setAccelY(CGameConstants.GRAVITY);
            }

            if (this.isEnded())
            {
                this.setState(STATE_JUMPING);
            }
        }
        else if (getState() == STATE_JUMPING)
        {
            controlMoveHorizontal();

            if (this.getVelY() > 0)
            {
                setState(STATE_FALLING);
                return;
            }

            if (isFloor(getX(), getY() + 1))
            {
                setY(mDownY * tileHeight - getHeight());
                setState(STATE_STAND);
                return;
            }

            if (isRoof(getX(), getY() - 1))
            {
                setY(((mUpY + 1) * tileHeight) - this.getTopOffsetBoundingBox());
                setVelY(0);
                setState(STATE_HIT_ROOF);
                return;
            }
        }
        else if (getState() == STATE_FALLING)
        {
            controlMoveHorizontal();

            if (isFloor(getX(), getY() + 1))
            {
                setY(mDownY * tileHeight - getHeight());
                setState(STATE_STAND);
                return;
            }
        }
        else if (getState() == STATE_HIT_ROOF)
        {
            if (getTimeState() > 0.02f * 5.0f)
            {
                setState(STATE_FALLING);
                return;
            }
        }
        else if (getState() == STATE_DASHING)
        {
            setVelY(0);
            // Si estamos en una pared, corregirnos.
            if (isWallLeft(getX(), mOldY))
            {
                // Reposicionar el personaje contra la pared.
                setX(((mLeftX + 1) * CTileMap.Instance.getTileWidth()) - this.getLeftOffsetBoundingBox());
            }
            if (isWallRight(getX(), mOldY))
            {
                // Reposicionar el personaje contra la pared.
                setX((((mRightX) * CTileMap.Instance.getTileWidth()) - getWidth()) + this.getRightOffsetBoundingBox());
            }

            if (isFloor(getX(), getY() + 1))
            {
                setY(mDownY * CTileMap.Instance.getTileHeight() - getHeight());
            }

            if (isRoof(getX(), getY() - 1))
            {
                setY(((mUpY + 1) * CTileMap.Instance.getTileHeight()) - this.getTopOffsetBoundingBox());
            }

            if (this.getTimeState() >= 0.6f / 3 * 2)
            {
                this.initAnimation(47, 49, 12, false);
            }

            if (this.getTimeState() >= 0.6f)
            {
                this.setState(STATE_STAND);
            }
        }


        // Chequear el paso entre pantallas.
        controlRooms();

        textoPoderes.setXY(this.getX(), this.getY() - textoPoderes.getHeight());
        textoPoderes.setText(this.powers[this.selectedPower].getName());
        textoPoderes.update();

        for (int i = 0; i < this.powers.Count; i++)
        {
            this.powers[i].update();
        }
    }
예제 #5
0
    override public void update()
    {
        base.update();
        //CSpriteManager.update();
        CMouse.update();
        if (current_state == STATE_PAUSE)
        {
            if (nextScreenClick())
            {
                screenDim.setImage(null);
                backMenuBttn.setImage(null);
                btnNextScreen.setImage(null);
                current_state = STATE_PLAYING;
            }
            if (backToMenuClick())
            {
                SoundList.instance.stopMusic();
                SoundList.instance.playMenuMusic();
                CGame.inst().setState(new CMenuState());
                return;
            }


            return;
        }
        mBoard.update();
        monster.update();
        building.update();
        screenDim.update();
        mText.setText("Moves: " + mBoard.getMovementsLeft().ToString());
        mText.update();
        btnNextScreen.update();
        optionsBttn.update();
        skills.update();
        backMenuBttn.update();
        tryAgainBttn.update();
        switch (current_state)
        {
        case STATE_PLAYING:
            if (optionsClick())
            {
                current_state = STATE_PAUSE;
                backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                screenDim.setX(0);
                screenDim.setY(0);
                btnNextScreen.setImage(Resources.Load <Sprite>("Sprites/Buttons/Button_Continue"));
                btnNextScreen.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 150);
                return;
            }
            if (mBoard.current_state == 0)
            {
                if (CurrentStageData.currentKaiju.scale >= 100)
                {
                    current_state = STATE_WIN;
                    SoundList.instance.stopMusic();

                    monster.setState(4);
                    building.setState(1);
                }
                else
                {
                    screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                    screenDim.setX(0);
                    screenDim.setY(0);
                    //nextScreen.setVisible(true);
                    current_state = STATE_LOSE;
                    backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton"));
                    backMenuBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
                    tryAgainBttn.setImage(Resources.Load <Sprite>("Sprites/tryAgainButton"));
                    tryAgainBttn.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2 + 150);
                    monster.setState(2);
                }
            }
            break;

        case STATE_WIN:
            if (!building.building.isEnded())
            {
                CurrentStageData.cameraShake();
            }
            else
            {
                screenDim.setImage(Resources.Load <Sprite>("Sprites/screenShade"));
                screenDim.setX(0);
                screenDim.setY(0);
                btnNextScreen.setImage(Resources.Load <Sprite>("Sprites/Buttons/Button_Continue"));
                btnNextScreen.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);

                if (nextScreenClick())
                {
                    CurrentStageData.clearData();
                    if (CurrentStageData.currentStage >= LevelsInfo.getLevelsAmount())
                    {
                        SoundList.instance.stopMusic();
                        SoundList.instance.playMenuMusic();
                        CGame.inst().setState(new CMenuState());
                    }
                    else
                    {
                        CGame.inst().setState(new CLevelState(CurrentStageData.currentStage + 1));
                    }
                }

                if (Camera.main.transform.position.x > 360)
                {
                    Camera.main.transform.Translate(new Vector3(-15, 0, 0));
                }
                if (Camera.main.transform.position.x < 360)
                {
                    Camera.main.transform.Translate(new Vector3(15, 0, 0));
                }
            }
            break;

        case STATE_LOSE:
            if (backToMenuClick())
            {
                backMenuBttn.setImage(Resources.Load <Sprite>("Sprites/BackMenuButton_P"));
                current_state = GO_BACKMENU;
                return;
            }
            if (tryAgainClick())
            {
                tryAgainBttn.setImage(Resources.Load <Sprite>("Sprites/tryAgainButton_P"));
                current_state = GO_TRYAGAIN;
                return;
            }
            break;

        case GO_BACKMENU:
            CurrentStageData.clearData();
            SoundList.instance.stopMusic();
            SoundList.instance.playMenuMusic();
            CGame.inst().setState(new CMenuState());
            return;

        case GO_TRYAGAIN:
            CurrentStageData.clearData();
            CGame.inst().setState(new CLevelState(CurrentStageData.currentStage));
            return;
        }
    }