예제 #1
0
        List <Data.Character> retrayPlayerCaracters; // リトライ時の記録・再現用

        public BattleScene(string scriptPath)
        {
            scriptAPI = new ScriptAPI();
            script    = new Emugen.Script.Script <ScriptAPI>(scriptPath, scriptAPI);
            script.Run();

            var data = Data.DataCreater.Instance;

            if (scriptAPI.__bgmPath != null)
            {
                var bgm = new Emugen.Sound.SoundPlayer(scriptAPI.__bgmPath, 0.20f, true, Emugen.Sound.SoundPlayer.SoundType.BGM);
            }

            SetupPlayers();
            SetupEnemys();

            {
                PlayerCards = new UI.PlayerCard.PlayerCards();
                layer.Add(PlayerCards, 30);
            }

            {
                EnemyCards = new UI.EnemyCard.EnemyCards();
                layer.Add(EnemyCards, 20);
            }

            {
                var bmp     = new System.Drawing.Bitmap(scriptAPI.__backGroundImagePath);
                var texture = new Texture(bmp);

                var w      = 1600;
                var h      = (int)((double)bmp.Height / (double)bmp.Width * w);
                var sprite = new ImageSprite(texture, new Rect(new Vector2D(0, 0), new Vector2D(w, h)), new Color(1, 1, 1, 1));
                layer.Add(sprite, 10);
            }
            {
                var skillCards = new UI.SkillCard.SkillCards();
                layer.Add(skillCards, 40);
                SkillCards = skillCards;
            }

            {
                var sprite = new PlaneSprite(new Rect(new Vector2D(20, 100), new Vector2D(200, 1)), new Color(0.5, 1, 1, 1));
                layer.Add(sprite, 10);
            }
            {
                foreach (var chara in data.playerCharacters)
                {
                    PlayerCards.Add(chara);
                }
                PlayerCards.SetupCardPos();
            }
            SetupEnemysCard();

            {
                PlayerCards.OnSelected += (selectCards) =>
                {
                    switch (uiStep)
                    {
                    case UIStep.None:
                    {
                        var i = (List <UI.PlayerCard.PlayerCard>)selectCards;
                        if (i[0].character.HP.Now == 0)
                        {
                            // 戦闘不能
                        }
                        else
                        {
                            SkillCards.SetStep(UI.SkillCard.SkillCards.Step.ShowPlayerCharacterSkills, i[0].character);
                            var soundPlayer = new Emugen.Sound.SoundPlayer(MainConfig.SoundEffect.UISelect01, 0.10f, false, Emugen.Sound.SoundPlayer.SoundType.SE);
                            uiStep           = UIStep.SkillSelect;
                            SelectPlayerCard = selectCards[0];
                        }
                    }
                    break;

                    case UIStep.SkillSelect:
                        break;

                    case UIStep.SkillTargetSelect:
                        if (!isInputEventNowFrame)
                        {
                            isInputEventNowFrame = true;
                            new Emugen.Sound.SoundPlayer(MainConfig.SoundEffect.UISelect01, 0.10f, false, Emugen.Sound.SoundPlayer.SoundType.SE);

                            uiStep = UIStep.None;
                            EnemyCards.uITargetSelectType  = UI.EnemyCard.EnemyCards.UITargetSelectType.None;
                            PlayerCards.uITargetSelectType = UI.PlayerCard.PlayerCards.UITargetSelectType.None;

                            var i = (List <UI.PlayerCard.PlayerCard>)selectCards;
                            //var i = (List<FafTk.UI.EnemyCard.EnemyCard>)selectCards;
                            var targetCharacters = new List <Data.Character>();
                            foreach (var j in i)
                            {
                                targetCharacters.Add(j.character);
                            }

                            SelectPlayerCard.character.Action(SelectSkillCard.actionSkill, targetCharacters);
                        }
                        break;
                    }
                };
            }
            {
                SkillCards.OnSelected += (selectCard) =>
                {
                    switch (uiStep)
                    {
                    case UIStep.None:
                        break;

                    case UIStep.SkillSelect:
                        if (!isInputEventNowFrame)
                        {
                            isInputEventNowFrame = true;
                            var soundPlayer = new Emugen.Sound.SoundPlayer(MainConfig.SoundEffect.UISelect01, 0.10f, false, Emugen.Sound.SoundPlayer.SoundType.SE);
                            uiStep          = UIStep.SkillTargetSelect;
                            SelectSkillCard = selectCard;

                            if (SelectSkillCard.actionSkill.Main.TargetWord.IndexOf("横列") == 0)
                            {
                                var command = SelectSkillCard.actionSkill.Main.TargetWord.Split(' ');

                                EnemyCards.uITargetSelectType        = UI.EnemyCard.EnemyCards.UITargetSelectType.LineHorizontal;
                                EnemyCards.uITargetSelectTypePalams  = new int[] { int.Parse(command[1]), int.Parse(command[2]), int.Parse(command[3]) };
                                PlayerCards.uITargetSelectType       = UI.PlayerCard.PlayerCards.UITargetSelectType.LineHorizontal;
                                PlayerCards.uITargetSelectTypePalams = new int[] { int.Parse(command[1]), int.Parse(command[2]), int.Parse(command[3]) };
                            }
                            else
                            {
                                var command = SelectSkillCard.actionSkill.Main.TargetWord.Split(' ');

                                EnemyCards.uITargetSelectType        = UI.EnemyCard.EnemyCards.UITargetSelectType.One;
                                EnemyCards.uITargetSelectTypePalams  = new int[] { int.Parse(command[1]) };
                                PlayerCards.uITargetSelectType       = UI.PlayerCard.PlayerCards.UITargetSelectType.One;
                                PlayerCards.uITargetSelectTypePalams = new int[] { int.Parse(command[1]) };
                            }
                        }
                        break;

                    case UIStep.SkillTargetSelect:
                        break;
                    }
                };

                SkillCards.OnClose += () =>
                {
                    switch (uiStep)
                    {
                    case UIStep.None:
                        break;

                    case UIStep.SkillSelect:
                        if (!isInputEventNowFrame)
                        {
                            isInputEventNowFrame = true;
                            var soundPlayer = new Emugen.Sound.SoundPlayer(MainConfig.SoundEffect.UICancel01, 0.15f, false, Emugen.Sound.SoundPlayer.SoundType.SE);

                            uiStep = UIStep.None;
                            EnemyCards.uITargetSelectType  = UI.EnemyCard.EnemyCards.UITargetSelectType.None;
                            PlayerCards.uITargetSelectType = UI.PlayerCard.PlayerCards.UITargetSelectType.None;
                        }
                        break;

                    case UIStep.SkillTargetSelect:
                        break;
                    }
                };
            }
            {
                EnemyCards.OnSelected += (selectCards) =>
                {
                    switch (uiStep)
                    {
                    case UIStep.None:
                        break;

                    case UIStep.SkillSelect:
                        break;

                    case UIStep.SkillTargetSelect:
                        if (!isInputEventNowFrame)
                        {
                            isInputEventNowFrame = true;

                            uiStep = UIStep.None;
                            EnemyCards.uITargetSelectType  = UI.EnemyCard.EnemyCards.UITargetSelectType.None;
                            PlayerCards.uITargetSelectType = UI.PlayerCard.PlayerCards.UITargetSelectType.None;

                            //var result = false;

                            var targetCharacters = new List <Character>();
                            var i = (List <UI.EnemyCard.EnemyCard>)selectCards;
                            foreach (var j in i)
                            {
                                targetCharacters.Add(j.character);
                            }
                            var result = SelectPlayerCard.character.Action(SelectSkillCard.actionSkill, targetCharacters);

                            if (result)
                            {
                                new Emugen.Sound.SoundPlayer(MainConfig.SoundEffect.UISelect01, 0.10f, false, Emugen.Sound.SoundPlayer.SoundType.SE);
                            }
                            else
                            {
                                new Emugen.Sound.SoundPlayer(MainConfig.SoundEffect.UICancel01, 0.10f, false, Emugen.Sound.SoundPlayer.SoundType.SE);
                            }
                        }

                        break;
                    }
                };
            }
        }
예제 #2
0
        public void Update()
        {
            UI.PlayerCard.PlayerCard selectCard = null;
            foreach (var card in cards)
            {
                card.Update();
                if (card.isMouseOn)
                {
                    selectCard = card;
                }
            }

            switch (uITargetSelectType)
            {
            case UITargetSelectType.None:
                foreach (var card in cards)
                {
                    if (card == selectCard)
                    {
                        card.isMouseOnUITarget    = true;
                        card.mouseOnTarget.IsDraw = true;
                    }
                    else
                    {
                        card.isMouseOnUITarget    = false;
                        card.mouseOnTarget.IsDraw = false;
                    }
                }
                break;

            case UITargetSelectType.One:
                foreach (var card in cards)
                {
                    if (card == selectCard)
                    {
                        card.isMouseOnUITarget    = true;
                        card.mouseOnTarget.IsDraw = true;
                    }
                    else
                    {
                        card.isMouseOnUITarget    = false;
                        card.mouseOnTarget.IsDraw = false;
                    }
                }
                break;

            case UITargetSelectType.LineHorizontal:
            {
                // todo : 味方に列がないような作りになっている(いったんは、3人と人数が少ないので
                if (selectCard != null)
                {
                    foreach (var card in cards)
                    {
                        card.isMouseOnUITarget    = true;
                        card.mouseOnTarget.IsDraw = true;
                    }
                }
                else
                {
                    foreach (var card in cards)
                    {
                        card.isMouseOnUITarget    = false;
                        card.mouseOnTarget.IsDraw = false;
                    }
                }

                if ((lastMouseOnTargetCard != selectCard) && (selectCard != null))
                {
                    var linePosition = selectCard.character.linePosition;
                    foreach (var card in cards)
                    {
                        if (card.character.linePosition == linePosition)
                        {
                            card.mouseOnTargetFadeTimer = 0;
                        }
                    }
                }
                lastMouseOnTargetCard = selectCard;
            }
            break;
            }

            {
                var input = Emugen.Input.InputCore.Instance;
                if ((input.GetKeyEventType(Emugen.Input.InputCore.KeyEventCode.MouseLeftButton) == Emugen.Input.InputCore.KeyEventType.Up) && (selectCard != null))
                {
                    var selectCards = new List <PlayerCard>();
                    foreach (var card in cards)
                    {
                        if (card.isMouseOnUITarget)
                        {
                            selectCards.Add(card);
                        }
                    }
                    if (OnSelected != null)
                    {
                        OnSelected(selectCards);
                    }
                }
            }
        }