コード例 #1
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);
        }
コード例 #2
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"));
            }
        }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (grindLockers.IsLocked())
        {
            return;
        }

        // get all of the gravity rails in range
        float grabDist = maxGrabDist;//!masterComp.steeringCont.IsStunned() ? maxGrabDist : maxGrabDist * 0.75f;
        List <GravityRail.RailInfo> railsInRange = track.GetRailInfoWithinDist(transform.position, grabDist);

        // see if grind is released
        if (masterComp.inputCont.shipInputs.grind.wasReleased)
        {
            grindReleased  = true;
            grabFramesLeft = 0;

            if (currentRailInfo != null)
            {
                // launch the player off the rail and detach
                LaunchOffRail();
                // start rail jump slow timer
                railJumpTimer.Activate();
            }
        }
        else
        {
            // set grab frames left to 0 if stunned to make it harder to grab when stunned
            //if (masterComp.steeringCont.IsStunned()) { grabFramesLeft = 0; }

            // grab is pressed if block is entered

            /*
             * Attempt to grab a rail if:
             * 1. No currently attached to a rail
             * 2.  - Grab is not on cooldown and grind was released last frame
             *  - There are grab frames left from attempting to grab in prev frame
             */
            if (currentRailInfo == null &&
                ((!grabCoolDown.isActive && grindReleased) || grabFramesLeft > 0))
            {
                AttemptToGrabRail(railsInRange);
            }

            // set grab on cooldown if just pressed
            if (grindReleased && !grabCoolDown.isActive)
            {
                grabCoolDown.Activate();
            }

            // save that grind has been pressed
            grindReleased = false;
        }

        // save whether not in range of any tracks
        noRailsInRange = railsInRange.Count == 0;
        if (noRailsInRange)
        {
            canGetGrabBonus = true;
        }

        // tick grab cooldown
        grabCoolDown.Update(Time.deltaTime);

        // update jump cooldown
        if (railJumpTimer.isActive)
        {
            if (railJumpTimer.Update(Time.deltaTime))
            {
                masterComp.speedCont.maxSpeedAdjustors.RemoveAdjustor(JUMP_SPEED_ADJUSTER_NAME);
            }
        }

        // if grind changed, send a new grind input command
        if (prevGrindButton != masterComp.inputCont.shipInputs.grind)
        {
            GrindInputState grindInputState = new GrindInputState();
            grindInputState.grind = masterComp.inputCont.shipInputs.grind;
            int index = clientGrindInputCmdID % clientCmdHistorySize;
            grindInputState.id        = clientGrindInputCmdID++;
            grindInputState.timeStamp = GameMode.singleton.gameTime;

            clientGrindHistory[index] = grindInputState;

            //CmdUploadGrindInput(grindInputState);
        }

        prevGrindButton = masterComp.inputCont.shipInputs.grind;
    }