Esempio n. 1
0
    private void onShieldDrag(GameObject go, Vector2 delta)
    {
        BaseScene       Base   = SceneManager.Instance.GetCurScene();
        SceneObjManager objMng = Base.GetSceneObjManager();
        UIScrollBar     Bar    = go.GetComponentInChildren <UIScrollBar>() ? go.GetComponentInChildren <UIScrollBar>() : go.GetComponentInParent <UIScrollBar>();

        if (null == Bar || null == objMng)
        {
            return;
        }

        if (0.5 > Bar.value)
        {
            objMng.IsDelete = true;
            Base.RemoveAllGhost();
        }
        else
        {
            objMng.IsDelete = false;
            if (!objMng.HasObjectByAlias(Base.GhostObjects()[0].alias))
            {
                Base.AddAllGhost();
            }
        }
    }
Esempio n. 2
0
        private void RegisterLoaderForSmallMap(Contexts contexts)
        {
            SceneObjManager sm = new SceneObjManager();

            contexts.session.commonSession.LevelManager.SceneLoaded   += (scene, type) => sm.OnSceneLoaded_SmallMap(scene);
            contexts.session.commonSession.LevelManager.SceneUnloaded += scene => sm.OnSceneUnloaded(scene);
        }
    /// <summary>
    /// 使场景变暗
    /// </summary>
    /// <param name="excludeobjs"></param>
    public void DarkenScene(uint[] excludeobjs, float alpha = 0.7f)
    {
        GameObject cameraobj = CameraController.Instance.CurCamera.gameObject;

        //场景变暗
        if (mSceneMask == null)
        {
            mSceneMask = cameraobj.AddComponent <SceenMask>();
        }
        mSceneMask.enabled = true;
        mSceneMask.SetAlpha(alpha);
        //排除某些物体
        SceneObjManager objMng = SceneManager.Instance.GetCurScene().GetSceneObjManager();

        mDarkExcludeList.Clear();
        foreach (uint instid in excludeobjs)
        {
            ObjectBase obj = objMng.FindObject(instid);
            if (obj == null)
            {
                continue;
            }
            VisualObject vObj = obj as VisualObject;
            if (vObj == null)
            {
                continue;
            }
            if (vObj.OriginalMtl == null)
            {
                continue;
            }

            DarkTask task = new DarkTask();
            task.instID = instid;
            List <int> q = new List <int>();
            for (int i = 0; i < vObj.OriginalInstMtl.Length; ++i)
            {
                Material mtl = vObj.OriginalInstMtl[i];
                if (mtl == null)
                {
                    continue;
                }
                q.Add(mtl.renderQueue);
                mtl.renderQueue = 4000 + 1;
            }
            task.queue = q.ToArray();
            mDarkExcludeList.Add(task);
        }
    }
Esempio n. 4
0
    void Awake()
    {
        instance = this;

        GameObject.DontDestroyOnLoad(GameObject.Find("Main"));

        //ApplicationFacade.GetInstance().Init();
        //ApplicationFacade.GetInstance().SendNotification(EventName.GameStart,);

        UIManager.GetInstance().Init();
        LevelManager.GetInstance().Init();
        ResManager.GetInstance().Init(LoadResources ? ResLoadType.LoadByResources : ResLoadType.LoadByAssetsBundle);
        SceneObjManager.GetInstance().Init();
        //CoroutineManager.GetInstance().Init();
    }
Esempio n. 5
0
    private void onShieldClick(GameObject go)
    {
        SceneObjManager objMng = SceneManager.Instance.GetCurScene().GetSceneObjManager();
        UIScrollBar     Bar    = go.GetComponentInChildren <UIScrollBar>() ? go.GetComponentInChildren <UIScrollBar>() : go.GetComponentInParent <UIScrollBar>();

        if (null == Bar || null == objMng)
        {
            return;
        }

        if (objMng.IsDelete)
        {
            Bar.value       = 1;
            objMng.IsDelete = false;
            SceneManager.Instance.GetCurScene().AddAllGhost();
        }
        else
        {
            Bar.value       = 0;
            objMng.IsDelete = true;
            SceneManager.Instance.GetCurScene().RemoveAllGhost();
        }
    }
Esempio n. 6
0
        private void RegisterLoaderForBigMap(Contexts contexts)
        {
            SceneObjManager sm      = new SceneObjManager();
            var             manager = SingletonManager.Get <TriggerObjectManager>();

            if (SharedConfig.IsServer)
            {
//                contexts.session.commonSession.LevelManager.SceneLoaded +=
//                    (scene, type) => sm.OnSceneLoaded_BigMap(scene);
//                contexts.session.commonSession.LevelManager.SceneUnloaded += (scene) => sm.OnSceneUnloaded(scene);
                contexts.session.commonSession.LevelManager.AfterGoLoaded    += gameObj => manager.OnMapObjLoaded(gameObj, gameObj.SceneObjAttr.Id);
                contexts.session.commonSession.LevelManager.BeforeGoUnloaded += gameObj => manager.OnMapObjUnloaded(gameObj);
            }
            else
            {
                contexts.session.commonSession.LevelManager.AfterGoLoaded += gameObj =>
                {
                    var id = gameObj.SceneObjAttr.Id;
                    manager.OnMapObjLoaded(gameObj, id);
                };
                contexts.session.commonSession.LevelManager.BeforeGoUnloaded += gameObj => manager.OnMapObjUnloaded(gameObj);
            }
        }
    public void RecoverScene()
    {
        if (mSceneMask != null)
        {
            mSceneMask.enabled = false;
        }
        SceneObjManager objMng = SceneManager.Instance.GetCurScene().GetSceneObjManager();

        //还原场景中的物体的渲染队列
        foreach (DarkTask task in mDarkExcludeList)
        {
            ObjectBase obj = objMng.FindObject(task.instID);
            if (obj == null)
            {
                continue;
            }
            VisualObject vObj = obj as VisualObject;
            if (vObj == null)
            {
                continue;
            }
            if (task.queue == null || vObj.OriginalInstMtl == null || task.queue.Length != vObj.OriginalInstMtl.Length)
            {
                continue;
            }
            for (int i = 0; i < vObj.OriginalInstMtl.Length; ++i)
            {
                Material mtl = vObj.OriginalInstMtl[i];
                if (mtl == null)
                {
                    continue;
                }
                mtl.renderQueue = task.queue[i];
            }
        }
        mDarkExcludeList.Clear();
    }
Esempio n. 8
0
    protected override void DieAward(uint killerid)
    {
        if (mRes == null)
        {
            return;
        }

        // 掉货币
        if (mRes.dropMoney > 0 && mRes.dropMoneyWeight > 0)
        {
            int rand = Random.Range(0, DropManager.MAX_WEIGHT);
            if (mRes.dropMoneyWeight > rand)
            {
                if (mRes.dropMoneyPickId < 0 || !DataManager.PickTable.ContainsKey(mRes.dropMoneyPickId))
                {
                    if (killerid != uint.MaxValue)
                    {
                        ObjectBase obj = PlayerController.Instance.GetControlObj();
                        if (obj != null && obj.InstanceID == killerid)
                        {
                            PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                            if (pdm != null)
                            {
                                //  pdm.ChangeProceeds(ProceedsType.Money_Game, mRes.dropMoney);
                            }
                        }
                    }
                }
                else
                {// 掉进场景
                    List <PickInitParam> paramList = new List <PickInitParam>();
                    if (SceneObjManager.CreatePickInitParam(Pick.PickType.MONEY, mRes.dropMoneyPickId, mRes.dropMoney, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, false))
                    {
                        foreach (PickInitParam param in paramList)
                        {
                            mScene.CreateSprite(param);
                        }
                    }
                }
            }
        }

        // 掉buff
        if (mRes.buffDropBoxId >= 0)
        {
            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam(Pick.PickType.BUFF, -1, mRes.buffDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
            {
                foreach (PickInitParam param in paramList)
                {
                    mScene.CreateSprite(param);
                }
            }
        }

        // 掉道具
        if (mRes.itemDropBoxId >= 0)
        {
            if (mRes.isDropOnGround > 0)
            {// 掉地上
                List <PickInitParam> paramList = new List <PickInitParam>();
                if (SceneObjManager.CreatePickInitParam(Pick.PickType.ITEM, -1, mRes.itemDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
                {
                    foreach (PickInitParam param in paramList)
                    {
                        mScene.CreateSprite(param);
                    }
                }
            }
//             else
//             {
//                 ArrayList itemList = new ArrayList();
//                 if (DropManager.Instance.GenerateDropBox(mRes.itemDropBoxId, out itemList))
//                 {
//                     foreach (DropBoxItem item in itemList)
//                     {
//                         ItemTableItem itemres = ItemManager.GetItemRes(item.itemid);
//                         if (itemres == null)
//                             continue;
//
//                         if (killerid != uint.MaxValue)
//                         {
//                             ObjectBase obj = PlayerController.Instance.GetControlObj();
//                             if (obj != null && obj.InstanceID == killerid)
//                             {
//                                 PlayerDataModule pdm = ModuleManager.Instance.FindModule<PlayerDataModule>();
//                                 if (pdm != null)
//                                 {
//                                     //pdm.CreateItemUnreal(item.itemid, PackageType.Pack_Bag);
//                                 }
//                             }
//                         }
//                     }
//                 }
//             }
        }
    }
Esempio n. 9
0
    public override void HpDamageAward(uint objtarget, int time)
    {
        if (mRes == null)
        {
            return;
        }

        if (uint.MaxValue == objtarget)
        {
            return;
        }

        if (0 == cdTime)
        {
            cdTime = time * 1000;
        }
        else
        {
            return;
        }

        // 掉货币
        if (mRes.dropMoney > 0 && mRes.dropMoneyWeight > 0)
        {
            int rand = Random.Range(0, DropManager.MAX_WEIGHT);
            if (mRes.dropMoneyWeight > rand)
            {
                List <PickInitParam> paramList = new List <PickInitParam>();
                if (SceneObjManager.CreatePickInitParam(Pick.PickType.MONEY, mRes.dropMoneyPickId, mRes.dropMoney, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, false))
                {
                    foreach (PickInitParam param in paramList)
                    {
                        mScene.CreateSprite(param);
                    }
                }
            }
        }

        // 掉buff
        if (mRes.buffDropBoxId >= 0)
        {
            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam(Pick.PickType.BUFF, -1, mRes.buffDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
            {
                foreach (PickInitParam param in paramList)
                {
                    mScene.CreateSprite(param);
                }
            }
        }

        // 掉道具
        if (mRes.itemDropBoxId >= 0)
        {
            if (mRes.isDropOnGround > 0)
            {            // 掉地上
                List <PickInitParam> paramList = new List <PickInitParam>();
                if (SceneObjManager.CreatePickInitParam(Pick.PickType.ITEM, -1, mRes.itemDropBoxId, GetPosition(), GetDirection(), out paramList, true, Pick.FlyType.FLY_OUT, true))
                {
                    foreach (PickInitParam param in paramList)
                    {
                        mScene.CreateSprite(param);
                    }
                }
            }
            else
            {
                ArrayList itemList = new ArrayList();
                if (DropManager.Instance.GenerateDropBox(mRes.itemDropBoxId, out itemList))
                {
                    foreach (DropBoxItem item in itemList)
                    {
                        ItemTableItem itemres = ItemManager.GetItemRes(item.itemid);
                        if (itemres == null)
                        {
                            continue;
                        }

                        ObjectBase obj = PlayerController.Instance.GetControlObj();
                        if (obj != null)
                        {
                            PlayerDataModule pdm = ModuleManager.Instance.FindModule <PlayerDataModule>();
                            if (pdm != null)
                            {
                                //pdm.CreateItemUnreal(item.itemid, PackageType.Pack_Bag);
                            }
                        }
                    }
                }
            }
        }
    }
Esempio n. 10
0
    private bool doSlowCreate(bool killAll)
    {
        if (slowCreateIds.Count < 1)
        {
            return(false);
        }

        GrowthTriggerInfo info = slowCreateIds[0] as GrowthTriggerInfo;

        if (info.type == "NPC")
        {
            NpcInitParam npcParam = new NpcInitParam();
            npcParam.npc_res_id = info.resId;
            float y = mScene.GetHeight(info.x, info.z);
            npcParam.init_pos = new Vector3(info.x, y, info.z);
            npcParam.init_dir = info.dir;
            npcParam.alias    = info.alias;
            npcParam.talk_id  = info.talkID;

            ObjectBase obj = mScene.CreateSprite(npcParam);
            if (obj == null)
            {
                GameDebug.LogError("创建Npc失败。npcId:" + info.resId);
                return(false);
            }

            if ("ghost" == info.alias)
            {
                mScene.GhostObjects().Add(info);
            }

            if (obj != null)
            {
                if (killAll)
                {
                    cacheIdKillAll.Add(obj.InstanceID);
                }
                else
                {
                    cacheId.Add(obj.InstanceID);
                }
            }
        }
        else if (info.type == "PICK")
        {
            PickGrowthTriggerInfo pickinfo = info as PickGrowthTriggerInfo;

            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam((Pick.PickType)(System.Enum.Parse(typeof(Pick.PickType), pickinfo.picktype.ToString())),
                                                    pickinfo.resId, pickinfo.content, new Vector3(info.x, mScene.GetHeight(info.x, info.z), info.z), info.dir, out paramList, false,
                                                    Pick.FlyType.FLY_OUT, pickinfo.picktype != (int)Pick.PickType.SUPER_WEAPON))
            {
                foreach (PickInitParam param in paramList)
                {
                    param.init_pos.y = mScene.GetHeight(param.init_pos.x, param.init_pos.z);
                    param.alias      = info.alias;
                    ObjectBase obj = mScene.CreateSprite(param);
                    if (obj == null)
                    {
                        GameDebug.LogError("创建Pick失败。pickId:" + info.resId);
                        return(false);
                    }

                    if (obj != null)
                    {
                        if (killAll)
                        {
                            cacheIdKillAll.Add(obj.InstanceID);
                        }
                        else
                        {
                            cacheId.Add(obj.InstanceID);
                        }
                    }
                }
            }
        }
        else if (info.type == "BUILD")
        {
            BuildGrowthTriggerInfo buildinfo = info as BuildGrowthTriggerInfo;

            BuildInitParam buildParam = new BuildInitParam();
            buildParam.build_res_id = info.resId;
            float y = mScene.GetHeight(info.x, info.z);
            buildParam.init_pos      = new Vector3(info.x, y, info.z);
            buildParam.init_dir      = info.dir;
            buildParam.build_barrier = buildinfo.barrier > 0;
            buildParam.alias         = info.alias;

            ObjectBase obj = mScene.CreateSprite(buildParam);
            if (obj == null)
            {
                GameDebug.LogError("创建Building失败。buildId:" + info.resId);
                return(false);
            }

            if (obj != null)
            {
                if (killAll)
                {
                    cacheIdKillAll.Add(obj.InstanceID);
                }
                else
                {
                    cacheId.Add(obj.InstanceID);
                }
            }
        }
        else if (info.type == "PARTICLE")
        {
            Vector3 pos = new Vector3(info.x, mScene.GetHeight(info.x, info.z), info.z);
            mScene.CreateEffect(info.resId, Vector3.one, pos, info.dir, info.alias);
        }

        slowCreateIds.RemoveAt(0);

        if (slowCreateIds.Count < 1)
        {
            return(false);
        }

        return(true);
    }
Esempio n. 11
0
 void Update()
 {
     //Debug.Log("Update");
     SceneObjManager.GetInstance().Update();
 }
Esempio n. 12
0
    // 掉落首次&&通关&&Boss奖励
    public void DropPassAward()
    {
        ObjectBase obj = PlayerController.Instance.GetControlObj();

        if (obj == null)
        {
            return;
        }

        // 首次通关掉落
        PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>();

        if (!module.IsStageHasPassed(mSubRes.resID))
        {
            List <role_dropaward> fpList = StageDataManager.Instance.GetFirstPassAwards();
            if (fpList != null)
            {
                for (int i = 0; i < fpList.Count; ++i)
                {
                    role_dropaward fpAward = fpList[i];
                    if (fpAward != null)
                    {
                        if (fpAward.drop_id_type == 0)
                        {
                            GameDebug.LogWarning("掉落物的Dropbox表不使用ConditionId了.");
                        }
                        else
                        {
                            List <PickInitParam> paramList = new List <PickInitParam>();
                            if (SceneObjManager.CreatePickInitParam(Pick.PickType.ITEM, -1, fpAward.drop_id, obj.GetPosition(), 0, out paramList, true, Pick.FlyType.DROP_DOWN, false))
                            {
                                foreach (PickInitParam param in paramList)
                                {
                                    CreateSprite(param);
                                }
                            }
                        }
                    }
                }
            }
        }

        Vector3 pos = BossDeadPos != Vector3.zero ? BossDeadPos : obj.GetPosition();

        if (pos == null)
        {
            return;
        }

        // 通关随机掉落
        List <role_dropaward> dropList = StageDataManager.Instance.GetBossKillAwards();

        if (dropList != null && dropList.Count > 0)
        {
            for (int i = 0; i < dropList.Count; ++i)
            {
                role_dropaward dropAward = dropList[i];
                if (dropAward != null)
                {
                    if (dropAward.drop_id_type == 0)
                    {
                        GameDebug.LogWarning("掉落物的Dropbox表不使用ConditionId了.");
                    }
                    else
                    {
                        List <PickInitParam> paramList = new List <PickInitParam>();
                        if (SceneObjManager.CreatePickInitParam(Pick.PickType.ITEM, -1, dropAward.drop_id, obj.GetPosition(), 0, out paramList, true, Pick.FlyType.FLY_OUT, false))
                        {
                            foreach (PickInitParam param in paramList)
                            {
                                CreateSprite(param);
                            }
                        }
                    }
                }
            }
        }

        // 金币随机掉落
        uint gold = StageDataManager.Instance.GetGoldAwards();

        if (gold != 0 && gold != uint.MaxValue)
        {
            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam(Pick.PickType.MONEY, 3, (int)gold, pos, 0, out paramList, true, Pick.FlyType.FLY_OUT, false))
            {
                foreach (PickInitParam param in paramList)
                {
                    CreateSprite(param);
                }
            }
        }
    }