Exemplo n.º 1
0
        public static Entity ConstructEntityFromCharacterData(HexCoords position, StarEntity character, Guid playerId, Hub simulationHub)
        {
            var state = new StateComponent();
            var stats = new StatsComponent()
            {
                Health        = character.Health,
                AttackRange   = character.AttackRange,
                Armor         = character.Armor,
                MagicArmor    = character.MagicResist,
                AttackSpeed   = character.AttackSpeed,
                MovementSpeed = character.Movespeed,
                AttackPower   = character.AttackDamage,
                Name          = character.Name,
                StarLevel     = character.StarLevel
            };

            return(new Entity(
                       new LocationComponent()
            {
                StartingCoords = position
            },
                       new TeamComponent()
            {
                Team = playerId
            },
                       stats,
                       new SpellComponent(),
                       new MovementComponent(simulationHub, stats),
                       new AttackComponent(simulationHub, state, stats),
                       state
                       ));
        }
Exemplo n.º 2
0
        public void Purchase(int shopIndex)
        {
            if (shopIndex >= 0 && shopIndex < 5)
            {
                if (Gold >= 0)
                {
                    Gold -= 0;

                    // Have to verify a character is at that index still
                    var character = Shop[shopIndex];
                    if (!(character is null))
                    {
                        Shop[shopIndex] = null;
                        var starEntity = new StarEntity(character);
                        var index      = Bench.Add(starEntity);
                        if (!(index is null))
                        {
                            Hub.Default.Publish(new UnitPurchased {
                                connection = Connection,
                                shopIndex  = shopIndex,
                                name       = starEntity.Name,
                                location   = new BenchLocation()
                                {
                                    seat = index.Value
                                },
                            });
                            TryCombineUnits(starEntity);
                        }
                        else
                        {
                            Logger.Error("Failed to add a unit to the bench because there were no open seats.");
                        }
                    }
                    else
                    {
                        Logger.Error("Someone tried to request a shop index that doesn't have a character.");
                    }
                }