Exemple #1
0
    public void CreateMonster(int monsterDataPOId, Vector3 pos, Transform bindBone, float summonDelay)
    {
        if (summonDelay <= 0)
        {
            // 马上刷新
            Vector3 newPos = pos;
            if (bindBone != null)
            {
                newPos = bindBone.position;
            }

            Monster go = MonsterManager.instance.CreateMonster(uniqueId, newPos, new Vector3(0, 180, 0), monsterDataPOId);
            ++uniqueId;
            monsterDict.Add(go.name, go);
            monsterNameList.Add(go.name);
        }
        else
        {
            // 延迟刷新
            DelayRefresh delay = new DelayRefresh();
            delay.refreshId   = monsterDataPOId;
            delay.refreshTime = summonDelay;
            delay.bind        = bindBone;
            delay.pos         = pos;
            delaySummonDict.Add(delay);
        }
    }
Exemple #2
0
 /// <summary>
 /// 怪物延迟召唤
 /// </summary>
 void OnDelaySummon()
 {
     while (delaySummonDict.Count > 0)
     {
         DelayRefresh element = delaySummonDict[0];
         element.refreshTime -= Time.deltaTime;
         if (element.refreshTime <= 0)
         {
             CreateMonster(element.refreshId, element.pos, element.bind, -1);
             delaySummonDict.RemoveAt(0);
         }
         else
         {
             delaySummonDict[0] = element;
             break;
         }
     }
 }
Exemple #3
0
    /// <summary>
    /// 怪物刷新
    /// </summary>
    void OnRefresh()
    {
        while (true)
        {
            int refreshId;
            if ((int)sceneId != 3)
            {
                refreshId = ((int)sceneId * 10000000) + 10000 + refreshIndex;
            }
            else
            {
                refreshId = ((int)sceneId * 10000000) + (GameConfig.GAME_CONFIG_DIFFICULTY * 10001) + refreshIndex - 1;
            }

            MonsterRefreshPO refreshPO = MonsterRefreshData.Instance.GetMonsterRefreshPO(refreshId);
            if (refreshPO == null)
            {
                return;
            }

            MonsterPO monsterPO = MonsterData.Instance.GetMonsterPO(refreshPO.MonsterId);
            if (monsterPO == null)
            {
                return;
            }

            if (Main.GameMode.CheckPoint < refreshPO.CheckPoint)
            {
                return;
            }

            if (Main.GameMode.CheckPoint > refreshPO.CheckPoint)
            {
                ++refreshIndex;
                continue;
            }

            // 判断时间
            float refreshTime = (float)refreshPO.AppeareTime / 1000.0f;
            if (refreshTime > Main.GameMode.GameTime)
            {
                return;
            }

            // 针对有限数量的刷新
            if (refreshPO.MonsterNumber > 0)
            {
                for (int index = 0; index < refreshPO.MonsterNumber; ++index)
                {
                    // 马上刷出
                    if (refreshPO.SeparateTime == 0)
                    {
                        if (monsterPO.FireCarId > 0 && !Main.PlayerManager.getPlayer(monsterPO.FireCarId - 1).IsPlaying())
                        {
                            return;
                        }

                        if (refreshPO.WindowName.Length > 0 && !DoorManager.instance.OpenDoor(refreshPO.WindowName))
                        {
                            return;
                        }
                        Monster go = CreateMonster(refreshPO);
                        CarManager.instance.Help(go.CarId, go);
                    }
                    // 延迟刷出
                    else
                    {
                        DelayRefresh delay = new DelayRefresh();
                        delay.refreshId   = refreshId;
                        delay.refreshTime = Main.GameMode.GameTime + ((float)refreshPO.SeparateTime / 1000.0f) * index;
                        //delayRefreshDict.Add(delayId++, delay);
                        delayRefreshDict.Add(delay);
                    }
                }
            }
            // 如果要循环刷新,这两个值必须有规定
            else if (refreshPO.MonsterNumber == -1 && refreshPO.SeparateTime > 0)
            {
                bool createFlag = true;
                if (monsterPO.FireCarId > 0 && !Main.PlayerManager.getPlayer(monsterPO.FireCarId - 1).IsPlaying())
                {
                    createFlag = false;
                }

                if (createFlag)
                {
                    if (refreshPO.WindowName.Length > 0 && !DoorManager.instance.OpenDoor(refreshPO.WindowName))
                    {
                        return;
                    }

                    Monster go = CreateMonster(refreshPO);
                    CarManager.instance.Help(go.CarId, go);
                }

                DelayRefresh delay = new DelayRefresh();
                delay.refreshId   = refreshId;
                delay.refreshTime = Main.GameMode.GameTime + ((float)refreshPO.SeparateTime / 1000.0f);
                //delayRefreshDict.Add(delayId++, delay);
                delayRefreshDict.Add(delay);
            }

            ++refreshIndex;
        }
    }
Exemple #4
0
    /// <summary>
    /// 怪物延迟刷新
    /// </summary>
    void OnDelayRefresh()
    {
        // 按照策划的要求,延迟队列必须是每次全部执行,保证所有怪物的刷新时间能够得到有效的判断
        //List<int> deleteList = new List<int>();
        //foreach(KeyValuePair<int, DelayRefresh> element in delayRefreshDict)
        for (int index = 0; index < delayRefreshDict.Count; ++index)
        {
            DelayRefresh     element   = delayRefreshDict[index];
            MonsterRefreshPO refreshPO = MonsterRefreshData.Instance.GetMonsterRefreshPO(element.refreshId);
            if (refreshPO == null)
            {
                continue;
            }

            MonsterPO monsterPO = MonsterData.Instance.GetMonsterPO(refreshPO.MonsterId);
            if (monsterPO == null)
            {
                return;
            }

            if (Main.GameMode.CheckPoint != refreshPO.CheckPoint)
            {
                //deleteList.Add(element.Key);
                delayRefreshDict.RemoveAt(index);
                return;
            }

            if (element.refreshTime >= Main.GameMode.GameTime)
            {
                continue;
            }

            bool createFlag = true;
            if (monsterPO.FireCarId > 0 && !Main.PlayerManager.getPlayer(monsterPO.FireCarId - 1).IsPlaying())
            {
                createFlag = false;
            }

            if (createFlag)
            {
                if (refreshPO.WindowName.Length > 0 && !DoorManager.instance.OpenDoor(refreshPO.WindowName))
                {
                    continue;
                }

                Monster go = CreateMonster(refreshPO);
                CarManager.instance.Help(go.CarId, go);
            }

            if (refreshPO.MonsterNumber == -1)
            {
                element.refreshTime     = Main.GameMode.GameTime + ((float)refreshPO.SeparateTime / 1000.0f);
                delayRefreshDict[index] = element;
                continue;
            }

            //deleteList.Add(element.Key);
            delayRefreshDict.RemoveAt(index);
            return;
        }

        //for (int index = 0; index < deleteList.Count; ++index)
        //{
        //    delayRefreshDict.Remove(deleteList[index]);
        //}
    }