Exemplo n.º 1
0
        /// <summary>
        /// 移除区域
        /// </summary>
        /// <param name="id"></param>
        public void RemoveColliderObject(int id)
        {
            ColliderObject o = GetColliderObject(id);

            if (o != null)
            {
                o.CleanUp();
            }
            ColliderObjects.Remove(id);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 获取区域
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ColliderObject GetColliderObject(int id)
        {
            ColliderObject o = null;

            if (ColliderObjects.TryGetValue(id, out o))
            {
                return(o);
            }
            return(o);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取ColliderObjectBehaviour组件
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ColliderObjectBehaviour GetColliderObjectBehaviour(int id)
        {
            ColliderObject o = GetColliderObject(id);

            if (o != null && o.BindGameObject != null)
            {
                var behaviour = o.BindGameObject.GetComponent <ColliderObjectBehaviour>();
                if (behaviour != null)
                {
                    return(behaviour);
                }
            }
            return(null);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 创建区域
        /// </summary>
        /// <param name="data"></param>
        /// <returns></returns>
        public ColliderObject CreateColliderObject(Neptune.Collider data)
        {
            if (ColliderObjects.ContainsKey(data.Id) == true)
            {
                GameDebug.LogError("Create collider object error, id " + data.Id + " has already exist!!!");
                return(null);
            }

            // 已经触发过的的LifeTime是ONCE的触发器不再创建
            if (data.LifeTime == Neptune.Collider.ETypeLifeTime.ONCE && mTriggeredColliderObjectIds.Contains(data.Id) == true)
            {
                return(null);
            }

            // 前置任务未完成不创建
            if (data.PreMainTaskId > 0 && TaskHelper.MainTaskIsPassed(data.PreMainTaskId) == false)
            {
                return(null);
            }

            ColliderObject o = new ColliderObject(data);

            if (o != null)
            {
                //o.SetLocalPlayerRadius(Game.Instance.LocalPlayerRadius);
                if (ColliderObjects.ContainsKey(o.Id) == false)
                {
                    ColliderObjects.Add(o.Id, o);
                }
                else
                {
                    GameDebug.LogError("Add collider object error, id " + o.Id + " has already exist!!!");
                }
            }
            return(o);
        }