mirror of
https://github.com/openeggbert/mobile-eggbert-monogame-desktop.git
synced 2025-03-29 20:42:26 +01:00
Fixed the accelerometer related code, but accelerometer now does not work and has a dummy implementation. This must be fixed and implemented for Android and iOS
This commit is contained in:
parent
baa67de290
commit
cdda21a0cc
15
Accelerometer.cs
Normal file
15
Accelerometer.cs
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WindowsPhoneSpeedyBlupi
|
||||||
|
{
|
||||||
|
public interface Accelerometer
|
||||||
|
{
|
||||||
|
void Start();
|
||||||
|
void Stop();
|
||||||
|
event EventHandler<AccelerometerEventArgs> CurrentValueChanged;
|
||||||
|
}
|
||||||
|
}
|
23
AccelerometerDummyImpl.cs
Normal file
23
AccelerometerDummyImpl.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WindowsPhoneSpeedyBlupi
|
||||||
|
{
|
||||||
|
public class AccelerometerDummyImpl : Accelerometer
|
||||||
|
{
|
||||||
|
public event EventHandler<AccelerometerEventArgs> CurrentValueChanged;
|
||||||
|
|
||||||
|
public void Start()
|
||||||
|
{
|
||||||
|
//throw new AccelerometerFailedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Stop()
|
||||||
|
{
|
||||||
|
//throw new AccelerometerFailedException();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
23
AccelerometerEventArgs.cs
Normal file
23
AccelerometerEventArgs.cs
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WindowsPhoneSpeedyBlupi
|
||||||
|
{
|
||||||
|
public class AccelerometerEventArgs : EventArgs
|
||||||
|
{
|
||||||
|
|
||||||
|
public float X { get; }
|
||||||
|
public float Y { get; }
|
||||||
|
public float Z { get; }
|
||||||
|
|
||||||
|
public AccelerometerEventArgs(float x, float y, float z)
|
||||||
|
{
|
||||||
|
X = x;
|
||||||
|
Y = y;
|
||||||
|
Z = z;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
13
AccelerometerFactory.cs
Normal file
13
AccelerometerFactory.cs
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WindowsPhoneSpeedyBlupi
|
||||||
|
{
|
||||||
|
public class AccelerometerFactory
|
||||||
|
{
|
||||||
|
public static Accelerometer Create() { return new AccelerometerDummyImpl(); }
|
||||||
|
}
|
||||||
|
}
|
12
AccelerometerFailedException.cs
Normal file
12
AccelerometerFailedException.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace WindowsPhoneSpeedyBlupi
|
||||||
|
{
|
||||||
|
public class AccelerometerFailedException : Exception
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
12
InputPad.cs
12
InputPad.cs
@ -4,7 +4,6 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using Microsoft.Xna.Framework.Input;
|
using Microsoft.Xna.Framework.Input;
|
||||||
using Microsoft.Devices.Sensors;
|
|
||||||
using Microsoft.Xna.Framework.Input.Touch;
|
using Microsoft.Xna.Framework.Input.Touch;
|
||||||
using WindowsPhoneSpeedyBlupi;
|
using WindowsPhoneSpeedyBlupi;
|
||||||
|
|
||||||
@ -214,8 +213,8 @@ namespace WindowsPhoneSpeedyBlupi
|
|||||||
this.sound = sound;
|
this.sound = sound;
|
||||||
this.gameData = gameData;
|
this.gameData = gameData;
|
||||||
pressedGlyphs = new List<Def.ButtonGlygh>();
|
pressedGlyphs = new List<Def.ButtonGlygh>();
|
||||||
accelSensor = new Accelerometer();
|
accelSensor = AccelerometerFactory.Create();
|
||||||
((SensorBase<AccelerometerReading>)(object)accelSensor).CurrentValueChanged += HandleAccelSensorCurrentValueChanged;
|
accelSensor.CurrentValueChanged += HandleAccelSensorCurrentValueChanged;
|
||||||
accelSlider = new Slider
|
accelSlider = new Slider
|
||||||
{
|
{
|
||||||
TopLeftCorner = new TinyPoint
|
TopLeftCorner = new TinyPoint
|
||||||
@ -856,13 +855,14 @@ namespace WindowsPhoneSpeedyBlupi
|
|||||||
accelStarted = false;
|
accelStarted = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private void HandleAccelSensorCurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
|
private void HandleAccelSensorCurrentValueChanged(object sender, AccelerometerEventArgs e)
|
||||||
{
|
{
|
||||||
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
//IL_0001: Unknown result type (might be due to invalid IL or missing references)
|
||||||
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
//IL_0006: Unknown result type (might be due to invalid IL or missing references)
|
||||||
AccelerometerReading sensorReading = e.SensorReading;
|
|
||||||
float y = ((AccelerometerReading)(ref sensorReading)).Acceleration.Y;
|
float y = e.Y;
|
||||||
float num = (1f - (float)gameData.AccelSensitivity) * 0.06f + 0.04f;
|
float num = (1f - (float)gameData.AccelSensitivity) * 0.06f + 0.04f;
|
||||||
float num2 = (accelLastState ? (num * 0.6f) : num);
|
float num2 = (accelLastState ? (num * 0.6f) : num);
|
||||||
if (y > num2)
|
if (y > num2)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user