/// <summary> /// Moves the projectile, sets a new target if applicable, then calls the parent, which applies effects to the new target, if applicable. /// </summary> public override void Update() { if (endFlag) { if(!tempTarget.TemporarySprites.Contains(impactSprite)) { tempTarget.TemporarySprites.Add(impactSprite); foreach (Sprite travelSprite in projectileAnimations) { tempTarget.TemporarySprites.Add(travelSprite); } } deleteFlag = true; } else if (moveFlag) { moveFlag = false; Vector2 temp = Path[0]; Path.RemoveAt(0); parentSpace = parentGrid.GridSpaces[(int)temp.X, (int)temp.Y]; endFlag = Path.Count == 0; tempTarget = (Person)parentSpace.tryGetActor(); for (int i = 0; i < drawFlagArray.Length; ++i) { drawFlagArray[i] = true; } } base.Update(); }
public void MoveNPC(GridSpace node) { //GridSpace grid = BigBoss.Levels.Level[node.X, node.Y]; if (!node.IsBlocked() && subtractPoints(BigBoss.Time.regularMoveCost)) { GridSpace = node; move(node); } }
internal void MoveNPCStepwise(GridSpace gridTarget) { GO.MoveStepWise(new Vector3(gridTarget.X, 0, gridTarget.Y), NPCSpeed); //heading = new Vector3(gridTarget.X - GO.transform.position.x, 0f, gridTarget.Y - GO.transform.position.z); //GO.transform.Translate(Vector3.forward * NPCSpeed * Time.deltaTime, Space.Self); //Quaternion toRot = Quaternion.LookRotation(heading); //GO.transform.rotation = toRot; //GO.transform.rotation = Quaternion.Slerp(GO.transform.rotation, toRot, NPCRotationSpeed); }
public void Initialize() { _levels = new Level[_maxLevels]; ArrayExt.Converters[typeof(GridType)] = (b) => { return(GridTypeEnum.Convert((GridType)b)); }; ArrayExt.Converters[typeof(GridSpace)] = (b) => { GridSpace s = b as GridSpace; if (s == null) { return(GridTypeEnum.Convert(GridType.NULL)); } return(GridTypeEnum.Convert(s.Type)); }; ArrayExt.Converters[typeof(GenSpace)] = (b) => { GenSpace s = b as GenSpace; if (s == null) { return(GridTypeEnum.Convert(GridType.NULL)); } return(s.GetChar()); }; ArrayExt.Converters[typeof(IGridSpace)] = (b) => { IGridSpace s = b as IGridSpace; if (s == null) { return(GridTypeEnum.Convert(GridType.NULL)); } if (s is GenSpace) { return(((GenSpace)s).GetChar()); } return(GridTypeEnum.Convert(s.Type)); }; if (Seed == -1) { Seed = Probability.Rand.Next(); } System.Random rand = new System.Random(Seed); for (int i = 0; i < _maxLevels; i++) { _levelSeeds[i] = rand.Next(); } LevelBuilder.Initialize(); foreach (IInitializable init in this.FindAllDerivedObjects <IInitializable>()) { init.Init(); } #region DEBUG if (BigBoss.Debug.logging(Logs.LevelGenMain)) { BigBoss.Debug.w(Logs.LevelGenMain, "Random seed int: " + Seed); } #endregion }
protected override void InternalUpdateChemistry(GridSpace selfSpace) { var interactions = selfSpace.m_components; if (interactions.ContainsKey(ComponentType.Plant)) { // Water is consumed by plants m_amountRemaining -= Simulation.DeltaTime * 0.001f; } }
/** * Create the spaces for putting the cards into the hand * arg: [int handLength] size of the hand */ private void createHandSpaces(int handLength) { for (int i = 0; i < handLength; i++, handSpaceY -= handSpaceOffsetY) { GridSpace spaceCopy = Instantiate(space) as GridSpace; spaceCopy.transform.position = new Vector3(handSpaceX, handSpaceY, -i - 1); spaceCopy.transform.SetParent(canvas.transform, false); handSpaces [i] = spaceCopy; } }
public void PlacePlayer(Level l, GridSpace stairsUp) { Value2D <GridSpace> grid; l.Array.GetPointAround(stairsUp.X, stairsUp.Y, false, (arr, x, y) => { return(arr[x, y].Type == GridType.Floor); }, out grid); BigBoss.PlayerInfo.transform.position = new Vector3(grid.x, 0, grid.y); }
public override bool Equals(object obj) { GridSpace rhs = obj as GridSpace; if (rhs == null) { return(false); } return((X == rhs.X) && (Y == rhs.Y)); }
private void setupBoard(GridSpace[,] board) { for (int row = 0; row < board.GetLength(0); row++) { for (int col = 0; col < board.GetLength(1); col++) { board[row, col] = new GridSpace(); } } }
public void Awake() { timer = 0; grid = new GridSpace[outputStream.boardHeight][]; for (int i = 0; i < grid.Length; ++i) { grid[i] = new GridSpace[outputStream.boardWidth]; } PlayerPhase = true; }
/* Input */ void OnClick() { if (prevHover != null && prevHover.tag.Equals("GridSpace") && prevHover.GetComponent <GridSpace>().MoveQueue.Count > 0 && !promptUp) { target = prevHover.GetComponent <GridSpace>(); manBtn.interactable = false; ays.SetActive(true); promptUp = true; } }
public void moveTo(GridSpace gridSpace) { int direction = Coordinate.getDirectionOf(this.position, gridSpace.position); if (gridSpace.block.GetComponent <BlockScript>().walkable[direction]) { this.position = gridSpace.position; this.gameObject.transform.position = this.position.getWorldCoordinate(); } }
public List <PlayerBoardSpace> getAttackableGhostSpaces(GridSpace origin) { List <PlayerBoardSpace> spaces = new List <PlayerBoardSpace>(); if (origin.GridSpacePosition.col == GridSpace.GridSpaceCol.Left) { if (origin.GridSpacePosition.row == GridSpace.GridSpaceRow.Top) { spaces.Add(TopBoard.rightSpace); spaces.Add(LeftBoard.leftSpace); } else if (origin.GridSpacePosition.row == GridSpace.GridSpaceRow.Center) { spaces.Add(LeftBoard.middleSpace); } else { spaces.Add(LeftBoard.rightSpace); spaces.Add(BottomBoard.leftSpace); } } else if (origin.GridSpacePosition.col == GridSpace.GridSpaceCol.Center) { if (origin.GridSpacePosition.row == GridSpace.GridSpaceRow.Top) { spaces.Add(TopBoard.middleSpace); } else if (origin.GridSpacePosition.row == GridSpace.GridSpaceRow.Center) { } else { spaces.Add(BottomBoard.middleSpace); } } else { if (origin.GridSpacePosition.row == GridSpace.GridSpaceRow.Top) { spaces.Add(RightBoard.rightSpace); spaces.Add(TopBoard.leftSpace); } else if (origin.GridSpacePosition.row == GridSpace.GridSpaceRow.Center) { spaces.Add(RightBoard.middleSpace); } else { spaces.Add(RightBoard.leftSpace); spaces.Add(BottomBoard.rightSpace); } } return(spaces.Where(space => space.hasGhost()).ToList()); }
public override GridSpace GetTurn(Text[] buttons) { GridSpace button = GetBestOfThree(buttons); if (button == null) { button = GetRandomTurn(buttons); } return(button); }
private void AddSpaceToGrid(GridSpace gridSpace, Vector2Int gridPosition) { LevelGrid[gridPosition.x, gridPosition.y] = gridSpace; Vector2 _position = GridPositionToWalkerPosition(gridPosition); if (GridSpace.FLOOR == gridSpace) { FloorCount++; } AddSpaceImplementation.AddSpaceToWorld(gridSpace, _position); }
bool moveBlockDown() { GridSpace nextOne = occupying.GetDownSpace(); while ((nextOne != null && (!nextOne.isOccupied))) { updatePosition(nextOne); return(true); } return(false); }
void updatePosition(GridSpace nextOne) { occupying = nextOne; occupying.isOccupied = false; occupying.block = null; nextOne.block = this; nextOne.isOccupied = true; this.transform.position = nextOne.transform.position; }
bool currentlyOccupying(GridSpace nextOne) { if (nextOne == null) { return(false); } bool nextOneEquals = (nextOne.transform.gameObject == blockOne.occupying.gameObject) || (nextOne.transform.gameObject == blockTwo.occupying.gameObject); return(nextOneEquals); }
public void UpdateSpread(GridSpace otherSpace) { InternalUpdateSpread(otherSpace); m_amountRemaining = Mathf.Clamp(m_amountRemaining, 0.0f, 1.0f); if (m_amountRemaining == 0.0f) { FlagForDestroying(); } }
public NPC SpawnNPC(GridSpace g, Percent variety, params SpawnKeywords[] keywords) { if (Probability.SpawnRand.Percent(variety)) { return(SpawnNPC(g)); } else { return(SpawnNPC(g, keywords)); } }
public NPC SpawnNPC(GridSpace g, NPC n) { try { return(BigBoss.Objects.NPCs.InstantiateAndWrap(n, g)); } catch (ArgumentException) { throw new ArgumentException("The prefab is null: '" + n.Prefab + "' on NPC " + n.ToString()); } }
public NPC SpawnNPC(GridSpace g, GenericFlags <SpawnKeywords> keywords) { LeveledPool <NPC> pool = GetPool(keywords); NPC n; if (!pool.Get(Probability.SpawnRand, out n, BigBoss.Player.Level)) { throw new ArgumentException("NPC Pool was empty for keywords: " + keywords); } return(SpawnNPC(g, n)); }
private void GridGen(int pGridWidth, int pGridHeight) { Grid = new GridSpace[pGridWidth, pGridHeight]; for (int i = 0; i < pGridWidth; i++) { for (int j = 0; j < pGridHeight; j++) { Grid[i, j] = new GridSpace(i, j, pTileSize: TileScale); } } }
public bool TryGetNeighbor(out GridSpace space, Direction direction) { if (HasDirection(direction)) { space = neighbors[direction]; return(true); } space = null; return(false); }
public void UpdateChemistry(GridSpace selfSpace) { InternalUpdateChemistry(selfSpace); m_amountRemaining = Mathf.Clamp(m_amountRemaining, 0.0f, 1.0f); if (m_amountRemaining == 0.0f) { FlagForDestroying(); } }
public override void setup(GridSpace space, int owner, OccupantTracker tracker) { base.setup(space, owner, tracker); turnsBetweenActions = 1; if (owner == 2) { SpriteRenderer renderer = GetComponent <SpriteRenderer>(); Sprite tempSprite = Sprite.Create(player2Sprite, new Rect(0f, 0f, player2Sprite.width, player2Sprite.height), new Vector2(.5f, .5f)); renderer.sprite = tempSprite; } }
void FillavailblePositions() { // Loop the array, anywhere there isn't a walkway add an empty space for (int x = 0; x < gridSizeX; x++) { for (int y = 0; y < gridSizeY; y++) { Vector2 temp = new Vector2 (x, y); if (!takenPositions.Contains(temp)) { spaces [x, y] = new GridSpace (temp); } } } }
public override GridSpace GetTurn(Text[] buttons) { SetRandomDefenseOrAttac(); GridSpace button = GetBestOfThree(buttons); if (button == null) { button = GetRandomTurn(buttons); } return(button); }
public void ResizeGrid(int width, int height) { // Width has gotten smaller, we need to delete grid spaces if (width < m_gridWidth) { for (int x = width; x < m_gridWidth; ++x) { foreach (var space in m_grid[x]) { Destroy(space.m_object); } } } // Height has gotten smaller, we need to delete grid spaces if (height < m_gridHeight) { for (int x = width; x < m_grid.Count; ++x) { for (int y = height; y < m_gridHeight; ++y) { Destroy(m_grid[x][y].m_object); } } } m_gridWidth = width; m_gridHeight = height; m_grid.Resize(width, null); for (int x = 0; x < width; ++x) { if (m_grid[x] == null) { m_grid[x] = new List <GridSpace>(height); } m_grid[x].Resize(height, null); for (int y = 0; y < height; ++y) { if (m_grid[x][y] == null) { var space = new GridSpace(this, x, y); m_grid[x][y] = space; space.Initialize(); } } } }
public void makeAMove() { string[] state = new string[9]; for (int i = 0; i < gameController.buttonList.Length; i++) { state [i] = gameController.buttonList [i].text; } int space = minimax(new Node(state)); GridSpace gridSpace = gameController.buttonList [space].GetComponentInParent <GridSpace> (); gridSpace.SetSpace(); }
//Fills out the gridspace array void FillSpaces() { // Loop the array, adding a space variable for (int x = 0; x < gridSizeX; x++) { for (int y = 0; y < gridSizeY; y++) { Vector2 temp = new Vector2(x, y); spaces[x, y] = new GridSpace(temp); } } }
/// <summary> /// Two-way set parent/child /// </summary> /// <param name="newParent"></param> /// <param name="bAlsoSetLocation"></param> /// <returns></returns> public GridSpace SetParent( ref GridSpace newParent ) { ParentGridSpace = newParent; ParentGridSpace.GridTile = this; return ParentGridSpace; }
protected void InitialiseGrid() { for(int i = 0; i < GetHeight(); ++i) { for(int j = 0; j < GetWidth(); ++j) { grid[j,i] = new GridSpace(); } } }
/// <summary> /// Sets the parent back pointer for the current space /// </summary> /// <param name="parentSpace">Space into which this projectile should move.</param> protected void setParentSpace(GridSpace parentSpace) { this.parentSpace = parentSpace; }
/// <summary> /// Sets the parent backPointers necessary for target tracking /// </summary> /// <param name="parentGrid">Grid to which this projectile belongs</param> /// <param name="parentSpace">Space in which this projectile should now reside</param> protected void setParents(Grid parentGrid, GridSpace parentSpace) { this.parentGrid = parentGrid; this.parentSpace = parentSpace; }
public static Color GridSpaceToColor( GridSpace.GridSpaceType spaceType ) { return Color.white; }
public static void SetTileColorByRef( Color newColor, ref GridSpace tile ) { tile.SpaceType = ColorToGridSpace( newColor ); }