static int VersionToInt(GamePlatform platform, string version) { int max = 1000 * 1000 * 1000; if (!IsVersionDate(platform, version)) { return(max); } FloatRef year = new FloatRef(); FloatRef month = new FloatRef(); FloatRef day = new FloatRef(); if (platform.FloatTryParse(StringTools.StringSubstring(platform, version, 0, 4), year)) { if (platform.FloatTryParse(StringTools.StringSubstring(platform, version, 5, 2), month)) { if (platform.FloatTryParse(StringTools.StringSubstring(platform, version, 8, 2), day)) { int year_ = platform.FloatToInt(year.value); int month_ = platform.FloatToInt(month.value); int day_ = platform.FloatToInt(day.value); return(year_ * 10000 + month_ * 100 + day_); } } } return(max); }
float FloatParse(string s) { FloatRef ret = new FloatRef(); p.FloatTryParse(s, ret); return(ret.value); }
public static FloatRef Create(float value_) { FloatRef f = new FloatRef(); f.value = value_; return(f); }
public MainMenu() { one = 1; textures = new DictionaryStringInt1024(); textTextures = new TextTexture[256]; textTexturesCount = 0; screen = new ScreenMain(); screen.menu = this; loginClient = new LoginClientCi(); assets = new AssetList(); assetsLoadProgress = new FloatRef(); }
internal void LimitThirdPersonCameraToWalls(Game game, Vector3Ref eye, Vector3Ref target, FloatRef curtppcameradistance) { float one = 1; Vector3Ref ray_start_point = target; Vector3Ref raytarget = eye; Line3D pick = new Line3D(); float raydirX = (raytarget.X - ray_start_point.X); float raydirY = (raytarget.Y - ray_start_point.Y); float raydirZ = (raytarget.Z - ray_start_point.Z); float raydirLength1 = game.Length(raydirX, raydirY, raydirZ); raydirX /= raydirLength1; raydirY /= raydirLength1; raydirZ /= raydirLength1; raydirX = raydirX * (game.tppcameradistance + 1); raydirY = raydirY * (game.tppcameradistance + 1); raydirZ = raydirZ * (game.tppcameradistance + 1); pick.Start = Vec3.FromValues(ray_start_point.X, ray_start_point.Y, ray_start_point.Z); pick.End = new float[3]; pick.End[0] = ray_start_point.X + raydirX; pick.End[1] = ray_start_point.Y + raydirY; pick.End[2] = ray_start_point.Z + raydirZ; //pick terrain IntRef pick2Count = new IntRef(); BlockPosSide[] pick2 = game.Pick(game.s, pick, pick2Count); if (pick2Count.value > 0) { BlockPosSide pick2nearest = game.Nearest(pick2, pick2Count.value, ray_start_point.X, ray_start_point.Y, ray_start_point.Z); //pick2.Sort((a, b) => { return (FloatArrayToVector3(a.blockPos) - ray_start_point).Length.CompareTo((FloatArrayToVector3(b.blockPos) - ray_start_point).Length); }); float pickX = pick2nearest.blockPos[0] - target.X; float pickY = pick2nearest.blockPos[1] - target.Y; float pickZ = pick2nearest.blockPos[2] - target.Z; float pickdistance = game.Length(pickX, pickY, pickZ); curtppcameradistance.value = MathCi.MinFloat(pickdistance - 1, curtppcameradistance.value); if (curtppcameradistance.value < one * 3 / 10) { curtppcameradistance.value = one * 3 / 10; } } float cameraDirectionX = target.X - eye.X; float cameraDirectionY = target.Y - eye.Y; float cameraDirectionZ = target.Z - eye.Z; float raydirLength = game.Length(raydirX, raydirY, raydirZ); raydirX /= raydirLength; raydirY /= raydirLength; raydirZ /= raydirLength; eye.X = target.X + raydirX * curtppcameradistance.value; eye.Y = target.Y + raydirY * curtppcameradistance.value; eye.Z = target.Z + raydirZ * curtppcameradistance.value; }
public int GetInt(string key, int default_) { if (GetString(key, null) == null) { return(default_); } FloatRef ret = new FloatRef(); if (platform.FloatTryParse(GetString(key, null), ret)) { return(platform.FloatToInt(ret.value)); } return(default_); }
public override void OnButton(MenuWidget w) { if (w == buttonConnect) { FloatRef ret = new FloatRef(); if (!Game.StringEquals(textboxIp.text, "") && menu.p.FloatTryParse(textboxPort.text, ret)) { menu.StartLogin(null, textboxIp.text, menu.p.IntParse(textboxPort.text)); } } if (w == back) { OnBackPressed(); } }
public override void OnButton(MenuWidget w) { if (w == buttonConnect) { FloatRef ret = new FloatRef(); if (!Game.StringEquals(textboxIp.text, "") && menu.p.FloatTryParse(textboxPort.text, ret)) { menu.StartLogin(null, textboxIp.text, menu.p.IntParse(textboxPort.text)); } } if (w == back) { OnBackPressed(); } }
internal float[] OverheadCamera(Game game) { game.overheadcameraK.GetPosition(game.platform, OverheadCamera_cameraEye); Vector3Ref cameraEye = OverheadCamera_cameraEye; Vector3Ref cameraTarget = Vector3Ref.Create(game.overheadcameraK.Center.X, game.overheadcameraK.Center.Y + game.GetCharacterEyesHeight(), game.overheadcameraK.Center.Z); FloatRef currentOverheadcameradistance = FloatRef.Create(game.overheadcameradistance); LimitThirdPersonCameraToWalls(game, cameraEye, cameraTarget, currentOverheadcameradistance); float[] ret = new float[16]; Mat4.LookAt(ret, Vec3.FromValues(cameraEye.X, cameraEye.Y, cameraEye.Z), Vec3.FromValues(cameraTarget.X, cameraTarget.Y, cameraTarget.Z), upVec3); game.CameraEyeX = cameraEye.X; game.CameraEyeY = cameraEye.Y; game.CameraEyeZ = cameraEye.Z; return(ret); }
public void LoadAssetsAsync(AssetList list, FloatRef progress) { List <Asset> assets = new List <Asset>(); foreach (string path in datapaths) { try { if (!Directory.Exists(path)) { continue; } foreach (string s in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)) { try { FileInfo f = new FileInfo(s); if (f.Name.Equals("thumbs.db", StringComparison.InvariantCultureIgnoreCase)) { continue; } Asset a = new Asset(); a.data = File.ReadAllBytes(s); a.dataLength = a.data.Length; a.name = f.Name.ToLowerInvariant(); a.md5 = Md5(a.data); assets.Add(a); } catch { } } } catch { } } progress.value = 1; list.count = assets.Count; list.items = new Asset[2048]; for (int i = 0; i < assets.Count; i++) { list.items[i] = assets[i]; } }
public void LoadAssetsAsync(AssetList list, FloatRef progress) { List<Asset> assets = new List<Asset>(); foreach (string path in datapaths) { try { if (!Directory.Exists(path)) { continue; } foreach (string s in Directory.GetFiles(path, "*.*", SearchOption.AllDirectories)) { try { FileInfo f = new FileInfo(s); if (f.Name.Equals("thumbs.db", StringComparison.InvariantCultureIgnoreCase)) { continue; } Asset a = new Asset(); a.data = File.ReadAllBytes(s); a.dataLength = a.data.Length; a.name = f.Name.ToLowerInvariant(); a.md5 = Md5(a.data); assets.Add(a); } catch { } } } catch { } } progress.value = 1; list.count = assets.Count; list.items = new Asset[2048]; for (int i = 0; i < assets.Count; i++) { list.items[i] = assets[i]; } }
internal float[] FppCamera(Game game) { Vector3Ref forward = new Vector3Ref(); VectorTool.ToVectorInFixedSystem(0, 0, 1, game.player.position.rotx, game.player.position.roty, forward); Vector3Ref cameraEye = new Vector3Ref(); Vector3Ref cameraTarget = new Vector3Ref(); float playerEyeX = game.player.position.x; float playerEyeY = game.player.position.y + game.GetCharacterEyesHeight(); float playerEyeZ = game.player.position.z; if (!game.ENABLE_TPP_VIEW) { cameraEye.X = playerEyeX; cameraEye.Y = playerEyeY; cameraEye.Z = playerEyeZ; cameraTarget.X = playerEyeX + forward.X; cameraTarget.Y = playerEyeY + forward.Y; cameraTarget.Z = playerEyeZ + forward.Z; } else { cameraEye.X = playerEyeX + forward.X * -game.tppcameradistance; cameraEye.Y = playerEyeY + forward.Y * -game.tppcameradistance; cameraEye.Z = playerEyeZ + forward.Z * -game.tppcameradistance; cameraTarget.X = playerEyeX; cameraTarget.Y = playerEyeY; cameraTarget.Z = playerEyeZ; FloatRef currentTppcameradistance = FloatRef.Create(game.tppcameradistance); LimitThirdPersonCameraToWalls(game, cameraEye, cameraTarget, currentTppcameradistance); } float[] ret = new float[16]; Mat4.LookAt(ret, Vec3.FromValues(cameraEye.X, cameraEye.Y, cameraEye.Z), Vec3.FromValues(cameraTarget.X, cameraTarget.Y, cameraTarget.Z), upVec3); game.CameraEyeX = cameraEye.X; game.CameraEyeY = cameraEye.Y; game.CameraEyeZ = cameraEye.Z; return(ret); }
float FloatParse(string s) { FloatRef ret = new FloatRef(); p.FloatTryParse(s, ret); return ret.value; }
internal void LimitThirdPersonCameraToWalls(Game game, Vector3Ref eye, Vector3Ref target, FloatRef curtppcameradistance) { float one = 1; Vector3Ref ray_start_point = target; Vector3Ref raytarget = eye; Line3D pick = new Line3D(); float raydirX = (raytarget.X - ray_start_point.X); float raydirY = (raytarget.Y - ray_start_point.Y); float raydirZ = (raytarget.Z - ray_start_point.Z); float raydirLength1 = game.Length(raydirX, raydirY, raydirZ); raydirX /= raydirLength1; raydirY /= raydirLength1; raydirZ /= raydirLength1; raydirX = raydirX * (game.tppcameradistance + 1); raydirY = raydirY * (game.tppcameradistance + 1); raydirZ = raydirZ * (game.tppcameradistance + 1); pick.Start = Vec3.FromValues(ray_start_point.X, ray_start_point.Y, ray_start_point.Z); pick.End = new float[3]; pick.End[0] = ray_start_point.X + raydirX; pick.End[1] = ray_start_point.Y + raydirY; pick.End[2] = ray_start_point.Z + raydirZ; //pick terrain IntRef pick2Count = new IntRef(); BlockPosSide[] pick2 = game.Pick(game.s, pick, pick2Count); if (pick2Count.value > 0) { BlockPosSide pick2nearest = game.Nearest(pick2, pick2Count.value, ray_start_point.X, ray_start_point.Y, ray_start_point.Z); //pick2.Sort((a, b) => { return (FloatArrayToVector3(a.blockPos) - ray_start_point).Length.CompareTo((FloatArrayToVector3(b.blockPos) - ray_start_point).Length); }); float pickX = pick2nearest.blockPos[0] - target.X; float pickY = pick2nearest.blockPos[1] - target.Y; float pickZ = pick2nearest.blockPos[2] - target.Z; float pickdistance = game.Length(pickX, pickY, pickZ); curtppcameradistance.value = MathCi.MinFloat(pickdistance - 1, curtppcameradistance.value); if (curtppcameradistance.value < one * 3 / 10) { curtppcameradistance.value = one * 3 / 10; } } float cameraDirectionX = target.X - eye.X; float cameraDirectionY = target.Y - eye.Y; float cameraDirectionZ = target.Z - eye.Z; float raydirLength = game.Length(raydirX, raydirY, raydirZ); raydirX /= raydirLength; raydirY /= raydirLength; raydirZ /= raydirLength; eye.X = target.X + raydirX * curtppcameradistance.value; eye.Y = target.Y + raydirY * curtppcameradistance.value; eye.Z = target.Z + raydirZ * curtppcameradistance.value; }
public abstract void LoadAssetsAsyc(AssetList list, FloatRef progress);
public abstract bool FloatTryParse(string s, FloatRef ret);
public abstract void LoadAssetsAsyc(AssetList list, FloatRef progress);
static int VersionToInt(GamePlatform platform, string version) { int max = 1000 * 1000 * 1000; if (!IsVersionDate(platform, version)) { return max; } FloatRef year = new FloatRef(); FloatRef month = new FloatRef(); FloatRef day = new FloatRef(); if (platform.FloatTryParse(StringTools.StringSubstring(platform, version, 0, 4), year)) { if (platform.FloatTryParse(StringTools.StringSubstring(platform, version, 5, 2), month)) { if (platform.FloatTryParse(StringTools.StringSubstring(platform, version, 8, 2), day)) { int year_ = platform.FloatToInt(year.value); int month_ = platform.FloatToInt(month.value); int day_ = platform.FloatToInt(day.value); return year_ * 10000 + month_ * 100 + day_; } } } return max; }
public abstract bool FloatTryParse(string s, FloatRef ret);
public static FloatRef Create(float value_) { FloatRef f = new FloatRef(); f.value = value_; return f; }
public int GetInt(string key, int default_) { if (GetString(key, null) == null) { return default_; } FloatRef ret = new FloatRef(); if (platform.FloatTryParse(GetString(key, null), ret)) { return platform.FloatToInt(ret.value); } return default_; }
public override void LoadAssetsAsyc(AssetList list, FloatRef progress) { if (assetloader == null) { assetloader = new AssetLoader(datapaths); } assetloader.LoadAssetsAsync(list, progress); }
public override bool FloatTryParse(string s, FloatRef ret) { float f; if (float.TryParse(s, NumberStyles.Any, CultureInfo.InvariantCulture, out f)) { ret.value = f; return true; } else { return false; } }
public MainMenu() { one = 1; textures = new DictionaryStringInt1024(); textTextures = new TextTexture[256]; textTexturesCount = 0; screen = new ScreenMain(); screen.menu = this; loginClient = new LoginClientCi(); assets = new AssetList(); assetsLoadProgress = new FloatRef(); }
public TransitionFloat(T owner, ref FloatRef value1, float condition, eCompare compare = eCompare.EQUAL) : base(owner) { m_value = value1; m_condition = condition; m_compare = compare; }