Exemple #1
0
        public void CreateAim(string name, DateTime finalTime)
        {
            var currentAim = Aims.SingleOrDefault(a => a.Name == name);

            if (currentAim == null)
            {
                IsNew      = true;
                currentAim = new Aim(name, finalTime);

                if (Aims.Count == 0)
                {
                    currentAim.ID = 1;
                }
                else
                {
                    currentAim.ID = Aims.Last().ID + 1;
                }
            }
            else
            {
                IsNew = false;
            }

            CurrentAim = currentAim;
            Aims.Add(CurrentAim);
            Save();
        }
Exemple #2
0
        async Task ExecuteLoadItemsCommand()
        {
            if (IsBusy)
            {
                return;
            }

            IsBusy = true;

            try
            {
                Aims.Clear();
                var items = await repository.GetItemsAsync(User.Id);

                foreach (var item in items)
                {
                    Aims.Add(item);
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex);
            }
            finally
            {
                IsBusy = false;
            }
        }
Exemple #3
0
        public Aim Choose(int id)
        {
            if (id < 0)
            {
                throw new ArgumentOutOfRangeException(nameof(id), "ID не может быть NULL");
            }

            var currAim = Aims.SingleOrDefault(a => a.ID == id);

            if (currAim == null)
            {
                CurrentAim = null;
                return(null);
            }
            else
            {
                CurrentAim = currAim;
                return(CurrentAim);
            }
        }
Exemple #4
0
 public AimsController(int id)
 {
     Aims       = Load();
     CurrentAim = Aims.SingleOrDefault(a => a.ID == id);
 }
Exemple #5
0
        public override void Update(GameTime gameTime)
        {
            OKBS = KBS;
            KBS  = Keyboard.GetState();
            OMS  = MS;
            MS   = Mouse.GetState();
            MouseHandler(MS, OMS, State);
            KeyboardHandler(KBS, OKBS);
            if (KBS.IsKeyDown(Keys.Escape))
            {
                World.TObjects.Clear();
                World.TUnits.Clear();
                World.TBuildings.Clear();
                World.TCUnits.Clear();
                World.TEnemys.Clear();
                World.TStones.Clear();
                World.TTrees.Clear();
                World.DeadBuildings.Clear();
                World.DeadTrees.Clear();
                World.DeadUnits.Clear();
                Game.CurrentScreen = new MainMenuScreen(Game, settings);
            }
            for (int i = World.TUnits.Count - 1; i >= 0; i--)
            {
                Aims aim = World.TUnits[i].Aim;
                switch (aim)
                {
                case Aims.Attack:
                case Aims.Download:
                case Aims.MoveToPoint:
                case Aims.Upload:
                case Aims.FindResorse:
                    ImplementAims(World.TUnits[i]);
                    break;

                case Aims.Stand:
                    //World.TUnits[i].P = new Vector2(random.Next(World.Field.Width), random.Next(World.Field.Height));
                    //World.TUnits[i].Aim = Aims.MoveToPoint;
                    World.TUnits[i].CheckArea();
                    break;

                case Aims.UploadNow:
                    (World.TUnits[i] as TCWorker).Upload();
                    break;

                case Aims.AttackNow:
                    World.TUnits[i].Attack();
                    break;

                case Aims.DownloadNow:
                    (World.TUnits[i] as TCWorker).Download();
                    break;
                }
            }
            for (int i = World.TBuildings.Count - 1; i >= 0; i--)
            {
                if (World.TBuildings[i] is ICreate)
                {
                    (World.TBuildings[i] as ICreate).Create();
                }
            }
            DeadUnitsHandler(World.DeadUnits);
            DeadTreesHandler(World.DeadTrees);
            DeadBuildingsHandler(World.DeadBuildings);
            World.Scene = scene;

            base.Update(gameTime);
        }