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

        mBackground = new CSprite();
        mBackground.setImage(Resources.Load <Sprite> ("Sprites/ui/menu/fondo"));
        mBackground.setXY(0, 0);
        mBackground.setSortingLayerName("Background");
        mBackground.setName("background");



        mButtonPlay = new CButtonSprite("Play");
        mButtonPlay.setFrames(Resources.LoadAll <Sprite>("Sprites/ui/menu/button"));
        mButtonPlay.setName("PlayImage");
        mButtonPlay.setXY(CGameConstants.SCREEN_WIDTH / 2 + 700, CGameConstants.SCREEN_HEIGHT / 2 - 150);
        mButtonPlay.setScale(500);



        exitButton = new CButtonSprite("Exit");
        exitButton.setFrames(Resources.LoadAll <Sprite>("Sprites/ui/menu/button"));
        exitButton.setName("ExitImage");
        exitButton.setXY(mButtonPlay.getX(), CGameConstants.SCREEN_HEIGHT / 3 * 2 - 10);



        logo = new CText(" ");
        logo.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 4 * 1);
        logo.setFontSize(1000f);
        logo.setPivot(0.5f, 0.5f);
        logo.setWidth(CGameConstants.SCREEN_WIDTH);
        logo.setAlignment(TMPro.TextAlignmentOptions.Center);
    }
예제 #2
0
    override public void init()
    {
        foreach (var entity in this.playerParty)
        {
            CButtonSprite playerButton = new CButtonSprite(entity.getName());
            playerButton.setXY(200, (playerButton.getHeight() * this.playerPartyButtons.Count) + 50);
            //playerButton.setSortingLayerName("Game");
            this.playerPartyButtons.Add(playerButton, entity);
        }


        mBackground = new CBackground();
        mBackground.setXY(0, 0);
        mBackground.setSortingLayerName("Background");
        this.setState(BattleState.SELECTING_ACTIONS);
    }
예제 #3
0
    override public void init()
    {
        base.init();

        mBackground = new CSprite();
        mBackground.setImage(Resources.Load <Sprite> ("Sprites/menu/menu_background"));
        mBackground.setXY(0, 0);
        mBackground.setSortingLayerName("Background");
        mBackground.setName("background");

        mButtonPlay = new CButtonSprite();
        mButtonPlay.setFrames(Resources.LoadAll <Sprite> ("Sprites/ui"));
        mButtonPlay.gotoAndStop(1);
        mButtonPlay.setXY(CGameConstants.SCREEN_WIDTH / 2, CGameConstants.SCREEN_HEIGHT / 2);
        mButtonPlay.setWidth(190);
        mButtonPlay.setHeight(50);
        mButtonPlay.setSortingLayerName("UI");
        mBackground.setName("button");
    }
예제 #4
0
    override public void update()
    {
        switch (this.getState())
        {
        case BattleState.SELECTING_ACTIONS:
            // Botones de seleccion de personaje
            foreach (var entry in this.playerPartyButtons)
            {
                // entry.Key = CButtonSprite
                // entry.Value = BattleEntity
                entry.Key.update();

                //Si se hizo click en el botón y la entidad es diferente a la actual
                if (entry.Key.clicked() && this.selectedBattleEntity != entry.Value)
                {
                    this.selectedBattleEntity = entry.Value;

                    // Deselecciono la habilidad seleccionada
                    this.selectedSkill = null;

                    // Destruimos botones antiguos de skills
                    this.clearButtonDictionary(this.skillButtons);

                    // Agregamos botones con los skills de la entidad actual
                    foreach (var skill in this.selectedBattleEntity.getSkills())
                    {
                        CButtonSprite skillButton = new CButtonSprite(skill.getName());

                        /*
                         *      Posición de botones:
                         *      X = Ancho de pantalla - (Ancho de Botón + Margen)
                         *      Y = Alto de pantalla - (Alto de Botón * (Cantidad total de Skills - Cantidad de skills ya mostradas en botones))
                         */
                        skillButton.setXY(CGameConstants.SCREEN_WIDTH - (skillButton.getWidth() * 2.5f),
                                          CGameConstants.SCREEN_HEIGHT - (skillButton.getHeight() * (this.selectedBattleEntity.getSkills().Count - this.skillButtons.Count)));
                        //skillButton.setSortingLayerName("Game");
                        this.skillButtons.Add(skillButton, skill);
                    }
                }
                //for each entry in playerPartyButtons, if the entity is Dead, its key(button) and Value(unit) are
                deletebuttonsOfPartyMembers(entry.Key, entry.Value);
            }

            // Botones de skills
            foreach (var entry in this.skillButtons)
            {
                entry.Key.update();
                entry.Key.setVisible(this.selectedBattleEntity != null);

                // Si se hizo click en el botón de skill y la entidad es diferente a la actual
                if (entry.Key.clicked() && this.selectedSkill != entry.Value)
                {
                    this.selectedSkill = entry.Value;
                    this.setTargetButtons();
                }
            }

            // Botones de Enemigos
            foreach (var entry in this.targetButtons)
            {
                //Si no se ha clickeado un boton de skill anteriormente, el boton de enemigo no es visible.
                if (this.selectedSkill == null)
                {
                    entry.Key.setVisible(false);
                }
                else
                {
                    entry.Key.setVisible(true);
                }

                entry.Key.update();

                if (entry.Key.clicked())
                {
                    this.addAction(this.selectedBattleEntity, this.selectedSkill, entry.Value);

                    //Esconder el botón de el jugador que ya escogió accion
                    foreach (var playerButton in this.playerPartyButtons)
                    {
                        if (playerButton.Value == this.selectedBattleEntity)
                        {
                            playerButton.Key.setVisible(false);
                        }
                    }

                    this.selectedSkill        = null;
                    this.selectedBattleEntity = null;
                }
            }
            break;

        case BattleState.PERFORMING_ACTIONS:
            if (this.selectedActions.Count <= 0)
            {
                this.setState(BattleState.SELECTING_ACTIONS);
            }
            else
            {
                this.selectedActions[0].update();

                if (this.selectedActions[0].getState() == Action.FINISHED)
                {
                    Debug.Log("Accion: Terminada");
                    this.selectedActions[0].destroy();
                    this.selectedActions.RemoveAt(0);
                }
            }
            break;
        }

        foreach (var player in this.playerParty)
        {
            player.update();
        }

        foreach (var enemy in this.enemyParty)
        {
            enemy.update();
        }

        //se encarga de que cuando una abilidad que tiene efecto tardio y se esta performeando, se cargue la animacion
        //mTurnActionManager.update();
    }