public void SetCursor(InstalledObjectInfo obj, SpriteHolder objSpr) { Destroy(cursor); if (obj == null) { DefaultCursor(); } else { cursor = new GameObject(); cursor.name = "CursorCustom"; for (int i = 0; i < obj.RelativeTiles.Length; i++) { GameObject g = new GameObject(); g.name = "CursorCustomChild"; g.transform.SetParent(cursor.transform); g.transform.position = new Vector3(obj.RelativeTiles [i] [0], obj.RelativeTiles [i] [1]); SpriteRenderer sr = g.AddComponent <SpriteRenderer> (); sr.sprite = objSpr.Sprites [i]; sr.color = new Color(sr.color.r, sr.color.g, sr.color.b, sr.color.a * 0.5f); } cursorHeight = obj.Height; } }
public InstalledObject(InstalledObjectInfo info, Tile baseTile) { this.id = info.ID; this.name = info.Name; this.placementValidation = info.PlacementValidation; this.onInstallComplete = info.OnInstallComplete; this.onPlaced = info.OnPlaced; this.canMoveThrough = info.CanMoveThrough; this.moveCost = info.MoveCost; this.height = info.Height; this.width = info.Width; this.tiles = new List <Tile> (); for (int i = 0; i < this.Width; i++) { for (int j = 0; j < this.Height; j++) { this.tiles.Add(MapController.Instance.GetTileAtWorldPos(baseTile.X + i, baseTile.Y + j)); } } }
public static void Init() { interactionDictionary = new Dictionary <int, InstalledObjectInteractionInfo> (); spawnAddDictionary = new Dictionary <int, InstalledObjectSpawnAdditionalInfo> (); possJobsDictionary = new Dictionary <int, ObjectPossibleJobsInfo> (); //TODO read from file objs = new InstalledObjectInfo[maxObjID]; sprites = new SpriteHolder[maxObjID]; //Wall objs[0] = new InstalledObjectInfo(0, "Wall", FurnitureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd]); sprites [0] = new SpriteHolder(Resources.LoadAll <Sprite> ("Sprites/Map/woodwall"), "InstalledObject", 50); //Tree objs[1] = new InstalledObjectInfo(1, "Tree", NatureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd]); sprites [1] = new SpriteHolder(Resources.LoadAll <Sprite> ("Sprites/Map/Forest Assets/Trees/Tree 10"), "InstalledObject", 50); //Door objs[2] = new InstalledObjectInfo(2, "Door", FurnitureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd], 1, 1, null, true, 1.5f); sprites [2] = new SpriteHolder(Resources.LoadAll <Sprite> ("Sprites/Map/doors"), "InstalledObject", 50); interactionDictionary.Add(2, new InstalledObjectInteractionInfo(2, (tile) => { SwitchSprite(tile, sprites [2].Sprites [21]); }, (tile) => { SwitchSprite(tile, sprites [2].Sprites [0]); })); possJobsDictionary.Add(2, new ObjectPossibleJobsInfo(2, new List <PossibleJob> () { new PossibleJob((int)JobList.Jobs.Lock, true), new PossibleJob((int)JobList.Jobs.Unlock, false) })); //Doors start unlocked (i.e. cannot unlocked locked door) //Torch objs[3] = new InstalledObjectInfo(3, "Torch", FurnitureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd], 1, 1, null, true, 1f); sprites [3] = new SpriteHolder(Resources.LoadAll <Sprite>("Sprites/Map/torch"), "InstalledObject", 50); spawnAddDictionary.Add(3, new InstalledObjectSpawnAdditionalInfo(3, new List <GameObject>() { AdditionalsHolder.Instance.AllAdditionals[0] })); //Bed objs[4] = new InstalledObjectInfo(4, "Bed", FurnitureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd], 1, 2); sprites [4] = new SpriteHolder(Resources.LoadAll <Sprite> ("Sprites/Map/Forest Assets/Campsite/Bedroll 2"), "InstalledObject", 50); //Objects over multiple tiles! //Object with job list that only opens when you select a villager //Table objs[5] = new InstalledObjectInfo(5, "Table", FurnitureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd]); sprites [5] = new SpriteHolder(Resources.LoadAll <Sprite>("Sprites/Map/furnitureSprites")[13], "InstalledObject", 50); //Stock Pile (Tile) objs[6] = new InstalledObjectInfo(6, "Stock Pile", NatureValidation, JobList.JobFunctions[(int)JobList.Jobs.StandardInstallEnd], 1, 1, JobList.MakeTileStockPile, true, 1f); sprites [6] = new SpriteHolder(Resources.Load <Sprite> ("Sprites/stockpilemarker"), "UI", 50); }