public TileSlot(TileAbstSO tile) { if (tile == null) { throw new System.NullReferenceException(); } switch (tile) { case GatherableTileSO plant: tileState = new GatherableState(plant, this); break; case BlockTileSO block: tileState = new BlockState(block); break; case ProcessingTableTileSO table: tileState = new ProcessingTableTileState(table, this); break; case LightSourceTileSO lightSource: tileState = new LightSourceTileState(lightSource); break; default: throw new System.NotImplementedException(); } }
/// <summary> /// Method to remove the reticle graphic from all selectable objects in the scene /// </summary> private void RemoveReticle() { MonoBehaviour[] gameObjects = (MonoBehaviour[])FindObjectsOfType(typeof(MonoBehaviour)); foreach (var gameObject in gameObjects) { ITileState selectableObject = gameObject.GetComponents <ITileState>().Where(c => c.IsEnabled).FirstOrDefault(); if (selectableObject != null) { //Remove the reticle from the object selectableObject.OnMouseExitEvent(); } } }
private void Start() { switch (tileEnum) { case TileEnum.grass: state = new TileState.PlantableGrassTile().Init(this); break; case TileEnum.water: break; case TileEnum.soil: break; case TileEnum.seed: // state = new TileState.CompleteFlower().Init(this); break; case TileEnum.flower: // state = new TileState.CompleteFlower().Init(this); break; } }
/// <summary> /// Method to let the player see what they are selecting in the game /// Method uses Raycating to calcuate /// </summary> private void DrawReticle() { //Use Ray Casting to check for hit //Create ray Ray rayOrigin = Camera.main.ScreenPointToRay(Input.mousePosition); //Create hit info RaycastHit hitInfo; // *You can use RaycastAll() to get ack more than one object* // https://docs.unity3d.com/ScriptReference/Physics.RaycastAll.html //Did we hit anything? if (Physics.Raycast(rayOrigin, out hitInfo)) { //Grab the ISelectable Interface ofthe object we hit ITileState obj = hitInfo.collider.GetComponents <ITileState>().Where(c => c.IsEnabled).FirstOrDefault(); //We hit a "Selectable" object if (obj != null) { obj.OnMouseOverEvent(); } } }
// Use this for initialization void Start() { currentState = onIdle; }
public Tile builder(TileType type, Vector2 location) { factory = new SpriteFactory(); if (type == TileType.treeTile) { state = new GenericTileState(SpriteFactory.sprites.treeTile); } if (type == TileType.ledgeLeftCurve) { state = new GenericTileState(SpriteFactory.sprites.ledgeLeftCurve); } if (type == TileType.ledgeLeftEnd) { state = new GenericTileState(SpriteFactory.sprites.ledgeLeftEnd); } if (type == TileType.ledgeMiddle) { state = new GenericTileState(SpriteFactory.sprites.ledgeMiddle); } if (type == TileType.ledgeRightCurve) { state = new GenericTileState(SpriteFactory.sprites.ledgeRightCurve); } if (type == TileType.ledgeRightEnd) { state = new GenericTileState(SpriteFactory.sprites.ledgeRightEnd); } if (type == TileType.pokeEndCornerLeft) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCornerLeft); } if (type == TileType.pokeEndCornerRight) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCornerRight); } if (type == TileType.pokeEndCounterLeft) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCounterLeft); } if (type == TileType.pokeEndCounterRight) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCounterRight); } if (type == TileType.pokeHorizontal) { state = new GenericTileState(SpriteFactory.sprites.pokeHorizontal); } if (type == TileType.pokeMiddleSection) { state = new GenericTileState(SpriteFactory.sprites.pokeMiddleSection); } if (type == TileType.pokeVerticalLeft) { state = new GenericTileState(SpriteFactory.sprites.pokeVerticalLeft); } if (type == TileType.pokeVerticalRight) { state = new GenericTileState(SpriteFactory.sprites.pokeVerticalRight); } if (type == TileType.exit) { state = new GenericTileState(SpriteFactory.sprites.exit); } if (type == TileType.grass) { state = new GenericTileState(SpriteFactory.sprites.grassBack); } if (type == TileType.pokeFloorSpot) { state = new GenericTileState(SpriteFactory.sprites.pokeFloorSpot); } if (type == TileType.pokePlainFloor) { state = new GenericTileState(SpriteFactory.sprites.pokePlainFloor); } if (type == TileType.pokeBookShelf) { state = new GenericTileState(SpriteFactory.sprites.pokeBookShelf); } if (type == TileType.pokeChairs) { state = new GenericTileState(SpriteFactory.sprites.pokeChairs); } if (type == TileType.pokeComputer) { state = new GenericTileState(SpriteFactory.sprites.pokeComputer); } if (type == TileType.pokeFloorPrint) { state = new GenericTileState(SpriteFactory.sprites.pokeFloorPrint); } if (type == TileType.pokeStairsDown) { state = new GenericTileState(SpriteFactory.sprites.pokeStairsDown); } if (type == TileType.pokeTree) { state = new GenericTileState(SpriteFactory.sprites.pokeTree); } if (type == TileType.sign) { state = new GenericTileState(SpriteFactory.sprites.sign); } Tile product = new Tile(state, location); return(product); }
public Tile builder(TileType type, Vector2 location) { factory = new SpriteFactory(); if (type == TileType.treeTile) { state = new GenericTileState(SpriteFactory.sprites.treeTile); } if (type == TileType.ledgeLeftCurve) { state = new GenericTileState(SpriteFactory.sprites.ledgeLeftCurve); } if (type == TileType.ledgeLeftEnd) { state = new GenericTileState(SpriteFactory.sprites.ledgeLeftEnd); } if (type == TileType.ledgeMiddle) { state = new GenericTileState(SpriteFactory.sprites.ledgeMiddle); } if (type == TileType.ledgeRightCurve) { state = new GenericTileState(SpriteFactory.sprites.ledgeRightCurve); } if (type == TileType.ledgeRightEnd) { state = new GenericTileState(SpriteFactory.sprites.ledgeRightEnd); } if (type == TileType.pokeEndCornerLeft) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCornerLeft); } if (type == TileType.pokeEndCornerRight) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCornerRight); } if (type == TileType.pokeEndCounterLeft) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCounterLeft); } if (type == TileType.pokeEndCounterRight) { state = new GenericTileState(SpriteFactory.sprites.pokeEndCounterRight); } if (type == TileType.pokeHorizontal) { state = new GenericTileState(SpriteFactory.sprites.pokeHorizontal); } if (type == TileType.pokeMiddleSection) { state = new GenericTileState(SpriteFactory.sprites.pokeMiddleSection); } if (type == TileType.pokeVerticalLeft) { state = new GenericTileState(SpriteFactory.sprites.pokeVerticalLeft); } if (type == TileType.pokeVerticalRight) { state = new GenericTileState(SpriteFactory.sprites.pokeVerticalRight); } if (type == TileType.exit) { state = new GenericTileState(SpriteFactory.sprites.exit); } if (type == TileType.grass) { state = new GenericTileState(SpriteFactory.sprites.grassBack); } if (type == TileType.pokeFloorSpot) { state = new GenericTileState(SpriteFactory.sprites.pokeFloorSpot); } if (type == TileType.pokePlainFloor) { state = new GenericTileState(SpriteFactory.sprites.pokePlainFloor); } if (type == TileType.pokeBookShelf) { state = new GenericTileState(SpriteFactory.sprites.pokeBookShelf); } if (type == TileType.pokeChairs) { state = new GenericTileState(SpriteFactory.sprites.pokeChairs); } if (type == TileType.pokeComputer) { state = new GenericTileState(SpriteFactory.sprites.pokeComputer); } if (type == TileType.pokeFloorPrint) { state = new GenericTileState(SpriteFactory.sprites.pokeFloorPrint); } if (type == TileType.pokeStairsDown) { state = new GenericTileState(SpriteFactory.sprites.pokeStairsDown); } if (type == TileType.pokeTree) { state = new GenericTileState(SpriteFactory.sprites.pokeTree); } if (type == TileType.sign) { state = new GenericTileState(SpriteFactory.sprites.sign); } Tile product = new Tile(state, location); return product; }
public Tile(ITileState state, Vector2 position) { this.state = state; this.position = position; }