private void destroyAll(MovementRange movementRange) { foreach (GameObject gameObject in drawnMovement) { Destroy(gameObject); } }
public void act(Actor actor, GameState state) { MovementRange range = state.movementMode.movementRange; if (range.validMovementTiles.Count == 0) { state.nextTurn (); } int target = UnityEngine.Random.Range(0, range.validMovementTiles.Count); Tile targetTile = range.validMovementTiles [target]; state.currentMode.click (targetTile); }
public void drawMovementRange(MovementRange movementRange) { Debug.Log("Draw movement."); //delete old ones destroyAll(movementRange); //draw new ones foreach (Tile tile in movementRange.validMovementTiles) { GameObject movementGameObject = new GameObject(); movementGameObject.name = "Movement_" + tile.x + "_" + tile.y; movementGameObject.transform.position = new Vector3(tile.x, tile.y, 0); movementGameObject.transform.SetParent(this.transform, true); SpriteRenderer sr = movementGameObject.AddComponent <SpriteRenderer>(); sr.sprite = movementSprite; sr.sortingLayerName = "Movement"; drawnMovement.Add(movementGameObject); } }
public MovementMode(World world) { this.world = world; movementRange = new MovementRange(world); }