/// <summary> /// Creates a new exclusion checked tile grid. /// </summary> /// <param name="dimensions"></param> /// <param name="gameManager"></param> /// <param name="tileSelectionManager"></param> /// <param name="tileFocusManager"></param> /// <param name="prefab"></param> /// <param name="exclusionZones"></param> public ExclusionCheckedTileGrid(Dimensions <int> dimensions, GameManager gameManager, TileSelectionManager tileSelectionManager, ExclusiveSubsectionFocusManager tileFocusManager, Tile.Tile prefab, ICollection <IExclusionZone> exclusionZones) : base(dimensions, prefab) { GridInstantiate(new ExclusionCheckedTileGridInstantiationCreator(gameManager, tileSelectionManager, tileFocusManager, exclusionZones)); }
/// <summary> /// Creates a new TileInstantiationCreator /// </summary> /// <param name="gameManager"></param> /// <param name="tileSelectionManager"></param> /// <param name="tileFocusManager"></param> public TileInstantiationCreator(GameManager gameManager, TileSelectionManager tileSelectionManager, ExclusiveSubsectionFocusManager tileFocusManager) { this.gameManager = gameManager; this.tileSelectionManager = tileSelectionManager; this.tileFocusManager = tileFocusManager; }
public void OnAfterDraw(TileSelectionManager tsm, SpriteBatch sb) { if (_originalJobType == JobType.Invalid) { return; } JobTypeField.SetValue(tsm, _originalJobType); _originalJobType = JobType.Invalid; }
public void OnBeforeDraw(TileSelectionManager tsm, SpriteBatch sb) { JobType jobType = (JobType)JobTypeField.GetValue(tsm); if (jobType <= _maxJobType) { return; } _originalJobType = jobType; JobTypeField.SetValue(tsm, _customJobs[jobType].JobTypeImpersonator.ImpersonateJobType); }
public bool OnSelectionMade(TileSelectionManager tsm) { JobType jobType = (JobType)JobTypeField.GetValue(tsm); if (jobType <= _maxJobType) { return(false); } Vector3 startPosition = (Vector3)JobStartPosition.GetValue(tsm); Vector3 endPosition = (Vector3)JobEndPosition.GetValue(tsm); Vector3 selectionStartPosition = (Vector3)SelectionStartPosition.GetValue(tsm); Rectangle jobArea = new Rectangle((int)startPosition.X, (int)startPosition.Y, (int)(endPosition.X - startPosition.X), (int)(endPosition.Y - startPosition.Y)); IModJob modJob = _customJobs[jobType]; if (modJob.CreateJobs(jobArea, (int)endPosition.Z, selectionStartPosition)) { ClearSelection.Invoke(tsm, new object[0]); } return(true); }
private void Awake() { // in theory, this can be done without allocation. var minimal = pathManager.GetActivePath().GetExtrapolator().GetMinimalRepresentation().ToList(); foreach (var zone in exclusionZoneMonoBehaviours) { exclusionZones.Add(zone); } for (var i = 0; i < minimal.Count - 1; i++) { var first = minimal[i].Location; var second = minimal[i + 1].Location; exclusionZones.Add(new RectangleExclusionZone(first, second)); } selectionManager = GetComponent <TileSelectionManager>(); focusManager = GetComponent <TileFocusManager>(); TileGrid = new ExclusionCheckedTileGrid(new Dimensions <int>(21, 13), manager, selectionManager, focusManager, tilePrefab, exclusionZones); }
private void Awake() { selectionManager = GetComponent <TileSelectionManager>(); creationManager = GetComponent <TileCreationManager>(); focusManager = GetComponent <TileFocusManager>(); }
public GenerateBoardResponse generateTiles(TileManager tileManager, TileSelectionManager pathSelectManager) { GenerateBoardResponse response = new GenerateBoardResponse(); string[] mapItems = map.Split(NEWLINE); int y = 0; foreach (string line in mapItems) { bool horizontal = line.Contains(WALL_V + ""); char[] chars = line.ToCharArray(); for (int index = 0; index < chars.Length; index++) { char c = chars[index]; int x = index; if (c == TILE_NORMAL) { Position newPosition = new Position(x, y); GameObject newTile = Instantiate(tile); newTile.transform.position = transform.position + (x * right) + (y * up); newTile.GetComponent <Tile>().Init(newPosition, tileManager); newTile.GetComponentInChildren <OutlineOnHover>().Init(pathSelectManager); newTile.GetComponentInChildren <PathOnClick>().Init(pathSelectManager); response.coordinateToTile.Add(newPosition, newTile.GetComponent <Tile>()); newTile.transform.SetParent(Board.transform); } if (c == WALL) { GameObject newTile = Instantiate(wall); newTile.transform.position = transform.position + (x * right) + (y * up); //newTile.GetComponent<Tile>().Init(newPosition, tileManager); //newTile.GetComponentInChildren<OutlineOnHover>().Init(pathSelectManager); //newTile.GetComponentInChildren<PathOnClick>().Init(pathSelectManager); //response.coordinateToTile.Add(newPosition, newTile.GetComponent<Tile>()); newTile.transform.SetParent(Board.transform); } if (c == WALL_H) { Position pos1 = new Position(x, y); Position pos2 = new Position(x + 1, y); GameObject newWall = Instantiate(wallH); newWall.transform.position = transform.position + (x * right) + (y * up) + (.5f * right); response.tuppleToWall.Add(new Tuple <Position, Position>(pos1, pos2), newWall); newWall.transform.parent = Board.transform; } if (c == WALL_V) { Position pos1 = new Position(x, y); Position pos2 = new Position(x, y + 1); GameObject newWall = Instantiate(wallH); newWall.transform.position = transform.position + (x * right) + (y * up) + (.5f * up); newWall.transform.Rotate(new Vector3(0, 0, 1), 90); response.tuppleToWall.Add(new Tuple <Position, Position>(pos1, pos2), newWall); newWall.transform.SetParent(Board.transform); } } if (!horizontal) { y++; } } return(response); }
public void init(BoardEntitySelector boardEntitySelector, TileSelectionManager tileSelectionManager) { PathOnClick.pause = true; this.boardEntitySelector = boardEntitySelector; this.tileSelectionManager = tileSelectionManager; }
public static void QuickMine() { TileSelectionManager tileSelectionManager = GnomanEmpire.Instance.Region.TileSelectionManager; tileSelectionManager.SetMouseAction(s_QuickMineJobType, null, true, false, true, true); }
/// <summary> /// Constructs a new tile grid instantiation creator /// given a few arguments which will be useful for /// creating tiles. /// </summary> /// <param name="gameManager"></param> /// <param name="tileSelectionManager"></param> /// <param name="tileFocusManager"></param> /// <param name="exclusionZones"></param> public ExclusionCheckedTileGridInstantiationCreator(GameManager gameManager, TileSelectionManager tileSelectionManager, ExclusiveSubsectionFocusManager tileFocusManager, ICollection <IExclusionZone> exclusionZones) : base(gameManager, tileSelectionManager, tileFocusManager) { this.exclusionZones = exclusionZones; }
public bool OnSelectionMade(TileSelectionManager tsm) { JobType jobType = (JobType)JobTypeField.GetValue(tsm); if (jobType <= _maxJobType) return false; Vector3 startPosition = (Vector3)JobStartPosition.GetValue(tsm); Vector3 endPosition = (Vector3)JobEndPosition.GetValue(tsm); Vector3 selectionStartPosition = (Vector3)SelectionStartPosition.GetValue(tsm); Rectangle jobArea = new Rectangle((int)startPosition.X, (int)startPosition.Y, (int)(endPosition.X - startPosition.X), (int)(endPosition.Y - startPosition.Y)); IModJob modJob = _customJobs[jobType]; if (modJob.CreateJobs(jobArea, (int)endPosition.Z, selectionStartPosition)) ClearSelection.Invoke(tsm, new object[0]); return true; }
public void OnBeforeDraw(TileSelectionManager tsm, SpriteBatch sb) { JobType jobType = (JobType)JobTypeField.GetValue(tsm); if (jobType <= _maxJobType) return; _originalJobType = jobType; JobTypeField.SetValue(tsm, _customJobs[jobType].JobTypeImpersonator.ImpersonateJobType); }
public void OnAfterDraw(TileSelectionManager tsm, SpriteBatch sb) { if (_originalJobType == JobType.Invalid) return; JobTypeField.SetValue(tsm, _originalJobType); _originalJobType = JobType.Invalid; }
public NaiveTileGridInstantiationCreator(GameManager gameManager, TileSelectionManager tileSelectionManager, ExclusiveSubsectionFocusManager tileFocusManager) : base(gameManager, tileSelectionManager, tileFocusManager) { }
/// <summary> /// Construct a new NaiveTileGrid /// </summary> /// <param name="gameManager"></param> /// <param name="tileSelectionManager"></param> /// <param name="tileFocusManager"></param> /// <param name="prefab"></param> public NaiveTileGrid(GameManager gameManager, TileSelectionManager tileSelectionManager, ExclusiveSubsectionFocusManager tileFocusManager, Tile.Tile prefab) : base(GetTemplate(rows, cols, prefab), prefab) { GridInstantiate(new NaiveTileGridInstantiationCreator(gameManager, tileSelectionManager, tileFocusManager)); }
private void Awake() { selectionManager = GetComponent <TileSelectionManager>(); }
public static void KeepRequiredTorches() { TileSelectionManager tileSelectionManager = GnomanEmpire.Instance.Region.TileSelectionManager; tileSelectionManager.SetMouseAction(s_SafeTorchesJobType, null, false, false, false, false); }