Example #1
0
    public IEnumerator ControlWizard(int playerNumber, OptionsMenuButton button)
    {
        VirtualControlManager.SetupDefaultControls(playerNumber);

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        yield return(new WaitForEndOfFrame());

        foreach (string inputName in VirtualControlManager.inputNames)
        {
            cInput.ChangeKey(inputName + playerNumber);
            button.text.text = string.Format("Press key/button for {0}", inputName);

            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            yield return(new WaitForEndOfFrame());

            yield return(new WaitUntil(() => !cInput.scanning));
        }

        button.text.text = "Set controls for player " + (playerNumber + 1);
    }
Example #2
0
 void Awake()
 {
     main        = this;  //Poorly implemented singleton thing, I guess.
     hud         = FindObjectOfType <HUDManager>();
     musicPlayer = GetComponentInChildren <MusicSelector>();
     VirtualControlManager.SetAllDefaultPlayerControls();
     enemyPlacer = GetComponent <EnemyPlacer>();
 }
Example #3
0
    void FixedUpdate()
    {
        InputData input      = VirtualControlManager.SampleInput(main.playerNumber);
        Vector3   moveVector = new Vector3(input.Horizontal, 0f, input.Vertical);

        moveVector = Vector3.ClampMagnitude(moveVector, 1f);
        if (!stunned)
        {
            rigid.velocity = moveVector * moveSpeed;
        }
    }
Example #4
0
    void Update()
    {
        InputData input = VirtualControlManager.SampleInput(main.playerNumber);

        //Aim 360 degrees around
        if (aimMode == AimMode.Joystick)
        {
            if (input.AimHorizontal != 0 || input.AimVertical != 0)
            {
                Vector3    aimInput     = new Vector3(input.AimHorizontal, 0f, input.AimVertical);
                Quaternion aimDirection = Quaternion.LookRotation(aimInput, Vector3.up);
                transform.rotation = aimDirection;
            }
        }
        else if (aimMode == AimMode.Mouse)
        {
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, aimMask))
            {
                Vector3 aimVector = hit.point - transform.position;
                aimVector = Vector3.ProjectOnPlane(aimVector, Vector3.up);
                Quaternion aimDirection = Quaternion.LookRotation(aimVector, Vector3.up);
                transform.rotation = aimDirection;
            }
        }

        //Shoot
        if (fireRateTimer > 0)
        {
            fireRateTimer -= Time.deltaTime;
        }

        if (canFire(input))
        {
            //if(input.Fire1 || (Input.GetKey(KeyCode.Alpha1) && main.playerNumber != 0)) {
            if (fireRateTimer <= 0f)
            {
                FireBullet();
                fireRateTimer = fireRate;
            }
        }
    }
Example #5
0
 void Start()
 {
     VirtualControlManager.SetupDefaultControls(playerNumber);
     vfx.SetVFXColors(playerColor);
 }
Example #6
0
 void Awake()
 {
     VirtualControlManager.SetAllDefaultPlayerControls();
 }