Esempio n. 1
0
        /// <summary>
        /// Moves the Camera According to the CameraControllers returnValue, closes the game when ESP is pressed
        /// </summary>
        public void Update()
        {
            Movement(CameraController.CameraPosition());

            if (ControlKeysManager.GetKeyDown(KeyCode.Escape))
            {
                Application.LoadLevel("MainMenu");
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Feed the currently pressed key to the DFA.
        /// </summary>
        /// <remarks>
        /// If a special attack is detected, <see cref="DetectedSpecialAttack"/> is set
        /// to a non-NULL value. You can then call that callback to trigger the attack.
        /// </remarks>
        public void Check()
        {
            // No special attack detected yet, so make sure the last
            // detected action is cleared.
            _detectedSpecialAttack = null;

            // Check for the pressed key.
            KeyCode pressedKey = KeyCode.None;

            foreach (KeyCode key in _keyCodeMap.Keys)
            {
                if (ControlKeysManager.GetKeyDown(key))
                {
                    pressedKey = key;
                    break;
                }
            }

            if (pressedKey == KeyCode.None)
            {   // No (known) key pressed.
                return;
            }

            if (_lastTimePress > 0 && Time.time - _lastTimePress > COMBOTIME)
            {   // Timeout. Combo rejected.
                _currentState = 0;
            }

            _lastTimePress = Time.time;

            // This key maps to which index?
            int keyIndex = _keyCodeMap[pressedKey];

            // Determine the next state.
            _currentState = _stateChart[_currentState][keyIndex];

            // And, is it a special attack?
            if (!_attackMap.TryGetValue(_currentState, out _detectedSpecialAttack))
            {   // Nope. It's a normal state.
                return;
            }

            // Yes, it is a special attack! We are done.
            foreach (int nextState in _stateChart[_currentState])
            {
                if (nextState != 0)
                {   // We cannot return to state 0 as there may be another special attack
                    // after this one.
                    // DO NOT RESET THE STATE HERE. State needs to be kept so that
                    // e. g. the triple attack works.
                    return;
                }
            }

            // There is no special attack after this one; return to state 0.
            _currentState = 0;
        }
Esempio n. 3
0
        /// <summary>
        /// Updates the CameraPostion and end the game when ESC is pressed
        /// </summary>
        public void Update()
        {
            Movement(SpecialModeCameraController.CameraPosition());
            if (ControlKeysManager.GetKeyDown(KeyCode.Escape))
            {
                if (_net.IsClient)
                {
                    if (GameObject.Find("HeroClient") != null)
                    { // if someone klicked escape before his hero got initialised
                        _net.SendEscapeDisconnect(GameObject.Find("HeroClient").GetComponent <Hero>().Team.TeamNo);
                    }
                }
                else if (_net.IsServer)
                {
                    if (GameObject.Find("HeroServer") != null)
                    { // if someone klicked escape before his hero got initialised
                        _net.SendEscapeDisconnect(GameObject.Find("HeroServer").GetComponent <Hero>().Team.TeamNo);
                    }
                }

                Application.LoadLevel("MainMenu");
            }
        }
Esempio n. 4
0
 /// <summary>
 /// Set the ControlKeys for a player.
 /// </summary>
 /// <param name="player">Player ID</param>
 /// <param name="keys">Control keys</param>
 public void SetControlKeysForPlayer(int player, ControlKeysManager keys)
 {
     _playerControlKeys[player] = keys;
 }