Example #1
0
        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);
        }
Example #2
0
        GameObject CreateItem(Action <Character> effect, string description, int spriteX, int spriteY, int posX, int posY)
        {
            Player player        = GlobalScripts.GetComponent <Player>();
            Item   itemComponent = new Item(effect);

            GameObject item = new GameObjectBuilder()
                              .AddComponent(new Transform(new Vector2(Map.Size * posX, Map.Size * posY)))
                              .AddComponent(new SpriteRenderer(Items, new Rectangle(Map.Size * spriteX, Map.Size * spriteY, Map.Size, Map.Size)))
                              .AddComponent(itemComponent)
                              .AddComponent(new Dimentions(0, 0, Map.Size, Map.Size))
                              .AddComponent(new Hoverable(() => player.RequestInfoboxOverride(description, itemComponent),
                                                          () => player.InvalidateInfoboxOverride(itemComponent)))
                              .Register(this);

            Map[posX, posY].OccupiedBy = item;

            if (Map[posX, posY].Room.View != Room.Visibility.Visible)
            {
                item.GetComponent <SpriteRenderer>().Active = false;
            }

            return(item);
        }