// Use this for initialization void Start() { data = new DataController(); nbObjectsText.text = "0/" + nbObjects; GameObject go = GameObject.Find("PlacedObjects"); if (go == null) { Debug.LogError("Failed to find an object named 'PlacedObjects'"); this.enabled = false; return; } po = go.GetComponent <PlacedObjects> (); po.AddValues(id, src); RectTransform objectRectTransform = canvas.GetComponent <RectTransform> (); h_canvas = (int)objectRectTransform.rect.height; w_canvas = (int)objectRectTransform.rect.width; }
private void ClearMap() { const int count = BoardDensity * BoardDensity * 2; const string str = "Plain Grass"; Grids["GameMap"].Children.RemoveRange(count, Grids["GameMap"].Children.Count - count); PlacedObjects.Clear(); Selection.PersistBaseLayer(false); Selection.Reset(); AvailableObjects = null; TileObject grass = ResourceHolder.Get.GetTerrainTileObject(str); foreach (Tile tile in TileGrid) { Button button = tile.GetUiElement() as Button; if (tile.GetTextureName() != "grass.png") { tile.Change(grass[0], str); } if (button != null && !button.IsHitTestVisible) { button.IsHitTestVisible = true; } tile.Placeable = true; } }
public IPlacedObject PlaceObject(Object2D objectToPlace, Position2D position) { PlacedObject2D newObject = new PlacedObject2D(position, objectToPlace.Width, objectToPlace.Height); PlacedObjects.Add(newObject); return(newObject); }
public IPlacedObject PlaceObject(Object3D objectToPlace, Position3D position) { PlacedObject3D newObject = new PlacedObject3D(position, objectToPlace.Width, objectToPlace.Height, objectToPlace.Depth); PlacedObjects.Add(newObject); return(newObject); }
public AlgorithmExecutionResults CreateResults() { double averageFulfilment = 0.0; double standardDeviation = 0.0; var containerVolume = containers.Sum(x => x.Height * x.Width * x.Depth); var objectsTotalVolume = containers.Sum(container => container.PlacedObjects.Sum(o => (o as Object3D).Width * (o as Object3D).Height * (o as Object3D).Depth)); double worstFulfillment; PlacedObjects placedObjectsTotal = new PlacedObjects(); foreach (var container in containers) { placedObjectsTotal.AddRange(container.PlacedObjects); averageFulfilment += container.GetFulfilment(); } averageFulfilment /= containers.Count(); foreach (var container in containers) { standardDeviation += Math.Pow((double)(averageFulfilment - container.GetFulfilment()), 2.0); } standardDeviation = Math.Sqrt(standardDeviation / containers.Count); // If more than 1 container was used, do not take last created into account if (containers.Count > 1) { worstFulfillment = containers.OrderBy(x => x.GetFulfilment()).Skip(1).FirstOrDefault().GetFulfilment(); } else { worstFulfillment = containers.OrderBy(x => x.GetFulfilment()).FirstOrDefault().GetFulfilment(); } var results = new AlgorithmExecutionResults { PlacedObjects = placedObjectsTotal, ContainerSize = containers.First(), ContainerFulfillment = containerVolume, ObjectsTotalFulfillment = objectsTotalVolume, AverageFulfillmentRatio = averageFulfilment, FulfillmentRatioStandardDeviation = standardDeviation, Quality = (double)containerVolume / objectsTotalVolume, ContainersUsed = containers.Count, ObjectCount = placedObjectsTotal.Count, WorstFulfillment = worstFulfillment }; return(results); }
// Use this for initialization void Start() { nbObjectsText.text = "0/" + nbObjects; GameObject go = GameObject.Find("PlacedObjects"); if (go == null) { Debug.LogError("Failed to find an object named 'PlacedObjects'"); this.enabled = false; return; } po = go.GetComponent <PlacedObjects>(); }
private void SaveGame(object sender, RoutedEventArgs args) { List <Placement> allPlacements = PlacedObjects; int newCount = PlacedObjects.Count - InitialPlacerCount; PlacedObjects = PlacedObjects.GetRange(InitialPlacerCount, newCount); int gameId; try { _manager.SaveGame(this, LoadedMapId, out gameId); } catch (Exception e) { PlacedObjects = allPlacements; Console.WriteLine(e); return; } ChangeDisplayMode(true); GameScroll.Content = Grids["GameMap"]; PlacedObjects = allPlacements; Simulate(null, null); _simulator.ScoreToDatabase(gameId); }
// Use this for initialization void Start() { GameObject go = GameObject.Find("PlacedObjects"); if (go == null) { Debug.LogError("Failed to find an object named 'PlacedObjects'"); this.enabled = false; return; } po = go.GetComponent <PlacedObjects> (); po.RandInitObjects(); GameObject go2 = GameObject.Find("Timer"); if (go2 == null) { Debug.LogError("Failed to find an object named 'Timer'"); this.enabled = false; return; } time = go2.GetComponent <Timer>(); GameObject go3 = GameObject.Find("Player"); if (go3 == null) { Debug.LogError("Failed to find an object named 'Player'"); this.enabled = false; return; } player = go3.GetComponent <Player> (); }
/// <summary> /// /// </summary> /// <param name="batch"></param> public void Draw(SpriteBatch batch) { if (selectionUpdated) { // Reset the update flag selectionUpdated = false; // Update the selected entity selectedEntity = GetEntityFor(selectedPosition); } possibleMoves = MoveCalculator.GetMoves(selectedEntity, this); //var attackMoves = (moveCalculator == null) ? new MoveList() : moveCalculator.GetAvailableAttackLocations(); List <Move> attackMoves = new List <Move>(); for (var x = 0; x < Width; x++) { for (var y = 0; y < Height; y++) { Point point = GetPointForTile(new Vector2(x, y)); var left = point.X; var top = point.Y; var top2 = y * (TILEHEIGHT - TILEOFFSET) - (int)cameraPosition.Y; // DRAW TILES var tile = map[y, x]; if (tile.HasTexture) { var texture = tileTextures[tile.TextureIndex]; batch.Draw(texture, new Rectangle(left, top2, TILEWIDTH, TILEHEIGHT), Color.White); } // DRAW DECALS if (tile.HasDecal) { var decal = decalTextures[tile.DecalIndex]; batch.Draw(decal, new Rectangle(left, top2, TILEWIDTH, TILEHEIGHT), Color.White); } if (possibleMoves.Any <Move>(move => move.Contains(new Vector2(x, y)))) { batch.Draw(MoveIndicator, new Rectangle(left, top2, TILEWIDTH, TILEHEIGHT), Color.White); } else if (attackMoves.Any <Move>(move => move.Contains(new Vector2(x, y))) && GetEntityFor(new Vector2(x, y)) != null) { batch.Draw(AttackIndicator, new Rectangle(left, top2, TILEWIDTH, TILEHEIGHT), Color.IndianRed); } } } // Sort objects in order they need to be drawn PlacedObjects.Sort(); // Draw objects foreach (var renderObject in PlacedObjects) { Vector2 position = renderObject.Location; Point point = GetPointForTile(position); batch.Draw(renderObject.Entity.EntityTexture, new Rectangle(point.X, point.Y, TILEWIDTH, TILEHEIGHT), TurnManager.Instance.TeamDictionary[renderObject.Entity].Color); } for (var x = 0; x < Width; x++) { for (var y = 0; y < Height; y++) { var left = x * TILEWIDTH - (int)cameraPosition.X; var top = y * TILEHEIGHT - (int)cameraPosition.Y; var top2 = y * (TILEHEIGHT - TILEOFFSET) - (int)cameraPosition.Y; // ADD HIGHLIGHT if (x == currentPosition.X && y == currentPosition.Y) { batch.Draw(HighlightTexture, new Rectangle(left, top2 - (int)(0.5 * TILEOFFSET), TILEWIDTH, TILEHEIGHT), Color.White); } } } }
protected SubContainer2D(Position2D position, int width, int height) : base(position, width, height) { PlacedObjects = new PlacedObjects(); }
protected SubContainer2D(int x, int y, int width, int height) : base(x, y, width, height) { PlacedObjects = new PlacedObjects(); }
public double GetFulfilment() { return((double)PlacedObjects.Sum(o => (o as Object3D).Width * (o as Object3D).Height * (o as Object3D).Depth) / Volume); }
public Container3D(int width, int height, int depth) : base(width, height, depth) { IsClosed = false; PlacedObjects = new PlacedObjects(); }
protected SubContainer3D(Position3D position, int width, int height, int depth) : base(position, width, height, depth) { PlacedObjects = new PlacedObjects(); }
protected SubContainer3D(int x, int y, int z, int width, int height, int depth) : base(x, y, z, width, height, depth) { PlacedObjects = new PlacedObjects(); }
public double GetFulfilment() { return((double)PlacedObjects.Sum(o => (o as Object2D).Width * (o as Object2D).Height) / Area); }
public Container2D(int width, int height) : base(width, height) { IsClosed = false; PlacedObjects = new PlacedObjects(); }