AddNpc() public method

public AddNpc ( Npc npc ) : void
npc Npc
return void
Ejemplo n.º 1
0
        private void CreateNpc(NpcGroup group, NpcDef npcDef, Character character, int order)
        {
            Vector3     spawnPosition = SpawnPoint.Instance().GetObjectSpawnPoint(gameObject);
            GameObject  prefab        = GameEntityFactory.instance.GetGameEntityPrefab(npcDef.prefabName);
            IGameEntity gameEntity    = CreateGameEntity(character.playerId, character, spawnPosition, prefab);
            Npc         npc           = gameEntity.GetGameObject().AddComponent <Npc>() as Npc;

            npc.group      = group;
            npc.gameEntity = gameEntity;

            if (order == 0)
            {
                group.SetLeader(npc);
            }
            npc.order = order;
            npc.SetNpcDef(npcDef);
            group.AddNpc(npc);
            gameEntities.Add(gameEntity);
            characterIdToGameEntity[character.id]          = gameEntity;
            entityIdToGameEntity[gameEntity.GetEntityId()] = gameEntity;
        }
Ejemplo n.º 2
0
        private void CreateNpc(NpcGroup group, NpcDef npcDef, Character character, int order)
        {
            Vector3 spawnPosition = SpawnPoint.Instance().GetObjectSpawnPoint(gameObject);
            GameObject prefab = GameEntityFactory.instance.GetGameEntityPrefab(npcDef.prefabName);
            IGameEntity gameEntity = CreateGameEntity(character.playerId, character, spawnPosition, prefab);
            Npc npc = gameEntity.GetGameObject().AddComponent<Npc>() as Npc;
            npc.group = group;
            npc.gameEntity = gameEntity;

            if (order == 0) {
                group.SetLeader(npc);
            }
            npc.order = order;
            npc.SetNpcDef(npcDef);
            group.AddNpc(npc);
            gameEntities.Add(gameEntity);
            characterIdToGameEntity[character.id] = gameEntity;
            entityIdToGameEntity[gameEntity.GetEntityId()] = gameEntity;
        }