コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        // Retrieve our current WASD or Arrow Key input
        // Using GetAxisRaw removes any kind of gravity or filtering being applied to the input
        // Ensuring that we are getting either -1, 0 or 1
        Vector3 moveInput = new Vector3(Input.GetAxisRaw("Horizontal"), 0, 0);

        Vector2 mouseInput      = Vector2.zero;
        Vector2 rightStickInput = Vector2.zero;

        // pass rightStick values in place of mouse when non-zero
        //mouseInput.x = rightStickInput.x != 0 ? rightStickInput.x * RightStickMultiplier.x : mouseInput.x;
        //mouseInput.y = rightStickInput.y != 0 ? rightStickInput.y * RightStickMultiplier.y : mouseInput.y;

        bool jumpInput = Input.GetButtonDown("Jump");

        Current = new FighterInput()
        {
            MoveInput  = moveInput,
            MouseInput = mouseInput,
            JumpInput  = jumpInput
        };
    }
コード例 #2
0
        private Fighter GetFighter(Vector2 pos, Texture2D overlay, FighterInput input, bool flip, String type)
        {
            switch (type)
            {
            case ("wasp"):
                float  speed  = .7f;
                double health = 100;
                double power  = 10;

                var waspIdle   = LoadAnim("waspIdle");
                var waspPunch  = LoadAnim("waspPunch");
                var waspRecoil = LoadAnim("waspRecoil");
                List <HitBox.HitBoxFrame> hitFrames = new List <HitBox.HitBoxFrame>();
                hitFrames.Add(new HitBox.HitBoxFrame(waspPunch.GetNumFrames() / waspPunch.GetFps(), new Rectangle(waspPunch.GetWidth(), 50, 10, 10), power));
                var punch = new HitBox(p1, Load <SoundEffect>("Audio/waspPunch"), hitFrames);    //Gets null for p1


                return(new Fighter(pos, overlay, waspIdle, waspPunch, waspRecoil, input, punch, flip, speed, health, power));

            case ("beetle"):
                float  speed2  = .4f;
                double health2 = 100;
                double power2  = 11;

                var beetleIdle   = LoadAnim("beetleIdle");
                var beetlePunch  = LoadAnim("beetlePunch");
                var beetleRecoil = LoadAnim("beetleRecoil");
                List <HitBox.HitBoxFrame> hitFrames2 = new List <HitBox.HitBoxFrame>();
                hitFrames2.Add(new HitBox.HitBoxFrame(beetlePunch.GetNumFrames(), new Rectangle(beetlePunch.GetWidth(), 50, 10, 10), power2));
                var punch2 = new HitBox(p2, Load <SoundEffect>("Audio/beetlePunch"), hitFrames2);    //Gets null for p2, fix is below

                return(new Fighter(pos, overlay, beetleIdle, beetlePunch, beetleRecoil, input, punch2, flip, speed2, health2, power2));
            }

            return(null);
        }
コード例 #3
0
 // Use this for initialization
 void Start()
 {
     Current = new FighterInput();
 }