Пример #1
0
        public void ExitArea(int area_id)
        {
            if (!area_generates.ContainsKey(area_id))
            {
                return;
            }
            GenerateArea area = area_generates[area_id];

            if (area.player_count > 1)
            {
                area.player_count--;
                return;
            }

            lock (build_operates) {
                for (int i = build_operates.Count - 1; i >= 0; i--)
                {
                    var item = build_operates[i];
                    if (item.area_id == area_id)
                    {
                        build_operates.RemoveAt(i);
                    }
                }
                area_generates.Remove(area_id);
                area.Close();
            }
        }
Пример #2
0
        private void Update()
        {
            BuildOperate cur_operate = DequeueOperate();

            if (cur_operate != null)
            {
                switch (cur_operate.state)
                {
                case GenerateState.AreaTriiger:
                    Debug.Log("开始检测触发");
                    StartCoroutine(TriggerDetection());
                    //StartCoroutine(BuildWorld(triggers));
                    break;

                case GenerateState.CreateSea:
                    CreateWorldGameObject(grounds[0], -1);
                    break;

                case GenerateState.EnterArea:
                    EnterArea(cur_operate.area_id);
                    break;

                default:
                    if (area_generates.ContainsKey(cur_operate.area_id))
                    {
                        GenerateArea area = area_generates[cur_operate.area_id];
                        area.BuildGameObject(cur_operate);
                    }
                    break;
                }
            }
        }
Пример #3
0
        public void EnterArea(int area_id)
        {
            if (area_generates.ContainsKey(area_id))
            {
                area_generates[area_id].player_count++;
                return;
            }
            SpaceData groundData = grounds[1 + area_id * 2];
            SpaceData waterData  = grounds[2 + area_id * 2];
            SpaceData spaceData;

            if (area_id < citys.Length)
            {
                spaceData = citys[area_id];
            }
            else
            {
                spaceData = forests[area_id - citys.Length];
            }
            GenerateArea area = new GenerateArea(area_id, this, groundData, spaceData, waterData);

            area_generates.Add(area_id, area);
        }