Exemplo n.º 1
0
        private void ToolStripMenuItem_testMode_Click(object sender, EventArgs e)
        {
            ToolStripMenuItem modeItem = (ToolStripMenuItem)sender;
            var modeItemParent         = modeItem.GetCurrentParent();

            foreach (var VARIABLE in modeItemParent.Items)
            {
                if (VARIABLE is ToolStripMenuItem tempItem)
                {
                    tempItem.Checked = false;
                    tempItem.Enabled = true;
                }
            }

            modeItem.Checked = true;
            //  modeItem.Enabled = false;
            if (modeItem.Name == "ToolStripMenuItem_Auto")
            {
                _testMode = TestMode.Auto;
                toolStripStatusMode.ForeColor = Color.Black;
            }
            else
            {
                _testMode = TestMode.Manual;
                toolStripStatusMode.ForeColor = Color.Red;
            }

            toolStripStatusMode.Text = "test mode:" + _testMode.ToString();
        }
Exemplo n.º 2
0
 private ConnectionMultiplexer Create(TestMode mode)
 {
     switch (mode)
     {
         case TestMode.MultiExec:
             return Create();
         case TestMode.NoMultiExec:
             return Create(disabledCommands: new[] { "multi", "exec" });
         case TestMode.Twemproxy:
             return Create(proxy: Proxy.Twemproxy);
         default:
             throw new NotSupportedException(mode.ToString());
     }
 }
Exemplo n.º 3
0
 private ConnectionMultiplexer Create(TestMode mode)
 {
     switch(mode)
     {
         case TestMode.MultiExec:
             return Create();
         case TestMode.NoMultiExec:
             return Create(disabledCommands: new[] { "multi", "exec" });
         case TestMode.Twemproxy:
             return Create(proxy: Proxy.Twemproxy);
         default:
             throw new NotSupportedException(mode.ToString());
     }
 }
Exemplo n.º 4
0
Arquivo: server.cs Projeto: abhiss/sth
        public Server()
        {
            discord = new sthvDiscordController();

            currentMap = Shared.sthvMaps.Maps[2];
            FetchHandler fetchHandler = new FetchHandler();

            fetchHandler.addHandler <Shared.PlayerJoinInfo>(new Func <Player, Shared.BaseFetchClass>(source =>
            {
                Debug.WriteLine($"^3 player: {source.Name} Triggered PlayerJoinInfo handler.^7");
                string licenseId = source.Handle;
                source.TriggerEvent("sth:updateRunnerHandle", runnerHandle);
                refreshscoreboard();
                //if (gamemode == null || !gamemode.isGameloopActive)
                {
                    //spawns player at hunter spawn if gamemode is not active. This usually means server is waiting for more players.
                    sthvLobbyManager.getPlayerByLicense(source.getLicense()).Spawn(currentMap.HunterSpawn, false, playerState.ready);
                }
                //retry bc sometimes nui is still loading even after player is ready.
                var send_sb_later = new Action(async() =>
                {
                    await Delay(5000);
                    refreshscoreboard();
                    Debug.WriteLine("updating scoreboard again...");
                });
                send_sb_later();
                //todo isAllowedHostMenu should use database or something instead of ace perms.
                return(new Shared.PlayerJoinInfo
                {
                    hasDiscord = false,
                    isDiscordServerOnline = false,
                    isInSTHGuild = false,
                    isInVc = false,
                    runnerServerId = runnerHandle,
                    isAllowedHostMenu = API.IsPlayerAceAllowed(source.Handle, "sthv.host"),
                    gamemodeId = Server.GamemodeId
                });
            }));
            fetchHandler.addHandler <Shared.Ping>(new Func <Player, Shared.BaseFetchClass>(source =>
            {
                return(new Shared.Ping {
                    response = "pong!!"
                });
            }));

            EventHandlers["sth:sendServerDebug"] += new Action <string>((string info) => { Debug.WriteLine(info); });

            API.RegisterCommand("spawn", new Action <int, List <object>, string>((src, args, raw) =>
            {
                try
                {
                    int playerHandle      = int.Parse(args[0].ToString());
                    Player _playerToSpawn = GetPlayerFromHandle(playerHandle);
                    _playerToSpawn.TriggerEvent("sth:spawnall", true);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine($"^1Error (probably passed invalid arguments): {ex}^7");
                }
            }), true);
            API.RegisterCommand("testmode", new Action <int, List <object>, string>((src, args, raw) =>
            {
                TestMode = !TestMode;
                Debug.WriteLine("testmode: " + TestMode.ToString());
            }), true);
            API.RegisterCommand("endhunt", new Action <int, List <object>, string>((src, args, raw) =>
            {
                isHuntOver = true;
            }), true);
            API.RegisterCommand("remveh", new Action <int, List <object>, string>((src, args, raw) =>
            {
                TriggerClientEvent("removeveh");
            }), true);
            API.RegisterCommand("spawnall", new Action <int, List <object>, string>((src, args, raw) =>
            {
                Debug.WriteLine();
                TriggerClientEvent("sth:spawnall");
                TriggerClientEvent("hudintrooff");
            }), true);
            //test

            EventHandlers["logCoords"] += new Action <List <Vector3> >((coordlist) =>
            {
                Debug.WriteLine("triggered log");
                if (coordlist.Count > 0)
                {
                    string userpath = $"{API.GetResourcePath(API.GetCurrentResourceName())}/coordsData.txt";
                    Debug.WriteLine($"{userpath}");
                    var exists = File.Exists(userpath);

                    File.Delete(userpath);
                    if (true)
                    {
                        using (var file = File.CreateText(userpath))
                        {
                            foreach (var i in coordlist)
                            {
                                //file.WriteLine($"new Vector4({i.X}f, {i.Y}f, {i.Z}f),");
                                //Debug.WriteLine($"new Vector4({i.X}f, {i.Y}f, {i.Z}f,");
                            }
                            file.Flush();
                        }
                    }
                }
                else
                {
                    Debug.WriteLine("coordlist was empty");
                }
            });

            //new hunt related
            EventHandlers["sth:sendserverkillerserverindex"] += new Action <Player, int>(KillfeedEventHandler);
        }
Exemplo n.º 5
0
    private void Update()
    {
        if (InputManager.wiimote != null)
        {
            // Set variables
            if (mode != TestMode.Pointer)
            {
                held = false;
            }

            // Switch modes
            switch (mode)
            {
            case TestMode.Button:
                if (InputManager.inputs.GetWiimoteButtonDown(Button.B))
                {
                    rb.velocity = Vector3.up * 5f;
                }
                break;

            // ------------------------------------------------

            case TestMode.Acceleration:
                rb.velocity = InputManager.inputs.GetAccelVector();
                break;

            // ------------------------------------------------

            case TestMode.WMP:
                Vector3 newVelocity = InputManager.inputs.WMPVectorStandardized();

                /*if(newVelocity.magnitude > 0)
                 *  Debug.Log(newVelocity);*/

                if (newVelocity.y == 0)
                {
                    newVelocity.y = rb.velocity.y;
                }

                if (newVelocity.magnitude > 1f)
                {
                    rb.velocity = newVelocity;
                }
                break;

            // ------------------------------------------------

            case TestMode.Nunchuck:
                try {
                    Vector3 axis = new Vector3(InputManager.inputs.GetNunchuckAxis("Horizontal"), 0f, InputManager.inputs.GetNunchuckAxis("Vertical"));
                    Debug.Log(axis);
                    rb.velocity = axis * nunchuckSpeed;
                } catch (System.Exception e) {
                    Debug.LogError(e + InputManager.wiimote.current_ext.ToString());
                }
                break;

            // ------------------------------------------------

            case TestMode.Shake:
                if (shakeTimer == 0)
                {
                    if (InputManager.inputs.Shake)
                    {
                        rb.velocity        = new Vector3(0f, shakeJump, 0f);
                        rb.angularVelocity = new Vector3(0f, 1f, 1f).normalized *shakeSpin;
                        shakeTimer         = shakeCooldown;
                    }
                }
                else
                {
                    shakeTimer = Mathf.Clamp(shakeTimer - Time.deltaTime, 0, shakeCooldown);
                }
                break;

            // ------------------------------------------------

            case TestMode.Twist:
                if (shakeTimer == 0)
                {
                    if (InputManager.inputs.Twisting)
                    {
                        rb.velocity        = new Vector3(0f, shakeJump, 0f);
                        rb.angularVelocity = new Vector3(0f, 1f, 1f).normalized *shakeSpin;
                        shakeTimer         = shakeCooldown;
                    }
                }
                else
                {
                    shakeTimer = Mathf.Clamp(shakeTimer - Time.deltaTime, 0, shakeCooldown);
                }
                break;

            // ------------------------------------------------

            case TestMode.Pointer:
                // Pick up
                if (!held && InputManager.wiimote.Button.b && InputManager.inputs.AimingAtObject(gameObject))
                {
                    held = true;
                }
                else if (!InputManager.wiimote.Button.b || InputManager.inputs.pointer.anchorMin[0] == -1f)    // Button released or pointer offscreen
                {
                    held = false;
                }
                if (!held)
                {
                    break;
                }

                // Move
                float   offsetFromCamera = 10;
                Vector3 direction        = InputManager.inputs.PointerToWorldPos(offsetFromCamera) - transform.position;
                rb.velocity = direction * dragSpeedMultiplier;

                break;

            // ------------------------------------------------

            default:
                break;
            }
        }

        // --------

        if (Input.GetKeyDown(KeyCode.Space))
        {
            transform.position = new Vector3(0, 1, 0);
            rb.velocity        = Vector3.zero;
        }
        else if (Input.GetKeyDown(KeyCode.UpArrow))
        {
            if (mode == TestMode.Pointer)
            {
                mode = 0;
            }
            else
            {
                mode++;
            }

            Debug.Log("Cube test mode set to " + mode.ToString());
        }
        else if (Input.GetKeyDown(KeyCode.DownArrow))
        {
            if (mode == TestMode.Button)
            {
                mode = TestMode.Pointer;
            }
            else
            {
                mode--;
            }

            Debug.Log("Cube test mode set to " + mode.ToString());
        }
    }