예제 #1
0
    protected Monster CreateMonster(MonsterRefreshPO refreshPO)
    {
        Vector3 pos = new Vector3();

        if (refreshPO.AppearePoint.Length == 3)
        {
            pos.x = refreshPO.AppearePoint[0];
            pos.y = refreshPO.AppearePoint[1];
            pos.z = refreshPO.AppearePoint[2];
        }
        else if (refreshPO.AppeareArea != "NULL")
        {
            AreaManager.instance.getRandomPositionInArea(refreshPO.AppeareArea, ref pos);
        }

        Monster go = MonsterManager.instance.CreateMonster(uniqueId, pos, new Vector3(0, 180, 0), refreshPO.MonsterId);

        ++uniqueId;
        monsterDict.Add(go.name, go);
        monsterNameList.Add(go.name);
        return(go);
    }
예제 #2
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;
        }
    }
예제 #3
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]);
        //}
    }