void CreateMonsters() { MonsterPrototype prototype = new MonsterPrototype("Snake Monster", 8, 15, 4, CombatType.Paper); CreateMonster(prototype, 1, 0, 16, 5); //CreateMonster(prototype, 1, 0, 15, 1); }
GameObject CreateMonster(MonsterPrototype prototype, int spriteX, int spriteY, int posX, int posY) { Monster monsterComponent = new Monster(GlobalScripts, Map[posX, posY], prototype); Player player = GlobalScripts.GetComponent <Player>(); GameObject monster = new GameObjectBuilder() .AddComponent(new Transform(new Vector2(Map.Size * posX, Map.Size * posY))) .AddComponent(new SpriteRenderer(Monsters)) .AddComponent(CreateAnimator(Monsters, spriteX, spriteY)) .AddComponent(CreateAnimationStateMachine(Map.Size)) .AddComponent(monsterComponent) .AddComponent(new Dimentions(0, 0, Map.Size, Map.Size)) .AddComponent(new Hoverable(() => player.RequestInfoboxOverride( "<" + monsterComponent.Species + ">" + Environment.NewLine + "HP: " + monsterComponent.HitPoints.Remaining + " / " + monsterComponent.HitPoints.Max + Environment.NewLine + "Speed: " + monsterComponent.Speed.Max + Environment.NewLine + "Strength: " + monsterComponent.Strength + Environment.NewLine + "Possible Types: " + string.Join(", ", monsterComponent.Species.EnemyAwareness), monsterComponent), () => player.InvalidateInfoboxOverride(monsterComponent))) .Register(this); Map[posX, posY].OccupiedBy = monster; if (Map[posX, posY].Room.View != Room.Visibility.Visible) { monster.GetComponent <SpriteRenderer>().Active = false; } GlobalScripts.GetComponent <TurnManager>().Monsters.Add(monsterComponent); return(monster); }
public void SpawnMonster(int spawnpointId, MonsterPrototype monsterPrototype) { SoundController.Instance.PlaySound(SoundController.Instance.Popup); var monsterPrefab = PrefabManager.Instance.GetPrefab(monsterPrototype.PrefabName); var spawnPoint = Game.CurrentLevel.SpawnPoints.FirstOrDefault(s => s.Id == spawnpointId); if (monsterPrefab == null || spawnPoint == null) { Debug.LogWarning("Level.SpawnMonster ccoun't find monster prefab " + monsterPrototype.PrefabName + "or spawnpoint " + spawnpointId); return; } var ModelScale = MapRenderer.Instance.ModelScale; var position = new Vector3(spawnPoint.X * ModelScale, MapRenderer.Instance.GetHeight(spawnPoint.X, spawnPoint.Z), spawnPoint.Z * ModelScale); var monster = GameObject.Instantiate(monsterPrefab, position, Quaternion.identity); var monsterController = monster.AddComponent <MonsterController>(); monsterController.MonsterPrototype = monsterPrototype; monsterController.CurrentPath = spawnPoint.GetAnyDestinationPath(Game.CurrentLevel); monsterController.Speed = monsterPrototype.Speed; monsterController.Hp = monsterPrototype.Hp; monsterController.AddHealthBar(); CurrentMonsters.Add(monster); }
public Monster(GameObject globalScripts, MapNode position, MonsterPrototype prototype) { CM = globalScripts.GetComponent <CombatManager>(); Tile = position; Speed = new Status(prototype.Speed); HitPoints = new Status(prototype.HitPoints); Strength = prototype.Strength; Type = prototype.Type; Species = prototype; CurrentState = new Patrolling(this, globalScripts.GetComponent <TurnManager>().Heroes); }