private void NextState(object sender, EventArgs eventArgs) { Sex m_Playersex = (Sex)m_sexIndex; Dictionary <NeedIndex, EntityNeed> needs = EntityNeed.GetFullRandomisedNeeds(); EntityTemplate humanTemplate = EntityTemplateHandler.Get("Human"); m_Player = WorldState.EntityHandler.Create(humanTemplate, needs, 1, m_Jobs[m_JobIndex], m_Playersex, Sexuality.Bisexual, new UnityEngine.Vector2Int(-1, -1), ObjectIcons.GetSprites("Jobs", m_Jobs[m_JobIndex].name).ToList(), null); m_Player.PlayerControlled = true; m_Player.AddItem(new ItemInstance(ItemHandler.GetSpecificItem("Lantern"), new UnityEngine.Vector2Int(-1, -1), true)); }
public ItemInstance(BaseItemType type, Vector2Int position, bool identified, string interactionFile = null) : base(type.UnidentifiedName, type.GetHitPoints(), position, ObjectIcons.GetSprites(type.Category, type.UnidentifiedName), type.Category, false) { this.m_Type = type; this.Move(position); this.m_HitPoints = type.GetHitPoints(); this.m_HitPointsRemaining = this.m_HitPoints; this.GUID = GUIDManager.AssignGUID(); this.Identified = identified; //chosenIcon = RNG.Roll(0, m_Icons.Length - 1); this.m_Contents = new List <long>(); m_InteractionFile = interactionFile; }
public List <JoyObject> GenerateWalls(WorldTile[,] worldTiles) { List <JoyObject> walls = new List <JoyObject>(); for (int i = 0; i < m_UntreatedTiles.GetLength(0); i++) { for (int j = 0; j < m_UntreatedTiles.GetLength(1); j++) { if (m_UntreatedTiles[i, j] == GeneratorTileType.Perimeter || m_UntreatedTiles[i, j] == GeneratorTileType.Wall || m_UntreatedTiles[i, j] == GeneratorTileType.None) { walls.Add(new JoyObject("Surround", 1, new Vector2Int(i, j), ObjectIcons.GetSprites("Walls", "Surround"), "Wall", false, true)); } } } return(walls); }
public static List <Entity> PlaceEntities(WorldInstance worldRef, List <string> entityTypes) { List <Entity> entities = new List <Entity>(); List <EntityTemplate> templates = EntityTemplateHandler.Templates; templates = templates.Where(x => entityTypes.Contains(x.CreatureType)).ToList(); int numberToPlace = (worldRef.Tiles.GetLength(0) * worldRef.Tiles.GetLength(1)) / 50; List <Vector2Int> availablePoints = new List <Vector2Int>(); for (int i = 0; i < worldRef.Tiles.GetLength(0); i++) { for (int j = 0; j < worldRef.Tiles.GetLength(1); j++) { Vector2Int point = new Vector2Int(i, j); if (PhysicsManager.IsCollision(point, point, worldRef) == PhysicsResult.None && point != worldRef.SpawnPoint) { availablePoints.Add(point); } } } for (int i = 0; i < numberToPlace; i++) { int pointIndex = RNG.Roll(0, availablePoints.Count - 1); int entityIndex = RNG.Roll(0, templates.Count - 1); Entity newEntity = null; if (templates[entityIndex].Sentient) { CultureType culture = CultureHandler.Get(templates[entityIndex].CreatureType); JobType jobType = JobHandler.GetRandom(); Dictionary <string, int> jobLevels = new Dictionary <string, int>(); jobLevels.Add(jobType.name, 1); newEntity = WorldState.EntityHandler.Create(templates[entityIndex], EntityNeed.GetFullRandomisedNeeds(), 1, jobType, culture.ChooseSex(), culture.ChooseSexuality(), new Vector2Int(-1, -1), ObjectIcons.GetSprites(templates[entityIndex].Tileset, templates[entityIndex].CreatureType).ToList(), null); } else { CultureType culture = CultureHandler.Get(templates[entityIndex].CreatureType); JobType jobType = JobHandler.GetRandom(); Dictionary <string, int> jobLevels = new Dictionary <string, int>(); jobLevels.Add(jobType.name, 1); newEntity = WorldState.EntityHandler.Create(templates[entityIndex], EntityNeed.GetBasicRandomisedNeeds(), 1, jobType, culture.ChooseSex(), culture.ChooseSexuality(), new Vector2Int(-1, -1), ObjectIcons.GetSprites(templates[entityIndex].Tileset, templates[entityIndex].CreatureType).ToList(), null); } newEntity.Move(availablePoints[pointIndex]); newEntity.MyWorld = worldRef; entities.Add(newEntity); availablePoints.RemoveAt(pointIndex); } return(entities); }
// Use this for initialization void Start() { InitialiseEverything(); m_StateManager = new StateManager(); Entity thief = WorldState.EntityHandler.Create(EntityTemplateHandler.Get("Human"), EntityNeed.GetFullRandomisedNeeds(), 1, JobHandler.Get("Thief"), Sex.Neutral, Sexuality.Bisexual, Vector2Int.zero, ObjectIcons.GetSprites("Jobs", "Thief"), null); thief.PlayerControlled = true; m_StateManager.ChangeState(new WorldCreationState(thief)); GameObject.Find("NeedsText").GetComponent <GUINeedsAlert>().SetPlayer(thief); }