Exemplo n.º 1
0
 protected virtual void OnEnable()
 {
     if (_playerInput == null)
     {
         return;
     }
     _playerInput.ActivateInput();
 }
    void Update()
    {
        if (!hasAuthority || !isLocalPlayer)
        {
            if (bResetInputs)
            {
                Inputs.enabled = false;
            }
            return;
        }
        else
        {
            if (bResetInputs)
            {
                //Inputs.SwitchCurrentActionMap(Inputs.defaultActionMap);
                Inputs.SwitchCurrentControlScheme(Inputs.defaultControlScheme);
                Inputs.ActivateInput();
                bResetInputs = false;
            }

            if (bIsDying)
            {
                if (animator.GetCurrentAnimatorStateInfo(0).IsName("Death"))
                {
                    // Need to reset parameter state since we use "Any State"
                    animator.SetBool("Dying", false);
                    bIsDying = false;
                }
            }
        }
    }
Exemplo n.º 3
0
        /// <summary>
        /// Currently typechecks all objects to see if they conform to what
        /// the script is expecting and displays a warning if the do not.
        /// However, all data is saved as strings to be parsed when needed
        /// anyway, so...maybe it's not necessary?
        /// </summary>
        /// <param name="inputParams"></param>
        public void StartEvent(string[] inputParams)
        {
            ClearPanels();
            eventQueue.Clear();

            if (scriptStart.data.connections.Count - 1 != inputParams.Length)
            {
                Debug.LogError("Invalid Scenimatic Event setup for event " + eventPath
                               + ".\nInput parameter count " + inputParams.Length
                               + " does not match expected count of " + scriptStart.data.connections.Count);
            }

            guidPassedVariables = new Dictionary <string, string>();
            var conns = scriptStart.data.connections;

            for (int i = 1; i < conns.Count; ++i)
            {
                if (!TestValidInputType(conns[i].type, inputParams[i - 1]))
                {
                    Debug.LogWarning("input param #" + i + " does not match event input." +
                                     " Event was expecting " + conns[i].type + ".");
                }

                guidPassedVariables.Add(conns[i].GUID, inputParams[i - 1].ToString());
            }

            LoadBranch(scriptStart.data.connections[0].connectedToGUIDs[0]);

            if (Application.isPlaying)
            {
                playerInput.ActivateInput();
            }
            eventPrepared = true;
        }
Exemplo n.º 4
0
 private void EnableControllers()
 {
     for (int i = 0; i < spawnPoints.Length; i++)
     {
         PlayerInput pInput = players[i].GetComponent <PlayerInput>();
         pInput.actions.FindAction("Movement").Enable();
         pInput.ActivateInput();
     }
 }
Exemplo n.º 5
0
    /// <summary>
    /// "Spawn" the player by causing them to float up through the stage
    /// </summary>
    /// <param name="obj">Object to spawn</param>
    /// <param name="speed">How fast the spawn should be</param>
    /// <param name="delay">How many seconds to wait before spawning</param>
    /// <param name="cooldown">How many seconds to wait before enabling the enemy's movement</param>
    protected override IEnumerator Spawn(GameObject obj, float speed = 0.05f, float delay = 0f, float cooldown = 0)
    {
        // disable player input until spawn sequence is done
        PlayerInput playerInput = GetComponent <PlayerInput>();

        playerInput.PassivateInput();
        yield return(base.Spawn(obj, speed, delay, cooldown));

        playerInput.ActivateInput();
    }
 public void Respawn()
 {
     playerInput.ActivateInput();
     isDead       = false;
     Anim.enabled = true;
     EnableRagdoll(false);
     health.Add(health.maxValue * 0.6f);
     health.StartRegen();
     mana.StartRegen();
     statBars.Show();
     StartCoroutine(AudioHelper.PlayAudioOverlap(VocalAudio, playerRespawnedSFX));
 }
Exemplo n.º 7
0
    public void OnContinueClicked()
    {
        mainMenuUI.SetActive(false);
        inGameUI.SetActive(true);

        // Reenable gameplay inputs.
        playerInput.ActivateInput();

        m_State = State.InGame;

        RepaintInspector();
    }
    public void SetInputActiveState(bool gameIsPaused)
    {
        switch (gameIsPaused)
        {
        case true:
            playerInput.DeactivateInput();
            break;

        case false:
            playerInput.ActivateInput();
            break;
        }
    }
Exemplo n.º 9
0
 private void Toggle()
 {
     if (inMenu)
     {
         inMenu = false;
         input.ActivateInput();
     }
     else
     {
         inMenu = true;
         input.DeactivateInput();
     }
 }
Exemplo n.º 10
0
    public void Resume()
    {
        if (!isPaused)
        {
            return;
        }
        isPaused       = false;
        Time.timeScale = 1;
        Cursor.visible = false;
        if (playerInput != null)
        {
            playerInput.ActivateInput();
        }

        onResume.Invoke();
    }
    IEnumerator Respawn(PlayerInput player)
    {
        player.DeactivateInput();
        player.GetComponent <Rigidbody2D>().simulated = false;
        foreach (var sprite in player.GetComponent <Player>().Sprites)
        {
            sprite.enabled = false;
        }
        Debug.Log($"Player {player.playerIndex + 1} has died!");
        yield return(new WaitForSecondsRealtime(3));

        player.ActivateInput();
        player.gameObject.transform.position = _spawner.spawnPoints[player.playerIndex];
        foreach (var sprite in player.GetComponent <Player>().Sprites)
        {
            sprite.enabled = true;
        }
        player.GetComponent <Rigidbody2D>().velocity  = Vector2.zero;
        player.GetComponent <Rigidbody2D>().simulated = true;
    }
Exemplo n.º 12
0
    public void Respawn() //respawns player and resets necessary values
    {
        GameObject _cam = GameObject.Find("Main Camera");

        _cfl.Follow             = _pf;
        _cam.transform.position = playerSpawnPoint.position + new Vector3(0, 5, -17);
        _pf.position            = playerSpawnPoint.position;
        transform.position      = playerSpawnPoint.position;
        _rb.velocity            = Vector3.zero;

        if (_pi.heldPowerOrb != null)
        {
            _pi.heldPowerOrb.SetActive(true);
            _pi.heldPowerOrb.transform.GetChild(0).gameObject.GetComponent <powerOrb>().Die();
            _pi.heldPowerOrb = null;
            _pi.hasPowerOrb  = false;
            _rds.hasNothing();
        }

        RagdollOff();
        _playerInput.ActivateInput();
        isPlayerDead = false;
    }
Exemplo n.º 13
0
 public static void EnableInputs()
 {
     Inputs.ActivateInput();
 }
Exemplo n.º 14
0
 public void EnableInput()
 {
     _playerInput.ActivateInput();
     _shouldInteract = true;
 }