public ArmyList Add(ArmyList armyList)
        {
            _context.ArmyLists.Add(armyList);
            _context.SaveChanges();

            return(armyList);
        }
        public ArmyList Update(ArmyList armyList)
        {
            _context.Attach(armyList).State = EntityState.Modified;
            _context.SaveChanges();

            return(armyList);
        }
Пример #3
0
        public int Remove(IUnit removeUnit)
        {
            var ind = ArmyList.IndexOf(removeUnit);

            ArmyList.Remove(removeUnit);
            return(ind);
        }
Пример #4
0
 public ArmyListViewModel(ArmyList armyList)
 {
     Id               = armyList.Id;
     Name             = armyList.Name;
     Data             = armyList.Data;
     ModificationDate = armyList.ModificationDate;
 }
        public ArmyList Update(ArmyList armyList)
        {
            ArmyList oldList = _armyLists.FirstOrDefault(al => al.Id == armyList.Id);

            oldList.Name = armyList.Name;

            return(armyList);
        }
Пример #6
0
 public void ClearAll()
 {
     PlayerList.Clear();
     CityList.Clear();
     ArmyList.Clear();
     ResearchList.Clear();
     DebugList.Clear();
 }
Пример #7
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArmyList armyList = db.ArmyLists.Find(id);

            db.ArmyLists.Remove(armyList);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Пример #8
0
 public ArmyListViewModel(ArmyList armyList)
 {
     ArmyList = armyList;
     UpdateArmyListDataSource();
     UpdateForceOrgCount();
     Units.CollectionChanged += UnitsOnCollectionChanged;
     UpdateArmyUnitsListDataSource();
     UpdatePointsTotal();
 }
Пример #9
0
 public ActionResult Edit([Bind(Include = "ID,Title,DateCreated,MainFaction,SubFaction,PointTotal")] ArmyList armyList)
 {
     if (ModelState.IsValid)
     {
         db.Entry(armyList).State = EntityState.Modified;
         db.SaveChanges();
         return(RedirectToAction("Index"));
     }
     return(View(armyList));
 }
Пример #10
0
    /// <summary>
    /// 处理添加单位
    /// </summary>
    /// <param name="army"></param>
    private void processAddArmy(GameObject army)
    {
        OtherArmyCtrl otherArmyCtrl = army.gameObject.GetComponent <OtherArmyCtrl>();

        //therArmyCtrl.Init();
        otherArmyCtrl.ArmySelectDelegate = processOtherArmySelect;

        OtherArmyCtrlList.Add(otherArmyCtrl);
        ArmyList.Add(army);
    }
Пример #11
0
        public ActionResult Create([Bind(Include = "ID,Title,DateCreated,MainFaction,SubFaction,PointTotal")] ArmyList armyList)
        {
            if (ModelState.IsValid)
            {
                db.ArmyLists.Add(armyList);
                db.SaveChanges();
                return(RedirectToAction("Index"));
            }

            return(View(armyList));
        }
Пример #12
0
 public void RemoveArmy(Army army)
 {
     if (ArmyList.Contains(army))
     {
         ArmyList.Remove(army);
         manager.RemoveArmy(army);
     }
     else
     {
         throw new System.ArgumentException("Attempt to remove army not owned by player");
     }
 }
Пример #13
0
        public IActionResult Edit(ArmyList armyList)
        {
            if (ModelState.IsValid)
            {
                _service.Update(armyList);

                return(RedirectToAction("Details", "Home", new { id = armyList.Id }));
            }
            else
            {
                return(RedirectToAction("Index", "Home"));
            }
        }
Пример #14
0
        // GET: ArmyLists/Delete/5
        public ActionResult Delete(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            ArmyList armyList = db.ArmyLists.Find(id);

            if (armyList == null)
            {
                return(HttpNotFound());
            }
            return(View(armyList));
        }
Пример #15
0
 public ActionResult Delete(int id)
 {
     try
     {
         ArmyList armyList = db.ArmyLists.Find(id);
         db.ArmyLists.Remove(armyList);
         db.SaveChanges();
     }
     catch (DataException /*dex*/)
     {
         //dex for logging
         return(RedirectToAction("Delete", new { id = id, SaveChangError = true }));
     }
     return(RedirectToAction("Index"));
 }
Пример #16
0
        public async Task <ActionResult <ArmyListViewModel> > Create(ArmyListEditViewModel model)
        {
            var user = await GetClaimedUser();

            if (user == null)
            {
                return(Forbid());
            }

            var armyList = new ArmyList(model.Name, user.Id, model.Data, DateTime.UtcNow);

            _context.ArmyLists.Add(armyList);
            await _context.SaveChangesAsync();

            return(Ok(new ArmyListViewModel(armyList)));
        }
Пример #17
0
        public IActionResult Create(ArmyList armyList)
        {
            if (ModelState.IsValid)
            {
                ArmyList newList = new ArmyList()
                {
                    Name = armyList.Name,
                };

                newList = _service.Add(armyList);
                return(RedirectToAction(nameof(Details), new { id = newList.Id }));
            }
            else
            {
                return(View());
            }
        }
Пример #18
0
        // GET: ArmyLists/Delete/5
        public ActionResult Delete(int?id, bool?saveChangesError = false)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            if (saveChangesError.GetValueOrDefault())
            {
                ViewBag.ErrorMessage = "Delete failed. Try again, and if the problem persists see your system administrator.";
            }
            ArmyList armyList = db.ArmyLists.Find(id);

            if (armyList == null)
            {
                return(HttpNotFound());
            }
            return(View(armyList));
        }
Пример #19
0
        public ActionResult Create([Bind(Include = "Title,DateCreated,Verified")] ArmyList armyList)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    db.ArmyLists.Add(armyList);
                    db.SaveChanges();
                    return(RedirectToAction("Index"));
                }
            }
            catch (DataException /*dex*/)
            {
                //Log the error, uncomment dex and add it to log
                ModelState.AddModelError("", "Unable to save changes. Try again, if the problem persists contact your system administrator.");
            }

            return(View(armyList));
        }
Пример #20
0
    /// <summary>
    /// 检查单位是否死亡
    /// </summary>
    /// <returns></returns>
    private void checkArmyDead()
    {
        int  index  = 0;
        bool isdead = false;

        foreach (var item in OtherArmyCtrlList)
        {
            if (item.armyState.Hp <= 0)
            {
                Dispatch(AreoCode.UI, UIEvent.PROMPT_PANEL_EVENTCODE, "敌方单位死亡");
                if (item.armyState.MoveType == ArmyMoveType.SKY)
                {
                    //如果是飞行单位
                    ArmyList.Remove(item.OtherMapPintctrl.SkyArmy);
                    Destroy(item.OtherMapPintctrl.SkyArmy);
                    item.OtherMapPintctrl.RemoveSkyArmy();
                }
                else if (item.armyState.MoveType == ArmyMoveType.LAND)
                {
                    //如果是陆地单位
                    ArmyList.Remove(item.OtherMapPintctrl.LandArmy);
                    Destroy(item.OtherMapPintctrl.LandArmy);
                    item.OtherMapPintctrl.RemoveLandArmy();
                }

                isdead = true;
                break;
            }
            index++;
        }
        if (isdead)
        {
            OtherArmyCtrlList.RemoveAt(index);
        }
        isdead = false;
    }
Пример #21
0
 public void Push(IUnit unit)
 {
     ArmyList.Add(unit);
 }
Пример #22
0
 public int IndexOf(IUnit unit)
 {
     return(ArmyList.IndexOf(unit));
 }
Пример #23
0
        public List <IUnit> ConstructArmy(int money, string name)
        {
            Random random = new Random();

            var infantryFactory = new InfantryFactory();
            var knightFactory   = new KnightFactory();
            var archerFactory   = new ArcherFactory();
            var healerFactory   = new HealerFactory();
            var wizardFactory   = new WizardFactory();

            while (money > 0)
            {
                int character = random.Next(1, 6);

                if (character == 1)
                {
                    if (money >= DefaultSettings.Infantry.Price)
                    {
                        var newUnit = infantryFactory.CreateUnit();
                        ArmyList.Add(newUnit);
                        money -= newUnit.Price;
                    }
                    else
                    {
                        break;
                    }
                }
                else if (character == 2)
                {
                    if (money >= DefaultSettings.Knight.Price)
                    {
                        var newUnit = knightFactory.CreateUnit();
                        ArmyList.Add(newUnit);
                        money -= newUnit.Price;
                    }
                    else
                    {
                        if (money >= DefaultSettings.Infantry.Price)
                        {
                            var newUnit = infantryFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else if (character == 3)
                {
                    if (money >= DefaultSettings.Archer.Price)
                    {
                        var newUnit = archerFactory.CreateUnit();
                        ArmyList.Add(newUnit);
                        money -= newUnit.Price;
                    }
                    else
                    {
                        if (money >= DefaultSettings.Infantry.Price)
                        {
                            var newUnit = infantryFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else if (character == 4)
                {
                    if (money >= DefaultSettings.Healer.Price)
                    {
                        var newUnit = healerFactory.CreateUnit();
                        ArmyList.Add(newUnit);
                        money -= newUnit.Price;
                    }
                    else if (money >= DefaultSettings.Archer.Price)
                    {
                        Random between = new Random();
                        if (between.Next(1, 11) % 2 == 0)
                        {
                            var newUnit = archerFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                        else
                        {
                            var newUnit = knightFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                    }
                    else
                    {
                        if (money >= DefaultSettings.Infantry.Price)
                        {
                            var newUnit = infantryFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
                else
                {
                    if (money >= DefaultSettings.Wizard.Price)
                    {
                        var newUnit = wizardFactory.CreateUnit();
                        ArmyList.Add(newUnit);
                        money -= newUnit.Price;
                    }
                    else if (money >= DefaultSettings.Healer.Price)
                    {
                        var newUnit = healerFactory.CreateUnit();
                        ArmyList.Add(newUnit);
                        money -= newUnit.Price;
                    }
                    else if (money >= DefaultSettings.Archer.Price)
                    {
                        Random between = new Random();
                        if (between.Next(1, 11) % 2 == 0)
                        {
                            var newUnit = archerFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                        else
                        {
                            var newUnit = knightFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                    }
                    else
                    {
                        if (money >= DefaultSettings.Infantry.Price)
                        {
                            var newUnit = infantryFactory.CreateUnit();
                            ArmyList.Add(newUnit);
                            money -= newUnit.Price;
                        }
                        else
                        {
                            break;
                        }
                    }
                }
            }
            return(ArmyList);
        }
 public ArmyList Add(ArmyList armyList)
 {
     armyList.Id = _armyLists.Max(al => al.Id) + 1;
     _armyLists.Add(armyList);
     return(armyList);
 }
Пример #25
0
 private void RemoveSelectedList(ArmyList list)
 {
     ArmyLists?.Remove(list);
 }
Пример #26
0
 public void AddList(ArmyList newList)
 {
     ArmyLists?.Add(newList);
 }
Пример #27
0
 public void AddArmy(Army army, Pos dest)
 {
     // create new army object
     ArmyList.Add(army);
     manager.AddArmy(army, dest);
 }