예제 #1
0
        /// <summary>
        /// Call a URL, waits for response and returns the response
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        public Variable Call(string url)
        {
            var request = new Variable();

            var trigger = new Trigger(ExecuteAtStart: true);


            var checkIfResponse = new Trigger()
            {
                MaxCalls = MaxCalls.INFINITE
            };

            var repeater = new Timer()
            {
                LaunchedOnStart = false,
                Target          = checkIfResponse,
                Delay           = 10,
                MaxCalls        = MaxCalls.INFINITE,
            };

            checkIfResponse.ContinueIf(Response != "loading...");
            checkIfResponse.AddAction(repeater.Deactivate());

            if (OnLoaded != null)
            {
                checkIfResponse.Execute(this.OnLoaded);
            }

            trigger.AddAction(request.SetValue(url));
            trigger.PostRequest(request, Response);
            trigger.AddAction(repeater.Activate());

            return(Response);
        }
예제 #2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="command">The command the player says that will trigger the command, for instance: -cmd</param>
        /// <param name="exact">If command shall be trigged if what player says is exactly the command, or just if the text contains the command?</param>
        /// <returns>Returns the trigger that will be executed when the command is triggered</returns>
        public Trigger TriggerOnCommand(string command, bool exact = true)
        {
            var textBeingSaid = new Variable();
            var onExecuted    = new Trigger()
            {
                MaxCalls = MaxCalls.INFINITE
            };

            var textChecker = new Trigger()
            {
                MaxCalls = MaxCalls.INFINITE
            };

            //Tell the single-listener to execute this
            Listener.Execute(textChecker);

            textChecker.AddAction(textBeingSaid.SetToTextBeingSaid());
            if (exact)
            {
                textChecker.ContinueIf(textBeingSaid == command);
            }
            else
            {
                textChecker.ContinueIf(textBeingSaid.Contains(command));
            }
            textChecker.Execute(onExecuted);

            return(onExecuted);
        }
예제 #3
0
        public Trigger ShowForDuration(string text, int duration)
        {
            var trigger         = new Trigger();
            var hideHintTrigger = new Trigger();
            var hideTimer       = new Timer()
            {
                Delay           = duration,
                LaunchedOnStart = false,
                MaxCalls        = MaxCalls.INFINITE,
                Target          = hideHintTrigger
            };


            trigger.ShowHint(text);
            trigger.AddAction(hideTimer.Activate());


            hideHintTrigger.HideHint();
            hideHintTrigger.AddAction(hideTimer.Deactivate());


            return(trigger);
        }
        /// <summary>
        ///     Execute a command asynchronously.
        /// </summary>
        /// <param name="command">Command to execute.</param>
        /// <returns>
        ///     Task which will be completed once the command has been executed.
        /// </returns>
        public async Task HandleAsync(IMessageContext context, CreateTrigger command)
        {
            var domainModel = new Trigger(command.ApplicationId)
            {
                Description       = command.Description,
                LastTriggerAction = DtoToDomainConverters.ConvertLastAction(command.LastTriggerAction),
                Id   = command.Id,
                Name = command.Name,
                RunForExistingIncidents = command.RunForExistingIncidents,
                RunForReopenedIncidents = command.RunForReOpenedIncidents,
                RunForNewIncidents      = command.RunForNewIncidents
            };

            foreach (var action in command.Actions)
            {
                domainModel.AddAction(DtoToDomainConverters.ConvertAction(action));
            }
            foreach (var rule in command.Rules)
            {
                domainModel.AddRule(DtoToDomainConverters.ConvertRule(rule));
            }

            await _repository.CreateAsync(domainModel);
        }
예제 #5
0
        public MMOGun(List <MMoGunData> gunDataList, Variable gunResponse, Variable currentSlot)
        {
            //META-GUN LOGIC

            /*
             *
             * //3) Sync all them variables when finished loading... (This is in level editor - just connect things once loaded)
             * //3.5) Clear boolean ("hasSlot2") for instance (Thiscan also be just in level editor - TBH)
             *
             */

            var spawnGunEntryPoint = new Trigger();

            spawnGunEntryPoint.X = 100;
            spawnGunEntryPoint.Y = 100;



            var allGunSlotData = new List <GunSlotData>();



            for (int i = 2; i < 10; i++)
            {
                var gun           = new Gun(Gun.GunModel.InvisibleGun);
                var weHaveGunSlot = new Variable("hasSlot_" + i);
                allGunSlotData.Add(new GunSlotData
                {
                    Gun    = gun,
                    HasGun = weHaveGunSlot,
                    Slot   = i
                });
            }


            //PER PLAYER
            for (int playerSlot = 0; playerSlot < 8; playerSlot++)
            {
                var gunDeactivator = new Trigger();

                var gunActivator = new Trigger();



                var checkIfPlayerIsDead = new Trigger();
                var playerHp            = new Variable();


                checkIfPlayerIsDead.AddAction(playerHp.SetToPlayerHp(GetPlayerIdBasedOnSlot(playerSlot)));
                checkIfPlayerIsDead.ContinueIf(playerHp < 1);
                checkIfPlayerIsDead.SetVariable("playerIsZero" + playerSlot, "true");
                checkIfPlayerIsDead.Execute(gunDeactivator);

                //Continually check if player is dead...
                var timer = new Timer()
                {
                    LaunchedOnStart = true,
                    Delay           = 30,
                    MaxCalls        = MaxCalls.INFINITE,
                    Target          = checkIfPlayerIsDead
                };


                var ticker = new Timer()
                {
                    LaunchedOnStart = false,
                    MaxCalls        = MaxCalls.INFINITE,
                    Target          = gunActivator,
                    Delay           = 10
                };

                var checkIfPlayerIsAlive = new Trigger();
                checkIfPlayerIsDead.AddAction(playerHp.SetToPlayerHp(GetPlayerIdBasedOnSlot(playerSlot)));
                checkIfPlayerIsDead.ContinueIf(playerHp > 0);
                checkIfPlayerIsDead.AddAction(ticker.SetRemainingCalls(1));
                checkIfPlayerIsDead.AddAction(ticker.Activate());

                //Continually check if player is alive...
                var aliveChecker = new Timer()
                {
                    LaunchedOnStart = false,
                    Delay           = 10,
                    MaxCalls        = MaxCalls.INFINITE,
                    Target          = checkIfPlayerIsAlive
                };


                foreach (var gunSlotData in allGunSlotData)
                {
                    gunDeactivator.AddAction(gunSlotData.Gun.AllowForVehicles());
                    gunDeactivator.AddAction(gunSlotData.Gun.MoveToRegion("#BEGONE"));

                    gunActivator.AddAction(gunSlotData.Gun.AllowForCharacters());
                    gunActivator.ContinueIf(currentSlot == playerSlot);

                    var isZeroVariable = new Variable("playerIsZero" + playerSlot);
                    gunActivator.ContinueIf(isZeroVariable == "true"); //Has the player been killed before?
                    //Executing trigger that already exists on map
                    gunActivator.Execute("#UNIVERSAL_DEATH");
                    gunActivator.AddAction(isZeroVariable.SetValue("false"));
                    gunActivator.Execute("#trigger*259");
                }
            }

            var loadGunEntryPoint = new Trigger();


            //PER GUN DATA LOGIC
            foreach (var gunData in gunDataList)
            {
                //Local variable


                var gunTester = new Trigger();
                loadGunEntryPoint.Execute(gunTester);

                var gunSlotData = allGunSlotData.Where(x => x.Slot == gunData.Slot).FirstOrDefault();

                gunTester.ContinueIf(gunResponse.Contains(gunData.Key));

                for (int i = 0; i < 8; i++)
                {
                    var playerGunSlotWeaponModel = new Variable("player_" + i + "_slot" + gunData.Slot);


                    //Loading
                    var setPlayerGunSlotModelBasedOnSlot = new Trigger();
                    setPlayerGunSlotModelBasedOnSlot.ContinueIf(currentSlot == i);
                    setPlayerGunSlotModelBasedOnSlot.AddAction(gunSlotData.HasGun.SetValue("true"));
                    setPlayerGunSlotModelBasedOnSlot.SetVariable(playerGunSlotWeaponModel, gunData.GetGunId());
                    setPlayerGunSlotModelBasedOnSlot.AddAction(playerGunSlotWeaponModel.Sync());

                    gunTester.Execute(setPlayerGunSlotModelBasedOnSlot);
                    setPlayerGunSlotModelBasedOnSlot.Y += i * 30;



                    //Upgrading...
                    var gunModifications = new Trigger();
                    gunModifications.ContinueIf(playerGunSlotWeaponModel == gunData.GetGunId());
                    if (gunData.Speed != 0)
                    {
                        gunModifications.AddAction(gunSlotData.Gun.SetSpeedMultiplier(gunData.Speed));
                    }
                    if (gunData.Recoil != 0)
                    {
                        gunModifications.AddAction(gunSlotData.Gun.SetSpeedMultiplier(gunData.Speed));
                    }
                    if (gunData.Power != 0)
                    {
                        gunModifications.AddAction(gunSlotData.Gun.SetSpeedMultiplier(gunData.Speed));
                    }
                }

                //Moving guns is per gunData...
                spawnGunEntryPoint.AddAction(gunSlotData.HasGun.SkipNextActionIfNotEquals("true"));
                spawnGunEntryPoint.AddAction(gunSlotData.Gun.MoveToRegion("#GUNPOS"));
            }
        }