Exemplo n.º 1
0
 private static void RegisterEvent()
 {
     InputHandle.Register(Commond.Commond.lstc, SelectAllClient);
     InputHandle.Register(Commond.Commond.tcs, ClientSend);
     InputHandle.Register(Commond.Commond.tcstop, ClientStop);
     InputHandle.Register(Commond.Commond.tsstop, ServerStop);
 }
Exemplo n.º 2
0
 protected override void MovementInput()
 {
     Move(InputHandle.GetSitterMovement());
     if (Input.GetKey(KeyCode.UpArrow))
     {
         _anim.SetBool("Back", true);
     }
     else if (Input.GetKey(KeyCode.DownArrow))
     {
         _anim.SetBool("Front", true);
     }
     else if (Input.GetKey(KeyCode.RightArrow))
     {
         _anim.SetBool("Side", true);
     }
     else if (Input.GetKey(KeyCode.LeftArrow))
     {
         _anim.SetBool("Left", true);
     }
     else
     {
         _anim.SetBool("Back", false);
         _anim.SetBool("Front", false);
         _anim.SetBool("Side", false);
         _anim.SetBool("Left", false);
     }
 }
Exemplo n.º 3
0
        public void Dispose()
        {
            if (configHandle != null)
            {
                configHandle.Dispose();
                configHandle = null;
            }

            if (inputHandle != null)
            {
                inputHandle.Dispose();
                inputHandle = null;
            }

            if (context != null)
            {
                context.Dispose();
            }

            if (logWriter != null)
            {
                logWriter.Dispose();
                logWriter = null;
            }
        }
Exemplo n.º 4
0
    protected override void InteractInput()
    {
        if (InputHandle.GetSitterInteractKey())
        {
            Debug.Log("Interacting...");
            CheckInteract(LayerMask.GetMask("Interactable"));
            _anim.SetBool("Fix", true);
        }
        else
        {
            _anim.SetBool("Fix", false);
        }

        if (InputHandle.GetSitterPickUpKey())
        {
            if (child == null)
            {
                Debug.Log("Picking up...");
                CheckInteract(LayerMask.GetMask("Pickupable"));
            }
            else
            {
                //drop child
                Drop();
            }
        }
    }
Exemplo n.º 5
0
 private void Update()
 {
     if (InputHandle.GetSwitchKey())
     {
         Switch();
         GetComponent <AudioSwitch>().OnSwitch();
     }
 }
Exemplo n.º 6
0
 public void Unpause()
 {
     if (_isPaused)
     {
         _isPaused = false;
         InputHandle.PopActive();
         Input.MouseUtil.SetRawPositionState(Vector2.Zero);
     }
 }
Exemplo n.º 7
0
 public PlayerEntity(Vector3 position, MouseLook mouseLook)
     : base()
 {
     Transform.LocalPosition = position;
     MouseLook             = mouseLook;
     Input                 = new InputHandle();
     Input.IsCursorVisible = false;
     Input.IsCursorClipped = true;
     IsGrounded            = false;
 }
Exemplo n.º 8
0
        static void Main(string[] args)
        {
            InputHandle.Start();

            //TCP.TCPTest.Run();

            UDPTest.Run();

            System.Console.ReadLine();
        }
Exemplo n.º 9
0
 // Update is called once per frame
 protected override void InteractInput()
 {
     if (active)
     {
         if (InputHandle.GetBabyInteractKey())
         {
             Debug.Log("Interacting...");
             CheckInteract(LayerMask.GetMask("Interactable"));
         }
     }
 }
Exemplo n.º 10
0
 protected override void Update(GameTime gameTime)
 {
     if (InputHandle.Active.WasKeyPressed(Keys.F4))
     {
         ToggleFullscreen();
     }
     GameState.Current.Update();
     InputHandle.Update();
     Time.Update(gameTime);
     IsMouseVisible = !IsActive || InputHandle.Active.IsCursorVisible;
     GameState.ApplyNextState();
 }
Exemplo n.º 11
0
        public CalculationEngine(InputParameter inputParam, Action <string> logDelegate)
        {
            logWriter = new LogWriter(inputParam.LogFolder, "log.txt");

            logWriter.Add(logDelegate);

            context = new SQLContext(logWriter.Write);

            configHandle = new ConfigHandle(inputParam.ConfigExcelFilePath, logWriter.Write);

            inputHandle = new InputHandle(inputParam.InputExcelFilePath, logWriter.Write);
        }
Exemplo n.º 12
0
 public PlayerState()
 {
     player         = GameObject.FindGameObjectWithTag("Player");
     checkOnGround  = new CheckOnGround();
     inputHandle    = new InputHandle();
     changeRotation = new ChangeRotation();
     animator       = player.GetComponent <Animator>();
     rigidbody      = player.GetComponent <Rigidbody>();
     stateMachine   = player.GetComponent <PlayerStateMachine>();
     moveVec        = Vector3.zero;
     input          = InputKey.NONE;
 }
Exemplo n.º 13
0
    protected override void InputStuff()//
    {
        if (InputHandle.GetSitterInteractKey())
        {
            CheckInteract();
        }

        if (InputHandle.GetSitterPickUpKey())
        {
            PickUp();
        }

        Move(InputHandle.GetSitterMovement());
    }
Exemplo n.º 14
0
    private void Update()
    {
        if (SceneManager.GetActiveScene().name == "Menu")
        {
            if (InputHandle.GetSitterInteractKey())
            {
                SceneManager.LoadScene("KazooMadness");
            }
        }

        if (SceneManager.GetActiveScene().name == "BabyWin" || SceneManager.GetActiveScene().name == "SitterWin")
        {
            if (InputHandle.GetSitterInteractKey())
            {
                SceneManager.LoadScene("Menu");
            }
        }
    }
Exemplo n.º 15
0
        public void Initialize()
        {
            m_inputHandle  = new InputHandle();
            m_currentState = new OnPlayerGroundedState();
            m_currentState.OnEnter(this);
            m_rigidbody = GetComponent <Rigidbody2D>();
            m_collider  = GetComponent <BoxCollider2D>();

            m_viewer = GetComponentInChildren <PlayerViewer>();
            m_viewer.Initialize(this);
            m_arm = GetComponentInChildren <Arm>();
            m_arm.SetOwner(this);
            m_arm.Initialize();
            m_hand         = FindObjectOfType <Hand>();
            m_playableArm  = m_arm;
            m_playableHand = m_hand;
            m_hand.SetOwner(this);
            m_hand.Initialize();
        }
Exemplo n.º 16
0
    private void Start()
    {
        camPos = cam.transform.position;
        camRot = cam.transform.rotation;

        inputHandle = new InputHandle();
        foreach (Transform child in transform)
        {
            children.Add(child);
        }

        int joystickCount = Input.GetJoystickNames().Where(x => x.Length > 0).Count();
        int limit         = joystickCount + 1 < 4 ? joystickCount + 1 : 4;

        for (int i = 0; i < limit; i++)
        {
            SpawnPlayer();
        }
        StartCoroutine(Wait());
    }
Exemplo n.º 17
0
        public bool DeleteAssetCommand(string cmdName, string[] cmdArgs)
        {
            OutputHandle.PutMessage("Enter the id of the asset you wish to delete.");

            int id = 0;

            while (!int.TryParse(InputHandle.GetEditableInputWithDefaultText(), out id))
            {
                OutputHandle.PutMessage("Please enter a valid number.", IConsoleOutput.Color.YELLOW);
            }

            if (Assets.GetAsset(id) == null)
            {
                OutputHandle.PutMessage("The provided id does not exist in the system.", IConsoleOutput.Color.YELLOW);
                return(false);
            }

            Assets.DeleteAsset(id);

            return(true);
        }
Exemplo n.º 18
0
    protected override void MovementInput()
    {
        if (active && !grabbed && !bath)
        {
            Move(InputHandle.GetBabyMovement());
            if (Input.GetKey(KeyCode.R))
            {
                _anim.SetBool("Back", true);
            }
            else if (Input.GetKey(KeyCode.F))
            {
                _anim.SetBool("Front", true);
            }
            else if (Input.GetKey(KeyCode.G))
            {
                _anim.SetBool("Side", true);
            }
            else if (Input.GetKey(KeyCode.D))
            {
                _anim.SetBool("Left", true);
            }
            else
            {
                _anim.SetBool("Back", false);
                _anim.SetBool("Front", false);
                _anim.SetBool("Side", false);
                _anim.SetBool("Left", false);
            }
        }

        if (grabbed)
        {
            Wiggle(InputHandle.GetBabyMovement());
            transform.position = transform.parent.position + grabbedOffset;
        }
    }
Exemplo n.º 19
0
 set => SetConsoleMode(InputHandle, value);
        public bool UpdateAssetCommand(string cmdName, string[] cmdArgs)
        {
            OutputHandle.PutMessage("Enter the id of the asset you wish to modify.");

            int id = 0;

            while (!int.TryParse(InputHandle.GetEditableInputWithDefaultText(), out id))
            {
                OutputHandle.PutMessage("Please enter a valid number.", IConsoleOutput.Color.YELLOW);
            }

            Asset changeTarget = Assets.GetAsset(id);

            // We will make changes to this object, and then transfer them to the original object
            // after validation. If the user entered something wrong, we can revert to the old state
            // by simply discarding this object.
            // This method seems to be the simplest when using the reflection-based approach, since we
            // do not know the order in which the properties will be presented to the user.
            Asset tmpCopy = changeTarget.ShallowCopy();

            PropertyInfo[] properties = tmpCopy.GetType().GetProperties();
            foreach (var property in properties)
            {
                if (property.Name != "AssetID") // We don't want the user changing the id!
                {
                    OutputHandle.PutMessage("Enter a new '" + property.Name + "' or press return to keep the existing value.");

                    // This could probably be written nicer without code duplication ...
                    if (property.PropertyType == typeof(string))
                    {
                        string newValue = InputHandle.GetEditableInputWithDefaultText(property.GetValue(changeTarget).ToString());
                        while (string.IsNullOrEmpty(newValue))
                        {
                            OutputHandle.PutMessage("Please enter a valid string.", IConsoleOutput.Color.YELLOW);
                        }
                        property.SetValue(tmpCopy, newValue);
                    }
                    else if (property.PropertyType == typeof(int))
                    {
                        int newValue = 0;
                        while (!int.TryParse(
                                   InputHandle.GetEditableInputWithDefaultText(property.GetValue(changeTarget).ToString()),
                                   out newValue))
                        {
                            OutputHandle.PutMessage("Please enter a valid number.", IConsoleOutput.Color.YELLOW);
                        }
                        property.SetValue(tmpCopy, newValue);
                    }
                    else if (property.PropertyType == typeof(double))
                    {
                        double newValue = 0;
                        while (!double.TryParse(
                                   InputHandle.GetEditableInputWithDefaultText(property.GetValue(changeTarget).ToString()),
                                   out newValue))
                        {
                            OutputHandle.PutMessage("Please enter a valid number.", IConsoleOutput.Color.YELLOW);
                        }
                        property.SetValue(tmpCopy, newValue);
                    }
                    else if (property.PropertyType == typeof(DateTime))
                    {
                        DateTime newValue;
                        while (!DateTime.TryParse(
                                   InputHandle.GetEditableInputWithDefaultText(property.GetValue(changeTarget).ToString()),
                                   out newValue))
                        {
                            OutputHandle.PutMessage("Please enter a valid Date.", IConsoleOutput.Color.YELLOW);
                        }
                        property.SetValue(tmpCopy, newValue);
                    }
                    else
                    {
                        throw new InvalidOperationException("Unknown type error: " + property.Name);
                    }
                }
            }

            // Now check that the dates and prices are correct
            if (tmpCopy.Price < 0)
            {
                OutputHandle.PutMessage("Error: The price must not be negative.", IConsoleOutput.Color.RED);
                return(false);
            }
            else if (tmpCopy.ExpiryDate < tmpCopy.PurchaseDate)
            {
                OutputHandle.PutMessage("Error: Expiry date cannot come after purchase date.", IConsoleOutput.Color.RED);
                return(false);
            }
            else if (DateTime.Now < tmpCopy.PurchaseDate)
            {
                OutputHandle.PutMessage("Error: The specified purchase date is in the future. The asset tracker is not a list of things to buy!", IConsoleOutput.Color.RED);
                return(false);
            }
            else if (Offices.GetOffice(tmpCopy.OfficeID) == null)
            {
                OutputHandle.PutMessage($"Error: An office with the specified id does not exist: {tmpCopy.OfficeID}.", IConsoleOutput.Color.RED);
                return(false);
            }
            else
            // If we get here things should be OK, we can now save changes
            {
                foreach (var property in properties)
                {
                    if (property.Name != "AssetID")
                    {
                        property.SetValue(changeTarget, property.GetValue(tmpCopy));
                    }
                }

                Assets.UpdateAsset(changeTarget);
                OutputHandle.PutMessage("Changes saved.");
                return(true);
            }
        }
        private bool ListFiltered(Expression <Func <Asset, bool> > predicate)
        {
            if (Assets.Count == 0)
            {
                OutputHandle.PutMessage("No assets in database.", IConsoleOutput.Color.GREEN);
                return(true);
            }

            var query = Assets.GetQueriable()
                        .Where(predicate)
                        //.OrderBy(a => Offices.GetOffice(a.OfficeID).Location)
                        .OrderBy(a => a.OfficeID)
                        .ThenBy(a => a.PurchaseDate);

            // Used when scrolling
            int pageSize         = 20;
            int totalPageNum     = query.Count() / pageSize; // Is there no better way than executing the query here?
            int currentPageIndex = 0;

            OutputHandle.PutMessage("Enter a number to go to that page. Type 'up' or 'down' to scroll up or down.", IConsoleOutput.Color.GREEN);
            OutputHandle.PutMessage("Type anything else to exit.", IConsoleOutput.Color.GREEN);

            // Header
            OutputHandle.PutMessage(
                "Id".PadRight(IndexdPad) +
                "Model".PadRight(Pad) +
                "Purchase Date".PadRight(Pad) +
                "Expiry Date".PadRight(Pad) +
                "Price".PadRight(Pad) +
                "Office Location".PadRight(Pad) +
                "Other info ...".PadRight(Pad));

            ShowPage(query, pageSize, currentPageIndex);

            // Let user scroll up or down among the pages
            // Loop until user is finished
            string input   = "";
            bool   notDone = true;

            while (notDone)
            {
                OutputHandle.PutMessage($"Displaying page {currentPageIndex + 1} of {totalPageNum}.");

                input = InputHandle.GetEditableInputWithDefaultText(currentPageIndex == 0 ? "down" : "").ToLower();

                if (input == "down")
                {
                    if (currentPageIndex + 1 >= totalPageNum)
                    {
                        OutputHandle.PutMessage("No more assets.", IConsoleOutput.Color.GREEN);
                    }
                    else
                    {
                        currentPageIndex++;
                        ShowPage(query, pageSize, currentPageIndex);
                    }
                }
                else if (input == "up")
                {
                    if (currentPageIndex == 0)
                    {
                        OutputHandle.PutMessage("You are already at the top page.", IConsoleOutput.Color.YELLOW);
                    }
                    else
                    {
                        currentPageIndex--;
                        ShowPage(query, pageSize, currentPageIndex);
                    }
                }
                else if (int.TryParse(input, out int userSelectedPage))
                {
                    if (userSelectedPage > 0 && userSelectedPage <= totalPageNum)
                    {
                        currentPageIndex = userSelectedPage - 1; // index is zero-based, but index in ui is not
                        ShowPage(query, pageSize, currentPageIndex);
                    }
                    else
                    {
                        OutputHandle.PutMessage("Invalid page.", IConsoleOutput.Color.YELLOW);
                    }
                }
                else
                {
                    OutputHandle.PutMessage("Aborted.");
                    notDone = false;
                }
            }


            return(true);
        }
Exemplo n.º 22
0
 private void Awake()
 {
     GetComponent <SpriteRenderer>().sprite = sprites[2];
     inputHandle = InputHandle.Instance;
 }
        /// <summary>
        /// Implementation of the 'add' command. Current usage:
        ///  add Computer
        ///  add Cellphone
        /// </summary>
        public bool AddAssetCommand(string cmdName, string[] cmdArgs)
        {
            Dictionary <string, string> parameters = new Dictionary <string, string>();

            // Type of asset
            string type;

            if (cmdArgs.Length > 0 && cmdArgs[0].ToLower() == "computer")
            {
                type = "Computer";
            }
            else if (cmdArgs.Length > 0 && cmdArgs[0].ToLower() == "cellphone")
            {
                type = "Cellphone";
            }
            else
            {
                OutputHandle.PutMessage("Usage: 'add computer' or 'add cellphone'.", IConsoleOutput.Color.YELLOW);
                OutputHandle.PutMessage("Note that these are the only assets that are implemented in this iteration.");
                return(false);
            }

            parameters["Type"] = type;

            // Logic to get location
            OutputHandle.PutMessage("In which country is the office located?");
            Office office = Offices.GetOffice(InputHandle.GetEditableInputWithDefaultText());

            while (office == null)
            {
                OutputHandle.PutMessage("Unknown country, please try again.", IConsoleOutput.Color.RED);
                OutputHandle.PutMessage("Available options: ");
                foreach (Office o in Offices.GetOffices())
                {
                    OutputHandle.PutMessage(o.Location);
                }
                office = Offices.GetOffice(InputHandle.GetEditableInputWithDefaultText());
            }

            OutputHandle.PutMessage($"Location set: {office}.");
            OutputHandle.PutMessage("");
            parameters["OfficeID"] = office.OfficeID.ToString();

            // Purchase date
            OutputHandle.PutMessage("Enter date of purchase. The date should be in local time.");
            DateTime purchaseDate;

            while (!DateTime.TryParse(InputHandle.GetEditableInputWithDefaultText(), out purchaseDate))
            {
                OutputHandle.PutMessage("Please enter a valid date.", IConsoleOutput.Color.RED);
            }

            parameters["PurchaseDate"] = purchaseDate.ToString();

            // Expiry date
            DateTime expiryDate = purchaseDate.AddYears(3);

            OutputHandle.PutMessage($"The expiry date has been calculated to: {expiryDate.ToShortDateString()} (local time).");
            parameters["ExpiryDate"] = expiryDate.ToString();

            // Price
            double price = -1;

            OutputHandle.PutMessage("Enter purchase price of asset, in USD.");
            while (!double.TryParse(InputHandle.GetEditableInputWithDefaultText(), out price) || price < 0)
            {
                if (price < 0)
                {
                    OutputHandle.PutMessage("Price must not be less than 0.", IConsoleOutput.Color.RED);
                }
                else
                {
                    OutputHandle.PutMessage("Please enter a valid number.", IConsoleOutput.Color.RED);
                }
            }

            parameters["Price"] = price.ToString();

            // Model name
            OutputHandle.PutMessage("Enter model name.");
            string name = InputHandle.GetEditableInputWithDefaultText();

            while (string.IsNullOrEmpty(name) || string.IsNullOrWhiteSpace(name))
            {
                OutputHandle.PutMessage("Name is blank. Please enter a valid model name.", IConsoleOutput.Color.RED);
                name = InputHandle.GetEditableInputWithDefaultText();
            }

            parameters["ModelName"] = name;

            // Read type-specific data
            if (type == "Computer")
            {
                // OS
                OutputHandle.PutMessage("Please enter the OS of the computer.");
                string os = InputHandle.GetEditableInputWithDefaultText().Trim();
                while (string.IsNullOrEmpty(os))
                {
                    OutputHandle.PutMessage("Name cannot be blank.", IConsoleOutput.Color.RED);
                    os = InputHandle.GetEditableInputWithDefaultText().Trim();
                }

                parameters["OS"] = os;

                // RAM
                OutputHandle.PutMessage("Please enter the amount of RAM in the computer.");
                string RAM = InputHandle.GetEditableInputWithDefaultText().Trim();
                while (string.IsNullOrEmpty(RAM))
                {
                    OutputHandle.PutMessage("Name cannot be blank.", IConsoleOutput.Color.RED);
                    RAM = InputHandle.GetEditableInputWithDefaultText().Trim();
                }

                parameters["RAM"] = RAM;

                // Processor
                OutputHandle.PutMessage("Please enter the processor.");
                string processor = InputHandle.GetEditableInputWithDefaultText().Trim();
                while (string.IsNullOrEmpty(processor))
                {
                    OutputHandle.PutMessage("Name cannot be blank.", IConsoleOutput.Color.RED);
                    processor = InputHandle.GetEditableInputWithDefaultText().Trim();
                }

                parameters["Processor"] = processor;
            }
            else // Cellphone
            {
                // Operator
                OutputHandle.PutMessage("Please enter the name of the phone operator.");
                string phoneOperator = InputHandle.GetEditableInputWithDefaultText().Trim();
                while (string.IsNullOrEmpty(phoneOperator))
                {
                    OutputHandle.PutMessage("Name cannot be blank.", IConsoleOutput.Color.RED);
                    phoneOperator = InputHandle.GetEditableInputWithDefaultText().Trim();
                }

                parameters["PhoneOperator"] = phoneOperator;

                // Phone number
                OutputHandle.PutMessage("Please enter the phone number.");
                string phoneNumber = InputHandle.GetEditableInputWithDefaultText().Trim();
                while (string.IsNullOrEmpty(phoneNumber))
                {
                    OutputHandle.PutMessage("Name cannot be blank.", IConsoleOutput.Color.RED);
                    phoneNumber = InputHandle.GetEditableInputWithDefaultText().Trim();
                }

                parameters["PhoneNumber"] = phoneNumber;
            }

            try
            {
                Assets.AddAsset(parameters);
            }
            catch (Exception e)
            {
                OutputHandle.PutMessage(e.Message);
            }

            OutputHandle.PutMessage("Asset added to the system successfully.");

            return(true);
        }
Exemplo n.º 24
0
 private static void Print(InputHandle s)
 {
     Console.WriteLine(s);
 }