Esempio n. 1
0
        /// <summary>
        /// Create a agent for a spawn point and add sp to the spawn data source
        /// </summary>
        void CreateAgent(SpawnDataSource ds, SpawnPoint sp)
        {
            // Create Monster Agent
            if (sp as MonsterSpawnPoint != null)
            {
                MonsterSpawnPoint msp = sp as MonsterSpawnPoint;

                if (ds.AddMonster(msp))
                {
                    SceneEntityAgent agent = _createMstAgent(msp, true, null, null, !msp.isDead);
                    msp.agent        = agent;
                    agent.ScenarioId = sp.ID;
                    AddMstDeadAgent(agent);
                }
                else
                {
                    Debug.LogError("Add Monster spawn point error");
                }
            }
            // Create Npc Agent
            else if (sp as NPCSpawnPoint != null)
            {
                NPCSpawnPoint nsp = sp as NPCSpawnPoint;
                if (ds.AddNpc(nsp))
                {
                    SceneEntityAgent agent = new SceneEntityAgent(nsp);
                    nsp.agent        = agent;
                    agent.ScenarioId = sp.ID;
                    SceneMan.AddSceneObj(agent);
                }
                else
                {
                    Debug.LogError("Add npc spawn point error");
                }
            }
            // Create Doodad Agent
            else if (sp as DoodadSpawnPoint != null)
            {
                DoodadSpawnPoint dsp = sp as DoodadSpawnPoint;
                if (ds.AddDoodad(dsp))
                {
                    SceneStaticAgent agent = new SceneStaticAgent(dsp, true);
                    dsp.agent        = agent;
                    agent.ScenarioId = sp.ID;
                    SceneMan.AddSceneObj(agent);
                }
                else
                {
                    Debug.LogError("Add doodad spawn point error");
                }
            }
            // Create Item
            else if (sp as ItemSpwanPoint != null)
            {
                ItemSpwanPoint isp = sp as ItemSpwanPoint;
                if (ds.AddItem(isp))
                {
                    DragArticleAgent agent = DragArticleAgent.PutItemByProroId(isp.Prototype
                                                                               , isp.spawnPos
                                                                               , isp.Scale
                                                                               , isp.Rotation
                                                                               , isp.CanPickup
                                                                               , isp.IsTarget);
                    if (agent != null)
                    {
                        isp.isNew        = false;
                        isp.ItemObjId    = agent.itemDrag.itemObj.instanceId;
                        agent.ScenarioId = sp.ID;
                    }
                }
                else
                {
                    Debug.LogError("Add item spawn point error");
                }
            }
            // Create Effect
            else if (sp as EffectSpwanPoint != null)
            {
            }
        }