Пример #1
0
        public ActionResult DmgCreature(DmgCreatureModel dmgCreatureModel)
        {
            List <CreatureModel> initiative = InitiativeIO.GetInitiative();
            int           pos          = initiative.FindIndex(item => item.Id == dmgCreatureModel.DmgCreatureId);
            CreatureModel thisCreature = initiative[pos];

            thisCreature.HP = thisCreature.HP - dmgCreatureModel.Dmg;


            if (thisCreature.HP <= 0 && thisCreature.CreatureType == CreatureTypeEnum.enemy)
            {
                InitiativeIO.DeleteRecord(thisCreature.Id);
            }
            else
            {
                if (thisCreature.HP < 0)
                {
                    thisCreature.HP = 0;
                }
                InitiativeIO.UpdateRecord(thisCreature);
            }

            BattleMapModel battlemapRecord = BattleMapIO.GetData();

            battlemapRecord.MovingId = 0;

            BattleMapIO.UpdateRecord(battlemapRecord);



            return(RedirectToAction("Index"));
        }
Пример #2
0
        public ActionResult SetToMove(int id)
        {
            BattleMapModel battlemapRecord = BattleMapIO.GetData();

            battlemapRecord.MovingId = id;

            BattleMapIO.UpdateRecord(battlemapRecord);

            return(RedirectToAction("Index"));
        }
Пример #3
0
        public ActionResult AddBackground(AddBackgroundModel model)
        {
            BattleMapModel battlemapRecord = BattleMapIO.GetData();

            battlemapRecord.BackgroundPath = model.FilePath;
            battlemapRecord.Width          = model.Width;
            battlemapRecord.Height         = model.Height;
            BattleMapIO.UpdateRecord(battlemapRecord);


            return(RedirectToAction("Index"));
        }
Пример #4
0
        public ActionResult Move(int id)
        {
            BattleMapModel battlemapRecord = BattleMapIO.GetData();

            int x = id % battlemapRecord.Width;
            int y = id / battlemapRecord.Width;


            CreatureModel creature = InitiativeIO.GetInitiative().Find(item => item.Id == battlemapRecord.MovingId);

            if (creature != null)
            {
                creature.PositionX = x;
                creature.PositionY = y;
                InitiativeIO.UpdateRecord(creature);
            }
            battlemapRecord.MovingId = 0;
            BattleMapIO.UpdateRecord(battlemapRecord);


            return(RedirectToAction("Index"));
        }