Exemplo n.º 1
0
    /// <summary> Returns true if the player has enough money for the provided
    /// <see cref="SelectedAction"/> <paramref name="sa"/>. Provide the <paramref name="sa"/>
    /// only if the action is building a new tower. Otherwise pass null. </summary>
    internal bool EnoughMoneyForAction(SelectedAction sa, Tower towerToBuild)
    {
        switch (sa)
        {
        case SelectedAction.BuildTower1:
        case SelectedAction.BuildTower2:
        case SelectedAction.BuildTower3:
        case SelectedAction.BuildTower4:
            if (towerToBuild != null)
            {
                return(Player.HasEnoughMoney(towerToBuild.GetBaseLevelCost()));
            }
            break;

        case SelectedAction.SellTower:
            return(true);

        case SelectedAction.UpgradeTower:
        {
            if (selectedLymphNode == null || selectedLymphNode.IsVacant())
            {
                return(false);
            }
            return(Player.HasEnoughMoney(selectedLymphNode.GetNextLevelCost()));
        }
        }
        return(false);
    }
Exemplo n.º 2
0
        private void RadioMethod(object parametr)
        {
            //Test();

            switch (parametr.ToString())
            {
            case "MyEncryptionAlgorithm":
                _selectedAction = SelectedAction.IsMyEncryptionAlgorithm;
                break;

            case "Vernam":
                _selectedAction = SelectedAction.IsVernam;
                break;

            case "MyDes":
                _selectedAction = SelectedAction.IsMyDes;
                break;

            case "StandartDes":
                _selectedAction = SelectedAction.IsStandartDes;
                break;

            case "RC4":
                _selectedAction = SelectedAction.IsRc4;
                break;
            }
        }
Exemplo n.º 3
0
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region Private Functions

        /// <summary>
        /// Item tapped in the list
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void ActionsItemTapped(object sender, ItemTappedEventArgs e)
        {
            try
            {
                if (_isExecute)
                {
                    _isExecute = false;
                    _popupContent.DismisPopup();
                    var selectedItem = (GroupedListModel)e.Item;

                    var visitMap = AppData.PropertyModel.SelectedAction.IndexMap;

                    var newAction = new SelectedAction(AppData.PropertyModel.SelectedAction.Action, visitMap, true)
                    {
                        Action = { ActionType = selectedItem.Code }
                    };

                    await VisitInstance.LoadActionsForm(newAction);

                    _isExecute = true;
                }
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
Exemplo n.º 4
0
 protected virtual void OnActionSelected()
 {
     if (SelectedAction != null)
     {
         SelectedAction.Invoke();
     }
 }
Exemplo n.º 5
0
        void ButtonToggled(UIMouseEvent evt, UIElement listeningElement)
        {
            UIPanelButton element;

            for (int i = 0; i < toggleElements.Length; i++)
            {
                element = toggleElements[i];
                if (element == listeningElement)
                {
                    if (element.toggleState)
                    {
                        selectedAction = SelectedAction.None;
                    }
                    else
                    {
                        selectedAction = (SelectedAction)i;
                    }
                    UpdateText();
                }
                else
                {
                    element.toggleState = false;
                }
            }
        }
        private ActionOption GetActionOption(Cell target)
        {
            List <ActionOption> actionOptions = new List <ActionOption>();

            if (SelectedAction != null)
            {
                if (SelectedAction.CanInteract(target))
                {
                    actionOptions.Add(new ActionOption(SelectedAction, target));
                }
            }
            else
            {
                foreach (EntityAction entityController in entityActions)
                {
                    if (!entityController.RequiredSelection && entityController.CanInteract(target))
                    {
                        actionOptions.Add(new ActionOption(entityController, target));
                    }
                }
            }

            actionOptions.Sort((a, b) => b.EntityAction.Priority.CompareTo(a.EntityAction.Priority));
            return(actionOptions.Count > 0 ? actionOptions[0] : null);
        }
Exemplo n.º 7
0
 void _Selected(TreeNodeAdv node, bool isKey)
 {
     ResultItem   = node.Tag;
     ResultWasKey = isKey;
     _Close();
     SelectedAction?.Invoke(this);
 }
 async Task PerformPaste()
 {
     if (SelectedAction != null)
     {
         await SelectedAction.PerformAsync(SelectedElement.Data);
     }
 }
Exemplo n.º 9
0
        public void GenerateUI(SelectedAction selectedAction, IList <PropertyInformationViewModel> columnZeroItems, IList <PropertyInformationViewModel> columnOneItems = null, IList <PropertyInformationViewModel> columnTwoItems = null)
        {
            if (columnZeroItems == null)
            {
                throw new ArgumentNullException(nameof(columnZeroItems));
            }

            this.ResultXaml = String.Empty;

            this.SelectedAction = selectedAction;

            this.IsUIGenerationInProgress = true;

            this.GenerateFormModel.ColumnLayouts.Clear();

            this.GenerateFormModel.ColumnLayouts.Add(columnZeroItems);
            if (columnOneItems != null && columnOneItems.Count > 0)
            {
                this.GenerateFormModel.ColumnLayouts.Add(columnOneItems);
            }
            if (columnTwoItems != null && columnTwoItems.Count > 0)
            {
                this.GenerateFormModel.ColumnLayouts.Add(columnTwoItems);
            }

            this.GenerateFormModel.CreateObjectDefinition = this.SelectedCreateObjectDefinition;

            var codeGenerator = new UIGeneration();

            try {
                var xaml = codeGenerator.Generate(this.GenerateFormModel).Trim();
                if (!String.IsNullOrWhiteSpace(xaml))
                {
                    this.ResultXaml = xaml;
                    if (selectedAction == SelectedAction.Generate)
                    {
                        this.RaiseCloseWindow();
                    }
                    else if (selectedAction == SelectedAction.Apply)
                    {
                        _applyAction(this.ResultXaml);
                        this.SelectedAction = SelectedAction.None;
                    }
                }
                else
                {
                    MessageBox.Show("No XAML was returned by the UI Code Generator.", "UI Code Generation Failed", MessageBoxButton.OK, MessageBoxImage.Error);
                }
            } catch (NotImplementedException ex) {
                this.SelectedAction = SelectedAction.None;
                MessageBox.Show(ex.ToString(), "Programmer Error", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (InvalidOperationException ex) {
                this.SelectedAction = SelectedAction.None;
                MessageBox.Show(ex.ToString(), "Compiler Error", MessageBoxButton.OK, MessageBoxImage.Error);
            } catch (Exception ex) {
                this.SelectedAction = SelectedAction.None;
                MessageBox.Show(ex.ToString(), "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            this.IsUIGenerationInProgress = false;
        }
Exemplo n.º 10
0
 public void EndFirstTurn()
 {
     firstTurn.SetActive(false);
     currentAction = SelectedAction.hold;
     currentPlayer = 1;
     GenerateBubbles();
     UpdatePlayerAndBubbleDisplay();
 }
Exemplo n.º 11
0
 void Start()
 {
     players           = FindObjectsOfType <PlayerActions>(); // find a better way to reference those objects
     playerPoints      = FindObjectsOfType <PlayerPoints>();  // find a better way to reference those objects
     leftPlayerAction  = SelectedAction.Null;
     rightPlayerAction = SelectedAction.Null;
     initialColor      = leftSquare.color;
 }
Exemplo n.º 12
0
        private void TreeElement_Selected(object sender, RoutedEventArgs e)
        {
            var node = e.OriginalSource as TreeViewItem ?? throw new NullReferenceException("Bad tree node");

            var trueNode = node.Header as ITreeNodeViewModel ?? throw new NullReferenceException("Bad tree node");

            SelectedAction?.Invoke(trueNode);
        }
 private void NativeControl_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (SelectedAction != null || SelectionChangedAction != null)
     {
         SelectedAction?.Invoke(e.CurrentSelection.Count > 0 ? (VisualNode)e.CurrentSelection[0] : null);
         SelectionChangedAction?.Invoke(e.CurrentSelection.Cast <VisualNode>().ToList(), e.PreviousSelection.Cast <VisualNode>().ToList());
         Invalidate();
     }
 }
        public void ExecutePlayerAction(MapElement[,] playField)
        {
            bool ValidAction = false;

            do
            {
                SelectedAction selectedAction = SelectPlayerAction();

                switch (selectedAction)
                {
                case SelectedAction.MoveUp:
                    if (Location.Y > 0 && playField[Location.X, Location.Y - 1] == null)
                    {
                        MoveUp();
                        ValidAction = true;
                    }
                    break;

                case SelectedAction.MoveRight:
                    if (Location.X < 19 && playField[Location.X + 1, Location.Y] == null)
                    {
                        MoveRight();
                        ValidAction = true;
                    }
                    break;

                case SelectedAction.MoveDown:
                    if (Location.Y < 19 && playField[Location.X, Location.Y + 1] == null)
                    {
                        MoveDown();
                        ValidAction = true;
                    }
                    break;

                case SelectedAction.MoveLeft:
                    if (Location.X > 0 && playField[Location.X - 1, Location.Y] == null)
                    {
                        MoveLeft();
                        ValidAction = true;
                    }
                    break;

                case SelectedAction.Shoot:
                    if (playField[Location.X + 1, Location.Y] is Rock || playField[Location.X + 1, Location.Y] is Monster)
                    {
                        Shoot();
                        Program.RemoveMapElement(Location.X + 1, Location.Y);
                        ValidAction = true;
                    }
                    break;

                default:
                    break;
                }
            } while (!ValidAction);
        }
Exemplo n.º 15
0
 //This happens when you click the STACK button.
 public void StackButtonClicked()
 {
     if (currentAction != SelectedAction.firstTurn)
     {
         currentAction = SelectedAction.stack;
         UnSelectAllButtons();
         UnSelectAllSquares();
         stackButtonImage.sprite = stackSpriteSelected;
     }
 }
Exemplo n.º 16
0
        public UIActionSheet ShowActionSheetForBelowiOS8(string[] menuItems)
        {
            UIActionSheet actionSheet = new UIActionSheet(null, null, "Cancel", null, menuItems);

            actionSheet.Clicked += (sender, e) =>
            {
                SelectedAction?.Invoke(sender, e);
            };
            return(actionSheet);
        }
Exemplo n.º 17
0
 private void HandleArrowKeyPresses()
 {
     if (Input.GetKeyDown(KeyCode.UpArrow))
     {
         SelectedAction = SelectedAction.Next();
     }
     if (Input.GetKeyDown(KeyCode.DownArrow))
     {
         SelectedAction = SelectedAction.Previous();
     }
 }
Exemplo n.º 18
0
 private void HandleScrolling()
 {
     if (ScrollingUp)
     {
         SelectedAction = SelectedAction.Next();
     }
     if (ScrollingDown)
     {
         SelectedAction = SelectedAction.Previous();;
     }
 }
Exemplo n.º 19
0
 public ApplicationViewModelPart3()
 {
     worker.DoWork                    += DoWork;
     worker.ProgressChanged           += ProgressChanged;
     worker.WorkerReportsProgress      = true;
     worker.WorkerSupportsCancellation = true;
     CurrentProgress                   = -1;
     IsRunning            = true;
     _selectedAction      = SelectedAction.IsNotChosen;
     _encryptionAlgorithm = new EncryptionAlgorithm(ref _currentProgress, worker, OnPropertyChanged);
 }
Exemplo n.º 20
0
 //SelectedAction to send when player clicks on UI button
 public void SendActionOnClick(int index, SelectedAction action, int id)
 {
     if (ActionAlreadySelected)
     {
         return;                                       // check if already sent action
     }
     ActionAlreadySelected = true;                     // the bool is set back to false in ActionReceiver.TriggerActions()
     timer.timerMustStop   = true;                     // so the TimerCircle stops running
     actionCombo.AddAction(action);
     ActionReceiver.current.ReceiveAction(id, action); // send action to ActionReceiver.current with id so you trigger right image
 }
Exemplo n.º 21
0
    //will calculate damage dealt. More damage is dealt depending on the battle loop
    public override double DealDamage(Character defender)
    {
        double damageDealt = SelectedAction.CalculateDamage(Attacker, Defender, gameController.BattleLoop);

        Defender.HP -= damageDealt;
        if (damageDealt > 0)
        {
            Defender.IsAbleToHealState = new CanHealState(ui, this, Defender);
        }
        return(damageDealt);
    }
Exemplo n.º 22
0
        async void Service_UserInterfaceHidden(object sender, UserInterfaceHiddenEventArgument e)
        {
            if (UserInterfaceHidden != null)
            {
                UserInterfaceHidden(this, e);
            }

            if (SelectedAction != null)
            {
                await SelectedAction.PerformAsync(SelectedElement);
            }
        }
Exemplo n.º 23
0
    private void ButtonAction(GameObject buttonObject, SelectedAction sa, Tower tower)
    {
        if (Scroller.IsDragging())
        {
            return;                        // don't do button action while scrolling
        }
        // destroy the info panel, if it was present
        if (infoPanel != null)
        {
            Destroy(infoPanel);
        }

        BuildManager buildManager = BuildManager.instance;

        if (sa == SelectedAction.SetRallyPoint)
        {
            buildManager.StartRallyPointSelector();
            // destroy the menu; deselecting the lymph node also destroys the menu, so that works fine
            // todo: if a design decision is made to not deselect the node after starting the action,
            // then this has to be redone, because not destroying the menu leaves the selected button
            buildManager.DeselectLymphNode();
            return;
        }

        if (buildManager.GetSelectedAction() == sa) // if this button is already selected, do the action
        {
            tempButton = null;

            buildManager.DoSelectedAction(tower);
            // destroy the menu; deselecting the lymph node also destroys the menu, so that works fine
            // todo: if a design decision is made to not deselect the node after starting the action,
            // then this has to be redone, because not destroying the menu leaves the selected button
            buildManager.DeselectLymphNode();
        }
        else // if this button isn't selected, just select it (if the action is possible)
        {
            ResetPreviouslySelectedButton();
            bool enoughMoney = buildManager.EnoughMoneyForAction(sa, tower);
            SetButtonAsSelected(buttonObject, enoughMoney);
            if (enoughMoney)
            {
                buildManager.SelectAction(sa);
            }
            else
            {
                buildManager.SelectAction(SelectedAction.Nothing);
                UIManager.instance.FlashNotEnoughMoney(1f);
            }
            // show info panel when selecting a button
            infoPanel = UIManager.instance.ShowInfoPanel(buttonObject.transform.parent, sa, tower);
        }
    }
Exemplo n.º 24
0
    //This happens when you click the PROGRESS button.
    public void ProgressButtonClicked()
    {
        if (currentAction != SelectedAction.firstTurn)
        {
            currentAction = SelectedAction.progress;

            UnSelectAllButtons();
            UnSelectAllSquares();
            progressButtonImage.sprite = progressSpriteSelected;
            Progress();
            //Invoke("ResetProgressButton", 1.0f);
        }
    }
Exemplo n.º 25
0
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        #region Public Functions
        /// ------------------------------------------------------------------------------------------------

        /// ------------------------------------------------------------------------------------------------
        /// Name        LoadActionForm
        /// ------------------------------------------------------------------------------------------------
        /// <summary>
        /// Sets the selected action and displays the actions edit form.
        /// </summary>
        /// <param name="selectedAction">Selected action.</param>
        ///
        /// ------------------------------------------------------------------------------------------------
        ///
        public async Task LoadActionsForm(SelectedAction selectedAction)
        {
            try
            {
                AppData.PropertyModel.SelectedAction = selectedAction;
                // Create the action edit view with a dismiss action
                //  await Navigation.PushModalAsync(new VisitActionDetailsPage());
                PageNavigation.PushMainPage(new VisitActionDetailsPage());
            }
            catch (Exception ex)
            {
                LogTracking.LogTrace(ex.ToString());
            }
        }
Exemplo n.º 26
0
        private async void EditAction()
        {
            if (SelectedAction == null)
            {
                return;
            }

            var modifiedAction = await _dialogsHelper.OpenActionEditor(SelectedAction, Actions,
                                                                       _objectsRepository, _variablesRepository, WindowType.ObjectBrowser);

            if (modifiedAction != null)
            {
                SelectedAction.Update(modifiedAction);
            }
        }
Exemplo n.º 27
0
    // Performs fighting moves when chosen.  Puts a delay between action selected and the move performing for a more natural feel
    public override void Fight(Character defender)
    {
        source.PlayOneShot(shootArrow);
        Defender = defender;
        double damage = DealDamage(Defender);

        //if the status effect attack hit, do status effect damage on the defender
        if (statusEffectAttacks.Contains(SelectedAction.GetType().Name) && damage > 0)
        {
            Defender.HasEffectDamage = true;
            Debug.Log(Attacker.Name + " HAS EFFECT DAMAGE");
            Defender.EffectDamage = SelectedAction.EffectDamage;
        }
        UpdateUIPostAttack(damage);
    }
Exemplo n.º 28
0
        public async void Execute(FrameworkElement source)
        {
            await Task.Run(() =>
            {
                try
                {
                    Status.SetMessage(this, "Executing");
                    IItem result = null;
                    if (ActionWithArguments != null)
                    {
                        result = ActionWithArguments.ActOn(Result.Item, Arguments);
                    }
                    else
                    {
                        result = SelectedAction.ActOn(Result.Item);
                    }
                    _autoCompleteText.LearnInputForCommandResult(Input, Result);
                    _getActionsForItem.LearnActionForCommandResult(Input, SelectedAction, Result);

                    result = result ?? NoReturnValue.Object;
                    if (result != NoReturnValue.Object)
                    {
                        _temporaryResults = result.ToListWithCurrentSelection();
                        UpdateCommandOptions(new ListWithCurrentSelection <AutoCompletionResult.CommandResult>());
                        Input = CommandOptions.First().Item.Text;
                    }
                    else
                    {
                        Input     = string.Empty;
                        Arguments = string.Empty;
                        // HACK
                        _temporaryResults = new ListWithCurrentSelection <AutoCompletionResult.CommandResult>();
                        UpdateCommandOptions(_temporaryResults);
                        Caliburn.Micro.Execute.OnUIThread(() => ((MainWindowView)Window.GetWindow(source)).HideWindow());
                    }

                    Status.SetMessage(this, "Done");
                }
                catch (Exception e)
                {
                    Status.SetMessage(this, "Error :" + e.Message);
                    Description = e.Message;
                    _log.Error(e);
                }
            });
        }
Exemplo n.º 29
0
    public void EndTurn()
    {
        Turn          = false;
        CurrentAction = SelectedAction.Nothing;
        foreach (GameObject tile in Tiles)
        {
            Tile t = tile.GetComponent <Tile>();
            t.Reset();
        }

        HasMoved = false;
        Transform indicator = transform.Find("Indicator/Cylinder");
        Transform effect    = transform.Find("Indicator/Cylinder/Sparkles");

        indicator.localScale = new Vector3(0.0f, 0.0f, 0.0f);
        effect.localScale    = new Vector3(0.0f, 0.0f, 0.0f);
    }
Exemplo n.º 30
0
        public Selector(SpriteBatch spriteBatch, Card card)
        {
            // Make card selector outline
            line = new Texture2D(spriteBatch.GraphicsDevice, 1, 1);
            line.SetData <Color>(new Color[] { Color.White });
            lineWidth = 4;

            // Other selector variables
            color        = Color.Black;
            selected     = card;
            attacking    = null; //idk
            summoning    = null; //idk
            settingMagic = null; //idk
            settingTrap  = null; //idk
            state        = SelectedState.P1_HAND;
            action       = SelectedAction.NONE;
            index        = 0;
        }
Exemplo n.º 31
0
    //returns int: -1 for create game, x for join game x
    public SelectedAction PrintGUI()
    {
        SelectedAction act = new SelectedAction(Option.NoAction);
        GUILayout.BeginArea(position);
            GUILayout.Space(20);
            GUILayout.BeginHorizontal();
                GUILayout.Label("Lobby");
                if(GUILayout.Button("Refresh")){
                    MasterServer.ClearHostList();
                    MasterServer.RequestHostList(Stats.uniqueGameID);
                }
            GUILayout.EndHorizontal();
            LobbyList();
            GUILayout.FlexibleSpace();
            HostData[] pollList = Poll();
            if( selectedGame >= 0 && pollList[selectedGame].passwordProtected){
                GUILayout.BeginHorizontal();
                GUILayout.Box("Password:"******"Join"))
                    act = new SelectedAction(Option.Join,selectedGame);
                    act.password = password;
                }else if(selectedGame < 0){
                    GUILayout.Box("Join");
                }
                if(GUILayout.Button("Create"))
                    act = new SelectedAction(Option.Create);
            GUILayout.EndHorizontal();
        GUILayout.EndArea();
        return act;
    }
Exemplo n.º 32
0
		/// <summary>
		/// Get current action
		/// </summary>
		/// <param name="sender"></param>
		/// <param name="e"></param>
		private void Action_Checked(object sender, RoutedEventArgs e)
		{
			var currentElement = (Control)sender;
			currentAction = (SelectedAction)Enum.Parse(typeof(SelectedAction), currentElement.Name);
		}