public SnakeDisplay() { InitializeComponent(); SetStyle(ControlStyles.AllPaintingInWmPaint | ControlStyles.UserPaint | ControlStyles.OptimizedDoubleBuffer | ControlStyles.ResizeRedraw, true); PosibleMovements = WorldConstants.GetPosibleMovements(); SnakePanel = new BufferedPanel(); Player player = new Player("Pepe"); game = new Game(player); game.OnGameEnd += OnGameEnd; this.Size = WorldConstants.GetDisplaySize(); this.Size = new Size(this.Size.Width + 100, this.Size.Height + 100); SnakePanel.BackColor = Color.Black; SnakePanel.Size = WorldConstants.GetDisplaySize(); CentrarSnakePanel(); //SnakePanel.Size = new Size(game.Board.GetMatrix().GetLength(0) * WorldConstants.BLOCK_SIZE.X, game.Board.GetMatrix().GetLength(1) * WorldConstants.BLOCK_SIZE.Y); //SnakePanel.Dock = DockStyle. //SnakePanel.Anchor = AnchorStyles.None; SnakePanel.Paint += DrawGame; Controls.Add(SnakePanel); }
/*************************************************************************** * CreateCatmullStrip * Creates a Catmull strip (one quad in width) mesh. * @param controlPoints, the control points of the Catmull-Rom Spline. * @param density, the mesh density measured in in game distance. ***************************************************************************/ public void CreateCatmullCurve(List <Vector3> controlPoints, float density) { mControlPoints = controlPoints; if (!InitMeshFilterAndRenderer()) { return; } int numPoints = controlPoints.Count; if (numPoints < 4) { // A Catmull-Rom Spline needs at least 4 control points. Debug.LogError("Too few control points!"); return; } List <Vector3> verts = new List <Vector3>(); Vector3 cp0, cp1, cp2, cp3; // The width of the curve in number of verts. float curveWidthOffsetLen = 0.5f; int curveVertsWidth = (int)(mStripWidth / curveWidthOffsetLen); // Go through all the control points and build the curve along them. for (int cpIdx = 1; cpIdx < numPoints - 2; ++cpIdx) { // Go through the time between each control point. for (float time = 0.0f; time <= 1.0f; time += 0.05f) { // Build the strip by plotting the curve and a curve with a bi-normal offset to it. cp0 = controlPoints[(cpIdx + (numPoints - 1)) % numPoints]; cp1 = controlPoints[(cpIdx) % numPoints]; cp2 = controlPoints[(cpIdx + 1) % numPoints]; cp3 = controlPoints[(cpIdx + 2) % numPoints]; Vector3 tangent = Curve.Catmull.NormalizedTangentAt(time, cp0, cp1, cp2, cp3); Vector3 normal = WorldConstants.GetWorldUp(); Vector3 biNormal = Vector3.Cross(normal, tangent); for (float widthOffset = -mStripWidth / 2.0f; widthOffset < (mStripWidth / 2.0f); widthOffset += curveWidthOffsetLen) { // Offset curve along biNormal. Vector3 curveOffset = biNormal * widthOffset; verts.Add(Curve.Catmull.CurvePointAt(time, cp0 + curveOffset, cp1 + curveOffset, cp2 + curveOffset, cp3 + curveOffset)); } } } CopyDataToMesh(verts, curveVertsWidth); AssignMaterial(); }
public DataStore() { activeConditions = new Dictionary<string, Condition> (); increasingConditions = new List<string> (); roomStates = IOManager.LoadRoomStates (); playerState = IOManager.LoadPlayerState (); worldState = IOManager.LoadWorldState (); worldConstants = IOManager.LoadWorldConstants (); WorldClock.SetDate (worldState.clock); WeatherSystem.SetWeather (worldState.weather); foreach(Condition c in playerState.conditions.Values) { DataStore.AddCondition (c); } }
private void Awake() { Instance = this; WorldConstants.SetDictionaries(); }
// Use this for initialization void Start() { WorldConstants.LoadObjects(); WorldConstants.MinePrefab = MinePrefab; }
public static Portal CreatePortal(Room room, MathConstants.eSignedDirection roomSide) { Portal newPortal = new Portal(); newPortal.portal_id = -1; // portal ID not set until this portal gets saved into the DB newPortal.target_portal_id = -1; newPortal.room_side = roomSide; newPortal.room_x = room.room_key.x; newPortal.room_y = room.room_key.y; newPortal.room_z = room.room_key.z; switch (roomSide) { case MathConstants.eSignedDirection.positive_x: { Point3d p1 = WorldConstants.ROOM_BOUNDS.Max; Point3d p0 = p1 - Vector3d.I * WorldConstants.PORTAL_WIDTH - Vector3d.J * WorldConstants.ROOM_Y_SIZE; newPortal.bounding_box = new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.negative_x: { Point3d p0 = WorldConstants.ROOM_BOUNDS.Min; Point3d p1 = p0 + Vector3d.I * WorldConstants.PORTAL_WIDTH + Vector3d.J * WorldConstants.ROOM_Y_SIZE; newPortal.bounding_box = new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.positive_y: { Point3d p1 = WorldConstants.ROOM_BOUNDS.Max; Point3d p0 = p1 - Vector3d.I * WorldConstants.ROOM_X_SIZE - Vector3d.J * WorldConstants.PORTAL_WIDTH; newPortal.bounding_box = new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.negative_y: { Point3d p0 = WorldConstants.ROOM_BOUNDS.Min; Point3d p1 = p0 + Vector3d.I * WorldConstants.ROOM_X_SIZE + Vector3d.J * WorldConstants.PORTAL_WIDTH; newPortal.bounding_box = new AABB3d(p0, p1); } break; case MathConstants.eSignedDirection.positive_z: case MathConstants.eSignedDirection.negative_z: { int column = RNGUtilities.RandomInt(WorldConstants.ROOM_X_TILES / 3, 2 * WorldConstants.ROOM_X_TILES / 3); int row = RNGUtilities.RandomInt(WorldConstants.ROOM_Y_TILES / 3, 2 * WorldConstants.ROOM_Y_TILES / 3); Point3d p0 = WorldConstants.GetTilePosition(column, row); Point3d p1 = p0 + Vector3d.I * WorldConstants.ROOM_TILE_SIZE + Vector3d.J * WorldConstants.ROOM_TILE_SIZE; newPortal.bounding_box = new AABB3d(p0, p1); } break; } return(newPortal); }