Пример #1
0
 public WarUnit GetInitiativeUnit(Situation situation)
 {
     do
     {
         // 行動可能な生存者を取得する
         while (_waitingUnits.Count != 0)
         {
             var unit = _waitingUnits.Dequeue();
             if (unit.Alive && unit.Status.IsFreezing == false)
             {
                 // イニシアチブを取ったので、行動値を減らす
                 unit.AddActivity(situation, -NEEDED_ACTIVITY);
                 return unit;
             }
         }
         // 行動可能な生存者の行動値を増やす
         var freeUnits = situation.Units.Alive
             .Where(u => !u.Status.IsFreezing);
         foreach (var unit in freeUnits)
         {
             unit.AddActivity(situation, (int)(unit.Status.Agi * 0.8 + 54.5));
             //
             if (unit.Status.Activity > NEEDED_ACTIVITY)
                 _waitingUnits.Enqueue(unit);
         }
         // ターン処理を進める
     } while (++_loopCount <= MAX_LOOP);
     _loopCount = 0;
     return null;
 }
Пример #2
0
        public void ShowMapWindow(Situation situation, WarPresentationModel model)
        {
            // �Ƃ肠�����S�ẴE�B���h�E��\������
            // MapWindow �C���X�^���X�̐���
            var mapWindow = new MapWindow(model);
            mainDock = mapWindow;
            mainDock.AllowEndUserDocking = false;
            mainDock.Show(dockPanel, DockState.Document);

            var commandWindow = new CommandWindow(model);
            commandWindow.Show(mapWindow.Pane, DockAlignment.Top, 0.12);

            var mapChipInfoWindow = new MapChipInfoWindow(model);
            mapChipInfoWindow.Show(commandWindow.Pane, DockAlignment.Right, 0.5);

            // UnitMiniInfoWindow�\���p
            Action<Point2> showUnitMiniInfoWindow = delegate(Point2 p) {
                var unit = model.WarMap[p].Unit;
                if (unit != null)
                {
                    MiniUnitInfoWindow.ShowWindow(this, unit);
                }
                else
                {
                    MiniUnitInfoWindow.HideWindow();
                }
            };

            // MapChip�N���b�N�ɂ��UnitInfoWindow�̕\���̃f���Q�[�g��lj�
            model.SelectMapChipEvent += p => {
                var unit = model.WarMap[p].Unit;
                if (unit != null && model.Scope == null)
                    UnitInfoWindow.ShowWindow(this, unit);
                else
                    UnitInfoWindow.HideWindow();
            };

            model.CursorChipPointChangedEvent += showUnitMiniInfoWindow;
            model.CursorEnterEvent += showUnitMiniInfoWindow;
            model.CursorLeaveEvent += delegate {
                if (MiniUnitInfoWindow.IsInitialized && !MiniUnitInfoWindow.IsOnCursor)
                    MiniUnitInfoWindow.HideWindow();
            };
        }
Пример #3
0
 public void HealMP(Situation situation, WarUnit doer, int value)
 {
     int newValue = _status.Params[StatusKey.MP] + value;
     _status.Params[StatusKey.MP] = newValue <= _status.MaxMP ? newValue : _status.MaxMP;
 }
Пример #4
0
        public void Die(Situation situation, WarUnit doer)
        {
            _status.Params[StatusKey.HP] = 0;
            Map.UnDeploy(this, Location);

            if (_area != null)
                _area.Units.Remove(_unit);

            DiedEvent.InvokeIfNotNull(situation, this, doer);
        }
Пример #5
0
 public void ExpendMP(Situation situation, WarUnit doer, int value)
 {
     int newValue = _status.Params[StatusKey.MP] - value;
     _status.Params[StatusKey.MP] = newValue > 0 ? newValue : _status.MaxMP;
 }
Пример #6
0
 public void DamageHP(Situation situation, WarUnit doer, int value)
 {
     int newValue = _status.Params[StatusKey.HP] - value;
     _status.Params[StatusKey.HP] = newValue > 0 ? newValue : 0;
     DamageEvent.InvokeIfNotNull(situation, this, doer, value);
     if (!Alive)
         Die(situation, doer);
 }
Пример #7
0
 public void AddActivity(Situation situation, int value)
 {
     _status.Params[StatusKey.Activity] += value;
 }
Пример #8
0
        public void Initialize()
        {
            // 戦争用データのロード
            var areaFileName = string.Format("BMap_NO{0}", _area.No);
            // TODO: 地形の読み込みは一回だけで良い
            var landformLoader = new LandformLoader(_gamePath);
            landformLoader.Load();
            var warMapLoader = new WarMapLoader(_gamePath);
            var warMap = warMapLoader.Load(areaFileName, 100, 200, 300,
                _conquerInfo.SelectToList(conquer => conquer.Item1));

            // キャラクタのロード
            var friends = new WarSide(true);
            var enemies = new WarSide(false);
            var units = new WarUnitCollection();

            //初期配置の時に必要になるので用意
            var friendUnits = new List<List<WarUnit>>();
            var enemyUnits = new List<WarUnit>();

            WarGlobal.UnitBuilder = new WarUnitBuilder(_gamePath, _units);

            // 味方軍
            foreach (var conquer in _conquerInfo)
            {
                friendUnits.Add(new List<WarUnit>());
                foreach (var unit in conquer.Item2)
                {
                    var warUnit = WarGlobal.UnitBuilder.Create(unit, friends, conquer.Item3);
                    units.AddUnit(warUnit);
                    friendUnits.Last().Add(warUnit);
                }
            }

            //敵軍
            foreach (var unit in _area.Units)
            {
                var warUnit = WarGlobal.UnitBuilder.Create(unit, enemies, _area);
                units.AddUnit(warUnit);
                enemyUnits.Add(warUnit);
            }

            // クラスの初期化
            var situation = new Situation(warMap, new[] { friends, enemies }, units);
            var model = new WarPresentationModel(situation);

            // ウィンドウの表示
            var mainWindow = new MainWindow();
            mainWindow.ShowMapWindow(situation, model);
            mainWindow.Show();

            //PhaseManager関連
            _phaseCreator.CreatePhase(model, friendUnits, enemyUnits, mainWindow);

            // 配置フェーズの開始
            situation.PhaseManager.StartPhase(situation, Phases.DeployUnitPhase);
        }
Пример #9
0
        private BattleResult checkBattleEnd(Situation situation_, WarSide friends, WarSide enemy)
        {
            var friendMaster = situation_.Units.WarUnits.SingleOrDefault((unit) => { return unit.IsMaster && unit.Side.IsPlayer; });
            if (friendMaster != null && !friendMaster.Alive)
            {
                MessageBox.Show("マスターが死亡しました。あなたの負けです。");
                return BattleResult.Lose;
            }

            var enemyMaster = situation_.Units.WarUnits.SingleOrDefault((unit) => { return unit.IsMaster && !unit.Side.IsPlayer; });
            if (enemyMaster != null && !enemyMaster.Alive)
            {
                MessageBox.Show("相手のマスターを倒しました。あなたの勝ちです。");
                return BattleResult.Win;
            }

            if (checkAnnihilation(situation_, enemy))
            {
                MessageBox.Show("相手を全滅させました。あなたの勝ちです。");
                return BattleResult.Win;
            }

            if (checkAnnihilation(situation_, friends))
            {
                MessageBox.Show("全滅しました。あなたの負けです。");
                return BattleResult.Lose;
            }

            return BattleResult.None;
        }
Пример #10
0
 /// <summary>
 /// 指定してWarSideのユニットが全員死亡しているか、退却していればtrue
 /// </summary>
 /// <param name="situation_"></param>
 /// <param name="side"></param>
 /// <returns></returns>
 private bool checkAnnihilation(Situation situation_, WarSide side)
 {
     return situation_.Units.WarUnits.Where(unit => unit.Side == side)
         .All(unit => unit.IsEscaped || !unit.Alive);
 }