コード例 #1
0
        // Updates the list of ships to give orders to and targets when the system changes
        public void RefreshShips(int a, int b)
        {
            if (SelectedSystem == null || _starSystems.SelectedIndex == -1)
            {
                return;
            }

            _shipList.Clear();
            foreach (Entity ship in SelectedSystem.GetAllEntitiesWithDataBlob <ShipInfoDB>(_gameVM.CurrentAuthToken))
            {
                if (ship.HasDataBlob <PropulsionDB>())
                {
                    ShipList.Add(ship, ship.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction));
                }
            }

            _shipList.SelectedIndex = 0;

            //RefreshTarget(0, 0);

            OnPropertyChanged(nameof(ShipList));
            OnPropertyChanged(nameof(MoveTargetList));

            OnPropertyChanged(nameof(SelectedShip));
            OnPropertyChanged(nameof(SelectedMoveTarget));

            return;
        }
コード例 #2
0
        public void RefreshTarget(int a, int b)
        {
            if (_starSystems.SelectedIndex == -1) //if b is not a valid selection
            {
                return;
            }

            _moveTargetList.Clear();
            _attackTargetList.Clear();

            int moveTargetIndex   = _moveTargetList.SelectedIndex;
            int attackTargetIndex = _attackTargetList.SelectedIndex;

            foreach (Entity target in SelectedSystem.GetAllEntitiesWithDataBlob <PositionDB>(_gameVM.CurrentAuthToken))
            {
                if (target != SelectedShip)
                {
                    _moveTargetList.Add(target, target.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction));
                    if (target.HasDataBlob <SensorProfileDB>())
                    {
                        _attackTargetList.Add(target, target.GetDataBlob <NameDB>().GetName(_gameVM.CurrentFaction));
                    }
                }
            }

            _moveTargetList.SelectedIndex   = moveTargetIndex;
            _attackTargetList.SelectedIndex = attackTargetIndex;

            if (SelectedPossibleMoveOrder == null)
            {
                TargetShown = false;
            }
            else if (SelectedPossibleMoveOrder.OrderType == orderType.MOVETO)
            {
                TargetShown = true;
            }
            else
            {
                TargetShown = false;
            }

            if (TargetShown)
            {
                TargetAreaWidth = 200;
            }
            else
            {
                TargetAreaWidth = 2;
            }

            OnPropertyChanged(nameof(TargetShown));
            OnPropertyChanged(nameof(TargetAreaWidth));
        }