Exemplo n.º 1
0
        /// <summary>
        /// Creates an ai-controlled WorldEntity from an EnemyFormationTemplate.
        /// </summary>
        /// <param name="template">The template to use to create the WorldEntity.</param>
        /// <returns></returns>
        public WorldEntity Create(AiFormationTemplate template)
        {
            var formation = _formationFactory.Create(template);

            return(new WorldEntity
            {
                Id = _id++,
                IconUris = new CharacterIconSet(template.IconUris),
                OwnerGuid = GameplayConstants.AiId,
                Name = template.Name,
                ActiveFormation = formation
            });
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates a Formation from an EnemyFormationTemplate.
        /// </summary>
        /// <param name="template">The EnemyFormationTemplate used to create the Formation.</param>
        /// <returns></returns>
        public Formation Create(AiFormationTemplate template)
        {
            var positions = new CombatEntity[GameplayConstants.MaxFormationRows][];
            int leaderId  = -1;

            for (int i = 0; i < template.EntityBases.Length; i++)
            {
                positions[i] = new CombatEntity[GameplayConstants.MaxFormationColumns];
                for (int j = 0; j < template.EntityBases[i].Length; j++)
                {
                    if (template.EntityBases[i][j] != null)
                    {
                        var entity = _combatEntityFactory.Create(template.EntityBases[i][j]);
                        positions[i][j] = entity;
                        if (template.EntityBases[i][j].Id == template.LeaderId && leaderId == -1)
                        {
                            leaderId = entity.Id;
                        }
                    }
                    else
                    {
                        positions[i][j] = null;
                    }
                }
            }

            return(new Formation
            {
                Id = _id++,
                LeaderId = leaderId,
                Name = template.Name,
                OwnerId = GameplayConstants.AiId,
                Positions = positions,
                AiRandomness = template.AiRandomness
            });
        }