public Game() { one = 1; map = new Map(); performanceinfo = new DictionaryStringString(); AudioEnabled = true; AutoJumpEnabled = false; playerPositionSpawnX = 15 + one / 2; playerPositionSpawnY = 64; playerPositionSpawnZ = 15 + one / 2; TextureId = new int[MaxBlockTypes][]; for (int i = 0; i < MaxBlockTypes; i++) { TextureId[i] = new int[6]; } TextureIdForInventory = new int[MaxBlockTypes]; language = new Language(); lastplacedblockX = -1; lastplacedblockY = -1; lastplacedblockZ = -1; mLightLevels = new float[16]; sunlight_ = 15; mvMatrix = new StackMatrix4(); pMatrix = new StackMatrix4(); mvMatrix.Push(Mat4.Create()); pMatrix.Push(Mat4.Create()); whitetexture = -1; cachedTextTexturesMax = 1024; cachedTextTextures = new CachedTextTexture[cachedTextTexturesMax]; for (int i = 0; i < cachedTextTexturesMax; i++) { cachedTextTextures[i] = null; } packetLen = new IntRef(); ENABLE_DRAW2D = true; AllowFreemove = true; enableCameraControl = true; textures = new DictionaryStringInt1024(); ServerInfo = new ServerInformation(); menustate = new MenuState(); mouseleftclick = false; mouseleftdeclick = false; wasmouseleft = false; mouserightclick = false; mouserightdeclick = false; wasmouseright = false; ENABLE_LAG = 0; znear = one / 10; CameraMatrix = new GetCameraMatrix(); ENABLE_ZFAR = true; TotalAmmo = new int[GlobalVar.MAX_BLOCKTYPES]; LoadedAmmo = new int[GlobalVar.MAX_BLOCKTYPES]; AllowedFontsCount = 1; AllowedFonts = new string[AllowedFontsCount]; AllowedFonts[0] = "Verdana"; fov = Game.GetPi() / 3; cameratype = CameraType.Fpp; ENABLE_TPP_VIEW = false; basemovespeed = 5; movespeed = 5; RadiusWhenMoving = one * 3 / 10; playervelocity = new Vector3Ref(); LocalPlayerId = -1; dialogs = new VisibleDialog[512]; dialogsCount = 512; blockHealth = new DictionaryVector3Float(); playertexturedefault = -1; a = new AnimationState(); constRotationSpeed = one * 180 / 20; modmanager = new ClientModManager1(); particleEffectBlockBreak = new ModDrawParticleEffectBlockBreak(); PICK_DISTANCE = 4.1f; selectedmodelid = -1; grenadetime = 3; rotationspeed = one * 15 / 100; entities = new Entity[entitiesMax]; for (int i = 0; i < entitiesMax; i++) { entities[i] = null; } entitiesCount = 512; PlayerPushDistance = 2; const int KeysMax = 256; keyboardState = new bool[KeysMax]; for (int i = 0; i < KeysMax; i++) { keyboardState[i] = false; } keyboardStateRaw = new bool[KeysMax]; for (int i = 0; i < KeysMax; i++) { keyboardStateRaw[i] = false; } overheadcameradistance = 10; tppcameradistance = 3; TPP_CAMERA_DISTANCE_MIN = 1; TPP_CAMERA_DISTANCE_MAX = 10; options = new OptionsCi(); overheadcameraK = new Kamera(); fillAreaLimit = 200; speculativeCount = 0; speculative = new Speculative[speculativeMax]; typinglog = new string[1024 * 16]; typinglogCount = 0; NewBlockTypes = new Packet_BlockType[GlobalVar.MAX_BLOCKTYPES]; localplayeranim = new AnimationState(); localplayeranimationhint = new AnimationHint(); enable_move = true; handTexture = -1; modelViewInverted = new float[16]; GLScaleTempVec3 = Vec3.Create(); GLRotateTempVec3 = Vec3.Create(); GLTranslateTempVec3 = Vec3.Create(); identityMatrix = Mat4.Identity_(Mat4.Create()); Set3dProjectionTempMat4 = Mat4.Create(); getAsset = new string[1024 * 2]; PlayerStats = new Packet_ServerPlayerStats(); mLightLevels = new float[16]; for (int i = 0; i < 16; i++) { mLightLevels[i] = one * i / 15; } soundnow = new BoolRef(); camera = Mat4.Create(); packetHandlers = new ClientPacketHandler[256]; player = new Entity(); player.position = new EntityPosition_(); currentlyAttackedEntity = -1; ChatLinesMax = 1; ChatLines = new Chatline[ChatLinesMax]; ChatLineLength = 64; audio = new AudioControl(); CameraEyeX = -1; CameraEyeY = -1; CameraEyeZ = -1; controls = new Controls(); movedz = 0; taskScheduler = new TaskScheduler(); commitActions = ListAction.Create(16 * 1024); constWallDistance = 0.3f; mouseSmoothing = true; }
private AnimationScenario PlayExpandAnimation(ViewStatus viewStatus, ColumnViewModel columnViewModel) { AnimationHint hint = null;// stashedViewStatus.AnimationHint; IEnumerable <RowViewModel> previousRowViewModels = (stashedViewStatus.TableViewState == TableViewState.AllRow) ? SheetViewModel.AllRowViewModels : stashedViewStatus.GroupedRowViewModels; IEnumerable <RowViewModel> currentRowViewModels = viewStatus.IsAllRowViewModelVisible ? SheetViewModel.AllRowViewModels : viewStatus.GroupedRowViewModels; Double beforeX = hint.ColumnViewModelPosition[columnViewModel]; Double afterX = columnViewModel.X; Int32 index = 0; Storyboard storyboard = new Storyboard(); Double horizontalAnimationDuration = 0; Canvas canvas = view.TableView.AnimatingRowCanvas; canvas.Children.Clear(); RowViewModel rootGroupedRowViewModel = stashedViewStatus.GroupedRowViewModels[0]; Int32 rootIndex = 0; IEnumerable <Row> rows = rootGroupedRowViewModel.Rows; IEnumerable <RowViewModel> expandingRowViewModels = currentRowViewModels .Where(rvm => (rvm.Row == null ? rows.Intersect(rvm.Rows).Count() > 0 : rows.Contains(rvm.Row)) && rvm.Y < mainPageViewModel.Bounds.Height) .OrderBy(rvm => rvm.Y) .Take(50); if (expandingRowViewModels.Count() < 5) { index = 0; foreach (GroupedRows groupedRows in stashedViewStatus.GroupedRows) { IEnumerable <RowViewModel> candidate = currentRowViewModels .Where(rvm => (rvm.Row == null ? groupedRows.Rows.Intersect(rvm.Rows).Count() > 0 : groupedRows.Rows.Contains(rvm.Row)) && rvm.Y < mainPageViewModel.Bounds.Height) .OrderBy(rvm => rvm.Y) .Take(50); if (candidate.Count() >= 5) { rootGroupedRowViewModel = stashedViewStatus.GroupedRowViewModels[index]; rows = groupedRows.Rows; expandingRowViewModels = candidate; rootIndex = index; break; } index++; } } viewStatus.ColorRowViewModels(allRowViewModels, viewStatus.GroupedRowViewModels, viewStatus.GroupedRows); if (viewStatus.IsAllRowViewModelVisible) { // root { AnimatingRowViewModel arvm = new AnimatingRowViewModel() { RowViewModel = rootGroupedRowViewModel, X = beforeX, ColumnViewModel = columnViewModel }; AnimatingRowPresenter arp = new AnimatingRowPresenter() { AnimatingRowViewModel = arvm }; arp.Opacity = 1; arp.Update(); canvas.Children.Add(arp); Canvas.SetTop(arp, rootGroupedRowViewModel.StashedY); arp.CellPresenter.Foreground = new SolidColorBrush(rootGroupedRowViewModel.Color); storyboard.Children.Add(Util.Animator.Generate(arp, "Opacity", 0, UnitAnimationDuration, DelayBeforeAnimation)); } index = 0; foreach (RowViewModel rvm in expandingRowViewModels) { AnimatingRowViewModel arvm = new AnimatingRowViewModel() { RowViewModel = rvm, X = beforeX, ColumnViewModel = columnViewModel }; AnimatingRowPresenter arp = new AnimatingRowPresenter() { AnimatingRowViewModel = arvm }; arp.Opacity = 0; arp.Update(); canvas.Children.Add(arp); Canvas.SetTop(arp, rootGroupedRowViewModel.StashedY); arp.CellPresenter.Foreground = new SolidColorBrush(rootGroupedRowViewModel.Color); storyboard.Children.Add(Util.Animator.Generate(arp, "(Canvas.Top)", rvm.Y, UnitAnimationDuration, DelayBeforeAnimation)); storyboard.Children.Add(Util.Animator.Generate(arp, "Opacity", 1, UnitAnimationDuration, DelayBeforeAnimation)); storyboard.Children.Add( Util.Animator.GenerateColorAnimation(arp.CellPresenter, "(TextBlock.Foreground).(SolidColorBrush.Color)", rvm.Color, UnitAnimationDuration, DelayBeforeAnimation) ); if (beforeX != afterX) { storyboard.Children.Add(Util.Animator.Generate(arp.CellPresenter, "(Canvas.Left)", afterX, UnitAnimationDuration, DelayBeforeAnimation + UnitAnimationDuration)); horizontalAnimationDuration = UnitAnimationDuration; } index++; } } else // grouped row visible { } stashedViewStatus = null; return(new AnimationScenario() { TotalAnimationDuration = DelayBeforeAnimation + UnitAnimationDuration + horizontalAnimationDuration, TableHeaderUpdateTime = DelayBeforeAnimation + UnitAnimationDuration, AnimationStoryboard = storyboard }); }
public void DrawCharacter(AnimationState animstate, Vector3 pos, byte heading, byte pitch, bool moves, float dt, int playertexture, AnimationHint animationhint) { if (animationhint.InVehicle) { moves = false; } pos += animationhint.DrawFix; if (animstate.data == null) { Dictionary <string, object> d = new Dictionary <string, object>(); animstate.data = d; } var variables = (Dictionary <string, object>)animstate.data; if (moves) { animstate.interp += dt; animstate.slowdownTimer = float.MaxValue; } else { if (animstate.slowdownTimer == float.MaxValue) { animstate.slowdownTimer = (float)(animperiod / 2 - (animstate.interp % (animperiod / 2))); } animstate.slowdownTimer -= dt; if (animstate.slowdownTimer < 0) { animstate.interp = 0; } else { animstate.interp += dt; } } GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.Translate(pos); variables["heading"] = (double)heading; variables["pitch"] = (double)pitch; variables["headingdeg"] = ((double)heading / 256) * 360; variables["pitchdeg"] = ((double)pitch / 256) * 360; variables["updown"] = (double)UpDown(animstate.interp, (float)animperiod); variables["limbrotation1"] = (double)LeftLegRotation(animstate.interp, (float)animperiod); variables["limbrotation2"] = (double)RightLegRotation(animstate.interp, (float)animperiod); variables["skin"] = (double)playertexture; variables["dt"] = (double)dt; variables["time"] = (double)animstate.interp; variables["anim"] = (double)currentanim; string[] animations = Animations(); for (int i = 0; i < animations.Length; i++) { variables[animations[i]] = (double)i; } int skinsizex = 64; int skinsizey = 32; int pc = 0; for (; ;) { if (pc >= code.Count) { break; } object[] ss = code[pc]; if (ss.Length > 0) { switch ((string)ss[0]) { case "set": { variables[(string)ss[1]] = getval(ss[2], variables); } break; case "pushmatrix": { GL.PushMatrix(); } break; case "popmatrix": { GL.PopMatrix(); } break; case "mul": { variables[(string)ss[1]] = (double)variables[(string)ss[1]] * getval(ss[2], variables); } break; case "add": { variables[(string)ss[1]] = (double)variables[(string)ss[1]] + getval(ss[2], variables); } break; case "rotate": { GL.Rotate( getval(ss[1], variables), getval(ss[2], variables), getval(ss[3], variables), getval(ss[4], variables)); } break; case "translate": { GL.Translate( getval(ss[1], variables), getval(ss[2], variables), getval(ss[3], variables)); } break; case "scale": { GL.Scale( getval(ss[1], variables), getval(ss[2], variables), getval(ss[3], variables)); } break; case "makecoords": { RectangleF[] coords = CuboidNet( (float)getval(ss[2], variables), (float)getval(ss[3], variables), (float)getval(ss[4], variables), (float)getval(ss[5], variables), (float)getval(ss[6], variables)); CuboidNetNormalize(coords, skinsizex, skinsizey); variables[(string)ss[1]] = coords; } break; case "drawcuboid": { DrawCuboid( new Vector3((float)getval(ss[1], variables), (float)getval(ss[2], variables), (float)getval(ss[3], variables)), new Vector3((float)getval(ss[4], variables), (float)getval(ss[5], variables), (float)getval(ss[6], variables)), (int)getval(ss[7], variables), (RectangleF[])variables[(string)ss[8]] ); } break; case "skinsize": { skinsizex = (int)getval(ss[1], variables); skinsizey = (int)getval(ss[2], variables); } break; case "dim": { if (!variables.ContainsKey((string)ss[1])) { variables[(string)ss[1]] = getval(ss[2], variables); } } break; case "fun": { if ((string)ss[2] == "tri") { variables[(string)ss[1]] = (double)TriWave(getval(ss[3], variables)); } if ((string)ss[2] == "sin") { variables[(string)ss[1]] = (double)Math.Sin(getval(ss[3], variables)); } if ((string)ss[2] == "abs") { variables[(string)ss[1]] = (double)Math.Abs(getval(ss[3], variables)); } } break; case "ifeq": { if (variables.ContainsKey((string)ss[1]) && (double)variables[(string)ss[1]] != getval(ss[2], variables)) { //find endif for (int i = pc; i < code.Count; i++) { if ((string)(code[i][0]) == "endif") { pc = i; goto next; } } } } break; } } pc++; next: ; } GL.PopMatrix(); }
public PlayerDrawInfo() { anim = new AnimationState(); AnimationHint_ = new AnimationHint(); }
public Player() { AnimationHint_ = new AnimationHint(); Model_ = "player.txt"; EyeHeight = DefaultEyeHeight(); ModelHeight = DefaultModelHeight(); CurrentTexture = -1; }
public void DrawCharacter(AnimationState animstate, Vector3 pos, byte heading, byte pitch, bool moves, float dt, int playertexture, AnimationHint animationhint) { if (animationhint.InVehicle) { moves = false; } pos += animationhint.DrawFix; if (animstate.data == null) { Dictionary<string, object> d = new Dictionary<string, object>(); animstate.data = d; } var variables = (Dictionary<string, object>)animstate.data; if (moves) { animstate.interp += dt; animstate.slowdownTimer = float.MaxValue; } else { if (animstate.slowdownTimer == float.MaxValue) { animstate.slowdownTimer = (float)(animperiod / 2 - (animstate.interp % (animperiod / 2))); } animstate.slowdownTimer -= dt; if (animstate.slowdownTimer < 0) { animstate.interp = 0; } else { animstate.interp += dt; } } GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.Translate(pos); variables["heading"] = (double)heading; variables["pitch"] = (double)pitch; variables["headingdeg"] = ((double)heading / 256) * 360; variables["pitchdeg"] = ((double)pitch / 256) * 360; variables["updown"] = (double)UpDown(animstate.interp, (float)animperiod); variables["limbrotation1"] = (double)LeftLegRotation(animstate.interp, (float)animperiod); variables["limbrotation2"] = (double)RightLegRotation(animstate.interp, (float)animperiod); variables["skin"] = (double)playertexture; variables["dt"] = (double)dt; variables["time"] = (double)animstate.interp; variables["anim"] = (double)currentanim; string[] animations = Animations(); for (int i = 0; i < animations.Length; i++) { variables[animations[i]] = (double)i; } int skinsizex = 64; int skinsizey = 32; int pc = 0; for (; ; ) { if (pc >= code.Count) { break; } object[] ss = code[pc]; if (ss.Length > 0) { switch ((string)ss[0]) { case "set": { variables[(string)ss[1]] = getval(ss[2], variables); } break; case "pushmatrix": { GL.PushMatrix(); } break; case "popmatrix": { GL.PopMatrix(); } break; case "mul": { variables[(string)ss[1]] = (double)variables[(string)ss[1]] * getval(ss[2], variables); } break; case "add": { variables[(string)ss[1]] = (double)variables[(string)ss[1]] + getval(ss[2], variables); } break; case "rotate": { GL.Rotate( getval(ss[1], variables), getval(ss[2], variables), getval(ss[3], variables), getval(ss[4], variables)); } break; case "translate": { GL.Translate( getval(ss[1], variables), getval(ss[2], variables), getval(ss[3], variables)); } break; case "scale": { GL.Scale( getval(ss[1], variables), getval(ss[2], variables), getval(ss[3], variables)); } break; case "makecoords": { RectangleF[] coords = CuboidNet( (float)getval(ss[2], variables), (float)getval(ss[3], variables), (float)getval(ss[4], variables), (float)getval(ss[5], variables), (float)getval(ss[6], variables)); CuboidNetNormalize(coords, skinsizex, skinsizey); variables[(string)ss[1]] = coords; } break; case "drawcuboid": { DrawCuboid( new Vector3((float)getval(ss[1], variables), (float)getval(ss[2], variables), (float)getval(ss[3], variables)), new Vector3((float)getval(ss[4], variables), (float)getval(ss[5], variables), (float)getval(ss[6], variables)), (int)getval(ss[7], variables), (RectangleF[])variables[(string)ss[8]] ); } break; case "skinsize": { skinsizex = (int)getval(ss[1], variables); skinsizey = (int)getval(ss[2], variables); } break; case "dim": { if (!variables.ContainsKey((string)ss[1])) { variables[(string)ss[1]] = getval(ss[2], variables); } } break; case "fun": { if ((string)ss[2] == "tri") { variables[(string)ss[1]] = (double)TriWave(getval(ss[3], variables)); } if ((string)ss[2] == "sin") { variables[(string)ss[1]] = (double)Math.Sin(getval(ss[3], variables)); } if ((string)ss[2] == "abs") { variables[(string)ss[1]] = (double)Math.Abs(getval(ss[3], variables)); } } break; case "ifeq": { if (variables.ContainsKey((string)ss[1]) && (double)variables[(string)ss[1]] != getval(ss[2], variables)) { //find endif for (int i = pc; i < code.Count; i++) { if ((string)(code[i][0]) == "endif") { pc = i; goto next; } } } } break; } } pc++; next: ; } GL.PopMatrix(); }
internal void DrawPlayers(Game game, float dt) { game.totaltimeMilliseconds = game.platform.TimeMillisecondsFromStart(); for (int i = 0; i < game.entitiesCount; i++) { if (game.entities[i] == null) { continue; } if (game.entities[i].drawModel == null) { continue; } Entity p_ = game.entities[i]; if (i == game.LocalPlayerId && (!game.ENABLE_TPP_VIEW)) { continue; } if ((p_.networkPosition != null) && (!p_.networkPosition.PositionLoaded)) { continue; } if (!game.d_FrustumCulling.SphereInFrustum(p_.position.x, p_.position.y, p_.position.z, 3)) { continue; } if (p_.drawModel.CurrentTexture == -1) { continue; } int cx = game.platform.FloatToInt(p_.position.x) / Game.chunksize; int cy = game.platform.FloatToInt(p_.position.z) / Game.chunksize; int cz = game.platform.FloatToInt(p_.position.y) / Game.chunksize; if (game.map.IsValidChunkPos(cx, cy, cz)) { if (!game.map.IsChunkRendered(cx, cy, cz)) { continue; } } float shadow = (one * game.GetLight(game.platform.FloatToInt(p_.position.x), game.platform.FloatToInt(p_.position.z), game.platform.FloatToInt(p_.position.y))) / Game.maxlight; if (p_.playerDrawInfo == null) { p_.playerDrawInfo = new PlayerDrawInfo(); } p_.playerDrawInfo.anim.light = shadow; float FeetPosX = p_.position.x; float FeetPosY = p_.position.y; float FeetPosZ = p_.position.z; AnimationHint animHint = game.entities[i].playerDrawInfo.AnimationHint_; float playerspeed_; if (i == game.LocalPlayerId) { if (game.player.playerDrawInfo == null) { game.player.playerDrawInfo = new PlayerDrawInfo(); } Vector3Ref playerspeed = Vector3Ref.Create(game.playervelocity.X / 60, game.playervelocity.Y / 60, game.playervelocity.Z / 60); float playerspeedf = playerspeed.Length() * (one * 15 / 10); game.player.playerDrawInfo.moves = playerspeedf != 0; playerspeed_ = playerspeedf; } else { playerspeed_ = (game.Length(p_.playerDrawInfo.velocityX, p_.playerDrawInfo.velocityY, p_.playerDrawInfo.velocityZ) / dt) * (one * 4 / 100); } { if (p_.drawModel.renderer == null) { p_.drawModel.renderer = new AnimatedModelRenderer(); byte[] data = game.GetFile(p_.drawModel.Model_); int dataLength = game.GetFileLength(p_.drawModel.Model_); if (data != null) { string dataString = game.platform.StringFromUtf8ByteArray(data, dataLength); AnimatedModel model = AnimatedModelSerializer.Deserialize(game.platform, dataString); p_.drawModel.renderer.Start(game, model); } } game.GLPushMatrix(); game.GLTranslate(FeetPosX, FeetPosY, FeetPosZ); //game.GLRotate(PlayerInterpolate.RadToDeg(p_.position.rotx), 1, 0, 0); game.GLRotate(PlayerInterpolate.RadToDeg(-p_.position.roty + Game.GetPi()), 0, 1, 0); //game.GLRotate(PlayerInterpolate.RadToDeg(p_.position.rotz), 0, 0, 1); game.platform.BindTexture2d(game.entities[i].drawModel.CurrentTexture); p_.drawModel.renderer.Render(dt, PlayerInterpolate.RadToDeg(p_.position.rotx + Game.GetPi()), true, p_.playerDrawInfo.moves, shadow); game.GLPopMatrix(); } } }