Both the Android and Desktop versions were synchronized
This commit is contained in:
parent
0bc2a80eef
commit
db5f25deb7
2
.gitignore
vendored
2
.gitignore
vendored
@ -240,3 +240,5 @@ ModelManifest.xml
|
||||
|
||||
# FAKE - F# Make
|
||||
.fake/
|
||||
|
||||
*.bak
|
||||
|
@ -1,15 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,23 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
@ -1,13 +0,0 @@
|
||||
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(); }
|
||||
}
|
||||
}
|
@ -1,12 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace WindowsPhoneSpeedyBlupi
|
||||
{
|
||||
public class AccelerometerFailedException : Exception
|
||||
{
|
||||
}
|
||||
}
|
12
Def.cs
12
Def.cs
@ -7,6 +7,18 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
|
||||
public static class Def
|
||||
{
|
||||
public const bool DETAILED_DEBUGGING = false;
|
||||
|
||||
public const Platform PLATFORM = Platform.Desktop;
|
||||
|
||||
public enum Platform
|
||||
{
|
||||
Desktop,
|
||||
Android,
|
||||
iOS,
|
||||
Web
|
||||
}
|
||||
|
||||
public enum Phase
|
||||
{
|
||||
None,
|
||||
|
5
Game1.cs
5
Game1.cs
@ -979,5 +979,10 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
this.graphics.ToggleFullScreen();
|
||||
}
|
||||
public bool IsFullScreen() { return this.graphics.IsFullScreen; }
|
||||
|
||||
public GraphicsDeviceManager getGraphics()
|
||||
{
|
||||
return graphics;
|
||||
}
|
||||
}
|
||||
}
|
46
InputPad.cs
46
InputPad.cs
@ -4,6 +4,7 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
using Microsoft.Devices.Sensors;
|
||||
using Microsoft.Xna.Framework.Input;
|
||||
using Microsoft.Xna.Framework.Input.Touch;
|
||||
using WindowsPhoneSpeedyBlupi;
|
||||
@ -215,7 +216,7 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
this.sound = sound;
|
||||
this.gameData = gameData;
|
||||
pressedGlyphs = new List<Def.ButtonGlygh>();
|
||||
accelSensor = AccelerometerFactory.Create();
|
||||
accelSensor = new Accelerometer();
|
||||
accelSensor.CurrentValueChanged += HandleAccelSensorCurrentValueChanged;
|
||||
accelSlider = new Slider
|
||||
{
|
||||
@ -287,6 +288,44 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
touchesOrClicks.Add(click);
|
||||
}
|
||||
|
||||
float screenWidth = game1.getGraphics().GraphicsDevice.Viewport.Width;
|
||||
float screenHeight = game1.getGraphics().GraphicsDevice.Viewport.Height;
|
||||
float screenRatio = screenWidth / screenHeight;
|
||||
|
||||
if (Def.PLATFORM == Platform.Android &&screenRatio < 1.3333333333333333)
|
||||
{
|
||||
for (int i = 0; i < touchesOrClicks.Count; i++)
|
||||
{
|
||||
|
||||
var touchOrClick = touchesOrClicks[i];
|
||||
if (touchOrClick.X == -1) continue;
|
||||
|
||||
float originalX = touchOrClick.X;
|
||||
float originalY = touchOrClick.Y;
|
||||
|
||||
float widthHeightRatio = screenWidth / screenHeight;
|
||||
float heightRatio = 480 / screenHeight;
|
||||
float widthRatio = 640 / screenWidth;
|
||||
if(Def.DETAILED_DEBUGGING)
|
||||
{
|
||||
Debug.WriteLine("-----");
|
||||
Debug.WriteLine("originalX=" + originalX);
|
||||
Debug.WriteLine("originalY=" + originalY);
|
||||
Debug.WriteLine("heightRatio=" + heightRatio);
|
||||
Debug.WriteLine("widthRatio=" + widthRatio);
|
||||
Debug.WriteLine("widthHeightRatio=" + widthHeightRatio);
|
||||
}
|
||||
if (screenHeight> 480) {
|
||||
touchOrClick.X = (int)(originalX * heightRatio);
|
||||
touchOrClick.Y = (int)(originalY * heightRatio);
|
||||
touchesOrClicks[i] = touchOrClick;
|
||||
}
|
||||
|
||||
if(Def.DETAILED_DEBUGGING) Debug.WriteLine("new X" + touchOrClick.X);
|
||||
if(Def.DETAILED_DEBUGGING) Debug.WriteLine("new Y" + touchOrClick.Y);
|
||||
}
|
||||
}
|
||||
|
||||
KeyboardState newState = Keyboard.GetState();
|
||||
{
|
||||
if (newState.IsKeyDown(Keys.LeftControl)) touchesOrClicks.Add(createTinyPoint(-1, Misc.keyboardPressToInt(KeyboardPress.LeftControl)));
|
||||
@ -952,12 +991,13 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
}
|
||||
|
||||
|
||||
private void HandleAccelSensorCurrentValueChanged(object sender, AccelerometerEventArgs e)
|
||||
private void HandleAccelSensorCurrentValueChanged(object sender, SensorReadingEventArgs<AccelerometerReading> e)
|
||||
{
|
||||
//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)
|
||||
|
||||
float y = e.Y;
|
||||
AccelerometerReading sensorReading = e.SensorReading;
|
||||
float y = ((AccelerometerReading)(sensorReading)).Acceleration.Y;
|
||||
float num = (1f - (float)gameData.AccelSensitivity) * 0.06f + 0.04f;
|
||||
float num2 = (accelLastState ? (num * 0.6f) : num);
|
||||
if (y > num2)
|
||||
|
10
Microsoft.Devices.Sensors/Accelerometer.cs
Normal file
10
Microsoft.Devices.Sensors/Accelerometer.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using Microsoft.Devices.Sensors;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public class Accelerometer : SensorBase<AccelerometerReading>
|
||||
{
|
||||
public void Start() { }
|
||||
public void Stop() { }
|
||||
}
|
||||
}
|
@ -0,0 +1,6 @@
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public class AccelerometerFailedException : SensorFailedException
|
||||
{
|
||||
}
|
||||
}
|
12
Microsoft.Devices.Sensors/AccelerometerReading.cs
Normal file
12
Microsoft.Devices.Sensors/AccelerometerReading.cs
Normal file
@ -0,0 +1,12 @@
|
||||
using System;
|
||||
using Microsoft.Xna.Framework;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
|
||||
{
|
||||
public struct AccelerometerReading : ISensorReading
|
||||
{
|
||||
public Vector3 Acceleration { get; internal set; }
|
||||
public DateTimeOffset Timestamp { get; internal set; }
|
||||
}
|
||||
}
|
10
Microsoft.Devices.Sensors/ISensorReading.cs
Normal file
10
Microsoft.Devices.Sensors/ISensorReading.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
|
||||
{
|
||||
public interface ISensorReading
|
||||
{
|
||||
DateTimeOffset Timestamp { get; }
|
||||
}
|
||||
}
|
15
Microsoft.Devices.Sensors/SensorBase.cs
Normal file
15
Microsoft.Devices.Sensors/SensorBase.cs
Normal file
@ -0,0 +1,15 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public abstract class SensorBase<TSensorReading> : IDisposable where TSensorReading : ISensorReading
|
||||
{
|
||||
private TSensorReading currentValue;
|
||||
|
||||
public event EventHandler<SensorReadingEventArgs<TSensorReading>> CurrentValueChanged;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
}
|
||||
}
|
||||
}
|
8
Microsoft.Devices.Sensors/SensorFailedException.cs
Normal file
8
Microsoft.Devices.Sensors/SensorFailedException.cs
Normal file
@ -0,0 +1,8 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
public class SensorFailedException : Exception
|
||||
{
|
||||
}
|
||||
}
|
10
Microsoft.Devices.Sensors/SensorReadingEventArgs.cs
Normal file
10
Microsoft.Devices.Sensors/SensorReadingEventArgs.cs
Normal file
@ -0,0 +1,10 @@
|
||||
using System;
|
||||
|
||||
namespace Microsoft.Devices.Sensors
|
||||
{
|
||||
|
||||
public class SensorReadingEventArgs<T> : EventArgs where T : ISensorReading
|
||||
{
|
||||
public T SensorReading { get; set; }
|
||||
}
|
||||
}
|
3
Misc.cs
3
Misc.cs
@ -1,6 +1,7 @@
|
||||
// WindowsPhoneSpeedyBlupi, Version=1.0.0.5, Culture=neutral, PublicKeyToken=6db12cd62dbec439
|
||||
// WindowsPhoneSpeedyBlupi.Misc
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using WindowsPhoneSpeedyBlupi;
|
||||
using static WindowsPhoneSpeedyBlupi.Def;
|
||||
@ -133,7 +134,7 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
case 6: return KeyboardPress.Space;
|
||||
case 7: return KeyboardPress.Escape;
|
||||
case 8: return KeyboardPress.Pause;
|
||||
default: throw new Exception("Unsupported number for KeyboardPress: " + i);
|
||||
default: Debug.WriteLine("Unsupported number for KeyboardPress: " + i); return KeyboardPress.None;
|
||||
}
|
||||
}
|
||||
public static int keyboardPressToInt(KeyboardPress kp)
|
||||
|
42
Pixmap.cs
42
Pixmap.cs
@ -1,6 +1,7 @@
|
||||
// WindowsPhoneSpeedyBlupi, Version=1.0.0.5, Culture=neutral, PublicKeyToken=6db12cd62dbec439
|
||||
// WindowsPhoneSpeedyBlupi.Pixmap
|
||||
using System;
|
||||
using System.Diagnostics;
|
||||
using Microsoft.Xna.Framework;
|
||||
using Microsoft.Xna.Framework.Graphics;
|
||||
using WindowsPhoneSpeedyBlupi;
|
||||
@ -63,20 +64,23 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
get
|
||||
{
|
||||
TinyRect result = default(TinyRect);
|
||||
double num = graphics.GraphicsDevice.Viewport.Width;
|
||||
double num2 = graphics.GraphicsDevice.Viewport.Height;
|
||||
if (num != 0.0 && num2 != 0.0)
|
||||
double screenWidth = graphics.GraphicsDevice.Viewport.Width;
|
||||
double screenHeight = graphics.GraphicsDevice.Viewport.Height;
|
||||
if(Def.PLATFORM == Def.Platform.Android && screenHeight > 480) {
|
||||
screenWidth = screenHeight * (640f / 480f);
|
||||
}
|
||||
if (screenWidth != 0.0 && screenHeight != 0.0)
|
||||
{
|
||||
double num3;
|
||||
double num4;
|
||||
if (num / num2 < 1.3333333333333333)
|
||||
if (screenWidth / screenHeight < 1.3333333333333333)
|
||||
{
|
||||
num3 = 640.0;
|
||||
num4 = 640.0 * (num2 / num);
|
||||
num4 = 640.0 * (screenHeight / screenWidth);
|
||||
}
|
||||
else
|
||||
{
|
||||
num3 = 480.0 * (num / num2);
|
||||
num3 = 480.0 * (screenWidth / screenHeight);
|
||||
num4 = 480.0;
|
||||
}
|
||||
result.Left = 0;
|
||||
@ -242,13 +246,17 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
|
||||
private void UpdateGeometry()
|
||||
{
|
||||
double num = graphics.GraphicsDevice.Viewport.Width;
|
||||
double num2 = graphics.GraphicsDevice.Viewport.Height;
|
||||
double val = num / 640.0;
|
||||
double val2 = num2 / 480.0;
|
||||
double screenWidth = graphics.GraphicsDevice.Viewport.Width;
|
||||
double screenHeight = graphics.GraphicsDevice.Viewport.Height;
|
||||
if (Def.PLATFORM == Def.Platform.Android && screenHeight > 480)
|
||||
{
|
||||
screenWidth = screenHeight * (640f / 480f);
|
||||
}
|
||||
double val = screenWidth / 640.0;
|
||||
double val2 = screenHeight / 480.0;
|
||||
zoom = Math.Min(val, val2);
|
||||
originX = (num - 640.0 * zoom) / 2.0;
|
||||
originY = (num2 - 480.0 * zoom) / 2.0;
|
||||
originX = (screenWidth - 640.0 * zoom) / 2.0;
|
||||
originY = (screenHeight - 480.0 * zoom) / 2.0;
|
||||
}
|
||||
|
||||
public void BackgroundCache(string name)
|
||||
@ -269,11 +277,15 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
|
||||
public void DrawBackground()
|
||||
{
|
||||
double num = graphics.GraphicsDevice.Viewport.Width;
|
||||
double num2 = graphics.GraphicsDevice.Viewport.Height;
|
||||
double screenWidth = graphics.GraphicsDevice.Viewport.Width;
|
||||
double screenHeight = graphics.GraphicsDevice.Viewport.Height;
|
||||
if (Def.PLATFORM == Def.Platform.Android && screenHeight > 480)
|
||||
{
|
||||
screenWidth = screenHeight * (640f / 480f);
|
||||
}
|
||||
Texture2D bitmap = GetBitmap(3);
|
||||
Rectangle srcRectangle = GetSrcRectangle(bitmap, 10, 10, 10, 10, 0, 0);
|
||||
Rectangle destinationRectangle = new Rectangle(0, 0, (int)num, (int)num2);
|
||||
Rectangle destinationRectangle = new Rectangle(0, 0, (int)screenWidth, (int)screenHeight);
|
||||
spriteBatch.Begin(SpriteSortMode.BackToFront, BlendState.AlphaBlend);
|
||||
spriteBatch.Draw(bitmap, destinationRectangle, srcRectangle, Color.White);
|
||||
spriteBatch.End();
|
||||
|
@ -42,16 +42,17 @@ namespace WindowsPhoneSpeedyBlupi
|
||||
text = streamReader.ReadToEnd();
|
||||
stream.Close();
|
||||
}
|
||||
catch
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Write(e.Message);
|
||||
Debug.Write("Fatal error. Loading world failed: " + worldFilename + "\n");
|
||||
Environment.Exit(1);
|
||||
//Environment.Exit(1);
|
||||
}
|
||||
if (text == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
return text.Split('\n');
|
||||
return text.Split("\n");
|
||||
}
|
||||
|
||||
private static string GetWorldFilename(int gamer, int rank)
|
||||
|
Loading…
x
Reference in New Issue
Block a user