void AliveEntityDeathEvent(SkEntity arg1, SkEntity arg2)
        {
            FixedSpawnPointInfo info = null;

            if (SceneEntityCreatorArchiver.Instance._fixedSpawnPointInfos.TryGetValue(_fixedId, out info))
            {
                SceneMan.RemoveSceneObj(info._agent);

                if (info._needCD > 0.0f)
                {
                    MissionManager.Instance.PeTimeToDo(delegate(){
                        if (info._bActive)
                        {
                            SceneMan.RemoveSceneObj(info._agent);
                            SceneMan.AddSceneObj(info._agent);
                        }
                    }, info._needCD, _fixedId);
                }
                else
                {
                    SceneEntityCreatorArchiver.Instance.SetFixedSpawnPointActive(_fixedId, false);
                }
                SceneEntityCreatorArchiver.Instance.GetEntityByFixedSpId(_fixedId).aliveEntity.deathEvent -= AliveEntityDeathEvent;
            }
        }
Exemplo n.º 2
0
        public virtual void OnDestruct()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            if (Entity.hasView)
            {
                if (!IsInvoking("FadeOut"))
                {
                    Invoke("FadeOut", 3f);
                }

                if (!IsInvoking("DelayDestroy"))
                {
                    Invoke("DelayDestroy", 5f);
                }

                DisablePhy();
            }

            if (onDestruct != null)
            {
                onDestruct(Entity);
            }
        }
        IEnumerator DelayBossReborn(SceneEntityPosAgent agent)
        {
            SceneMan.RemoveSceneObj(agent);
            yield return(new WaitForSeconds(240));              // wait 4 min

            SceneMan.AddSceneObj(agent);
        }
Exemplo n.º 4
0
        public virtual void OnActivate()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            //if (Entity.Equals(PeCreature.Instance.mainPlayer))
            //    Debug.LogError("OnActivate £º " + Time.time);

            Profiler.BeginSample("LodActive:" + name);

            CancelInvoke("FadeOut");
            CancelInvoke("DelayDestroy");

            if (!Entity.hasView)
            {
                BuildView();
            }
            else
            {
                FadeIn();
            }

            EnablePhy();

            Entity.SendMsg(EMsg.Lod_Collider_Created);
            if (onActivate != null)
            {
                onActivate(Entity);
            }
            Profiler.EndSample();
        }
 private void ReqReborn(SceneEntityPosAgent agent)
 {
     if (agent.IsIdle)
     {
         if (agent.entity == null || agent.entity.IsDead())
         {
             agent.entity  = null;
             agent.canRide = false;
             SceneMan.RemoveSceneObj(agent);
             SceneMan.AddSceneObj(agent);
         }
         else if (agent.entity != null && agent.entity.monstermountCtrl != null &&
                  agent.entity.monstermountCtrl.ctrlType == ECtrlType.Mount) //Lw2017.2.14:怪物已经被驯服,重新生成
         {
             agent.entity  = null;
             agent.canRide = false;
             //SceneMan.RemoveSceneObj(agent);
             SceneMan.AddSceneObj(agent);
         }
         else
         {
             agent.canRide = false;
             MonsterCmpt mc = agent.Go.GetComponent <MonsterCmpt>();
             if (mc != null)
             {
                 mc.Req_MoveToPosition(agent.Pos, 1, true, SpeedState.Run);
             }
         }
     }
 }
Exemplo n.º 6
0
        public virtual void OnConstruct()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            if (!PeGameMgr.IsMulti && Entity.Field == MovementField.Sky && Entity.gravity > -PETools.PEMath.Epsilon && Entity.gravity < PETools.PEMath.Epsilon)
            {
                CancelInvoke("FadeOut");
                CancelInvoke("DelayDestroy");

                if (!Entity.hasView)
                {
                    BuildView();
                }
                else
                {
                    FadeIn();
                }

                EnablePhy();
            }

            if (onConstruct != null)
            {
                onConstruct(Entity);
            }
        }
Exemplo n.º 7
0
 public override void OnDestroy()
 {
     SceneMan.RemoveSceneObj(this);
     if (onDestroyEntity != null)
     {
         onDestroyEntity(Entity);
     }
 }
Exemplo n.º 8
0
 public void DestroySelf()
 {
     RandomItemMgr.Instance.RemoveRandomItemObj(this);
     if (gameObj != null)
     {
         GameObject.Destroy(gameObj);
     }
     SceneMan.RemoveSceneObj(this);
 }
Exemplo n.º 9
0
 // HP 变化事件
 protected virtual void OnHpChange(float deltaHp, bool isDead)
 {
     if (isDead)
     {
         DragItemAgent item = DragItemAgent.GetById(GetComponent <DragItemLogicCreation>().id);
         SceneMan.RemoveSceneObj(item);
         ItemAsset.ItemMgr.Instance.DestroyItem(itemObject);
     }
 }
Exemplo n.º 10
0
 public void DestroySelf()
 {
     if (gameObj != null)
     {
         GameObject.Destroy(gameObj);
     }
     SceneMan.RemoveSceneObj(this);
     DungeonEntranceLabel.Remove(position);
 }
Exemplo n.º 11
0
        void OnEntityDeath(SkillSystem.SkEntity cur, SkillSystem.SkEntity caster)
        {
            SkAliveEntity skAlive = entity.GetCmpt <Pathea.SkAliveEntity> ();

            if (cur == skAlive)
            {
                scene.Notify(ESceneNoification.MonsterDead, this);
                SceneMan.RemoveSceneObj(this);
            }
        }
Exemplo n.º 12
0
        void OnEntityDeath(SkillSystem.SkEntity cur, SkillSystem.SkEntity caster)
        {
            SkAliveEntity skAlive = entity.GetCmpt <Pathea.SkAliveEntity>();

            if (cur == skAlive)
            {
                scene.Notify(ESceneNoification.DoodadDead, this);
                SceneMan.RemoveSceneObj(this);
                Debug.Log("Doodad Entity id [" + skAlive.GetId() + "] is dead");
            }
        }
Exemplo n.º 13
0
 public void Respawn()
 {
     if (!mIsProcessing)
     {
         if (entity == null || (entity.GetCmpt <SkAliveEntity>() != null && entity.GetCmpt <SkAliveEntity>().isDead))
         {
             entity = null;
             SceneMan.RemoveSceneObj(this);
             SceneMan.AddSceneObj(this);
         }
     }
 }
Exemplo n.º 14
0
 public void CheckDestroyObj()
 {
     if (items.Count() <= 0)
     {
         RandomItemMgr.Instance.RemoveRandomItemObj(this);
         if (gameObj != null)
         {
             GameObject.Destroy(gameObj);
         }
         SceneMan.RemoveSceneObj(this);
     }
 }
Exemplo n.º 15
0
        public override void OnDeactivate()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            if (onDeactivate != null)
            {
                onDeactivate(Entity);
            }
        }
Exemplo n.º 16
0
    void OnDeath(SkillSystem.SkEntity e1, SkillSystem.SkEntity e2)
    {
        _death = true;

        Clear();

        SceneMan.RemoveSceneObj(_agent);

        if (DeathEvent != null)
        {
            DeathEvent(this);
        }
    }
Exemplo n.º 17
0
    // Other methods/property
    void CreateEntityStatic()
    {
        _step = EStep.InCreating;

        DoodadEntityCreator.CreateDoodad(this);
        if (entity == null)
        {
            Debug.LogWarning("[EntityPosAgent]:Failed to create entity " + _type.ToString() + protoId);
        }
        // now doodad's lod(SceneDoodadLodCmpt) would handle doodads, posAgent not needed longer after dooad created.
        SceneMan.RemoveSceneObj(this);
        _step = EStep.Created;
    }
Exemplo n.º 18
0
    public static bool Destory(DragItemAgent item)
    {
        if (null == item)
        {
            return(false);
        }

        SceneMan.RemoveSceneObj(item);

        item.Destroy();

        return(true);
    }
Exemplo n.º 19
0
        public override void OnDestruct()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            if (onDestruct != null)
            {
                onDestruct(Entity);
            }
            DestroyView();
        }
Exemplo n.º 20
0
        public override void OnConstruct()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            BuildView();
            if (onConstruct != null)
            {
                onConstruct(Entity);
            }
        }
 public void CheckDestroyObj()
 {
     if (_itemList.Count <= 0)
     {
         if (gameObject != null)
         {
             RandomItemObj rio = RandomItemMgr.Instance.GetRandomItemObj(genPos);
             if (rio != null)
             {
                 RandomItemMgr.Instance.RemoveRandomItemObj(rio);
                 SceneMan.RemoveSceneObj(rio);
             }
             GameObject.Destroy(gameObject);
         }
     }
 }
Exemplo n.º 22
0
    protected virtual void OnPEDestroy()
    {
        StopAllCoroutines();

        if (null != Runner)
        {
            Runner.InitNetworkLayer(null);
        }

        Pathea.EntityMgr.Instance.Destroy(Id);
        ISceneObjAgent obj = SceneMan.GetSceneObjById(Id);

        if (null != obj)
        {
            SceneMan.RemoveSceneObj(obj);
        }
    }
Exemplo n.º 23
0
 void DestroySelf()
 {
     if (gameObject != null)
     {
         RandomItemObj rio = RandomItemMgr.Instance.GetRandomItemObj(genPos);
         if (rio != null)
         {
             if (rio.type == RandomObjType.MonsterFeces)
             {
                 Pathea.Effect.EffectBuilder.Instance.Register(EffectId.PICK_FECES, null, transform.position, Quaternion.identity);
             }
             RandomItemMgr.Instance.RemoveRandomItemObj(rio);
             SceneMan.RemoveSceneObj(rio);
         }
         GameObject.Destroy(gameObject);
     }
 }
Exemplo n.º 24
0
        public override void OnSuceededToCreate(SceneEntityPosAgent agent)
        {
            LodCmpt entityLodCmpt = agent.entity.lodCmpt;

            if (entityLodCmpt != null)
            {
                entityLodCmpt.onDestruct += (e) => { agent.DestroyEntity(); };
            }
            if (_bsRate >= 0)
            {
                if (agent.entity.aliveEntity != null)
                {
                    agent.entity.aliveEntity.deathEvent += (a, b) => {
                        SceneMan.self.StartCoroutine(DelayBossReborn(agent));
                    };
                }
            }
            if (_bcn != null)
            {
                SceneMan.RemoveSceneObj(agent);
            }
        }
    public void SetFixedSpawnPointActive(int pointID, bool active)
    {
        FixedSpawnPointInfo info = null;

        if (_fixedSpawnPointInfos.TryGetValue(pointID, out info))
        {
            if (PeGameMgr.IsMultiStory)
            {
                if (PlayerNetwork.mainPlayer != null)
                {
                    PlayerNetwork.mainPlayer.RPCServer(EPacketType.PT_AI_SetFixActive, pointID, active);
                }
            }
            else
            {
                info._bActive = active;
                if (null != SceneEntityCreatorArchiver.Instance.GetEntityByFixedSpId(pointID))
                {
                    if (!active)
                    {
                        SceneMan.RemoveSceneObj(info._agent);
                    }
                    else
                    {
                        ReqReborn(info._agent);
                    }
                }
                else
                {
                    if (active)
                    {
                        info._agent.canRide = false;
                        SceneMan.AddSceneObj(info._agent);
                    }
                }
            }
        }
    }
Exemplo n.º 26
0
    public override void OnActivate()
    {
        base.OnActivate();

        if (_entityBcn != null)
        {
            Debug.LogError("[MonsterBeaconItem]:MonsterBeacon has existed.");
            return;
        }
        //Put off aispawn tower defense
        int entityId = GameConfig.IsMultiMode ? id : -1;

        _entityBcn = EntityMonsterBeacon.CreateMonsterBeaconByTDID(m_monsterBeaconId, transform, new TowerInfoUIData(), entityId, null, -1, true);
        if (_entityBcn != null)
        {
            _entityBcn.handlerNewWave += OnNewWave;
            _agent = DragItemAgent.GetById(id);
            if (_agent != null)
            {
                SceneMan.RemoveSceneObj(_agent);                        // Not been managed by sceneMan
            }
        }
    }
Exemplo n.º 27
0
        public virtual void OnDeactivate()
        {
            if (Equals(null))
            {
                SceneMan.RemoveSceneObj(this);
                return;
            }

            //if (Entity.Equals(PeCreature.Instance.mainPlayer))
            //    Debug.LogError("OnDeactivate £º " + Time.time);

            //			if(Entity.IsDeath())
            //				DestroyView();

            if (PeGameMgr.IsMulti || Entity.Field != MovementField.Sky)
            {
                if (!Entity.Equals(PeCreature.Instance.mainPlayer))
                {
                    if (!IsInvoking("FadeOut"))
                    {
                        Invoke("FadeOut", 3f);
                    }
                    if (!IsInvoking("DelayDestroy"))
                    {
                        Invoke("DelayDestroy", 5f);
                    }
                }

                DisablePhy();
            }

            Entity.SendMsg(EMsg.Lod_Collider_Destroying);
            if (onDeactivate != null)
            {
                onDeactivate(Entity);
            }
        }
Exemplo n.º 28
0
 public override void OnSuceededToCreate(SceneEntityPosAgent agent)
 {
     SceneMan.RemoveSceneObj(agent);
 }
        /// <summary>
        /// Accept the notification for Views.
        /// </summary>
        /// <param name="msg_type">Msg_type.</param>
        /// <param name="data">Data.</param>
        public void OnNotification(ESceneNoification msg_type, params object[] data)
        {
            SpawnDataSource ds = mBinder.Get <SpawnDataSource>();

            switch (msg_type)
            {
            case ESceneNoification.SceneBegin:
                if (PeGameMgr.IsSingle)
                {
                    CreateAgents(ds);
                }
                break;

            case ESceneNoification.CreateAgent:
            {
                if (data.Length == 0)
                {
                    Debug.LogError("Create Agent notification parameters error");
                    break;
                }

                SpawnPoint sp = data[0] as SpawnPoint;

                CreateAgent(ds, sp);
            }
            break;

                #region SPAWNPOINT_CASE
            case ESceneNoification.RemoveSpawnPoint:
            {
                if (data.Length == 0)
                {
                    Debug.LogError("Remove SpawnPoint notification parameters error");
                    break;
                }

                SpawnPoint sp = data[0] as SpawnPoint;
                // Monster
                if (sp as MonsterSpawnPoint != null)
                {
                    MonsterSpawnPoint msp = sp as MonsterSpawnPoint;

                    // Destroy Entity First
                    if (msp.EntityID != -1)
                    {
                        CreatureMgr.Instance.Destory(sp.EntityID);
                    }

                    // Remove Agent
                    if (msp.agent != null)
                    {
                        SceneMan.RemoveSceneObj(msp.agent);
                    }

                    // Remove Spawn Point
                    ds.RemoveMonster(msp.ID);
                }
                // Npc
                else if (sp as NPCSpawnPoint != null)
                {
                    NPCSpawnPoint nsp = sp as NPCSpawnPoint;

                    // Destroy Entity First
                    if (nsp.EntityID != -1)
                    {
                        CreatureMgr.Instance.Destory(sp.EntityID);
                    }

                    if (nsp.agent != null)
                    {
                        SceneMan.RemoveSceneObj(nsp.agent);
                    }

                    ds.RemoveMonster(nsp.ID);
                }
                // Doodad
                else if (sp as DoodadSpawnPoint != null)
                {
                    DoodadSpawnPoint dsp = sp as DoodadSpawnPoint;

                    if (dsp.EntityID != -1)
                    {
                        CreatureMgr.Instance.Destory(sp.EntityID);
                    }

                    if (dsp.agent != null)
                    {
                        SceneMan.RemoveSceneObj(dsp.agent);
                    }

                    ds.RemoveMonster(dsp.ID);
                }
                // Item
                else if (sp as ItemSpwanPoint != null)
                {
                    ItemSpwanPoint isp = sp as ItemSpwanPoint;

                    List <ISceneObjAgent> agents = SceneMan.GetSceneObjs <DragArticleAgent>();
                    for (int i = 0; i < agents.Count; i++)
                    {
                        DragArticleAgent drag_agent = agents[i] as DragArticleAgent;
                        if (drag_agent != null && drag_agent.itemDrag.itemObj.instanceId == isp.ItemObjId)
                        {
                            ItemAsset.ItemMgr.Instance.DestroyItem(isp.ItemObjId);
                            SceneMan.RemoveSceneObj(drag_agent);
                            break;
                        }
                    }
                }
            }
            break;

            case ESceneNoification.EnableSpawnPoint:
            {
                if (data.Length < 1)
                {
                    Debug.LogError("Enable SpawnPoint notification parameters error");
                    break;
                }

                SpawnPoint sp     = data[0] as SpawnPoint;
                bool       enable = (bool)data[1];

                if (sp as MonsterSpawnArea != null)
                {
                    MonsterSpawnArea area = sp as MonsterSpawnArea;
                    for (int i = 0; i < area.Spawns.Count; i++)
                    {
                        for (int j = 0; j < area.Spawns[i].spawnPoints.Count; j++)
                        {
                            area.Spawns[i].spawnPoints[j].Enable = enable;
                        }
                    }
                }
                sp.Enable = enable;
            }
            break;
                #endregion

                #region CREATE_CASE
            case ESceneNoification.CreateMonster:
            {
                if (data.Length < 2)
                {
                    Debug.LogError("The [CreateMonster] notification parameter is wrong");
                    break;
                }

                SceneEntityAgent agent = data[0] as SceneEntityAgent;
                bool             save  = (bool)data[1];

                bool need_check = true;
                if (data.Length > 2)
                {
                    need_check = (bool)data[2];
                }

                Vector3 pos = agent.spawnPoint.spawnPos;
                if (!need_check || CheckPos(out pos, pos, agent.spawnPoint, agent.spawnArea))
                {
                    agent.spawnPoint.spawnPos = pos;

                    // Is Group Root?
                    if (agent.groupPoints != null)
                    {
                        agent.entityGp          = CreateMonsterGroup(agent.spawnPoint, agent.groupPoints, agent.spawnArea);
                        agent.entity            = agent.entityGp;
                        agent.entity.scenarioId = agent.ScenarioId;

                        break;
                    }

                    agent.entity            = CreateMonster(agent.mstPoint, save);
                    agent.entity.scenarioId = agent.ScenarioId;

                    if (agent.entityGp != null)
                    {
                        agent.entity.transform.parent = agent.entityGp.transform;
                    }

                    Debug.Log("Create the Monster ");
                }
            } break;

            case ESceneNoification.CreateNpc:
            {
                if (data.Length == 0)
                {
                    Debug.LogError("The [CreateNpc] notification parameters are wrong");
                    break;
                }

                SceneEntityAgent agent = data[0] as SceneEntityAgent;

                bool need_check = true;
                if (data.Length > 1)
                {
                    need_check = (bool)data[1];
                }

                Vector3 pos = agent.spawnPoint.spawnPos;
                if (!need_check || CheckPos(out pos, pos, agent.spawnPoint, agent.spawnArea))
                {
                    agent.spawnPoint.spawnPos = pos;
                    agent.entity = CreateNpc(agent.spawnPoint as NPCSpawnPoint);

                    if (agent.entity == null)
                    {
                        agent.entity.scenarioId = agent.ScenarioId;
                        Debug.LogError("[SceneEntityCreator]Failed to create npc:" + agent.protoId);
                    }
                    else
                    {
                        Debug.Log("Create the Npc [" + agent.entity.Id.ToString() + "]");
                    }
                }
            } break;

            case ESceneNoification.CreateDoodad:
            {
                if (data.Length < 2)
                {
                    Debug.LogError("The [CreateNpc] notification parameters are wrong");
                    break;
                }

                SceneStaticAgent agent = data[0] as SceneStaticAgent;
                //bool is_save = (bool)data[1];

                agent.entity            = CreadteDoodad(agent.spawnPoint as DoodadSpawnPoint, agent.IsSave);
                agent.entity.scenarioId = agent.ScenarioId;
            }
            break;
                #endregion


                #region DEAD_CASE
            case ESceneNoification.MonsterDead:
            {
                if (data.Length == 0)
                {
                    Debug.LogError("The [MonsterDead] notification parameters are wrong ");
                    break;
                }

                SceneEntityAgent agent = data[0] as SceneEntityAgent;

                MonsterSpawnPoint msp = agent.mstPoint;
                if (msp == null)
                {
                    Debug.LogError("he [MonsterDead] notification : the point is not a MonsterSpawnPoint");
                    break;
                }


                msp.isDead   = true;
                msp.EntityID = -1;

                Debug.Log("The monster [" + agent.entity.Id.ToString() + "] is Dead");
                agent.entity = null;

                if (agent.spawnArea != null)
                {
                    if (agent.spawnArea.MaxRespawnCount != 0)
                    {
                        AddMstDeadAgent(agent);
                    }
                }
                else if (msp.MaxRespawnCount != 0)
                {
                    AddMstDeadAgent(agent);
                }
            } break;

            case ESceneNoification.DoodadDead:
            {
                if (data.Length == 0)
                {
                    Debug.LogError("The [DoodadDead] notification parameters are wrong ");
                    break;
                }

                SceneStaticAgent agent = data[0] as SceneStaticAgent;

                DoodadSpawnPoint dsp = agent.spawnPoint as DoodadSpawnPoint;
                if (dsp == null)
                {
                    Debug.LogError("he [DoodadDead] notification : the point is not a DoodadSpawnPoint");
                    break;
                }

                dsp.isDead   = true;
                dsp.EntityID = -1;
            }
            break;

                #endregion
            case ESceneNoification.EntityDestroy:
            {
                if (data.Length < 2)
                {
                    Debug.LogError("The [EntityDestroy] notification parameters are wrong ");
                    break;
                }

                SpawnPoint sp     = data[0] as SpawnPoint;
                PeEntity   entity = data[1] as PeEntity;

                bool remove_data = false;
                if (data.Length > 2)
                {
                    remove_data = (bool)data[2];
                }

                if (remove_data)
                {
                    entity.Export();
                    CreatureMgr.Instance.Destory(sp.EntityID);
                    sp.EntityID = -1;
                }
                else
                {
                    CreatureMgr.Instance.DestroyAndDontRemove(sp.EntityID);
                }
            } break;
            }
        }
Exemplo n.º 30
0
 public virtual void OnFailedToCreate(SceneEntityPosAgent agent)
 {
     SceneMan.RemoveSceneObj(agent);
 }