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);
        }
Ejemplo n.º 3
0
        public int Remove(IUnit removeUnit)
        {
            var ind = ArmyList.IndexOf(removeUnit);

            ArmyList.Remove(removeUnit);
            return(ind);
        }
Ejemplo n.º 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);
        }
Ejemplo n.º 6
0
 public void ClearAll()
 {
     PlayerList.Clear();
     CityList.Clear();
     ArmyList.Clear();
     ResearchList.Clear();
     DebugList.Clear();
 }
Ejemplo n.º 7
0
        public ActionResult DeleteConfirmed(int id)
        {
            ArmyList armyList = db.ArmyLists.Find(id);

            db.ArmyLists.Remove(armyList);
            db.SaveChanges();
            return(RedirectToAction("Index"));
        }
Ejemplo n.º 8
0
 public ArmyListViewModel(ArmyList armyList)
 {
     ArmyList = armyList;
     UpdateArmyListDataSource();
     UpdateForceOrgCount();
     Units.CollectionChanged += UnitsOnCollectionChanged;
     UpdateArmyUnitsListDataSource();
     UpdatePointsTotal();
 }
Ejemplo n.º 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));
 }
Ejemplo n.º 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);
    }
Ejemplo n.º 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));
        }
Ejemplo n.º 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");
     }
 }
Ejemplo n.º 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"));
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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"));
 }
Ejemplo n.º 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)));
        }
Ejemplo n.º 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());
            }
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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));
        }
Ejemplo n.º 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;
    }
Ejemplo n.º 21
0
 public void Push(IUnit unit)
 {
     ArmyList.Add(unit);
 }
Ejemplo n.º 22
0
 public int IndexOf(IUnit unit)
 {
     return(ArmyList.IndexOf(unit));
 }
Ejemplo n.º 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);
 }
Ejemplo n.º 25
0
 private void RemoveSelectedList(ArmyList list)
 {
     ArmyLists?.Remove(list);
 }
Ejemplo n.º 26
0
 public void AddList(ArmyList newList)
 {
     ArmyLists?.Add(newList);
 }
Ejemplo n.º 27
0
 public void AddArmy(Army army, Pos dest)
 {
     // create new army object
     ArmyList.Add(army);
     manager.AddArmy(army, dest);
 }