Inheritance: MonoBehaviour, IPointerClickHandler
Exemplo n.º 1
0
		public OptionSet Add(string prototype, string description, OptionAction<string, string> action, bool hidden)
		{
			if (action is null)
			{
				throw new ArgumentNullException(nameof(action));
			}

			Option p = new ActionOption(prototype, description, 2,
					delegate (OptionValueCollection v) { action(v[0], v[1]); }, hidden);
			base.Add(p);
			return this;
		}
Exemplo n.º 2
0
        public OptionSet Add(string prototype, string description, Action <string> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            Option p = new ActionOption(prototype, description, 1,
                                        v => action(v [0]));

            base.Add(p);
            return(this);
        }
Exemplo n.º 3
0
 public override void Execute(ActionOption actionOption, Func <string, string> openPathCallBack, Func <string, string> savePathCallBack, string parameter = null, string parameter2 = null)
 {
     // parameter will be empty
     if (CanExecute(actionOption))
     {
         OwnEventmanager.Manager.DispatchEvent("addLilyPondToken", "\\tempo4=120");
     }
     else
     {
         Next.Execute(actionOption, openPathCallBack, savePathCallBack, parameter, parameter2);
     }
 }
Exemplo n.º 4
0
        public OptionSet Add(string prototype, string description, OptionAction <string, string> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException("action");
            }
            Option p = new ActionOption(prototype, description, 2,
                                        delegate(OptionValueCollection v) { action(v [0], v [1]); });

            base.Add(p);
            return(this);
        }
Exemplo n.º 5
0
        public OptionSet Add(string prototype, string description, Action <string> action, bool hidden)
        {
            if (action is null)
            {
                throw new ArgumentNullException("action");
            }
            Option p = new ActionOption(prototype, description, 1,
                                        delegate(OptionValueCollection v) { action(v[0]); }, hidden);

            base.Add(p);
            return(this);
        }
Exemplo n.º 6
0
        public OptionSet Add(string prototype, string description, OptionAction <string, string> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }

            Option p = new ActionOption(prototype, description, 2, x => action(x[0], x[1]));

            base.Add(p);
            return(this);
        }
Exemplo n.º 7
0
        public OptionSet Add(string prototype, string description, Action <string> action)
        {
            if (action == null)
            {
                throw new ArgumentNullException(nameof(action));
            }
            var p = new ActionOption(prototype, description, 1,
                                     delegate(OptionValueCollection v) { action(v[0]); });

            base.Add(p);
            return(this);
        }
Exemplo n.º 8
0
 private void CheckPlayerMove(MoveController playerController, ActionOption actionOption)
 {
     playerController.OnMoveSelected -= CheckPlayerMove;
     if (actionOption.EntityAction is IMovementController)
     {
         savedPlayerAction = actionOption;
         EnterState(TurnState.ForcedEnemyTurn);
     }
     else
     {
         MakePlayerMove(actionOption);
     }
 }
Exemplo n.º 9
0
        protected override void InitializeOptions()
        {
            base.InitializeOptions();
            AddFunctionArguments(1, 2);
            AddOption("-m", "--measure", 1, new string[] { "minutes" });
            AddOption("-mp", "--melody-path", 1, new string[] { @"C:\Windows\Media\Alarm04.wav" });
            AddOption("-r", "--repeat", 1, new string[] { "1" });
            AddOption("-ns", "--no-sound");
            AddOption("-n", "--name", 1);

            writeToWorker = new ActionOption("-w", "--write-to-worker", 1, TimerActions.WriteToDbWorker);
            writeToWorker.SetDefaultArguments(new string[] { TimerActions.DB_CONNECTION_STRING });
            AddPostFuncOption(writeToWorker);
        }
Exemplo n.º 10
0
 //call this method when bonus action is chosen.
 public void DoBonusAction(ActionOption actionOption)
 {
     if (bonusActionsLeft < 1 || actionOption.isUsed)
     {
         Debug.LogWarning("No bonusAction left warning!");
         return;
     }
     actionOption.action.Execute(creature);
     bonusActionsLeft--;
     //this is set so that we may show what bonus action was chosen
     usedBonusAction.setData(actionOption.action);
     //TODO different kind of bonusActions might have different used option. Some are 3 / day and some might be still active and so on.
     actionOption.isUsed = true;
     GameEvents.instance.FireRefreshActionDisplay(creature.gameObject);
 }
Exemplo n.º 11
0
        private void FinishForcedEnemyMove(MoveController enemyController)
        {
            enemyController.OnMoveFinished -= FinishForcedEnemyMove;
            forcedEnemiesToMove.Remove(enemyController);
            enemiesToMove.Remove(enemyController);

            if (forcedEnemiesToMove.Count == 0)
            {
                if (PlayerController != null)
                {
                    MakePlayerMove(savedPlayerAction);
                }
                savedPlayerAction = null;
            }
        }
Exemplo n.º 12
0
 public override void Execute(ActionOption actionOption, Func <string, string> openPathCallBack, Func <string, string> savePathCallBack, string parameter = null, string parameter2 = null)
 {
     // parameter is the optional additional time
     if (CanExecute(actionOption))
     {
         if (parameter == null)
         {
             parameter = "4/4";
         }
         OwnEventmanager.Manager.DispatchEvent("addLilyPondToken", "\\time " + parameter);
     }
     else
     {
         Next.Execute(actionOption, openPathCallBack, savePathCallBack, parameter, parameter2);
     }
 }
Exemplo n.º 13
0
		public OptionSet Add (string prototype, string description, Action<string> action, bool hidden)
		{
			if (action == null)
				throw new ArgumentNullException (nameof(action));
			Option p = new ActionOption (prototype, description, 1, 
					delegate (OptionValueCollection v)
                    {
                        var v0 = v[0];
                        if (!string.IsNullOrWhiteSpace(v0))
                        {
                            action(v0);
                        }
                    }, hidden);
			base.Add (p);
			return this;
		}
Exemplo n.º 14
0
    private void instantiateNewActionIcon()
    {
        GameObject instance = Instantiate(fab_actionIcon) as GameObject;

        instance.transform.SetParent(gameObject.transform);
        float colNumber = actionIcons.Count;
        float x         = firstActionCol + (colNumber * actionColWidth);

        instance.transform.localPosition = new Vector3(x, 0f, 0f);

        ActionIcon   actionIcon  = instance.GetComponent <ActionIcon> ();
        ActionOption emptyOption = ActionOptionBuilder.GetInstance().withEmptyAction().GetActionOption();

        actionIcon.Init(emptyOption, null);
        actionIcons.Add(actionIcon);
    }
Exemplo n.º 15
0
            public static void Think(Unit unit)
            {
                List <Ability> abilities = unit.m_Data.m_Abilities;

                List <ActionOption> options = EvaluateAction(abilities);

                if (options.Count <= 0)
                {
                    AIAction.Pass.Do();
                    return;
                }

                ActionOption op = Common.RandomOptionOfBest <ActionOption>(options);

                TriggerAction(unit, op);
            }
Exemplo n.º 16
0
        public void DoActionPlay([FromBody] ActionOptionDTO actionOptionDTO)
        {
            PlayerDTO pDto = HttpContext.Session.GetObject <PlayerDTO>("player");

            //Check if user logged in!
            if (pDto != null)
            {
                ActionOption actionOption = new ActionOption
                {
                    OptioName    = actionOptionDTO.OptioName,
                    OptionEffect = actionOptionDTO.OptionEffect,
                    OptionId     = actionOptionDTO.OptionId
                };
                context.DoActionPlay(actionOption, pDto.PlayerId);
                Response.StatusCode = (int)System.Net.HttpStatusCode.OK;
            }
        }
Exemplo n.º 17
0
    // Excludes Oceans
    static ActionOption <SelfCtx> PickLandThenTakeAction(
        ActionOption <TargetSpaceCtx> spaceAction,
        Func <TargetSpaceCtx, bool> filter, string filterDescription,
        string landPreposition = "in"          // Depending on Action, "from" or "to" might be better
        ) => new ActionOption <SelfCtx>($"{spaceAction.Description} {landPreposition} {filterDescription}.",
                                        async ctx => {
        var spaceOptions = ctx.AllSpaces
                           .Select(s => ctx.Target(s))
                           .Where(x => !x.Space.IsOcean && filter(x))
                           .ToArray();
        if (spaceOptions.Length == 0)
        {
            return;
        }

        var spaceCtx = await ctx.SelectSpace("Select space to " + spaceAction.Description, spaceOptions);
        await spaceAction.Execute(spaceCtx);
    }
                                        );
 public void HandleShortCut(List <Key> pressedKeys, out ActionOption act, out string param)
 {
     param = null;
     act   = FindShortCutAction(pressedKeys);
     if (act == ActionOption.AddTime)
     {
         if (pressedKeys.Count == 2 || pressedKeys[2] == Key.D4)
         {
             param = "4/4";
         }
         else if (pressedKeys[2] == Key.D3)
         {
             param = "3/4";
         }
         else
         {
             param = "6/8";
         }
     }
 }
Exemplo n.º 19
0
    // Excludes Oceans
    static public ActionOption <SelfCtx> PickDifferentLandThenTakeAction(
        string description,
        ActionOption <TargetSpaceCtx> spaceAction,
        Func <Space, bool> spaceFilter
        )
    {
        List <Space> used = new List <Space>();

        return(new ActionOption <SelfCtx>(description, async ctx => {
            var spaceOptions = ctx.AllSpaces.Where(s => !s.IsOcean && spaceFilter(s)).Except(used).ToArray();
            if (spaceOptions.Length == 0)
            {
                return;
            }

            var spaceCtx = await ctx.SelectSpace("Select space to " + spaceAction.Description, spaceOptions);
            used.Add(spaceCtx.Space);
            await spaceAction.Execute(spaceCtx);
        }));
    }
Exemplo n.º 20
0
        private ActionOption SelectActionOption()
        {
            List <ActionOption> actionOptions = new List <ActionOption>();

            foreach (IEntityActionAIController aiController in aiControllers)
            {
                ActionOption actionOption = aiController.GetAction();
                if (actionOption != null)
                {
                    actionOptions.Add(actionOption);
                }
            }

            actionOptions.Sort((a, b) => b.EntityAction.Priority.CompareTo(a.EntityAction.Priority));
            if (actionOptions.Count > 0)
            {
                return(actionOptions[0]);
            }
            return(null);
        }
Exemplo n.º 21
0
 public override void Execute(ActionOption actionOption, Func <string, string> openPathCallBack, Func <string, string> savePathCallBack, string parameter = null, string parameter2 = null)
 {
     if (CanExecute(actionOption))
     {
         string path;
         if (parameter == null)
         {
             path = openPathCallBack.Invoke(null);
         }
         else
         {
             path = parameter;
         }
         OwnEventmanager.Manager.DispatchEvent("changeFilePath", path);
         FileHandleFacade.Load(path);
     }
     else
     {
         Next.Execute(actionOption, openPathCallBack, savePathCallBack, parameter, parameter2);
     }
 }
Exemplo n.º 22
0
        private void ConfigMenuOptions()
        {
            _fullScreenOption = new ActionOption($"Full Screen: {(Game.Gdm.IsFullScreen ? "Yes" : "No")}", FullScreenActionToggle);
            _boardLessOption  = new ActionOption($"Borderless: {(Game.Window.IsBorderless ? "Yes" : "No")}", SetWindowBorderlessToggle);
            _randomMucisCycle = new ActionOption($"Random Music Order: {(GameConts.Instance.RandomMusicCycle ? "Yes" : "No")}", SetRandomMusicCycle);

            //Load menus into the Key->Value system, this just makes it easier lmao
            _menus.Add("sounds", new List <Option>
            {
                new VolumeContol(VolumeContol.SoundType.Effects, "Effects Volume: "),
                new VolumeContol(VolumeContol.SoundType.Music, "Music Volume: "),
                _randomMucisCycle,
                new ActionOption("Back to Options", () => RenderScrollingListTable(_menus["main"])),
            });
            _menus.Add("main", new List <Option>
            {
                new ActionOption("Audio Options", () => RenderScrollingListTable(_menus["sounds"])),
                _fullScreenOption,
                _boardLessOption,
                new ChangeMenuOption(_backTitle, Parent, Game)
            });
        }
Exemplo n.º 23
0
    private void InitActionIconsWithOptions()
    {
        //TODO when player changes, init ActionIcons with players actionometer

        List <ActionOption> options = creature.GetStatistics().actionOptions;

        Debug.Log("InitActionIconsWithOptions options.Count=" + options.Count);
        Actionometer actionometer = creature.GetActionometer();

        for (int i = 0; i < options.Count; i++)
        {
            ActionOption option = options [i];
            if (i >= actionIcons.Count)
            {
                Debug.LogError("Creature has too many options, you have not implemented paging for actionIcons. actionIcons.Count=" + actionIcons.Count + " i=" + i);
            }
            else
            {
                actionIcons [i].Init(option, actionometer);
            }
        }
    }
Exemplo n.º 24
0
        private void MakeForcedEnemiesMove(MoveController enemyController, ActionOption actionOption)
        {
            enemyController.OnMoveSelected -= MakeForcedEnemiesMove;
            if (actionOption?.EntityAction is EntityAttack)
            {
                enemyController.OnMoveFinished += FinishForcedEnemyMove;
                enemyController.MakeMove(actionOption);
            }
            else
            {
                forcedEnemiesToMove.Remove(enemyController);

                if (forcedEnemiesToMove.Count == 0)
                {
                    if (PlayerController != null)
                    {
                        MakePlayerMove(savedPlayerAction);
                    }
                    savedPlayerAction = null;
                }
            }
        }
Exemplo n.º 25
0
        public void MakeMove(ActionOption actionOption)
        {
            MoveState = MoveState.MakingMove;
            OnMoveMade?.Invoke(this, actionOption);

            if (actionOption == null)
            {
                FinishMove(null);
                return;
            }

            Direction direction = Direction.GetDirection(CellEntity.Cell.StagePosition, actionOption.Target.StagePosition);

            if (direction != null && CellEntity.Cell.BorderEntities[direction])
            {
                CellEntity.Cell.BorderEntities[direction].GetComponent <IInteractableThrough>()?.Interact(CellEntity, direction);
            }

            actionOption.EntityAction.OnMoveFinish += FinishMove;
            actionOption.EntityAction.Interact(actionOption.Target);

            DeselectAction();
        }
Exemplo n.º 26
0
        private int BasicAction( ActionOption Action )
        {
            ReturnCode = GetStringBuilder();

            switch(Action)
            {
                case(ActionOption.Pausecd):
                    CommandLine = "pause cd";
                    break;
                case(ActionOption.Playcd):
                    CommandLine = "play cd";
                    break;
                case(ActionOption.Stopcd):
                    CommandLine = "stop cd wait";
                    break;
            }

            return MciSendString( CommandLine, ReturnCode, ReturnCode.Length, new IntPtr(0) );
        }
Exemplo n.º 27
0
 public ActionMenuOption(ActionOption option, bool active)
 {
     Option = option;
     Active = active;
     Legal  = true;
 }
Exemplo n.º 28
0
		private string GetLog(ActorState state, ActionOption best)
		{
			var log = new StringBuilder();
			
			log.AppendFormat("{0:00}.{1,-5}", Current.Round, Current.SubRound)
				.Append(' ').Append(Hand);
			
			if (Current.SubRound != SubRoundType.Pre)
			{
				log.AppendFormat(", {0}", Table);
			}
			
			log.AppendFormat(", {0:0.0%}", state.Odds)
				.Append(", ")
				.Append(best.Action)
				.Append(" ")
				.Append(best.Profit > 0 ? "+" : "")
				.Append(best.Profit.ToString("#,##0.0"));

			return log.ToString();
		}
Exemplo n.º 29
0
 protected void AddPostFuncOption(ActionOption actOpt) => AddActionOption(postFunc, actOpt);
Exemplo n.º 30
0
 private void LockAction(ActionOption actionOption)
 {
     LockedAction = actionOption;
 }
Exemplo n.º 31
0
		public ActionOption GetOption(ActorState state)
		{
			if (state.AmountToCall == state.SmallBlind && state.Odds > 0.52)
			{
				return new ActionOption(GameAction.Call, state.AmountToCall * (state.Odds - 0.5));
			}

			var options = new ActionOptions();

			if (state.NoAmountToCall)
			{
				options.Add(new ActionOption(GameAction.Check, state.Odds * state.Pot, 1));
			}
			else
			{
				options.Add(GameAction.Call);
			}
			if (state.AmountToCall != state.SmallBlind)
			{
				var step = 1 + ((state.MaximumRaise - state.BigBlind) >> 4);

				for (var raise = state.BigBlind; raise <= state.MaximumRaise; raise += step)
				{
					options.Add(GameAction.Raise(raise));
				}
			}
			// Only add a fold if we have to call, and there is a change that we 
			// can play a next round.
			if (!state.NoAmountToCall && state.OtherPot >= state.BigBlind)
			{
				options.Add(GameAction.Fold);
			}

			Node test = state.ToNode();
			options.Sort(test, Nodes);

			var best = SelectOption(options);

			if (best.Action != GameAction.Fold)
			{
				if (best.Action != GameAction.Check)
				{
					test.Profit = (short)state.OwnPot;
					test.Action = best.Action;
					test.IsNew = true;
					Buffer.Add(test);
				}
			}
			else if(options.Count > 1)
			{
				best = new ActionOption(GameAction.Fold, options[1].Profit, options[1].Weight);
			}
			return best;
		}
Exemplo n.º 32
0
 public void SelectMove(ActionOption actionOption)
 {
     OnMoveSelected?.Invoke(this, actionOption);
 }
Exemplo n.º 33
0
 private void UnlockAction(ActionOption actionOption)
 {
     LockedAction = null;
 }