public static void ApplySpecies(MAP map) { switch (map.ResourceIndex) { case 8: for (int i = 0; i < map.Supp.Count; i++) { Moveset mset = map.SuppMsets[i]; Model mdl = map.Supp[i]; /*if (map.JustLoaded && mdl.ResourceIndex == 14) //TT08-mdl-Bird * { * mset.PlayingIndex = 0; * mset.FrameStep = 1.5f; * } * if (map.JustLoaded && mdl.ResourceIndex == 17 ) //TT08-mdl-Trees * { * mset.PlayingIndex = 0; * mset.FrameStep = 1f; * }*/ if (mdl.ResourceIndex == 13 /*.Name == "TT08-mdl-Bells"*/ && mset != null) { float newRot = 1.05f - ((DateTime.Now.Minute) / 60f) * (MainGame.PI * 2f); if (Math.Abs(mset.Skeleton.Bones[2].RotateZ - newRot) > 0.01) { if (!map.JustLoaded) { mset.PlayingIndex = 0; } mset.Skeleton.Bones[2].RotateZ = newRot; } newRot = -1.05f - (DateTime.Now.Minute / 15) * (MainGame.PI * 2f); if (Math.Abs(mset.Skeleton.Bones[1].RotateZ - newRot) > 0.01) { if (!map.JustLoaded) { mset.PlayingIndex = 1; } mset.Skeleton.Bones[1].RotateZ = newRot; } } if (mdl.ResourceIndex == 16 /*.Name=="TT08-mdl-Tram"*/) { /*if (map.JustLoaded) * Audio.Play(@"Content\Effects\Audio\Sounds\Shared\tramMotor.wav", true, mdl, 0);*/ if (mset.FrameStep > 0.05f) { mset.FrameStep = 0f; } if (!map.JustLoaded) { if (mset.FrameStep < 0.01f) { if (mdl.DestOpacity > 0.9999f) { Audio.Play(@"Content\Effects\Audio\Sounds\Shared\tramBrake.wav", false, mdl, 50); mdl.DestOpacity = 0.9999f; } } else { mdl.DestOpacity = 1f; } int ind = Audio.names.IndexOf(@"Content\Effects\Audio\Sounds\Shared\tramMotor.wav"); if (ind > -1) { Audio.effectInstances[ind].Volume += (mset.FrameStep - Audio.effectInstances[ind].Volume) / 5f; } } } if (mdl.ResourceIndex == 11 /*.Name=="TT08-Clock"*/) { /*try * { * string[] file = System.IO.File.ReadAllLines("fog.txt");*/ float newRot = -1.05f - ((DateTime.Now.Hour % 12) / 12f) * (MainGame.PI * 2f); if (Math.Abs(mdl.Skeleton.Bones[2].RotateZ - newRot) > 0.01) { if (!map.JustLoaded) { Audio.Play(@"Content\Effects\Audio\Sounds\Shared\tick.wav", false, mdl, 50); } mdl.Skeleton.Bones[2].RotateZ = newRot; } Matrix m = Matrix.CreateRotationZ(mdl.Skeleton.Bones[2].RotateZ) * Matrix.CreateTranslation(mdl.Skeleton.Bones[2].localMatrix.Translation); mdl.Skeleton.Bones[2].localMatrix = m; // newRot = 1.05f - ((DateTime.Now.Minute) / 60f) * (MainGame.PI * 2f); if (Math.Abs(mdl.Skeleton.Bones[3].RotateZ - newRot) > 0.01) { if (!map.JustLoaded) { Audio.Play(@"Content\Effects\Audio\Sounds\Shared\tick.wav", false, mdl, 50); } mdl.Skeleton.Bones[3].RotateZ = newRot; } m = Matrix.CreateRotationZ(mdl.Skeleton.Bones[3].RotateZ) * Matrix.CreateTranslation(mdl.Skeleton.Bones[3].localMatrix.Translation); mdl.Skeleton.Bones[3].localMatrix = m; m = Matrix.CreateRotationZ(mdl.Skeleton.Bones[1].RotateZ += 0.001f) * Matrix.CreateTranslation(mdl.Skeleton.Bones[1].localMatrix.Translation); mdl.Skeleton.Bones[1].localMatrix = m; m = Matrix.CreateRotationZ(mdl.Skeleton.Bones[5].RotateZ += 0.01f) * Matrix.CreateTranslation(mdl.Skeleton.Bones[5].localMatrix.Translation); mdl.Skeleton.Bones[5].localMatrix = m; m = Matrix.CreateRotationZ(mdl.Skeleton.Bones[4].RotateZ -= 0.001f) * Matrix.CreateTranslation(mdl.Skeleton.Bones[4].localMatrix.Translation); mdl.Skeleton.Bones[4].localMatrix = m; m = Matrix.CreateRotationZ(mdl.Skeleton.Bones[6].RotateZ -= 0.01f) * Matrix.CreateTranslation(mdl.Skeleton.Bones[6].localMatrix.Translation); mdl.Skeleton.Bones[6].localMatrix = m; Skeleton.Wrap(mdl.Skeleton); mdl.RecreateVertexBuffer(true); /*} * catch * { * * }*/ } } break; } }
public void SetMap(string name, bool bufferOnly, bool thread) { if (!thread && !bufferOnly && this.MapSet) { this.Map.Render = false; } if (WaitMap) { WaitMap = false; Spawn.Load(@"Content\Scenes\Spawn\twilight_town_test.spawn"); Loading = LoadingState.NotLoading; } else { int index = BufferedMaps.IndexOf(name); map = null; if (index < 0) { if (thread) { WaitMap = true; new System.Threading.Thread(() => { map = new MAP(name); map.Parse(); ResourceFiles.Insert(0, map); BufferedMaps.Add(name); Maps.Add(map); while (Transition[0] > 0) { } SetMap("", bufferOnly, false); }).Start(); return; } else { map = new MAP(name); for (int i = 0; i < 10; i++) { string plus = @"\texture"; if (i > 0) { plus = @"\texture" + i.ToString(); } if (File.Exists(Path.GetDirectoryName(name) + plus + ".zip") && !File.Exists(Path.GetDirectoryName(name) + plus)) { DecompressFileLZMA(Path.GetDirectoryName(name) + plus + ".zip", Path.GetDirectoryName(name) + plus); } } map.Parse(); ResourceFiles.Insert(0, map); BufferedMaps.Add(name); Maps.Add(map); } } else { map = Maps[index]; } } if (!bufferOnly) { if (Action.thread != null) { Action.thread.Abort(); Action.thread = null; } Action.thread = new System.Threading.Thread(() => { while (true) { if (Action.oldTick != Program.game.ticks && (Loading == LoadingState.NotLoading || Loading_Type != LoadingType.Block)) { int count = Action.aAccount * 1; if (count > 0) { Action.aAccount = -1; for (int i = 0; i < count; i++) { Action.ac[i].Verify(); } Action.aAccount = 0; } count = Action.bAccount * 1; if (count > 0) { Action.bAccount = -1; for (int i = 0; i < count; i++) { Action.be[i].Verify(); } Action.bAccount = 0; } Action.oldTick = Program.game.ticks; } } }); Action.aAccount = 0; Action.bAccount = 0; Action.ac = null; Action.be = null; Action.thread.Start(); if (map != null) { alphaTest.FogEnabled = map.FogStart > 0 || map.FogEnd > 0; alphaTest.FogStart = map.FogStart; alphaTest.FogEnd = map.FogEnd; alphaTest.FogColor = map.FogColor; map.Render = true; map.JustLoaded = true; if (File.Exists(@"Content\Effects\Audio\BGM\" + map.Name + ".wav")) { Audio.NextBGM = @"Content\Effects\Audio\BGM\" + map.Name + ".wav"; } } this.Map = map; } graphics.GraphicsDevice.SamplerStates[0] = MainGame.DefaultSmaplerState; graphics.GraphicsDevice.BlendState = BlendState.NonPremultiplied; }