Exemplo n.º 1
0
    void Awake()
    {
        //Singleton pattern
        if (Inputs == null)
        {
            DontDestroyOnLoad(gameObject);
            Inputs = this;
        }
        else if (Inputs != this)
        {
            Destroy(gameObject);
        }

        /*Assign each keycode when the game starts.
         * Loads data from PlayerPrefs so if a user quits the game,
         * their bindings are loaded next time. Default values
         * are assigned to each Keycode via the second parameter
         * of the GetString() function
         */
        jump     = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("jumpKey", "Space"));
        forward  = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("forwardKey", "W"));
        backward = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("backwardKey", "S"));
        left     = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("leftKey", "A"));
        right    = (KeyCode)System.Enum.Parse(typeof(KeyCode), PlayerPrefs.GetString("rightKey", "D"));
    }
    void Start()
    {
        rb               = GetComponent <Rigidbody2D>();
        sr               = GetComponentInChildren <SpriteRenderer>();
        trans            = GetComponent <Transform>();
        CI               = FindObjectOfType <CustomInputs>();
        actualJumpBuffer = jumpBuffer;

        initialSize = sr.transform.localScale.x;
    }
Exemplo n.º 3
0
        public override object Clone()
        {
            bsFormGroupStacked groupStacked = ((bsFormGroupStacked)base.Clone());

            groupStacked.CustomInputs = new List <bmInput>();
            foreach (bmInput input in CustomInputs.ToArray())
            {
                groupStacked.CustomInputs.Add(input.Clone() as bmInput);
            }
            return(groupStacked);
        }
 void InitializeInputs(ref CustomInputs inputs)
 {
     inputs.ChangeSpeed            = 0.0f;
     inputs.FastMoveLeft           = false;
     inputs.FastMoveRight          = false;
     inputs.Slide                  = false;
     inputs.Jump                   = false;
     inputs.MoveSide               = 0.0f;
     inputs.ChangeOrientationLeft  = 0.0f;
     inputs.ChangeOrientationRight = 0.0f;
 }
    CustomInputs getFrameDependentInput()
    {
        CustomInputs tmpInputs = playerInputs;

        tmpInputs.Shoot          = false;
        tmpInputs.SecondaryShoot = false;
        tmpInputs.StartRun       = false;

        if (anyInputAllowed)
        {
            if (Input.GetMouseButton(0) && shootingAllowed)
            {
                tmpInputs.Shoot = true;
            }

            if (Input.GetMouseButton(1) && shootingAllowed)
            {
                tmpInputs.SecondaryShoot = true;
            }

            if (Input.anyKey && !Input.GetKey(KeyCode.Escape) && playerInputs.ChangeSpeed == 0.0f)
            {
                tmpInputs.StartRun = true;

                onInit();
            }
        }
        else
        {
            if (Input.GetMouseButton(0) && shootingAllowed)
            {
                tmpInputs.Shoot = true;
            }

            if (Input.GetMouseButton(1) && shootingAllowed)
            {
                tmpInputs.SecondaryShoot = true;
            }
        }
        return(tmpInputs);
    }
    void Start()
    {
        CI = FindObjectOfType <CustomInputs>();
        SS = FindObjectOfType <ScreenShake>();
        AM = FindObjectOfType <AudioManager>();

        fireOrigin = transform.Find("FireOrigin").transform;

        //Clone the bullet
        container = fireOrigin.Find("BulletContainer");
        var bullet = container.transform.Find("Bullet");

        bullet.gameObject.GetComponent <bullet>().parent = container;
        initialPosition = bullet.transform.position;
        for (int i = 0; i < maxBullets; i++)
        {
            var temp = Instantiate(bullet, container, true);
        }

        scale = fireOrigin.transform.localScale;
    }
    CustomInputs getInputs()
    {
        CustomInputs tmpInputs = playerInputs;

        InitializeInputs(ref tmpInputs);
        if (anyInputAllowed)
        {
            if (Input.GetKey(KeyCode.Space))
            {
                tmpInputs.Jump = true;
            }


            if (Input.GetKey(KeyCode.LeftShift))
            {
                tmpInputs.Slide = true;
            }

            if (Input.GetKey(KeyCode.Q) && dashingAllowed)
            {
                tmpInputs.FastMoveLeft = true;
            }

            if (Input.GetKey(KeyCode.E) && dashingAllowed)
            {
                tmpInputs.FastMoveRight = true;
            }

            if ((Input.GetAxisRaw("Vertical") > 0 && accelerationAllowed) || (Input.GetAxisRaw("Vertical") < 0 && brakingAllowed))
            {
                tmpInputs.ChangeSpeed = Input.GetAxisRaw("Vertical");
            }

            tmpInputs.MoveSide = Input.GetAxisRaw("Horizontal");
        }
        return(tmpInputs);
    }
Exemplo n.º 8
0
 void Awake()
 {
     controls        = new CustomInputs();
     player.controls = controls;
     controls.ExtraControls.OpenMenu.performed += ctx => FlipFlopMainMenu();
 }
Exemplo n.º 9
0
 public bool TryGetCustomInput(string name, out Input input) => CustomInputs.TryGetValue(name, out input);
Exemplo n.º 10
0
 void Start()
 {
     CI = FindObjectOfType <CustomInputs>();
 }
Exemplo n.º 11
0
 void Start()
 {
     player = FindObjectOfType <GameController>();
     CI     = FindObjectOfType <CustomInputs>();
     DM     = FindObjectOfType <DialogueManager>();
 }
    /*void FixedUpdate () {
     * playerInputs = getInputs();
     * }
     */

    void Update()
    {
        playerInputs = getFrameDependentInput();
        playerInputs = getInputs();
    }
Exemplo n.º 13
0
 private void Start()
 {
     CI = GetComponent <CustomInputs>();
     AM = GetComponent <AudioManager>();
     MM = GetComponent <MusicManager>();
 }