public StageSelect(ContentManager content, GraphicsDevice graphicsDevice)
        {
            this.content = content;
            this.graphicsDevice = graphicsDevice;

            background = content.Load<Texture2D>("Config/background");
            frame = content.Load<Texture2D>("Config/frame");
            itemBox = content.Load<Texture2D>("Config/item_box");
            enter = content.Load<Texture2D>("Config/enter");
            config = content.Load<Texture2D>("Config/config");
            stage = content.Load<Texture2D>("Config/stage");
            enemy = content.Load<Texture2D>("Config/enemy");
            start = content.Load<Texture2D>("Config/start");
            small = content.Load<Texture2D>("Config/small");
            regular = content.Load<Texture2D>("Config/regular");
            big = content.Load<Texture2D>("Config/big");
            few = content.Load<Texture2D>("Config/few");
            much = content.Load<Texture2D>("Config/much");
            selectLine = content.Load<Texture2D>("Config/select_line");
            selectItem = content.Load<Texture2D>("Config/select_item");

            configPosition = new Vector2(GameMain.ScreenWidth / 2.0f, 70);
            stagePosition = new Vector2(GameMain.ScreenWidth / 2.0f, 170);
            stageSelectPosition = new Vector2(GameMain.ScreenWidth / 2.0f, 230);
            enemyPosition = new Vector2(GameMain.ScreenWidth / 2.0f, 320);
            enemySelectPosition = new Vector2(GameMain.ScreenWidth / 2.0f, 380);
            startPosition = new Vector2(GameMain.ScreenWidth / 2.0f, 490);
            targetPosition = new Vector2(200, 0);

            select = Select.Stage;
            selectStage = SelectStage.Regular;
            selectEnemy = SelectEnemy.Regular;

            cueBGM = SoundManager.Instance.SoundBank.GetCue("config");
            cueBGM.Play();
        }
    // change this to return State
    public State SelectTile(State currentState, Tile targetTile)
    {
        Action action    = null;
        var    nextState = currentState;

        // I wonder if I can somehow make this a bit more logical
        // instead of stepping through the conditions and returning an Action/Transition,
        // can I define the conditions for an Action/Transition and return whatever Transition matches the current conditions?
        if (!(currentState is EnemyTurnState))
        {
            if (currentState is NoSelectionState)
            {
                if (targetTile.occupier != null)
                {
                    if (targetTile.occupier.isAllied)
                    {
                        action = new SelectAlly(targetTile.occupier);
                    }
                    else
                    {
                        action = new SelectEnemy(targetTile.occupier);
                    }
                }
                else
                {
                    action = new Unselect();
                }
            }
            if (currentState is AllySelectedState)
            {
                var stateData = (AllySelectedState)currentState;
                // what is the tile they are clicking on? do they want to move? do they want to attack?
                if (targetTile.occupier != null)
                {
                    var target = targetTile.occupier;
                    // clicking on another entity
                    // if entity is enemy: Attack
                    if (target.isHostile && stateData.attackRange.Contains(targetTile))
                    {
                        action = new Attack(stateData.source, target);
                    }
                    // if entity is ally: interact (to be implemented later)
                }
                else if (stateData.moveRange.Contains(targetTile))
                {
                    // if space is empty: move there (if possible)
                    // parent.tilemap.MoveEntity(selectedEntity.tile, targetTile);
                    action = new Move(stateData.source, targetTile);
                }
                else
                {
                    action = new Unselect();
                }
            }
            if (currentState is EnemySelectedState)
            {
                if (targetTile.occupier == null)
                {
                    action = new Unselect();
                }
            }
            if (currentState is SelectSkillActivatedState)
            {
                var stateData    = (SelectSkillActivatedState)currentState;
                var tilesInRange = stateData.validTiles.Union(stateData.selectedTiles);
                if (tilesInRange.Contains(targetTile))
                {
                    action = new SelectSkillTile(stateData.source, targetTile);
                }
            }
            if (currentState is TeleportActivatedState)
            {
                var stateData = (TeleportActivatedState)currentState;
                if (stateData.validTiles.Contains(targetTile))
                {
                    action = new SelectTeleportTile(stateData.source, targetTile);
                }
            }
        }

        if (action != null)
        {
            // remove all instances of parent here
            nextState = action.Transition(currentState, parent.tilemap, parent.dialog);
        }

        return(nextState);
    }
        public SceneInterface Update(GameTime gameTime)
        {
            // Spaceキー入力でゲーム画面へ移行
            if (Input.Instance.PushKey(Keys.Space) && select == Select.Start)
            {
                SoundManager.Instance.SoundBank.PlayCue("ok");
                cueBGM.Stop(AudioStopOptions.AsAuthored);
                return new GameIn(content, graphicsDevice, gameTime, selectStage, selectEnemy);
            }
            // タイトルへ
            if (Input.Instance.PushKey(Keys.B))
            {
                SoundManager.Instance.SoundBank.PlayCue("cancel");
                cueBGM.Stop(AudioStopOptions.AsAuthored);
                return new Title(content, graphicsDevice);
            }

            // 前の状態を保存
            Select prevSelect = select;
            SelectStage prevSelectStage = selectStage;
            SelectEnemy prevSelectEnemy = selectEnemy;

            if (Input.Instance.PushKey(Keys.Up))
                select--;
            if (Input.Instance.PushKey(Keys.Down))
                select++;
            if (select < 0)
                select = 0;
            if ((int)select >= Enum.GetNames(typeof(Select)).Length)
                select = (Select)Enum.GetNames(typeof(Select)).Length - 1;

            if (Input.Instance.PushKey(Keys.Left))
                switch (select)
                {
                    case Select.Stage:
                        selectStage--;
                        break;
                    case Select.Enemy:
                        selectEnemy--;
                        break;
                }
            if (Input.Instance.PushKey(Keys.Right))
                switch (select)
                {
                    case Select.Stage:
                        selectStage++;
                        break;
                    case Select.Enemy:
                        selectEnemy++;
                        break;
                }
            if (selectStage < 0)
                selectStage = 0;
            if ((int)selectStage >= Enum.GetNames(typeof(SelectStage)).Length)
                selectStage = (SelectStage)Enum.GetNames(typeof(SelectStage)).Length - 1;
            if (selectEnemy < 0)
                selectEnemy = 0;
            if ((int)selectEnemy >= Enum.GetNames(typeof(SelectEnemy)).Length)
                selectEnemy = (SelectEnemy)Enum.GetNames(typeof(SelectEnemy)).Length - 1;

            // 前の状態から変わっていたら音を鳴らす
            if (select != prevSelect || selectStage != prevSelectStage || selectEnemy != prevSelectEnemy)
                SoundManager.Instance.SoundBank.PlayCue("select");

            return this;
        }
Beispiel #4
0
 void Awake()
 {
     instance = this;
 }