public UnitPresenter(IUnityContainer container, IUnitView view)
        {
            View           = view;
            this.container = container;
            this.service   = new WMSServiceClient();
            View.Model     = this.container.Resolve <UnitModel>();

            //Event Delegate
            View.LoadSearch     += new EventHandler <DataEventArgs <string> >(this.OnLoadSearch);
            View.New            += new EventHandler <EventArgs>(this.OnNew);
            View.LoadData       += new EventHandler <DataEventArgs <Unit> >(this.OnLoadData);
            View.Save           += new EventHandler <EventArgs>(this.OnSave);
            View.Delete         += new EventHandler <EventArgs>(this.OnDelete);
            View.ShowOnlyGroups += new EventHandler <EventArgs>(OnShowOnlyGroups);


            ProcessWindow pw = new ProcessWindow("Loading ...");

            View.Model.EntityList = service.GetUnit(new Unit {
                Company = App.curCompany
            });
            View.Model.Record           = null;
            View.TxtUnitGroup.IsEnabled = false;

            //List Height
            View.ListRecords.MaxHeight = SystemParameters.FullPrimaryScreenHeight - 250;

            //loading Units
            View.Model.UnitGroupList = service.GetUnit(new Unit {
                Company = App.curCompany, BaseAmount = 1
            }).Where(f => f.BaseAmount == 1).ToList();

            pw.Close();
        }
Example #2
0
        public void RemoveUnit(IUnitView unit)
        {
            GameObject.Destroy(unit.GameObject);

            if (_all_units_on_location.Contains(unit))
            {
                _all_units_on_location.Remove(unit);
            }

            switch (unit)
            {
            case ICreatureView view:
                if (_all_creatures_on_location.Contains(view))
                {
                    _all_creatures_on_location.Remove(view);
                }
                break;

            case ICoinView coin_view:
                if (_all_coin_on_location.Contains(coin_view))
                {
                    _all_coin_on_location.Remove(coin_view);
                }
                break;
            }

            _total_units_count.Value = _all_units_on_location.Count(un => un is CrateView || un is ICreatureView);
        }
Example #3
0
 public UnitPresenter(IUnitView view)
 {
     _view = view;
     _navigationSystem = NavigationSystem.Instance;
     _enemyManager = EnemyManager.Instance;
     cellManager = CellManager.Instance;
 }
Example #4
0
        /// <summary>
        /// Synchronizes, called from callback
        /// </summary>
        internal void Synchronize(IUnitView item, MapVisualisator map)
        {
            serverUnit         = item;
            transform.position = map.ScaleToWorldCoords(item.Position, map.XSize, map.YSize, map.MapScale);

            if (animation != null)
            {
                if (item.IsWalking)
                {
                    animation.Play("UnitWalking");
                }
                else
                {
                    animation.Play("UnitStaying");
                }
            }

            if (lineRenderer != null)
            {
                if (serverUnit.Path == null)//!IsSelected ||
                {
                    lineRenderer.positionCount = 0;
                }
                else
                {
                    var lineRendererPath = ScaleToWotldCoords(map, serverUnit.Path);
                    lineRenderer.positionCount = lineRendererPath.Length;
                    lineRenderer.SetPositions(lineRendererPath);
                }
            }
        }
Example #5
0
        public UnitPresenter(IUnityContainer container, IUnitView view)
        {
            View = view;
            this.container = container;
            this.service = new WMSServiceClient();
            View.Model = this.container.Resolve<UnitModel>();

            //Event Delegate
            View.LoadSearch += new EventHandler<DataEventArgs<string>>(this.OnLoadSearch);
            View.New += new EventHandler<EventArgs>(this.OnNew);
            View.LoadData += new EventHandler<DataEventArgs<Unit>>(this.OnLoadData);
            View.Save += new EventHandler<EventArgs>(this.OnSave);
            View.Delete += new EventHandler<EventArgs>(this.OnDelete);
            View.ShowOnlyGroups += new EventHandler<EventArgs>(OnShowOnlyGroups);


            ProcessWindow pw = new ProcessWindow("Loading ...");

            View.Model.EntityList = service.GetUnit(new Unit { Company = App.curCompany });
            View.Model.Record = null;
            View.TxtUnitGroup.IsEnabled = false;

            //List Height
            View.ListRecords.MaxHeight = SystemParameters.FullPrimaryScreenHeight - 250;

            //loading Units
            View.Model.UnitGroupList = service.GetUnit(new Unit { Company = App.curCompany,  BaseAmount = 1 }).Where(f=>f.BaseAmount==1).ToList();

            pw.Close();
        }
Example #6
0
        private IUnitView SpawnUnit(UnitView view, Vector3 position)
        {
            IUnitView unit = _unit_factory.Create(view);

            unit.SetPosition(position);
            unit.Initialize();
            _location_model.AddUnit(unit);

            return(unit);
        }
        private void SelectUnit(IUnitView oldUnit, IUnitView newUnit)
        {
            if (newUnit == null)
            {
                return;
            }

            Context.selectedUnit = newUnit;
            ActionPerformed(EActionsType.SelectUnit);
        }
Example #8
0
        public void AddUnit(IUnitView unit)
        {
            _all_units_on_location.Add(unit);

            switch (unit)
            {
            case ICreatureView view:
                _all_creatures_on_location.Add(view);
                break;

            case ICoinView coin_view:
                _all_coin_on_location.Add(coin_view);
                break;
            }

            _total_units_count.Value = _all_units_on_location.Count(un => un is CrateView || un is ICreatureView);
        }
        public UnitPresenter(IUnitView view, Unidade unidade, IUnityContainer container)
        {
            if (view == null)
            {
                throw new ArgumentNullException("view");
            }
            if (unidade == null)
            {
                throw new ArgumentNullException("unidade");
            }
            if (container == null)
            {
                throw new ArgumentNullException("container");
            }

            this.SubmitCommand = new DelegateCommand <object>(this.Submit, this.CanSubmit);
            this.CancelCommand = new DelegateCommand <object>(this.Cancel);

            this._view = view;
            this._view.SetPresenter(this);
            this._container = container;

            this.Unidade = unidade;
        }
Example #10
0
        public void Initialize()
        {
            StartCrateSpawner();

            _input_stream = new CompositeDisposable();

            //Input release logic
            _input_controller.IsRelease
            .Where(release => release == true)
            .Subscribe(_ => {
                if (_current_drag_creature == null)
                {
                    IUnitView found_unit = _location_model.GetIntersectInputPositionUnit(_input_controller.InputWorldPosition.Value);
                    found_unit?.Interact();
                }
                else
                {
                    ICreatureView collide_creature = _location_model.GetIntersectInputPositionCreature(_current_drag_creature);

                    if (collide_creature != null)
                    {
                        if (collide_creature.Level == _current_drag_creature.Level)
                        {
                            _signal_bus.Fire(new SpawnCreatureFromMergeSignal {
                                first_creature  = _current_drag_creature,
                                second_creature = collide_creature
                            });
                        }
                    }
                    else
                    {
                        _current_drag_creature.Interact();
                    }

                    _current_drag_creature.SetDrag(false);
                    _current_drag_creature = null;
                }
            })
            .AddTo(_input_stream);

            //Input press logic
            _input_controller.IsPressed
            .Where(press => press)
            .Subscribe(_ => {
                if (_current_drag_creature == null)
                {
                    CrateView possible_crate =
                        _location_model.GetIntersectInputPositionUnit(_input_controller.InputWorldPosition.Value) as CrateView;

                    if (possible_crate == null)
                    {
                        ICreatureView unit = _location_model.GetIntersectInputPositionCreature(_input_controller.InputWorldPosition.Value);

                        if (unit != null)
                        {
                            _current_drag_creature = unit;
                            _current_drag_creature?.SetDrag(true);
                        }
                    }
                }
            })
            .AddTo(_input_stream);

            //Input move logic
            _input_controller.InputWorldPosition
            .Where(pos => _input_controller.IsPressed.Value)
            .Subscribe(pos => {
                if (_current_drag_creature == null)
                {
                    ICoinView[] coin_view = _location_model.GetIntersectInputPositionCoin(pos);

                    if (coin_view.Length > 0)
                    {
                        coin_view.ForEach(coin => {
                            if (!coin.IsCollected)
                            {
                                coin.Interact();
                            }
                        });
                    }
                }
                else
                {
                    _current_drag_creature.SetPosition(pos.VectorBoundInBound(_current_drag_creature.Bounds, _camera_bounds).SetZ(_current_drag_creature.Position.z));
                }
            })
            .AddTo(_input_stream);

            SpawnCrate();
        }
 private void UpdateHover(IUnitView oldUnit, IUnitView newUnit)
 {
     UpdateHoverHighlighting(oldUnit, newUnit);
 }