Esempio n. 1
0
    public void InitialiazePlayer(PlayerConfiguration pc)
    {
        _PlayerConfig = pc;

        //set correct color
        MeshRenderer[] meshRenderers = GetComponentsInChildren <MeshRenderer>();
        for (int t = 0; t < meshRenderers.Length; t++)
        {
            meshRenderers[t].material = _PlayerConfig.PlayerMaterial;
        }

        //controls
        InputBeh = _PlayerConfig.Input.gameObject.GetComponent <InputBehaviour>();

        InputBeh.StartJumpEvent.AddListener(StartJump);
        InputBeh.CancelJumpEvent.AddListener(CancelJump);

        InputBeh.StartPushEvent.AddListener(StartPush);
        InputBeh.EndPushEvent.AddListener(StopPush);

        InputBeh.StartInteractEvent.AddListener(StartInteract);

        //
        ++_PlayersAlive;
    }
Esempio n. 2
0
 void OnSceneEnded()
 {
     InputBehaviour.StartCoroutine(ManUtils.ManCoroutine.WaitAndAction(1, () =>
     {
         IsPlayerLeft = false;
     }));
 }
Esempio n. 3
0
 private void Start()
 {
     inputBehaviour     = FindObjectOfType <InputBehaviour>();
     myRigidbody2D      = GetComponent <Rigidbody2D>();
     myTriggerCollision = GetComponent <PlayerTriggerCollision>();
     oldMovementSpeed   = movementSpeed;
 }
Esempio n. 4
0
 public string GetBehaviourAxis(InputBehaviour inBehaviour)
 {
     if (!_playersBehavioursList.ContainsKey(inBehaviour))
     {
         throw new WarningException($"Players Behaviours List doesn't contains the given behaviour {inBehaviour}");
     }
     return(_playersBehavioursList[inBehaviour]);
 }
Esempio n. 5
0
 private void AssignBehaviour(InputBehaviour inBehaviour, string inBehaviourName)
 {
     if (string.IsNullOrEmpty(inBehaviourName))
     {
         return;
     }
     _playersBehavioursList.Add(inBehaviour, inBehaviourName);
 }
 void Start()
 {
     _slowMovement  = GetComponent <SpeedBehaviour>();
     _rigidbody2D   = GetComponent <Rigidbody2D>();
     _keyInput      = GetComponent <InputBehaviour>();
     _player_Health = GetComponent <Player_Health>();
     _slowMovement.Coroutine();
 }
Esempio n. 7
0
 private void Start()
 {
     input                    = FindObjectOfType <InputBehaviour>();
     myPlayerData             = FindObjectOfType <PlayerData>();
     myPlayerTriggerCollision = FindObjectOfType <PlayerTriggerCollision>();
     myComputerUI             = FindObjectOfType <DesktopUI>();
     StartCoroutine(myUpdate(.5f));
 }
Esempio n. 8
0
 public float GetAxis(InputBehaviour inBehaviour)
 {
     if (!IsRun || !_config)
     {
         return(0f);
     }
     return(Input.GetAxisRaw(_config.GetBehaviourAxis(inBehaviour)));
 }
Esempio n. 9
0
    private void Start()
    {
        input      = GetComponent <InputBehaviour>();
        itemInHand = null;
        Vector3 mousePos = Camera.main.ScreenToWorldPoint(new Vector3(Input.mousePosition.x, Input.mousePosition.y, 10.0f));

        myInventory   = GetComponent <Inventory>();
        myInventoryUI = GetComponent <InventoryUI>();
    }
Esempio n. 10
0
 void Start()
 {
     ib        = GetComponent <InputBehaviour>();
     conductor = ConductorManager.GetComponent <Conductor>();
     currnote  = 0;
     Sprite[0] = references[0].GetComponent <SpriteRenderer>();
     Sprite[1] = references[1].GetComponent <SpriteRenderer>();
     Sprite[2] = references[2].GetComponent <SpriteRenderer>();
     Sprite[3] = references[3].GetComponent <SpriteRenderer>();
     notecount = conductor.beatscount;
     InitSpaces();
 }
Esempio n. 11
0
    private void Start()
    {
        input     = GetComponent <InputBehaviour>();
        waypoints = pathCreator.path.CalculateEvenlySpacedPoints(spacing, resolution);

        /* foreach (Vector2 p in waypoints)
         * {
         *   GameObject g = GameObject.CreatePrimitive(PrimitiveType.Sphere);
         *   g.transform.position = p;
         *   g.transform.localScale = Vector3.one * spacing * .5f;
         * }*/
    }
Esempio n. 12
0
    public override void OnStateUpdate(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        InputBehaviour input = animator.GetBehaviour <InputBehaviour>();

        float horizontal = input.HorizontalInput();
        float vertical   = input.VerticalInput();
        float speed      = animator.GetComponent <CreatureController>().CreatureDataObject.SpeedPerSecond;

        Vector3 movement = new Vector3(horizontal, vertical, 0f).normalized;

        animator.gameObject.GetComponent <Rigidbody2D>().AddRelativeForce(movement * speed * Time.deltaTime);
    }
    private void StartGame()
    {
        m_LavaBeh.enabled = true;
        InputBehaviour.ResetSkipEvents();

        //enable movement
        foreach (GameObject player in m_Players)
        {
            player.GetComponentInChildren <CharacterControl>().enabled = true;
        }
        Destroy(this.gameObject);
    }
Esempio n. 14
0
    private void handleDown(int button, Vector3 position)
    {
        // VAMOS A DETECTAR SI TOCAMOS ALGO
        selectedInput = getGameObject(position, out lastPosition);

        if (selectedInput != null)
        {
            // SI LO QUE HEMOS TOCADO NO ESTÁ VACÍO,
            Debug.Log(selectedInput.gameObject.name);
            // LLAMAMOS A SU ACCION DE DENTRO DEL INPUTBEHAVIOUR
            selectedInput.triggerDown(button);
        }
    }
Esempio n. 15
0
    private void Start()
    {
        input     = FindObjectOfType <InputBehaviour>();
        rigidbody = GetComponent <Rigidbody>();

        if (isLocalPlayer)
        {
            this.gameObject.layer = LayerMask.NameToLayer("LocalPlayer");   // Changes the layer to local player.
        }
        else
        {
            this.gameObject.layer = LayerMask.NameToLayer("ConnectedPlayer");   // Changes the layer to connected player.
        }
    }
Esempio n. 16
0
        private void Start()
        {
            iB = GetComponent <InputBehaviour>();
            mB = GetComponent <MovementBehaviour>();
            sB = GetComponent <ShooterBehaviour>();
            tB = GetComponent <TeamMemberBehaviour>();
            hB = GetComponent <HealthBehaviour>();

            cB = GetComponentInChildren <CameraBehaviour>();

            audioHandler = GetComponent <PlayerSoundHandler>();

            points = 0;
        }
Esempio n. 17
0
    private InputBehaviour getGameObject(Vector3 screenPos, out Vector3 point)
    {
        InputBehaviour result = null;

        // Construct a ray from the current touch coordinates
        // LANZAMOS UN RAYCAST DESDE LA PANTALLA
        Ray        ray = camera.ScreenPointToRay(screenPos);
        RaycastHit hit;

        if (Physics.Raycast(ray, out hit))
        {
            Debug.Log("RayCast");
            // SI EL RAYCAST TOCA UN ELEMENTO CON INPUTBEHAVIOUR, LO RECOGEMOS
            result = hit.transform.gameObject.GetComponent <InputBehaviour>();
            point  = hit.point;
        }
        else
        {
            point = Vector3.zero;
            //distance = 0;
        }

        return(result);
    }
Esempio n. 18
0
 public void addInput(InputBehaviour input)
 {
     inputs.Add (input);
 }
Esempio n. 19
0
 public void removeInput(InputBehaviour input)
 {
     inputs.Remove (input);
 }
 private void Start()
 {
     myAnim = GetComponent <Animator>();
     input  = GetComponent <InputBehaviour>();
 }
 void Start()
 {
     _animator       = GetComponent <Animator>();
     _inputBehaviour = GameObject.FindObjectOfType <InputBehaviour>();
     _player_Health  = GetComponentInParent <Player_Health>();
 }
        /// <summary>
        /// Sets the <see cref="P:RawValue"/>.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="timeStamp">Time stamp.</param>
        public override void SetRawValue(KeyCode value, float timeStamp = -1f)
        {
            // Set the InteractionGauge.
            switch (InputBehaviour.InteractionType.Value)
            {
            case InteractionType.CONTINUOUS:
                // Set the raw and processed values.
                RawValue       = value;
                ProcessedValue = RawValue;

                // Trigger an event.
                TriggerValueReceivedEvent(this, ProcessedValue);

                // Set the InteractionGauge.
                InteractionGauge = 1f;

                // Trigger the interaction event.
                if (InteractionGauge >= InputBehaviour.MinimumInteraction.Value)
                {
                    TriggerInteractedEvent(this);
                }

                // Decrease the InteractionGauge.
                if (decreaseInteractionGaugeCrt != null)
                {
                    InputBehaviour.StopCoroutine(decreaseInteractionGaugeCrt);
                }
                decreaseInteractionGaugeCrt = InputBehaviour.StartCoroutine(DecreaseInteractionGauge(1f));

                break;

            case InteractionType.DISCONTINUOUS:
                // Reset the values coroutine.
                if (resetValuesCrt != null)
                {
                    InputBehaviour.StopCoroutine(resetValuesCrt);
                }

                // Set the raw and processed values.
                RawValue       = value;
                ProcessedValue = RawValue;

                // Trigger an event.
                TriggerValueReceivedEvent(this, ProcessedValue);

                // Set the interaction gauge to 1.
                InteractionGauge = 1f;

                // Trigger the interaction event.
                TriggerInteractedEvent(this);

                // Set the raw and processed values back to its initial value after 0.1 second.
                if (resetValuesCrt != null)
                {
                    InputBehaviour.StopCoroutine(resetValuesCrt);
                }
                resetValuesCrt = InputBehaviour.StartCoroutine(ManUtils.ManCoroutine.WaitAndAction(0.1f, () => RawValue = ProcessedValue = KeyCode.None));

                // Decrease the InteractionGauge.
                if (decreaseInteractionGaugeCrt != null)
                {
                    InputBehaviour.StopCoroutine(decreaseInteractionGaugeCrt);
                }
                decreaseInteractionGaugeCrt = InputBehaviour.StartCoroutine(DecreaseInteractionGauge(1f));

                break;
            }
        }
Esempio n. 23
0
 public void removeInput(InputBehaviour input)
 {
     inputs.Remove(input);
 }
Esempio n. 24
0
 void Start()
 {
     input = GetComponent <InputBehaviour> ();
     editorObjectSpawner = GetComponent <Editor_SpawnObject> ();
 }
Esempio n. 25
0
 // Use this for initialization
 void Start()
 {
     input   = GetComponent <InputBehaviour>();
     rb      = GetComponent <Rigidbody2D>();
     CanMove = false;
 }
 private void Start()
 {
     inventory = GetComponentInChildren <Inventory>();
     input     = GetComponent <InputBehaviour>();
 }
Esempio n. 27
0
 public bool GetButtonUp(InputBehaviour inBehaviour) => IsRun && _config && Input.GetButtonUp(_config.GetBehaviourAxis(inBehaviour));
Esempio n. 28
0
 public void addInput(InputBehaviour input)
 {
     inputs.Add(input);
 }
Esempio n. 29
0
        /// <summary>
        /// Sets the <see cref="P:RawValue"/>.
        /// </summary>
        /// <param name="value">Value.</param>
        /// <param name="timeStamp">Time stamp.</param>
        public override void SetRawValue(int value, float timeStamp = -1f)
        {
            // Set the InteractionGauge.
            switch (InteractionType.Value)
            {
            case Input.InteractionType.CONTINUOUS:
                // Update current variables.
                curTime = Time.unscaledTime;

                // Set the raw and processed values.
                RawValue       = value;
                ProcessedValue = (int)(ApplyFilter(value, timeStamp) * Gain.Value);

                // Trigger an event.
                TriggerValueReceivedEvent(ProcessedValue);

                // Calc. the change of the processed value over time.
                float d = Mathf.Abs((ProcessedValue - prevProcessedValue) / (curTime - prevTime));

                // Set the InteractionGauge.
                InteractionGauge = d;

                // Trigger the interaction event.
                if (InteractionGauge >= MinimumInteraction.Value)
                {
                    TriggerInteractedEvent();
                }

                // Update previous variables.
                prevProcessedValue = ProcessedValue;
                prevTime           = curTime;

                break;

            case Input.InteractionType.DISCONTINUOUS:
                // Reset the values coroutine.
                if (resetValuesCrt != null)
                {
                    InputBehaviour.StopCoroutine(resetValuesCrt);
                }

                // Set the raw and processed values.
                RawValue       = value;
                ProcessedValue = (int)(ApplyFilter(value, timeStamp) * Gain.Value);

                // Trigger an event.
                TriggerValueReceivedEvent(ProcessedValue);

                // Set the interaction gauge to 1.
                InteractionGauge = 1f;

                // Trigger the interaction event.
                TriggerInteractedEvent();

                // Set the raw and processed values back to its initial value after 0.1 second.
                if (resetValuesCrt != null)
                {
                    InputBehaviour.StopCoroutine(resetValuesCrt);
                }
                resetValuesCrt = InputBehaviour.StartCoroutine(ManUtils.ManCoroutine.WaitAndAction(0.1f, () => RawValue = prevProcessedValue = ProcessedValue = 0));

                // Decrease the InteractionGauge.
                if (decreaseInteractionGaugeCrt != null)
                {
                    InputBehaviour.StopCoroutine(decreaseInteractionGaugeCrt);
                }
                decreaseInteractionGaugeCrt = InputBehaviour.StartCoroutine(DecreaseInteractionGauge(1f));

                break;
            }
        }
    void PlayerPressedStart(InputAction.CallbackContext value)
    {
        //check for max amount of players
        if (m_ControllerIds.Count == m_MaxPlayers)
        {
            Debug.Log("The maximum amount of players has already been reached.");
        }
        else
        {
            //check if controller is already used
            if (m_ControllerIds.Contains(m_GameInputControls.MenuControls.Start.activeControl.device.deviceId))
            {
                Debug.Log("Device is already assigned to a player");
            }
            //add a player
            else
            {
                InputDevice controller = m_GameInputControls.MenuControls.Start.activeControl.device;
                m_ControllerIds.Add(controller.deviceId);

                //setup the controls and user
                Controls gameInputControls = new Controls();
                gameInputControls.MenuControls.Enable(); //we start in a menu

                InputUser user = InputUser.PerformPairingWithDevice(m_GameInputControls.MenuControls.Start.activeControl.device);
                user.AssociateActionsWithUser(gameInputControls);

                //spawn the player object and initiate it properly
                GameObject menu = Instantiate(m_SelectionMenu, m_MainLayout.transform);

                InputBehaviour inputBeh = menu.GetComponentInChildren <InputBehaviour>();
                if (inputBeh != null)
                {
                    inputBeh.SetInputUser(user, controller);
                    inputBeh.RumbleController(0.8f, 0.66f);
                }

                CharacterSelection characterSelection = menu.GetComponentInChildren <CharacterSelection>();
                if (characterSelection != null)
                {
                    characterSelection.SetPlayerIndex(m_PlayerId);
                    m_PlayerSelections.Add(characterSelection);
                }

                //set player id to the charactercontrol
                inputBeh.gameObject.GetComponent <CharacterControl>().PlayerId = m_PlayerId;


                //save the camera
                m_Cameras[m_PlayerId] = menu.GetComponentInChildren <Camera>();

                //inc playerid
                ++m_PlayerId;

                //this setup has to be after the increment (has to do with the actual player numbers and not their spot in an array which starts at 0)
                SetupCameras();

                Debug.Log("Player " + m_PlayerId + "joinend!");
            }
        }
        if (m_PlayerId == 4)
        {
            m_HelpText.SetActive(false);
        }
    }