Example #1
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List <StampInfo> GetPagedList(int pPageIndex, int pPageSize, SortDirection pOrderBy, string pSortExpression, out int pRecordCount)
        {
            if (pPageIndex <= 1)
            {
                pPageIndex = 1;
            }
            List <StampInfo> list = new List <StampInfo>();

            Query q = Stamp.CreateQuery();

            q.PageIndex = pPageIndex;
            q.PageSize  = pPageSize;
            q.ORDER_BY(pSortExpression, pOrderBy.ToString());
            StampCollection collection = new  StampCollection();

            collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Stamp stamp  in collection)
            {
                StampInfo stampInfo = new StampInfo();
                LoadFromDAL(stampInfo, stamp);
                list.Add(stampInfo);
            }
            pRecordCount = q.GetRecordCount();

            return(list);
        }
Example #2
0
        /// <summary>
        /// 获得数据列表
        /// </summary>
        /// <returns></returns>
        public static List <StampInfo> GetList()
        {
            string cacheKey = GetCacheKey();

            //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
            if (CachedEntityCommander.IsTypeRegistered(typeof(StampInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
            {
                return(CachedEntityCommander.GetCache(cacheKey) as List <StampInfo>);
            }
            else
            {
                List <StampInfo> list       = new List <StampInfo>();
                StampCollection  collection = new  StampCollection();
                Query            qry        = new Query(Stamp.Schema);
                collection.LoadAndCloseReader(qry.ExecuteReader());
                foreach (Stamp stamp in collection)
                {
                    StampInfo stampInfo = new StampInfo();
                    LoadFromDAL(stampInfo, stamp);
                    list.Add(stampInfo);
                }
                //生成缓存
                if (CachedEntityCommander.IsTypeRegistered(typeof(StampInfo)))
                {
                    CachedEntityCommander.SetCache(cacheKey, list);
                }
                return(list);
            }
        }
Example #3
0
        /// <summary>
        /// The view sends messages using this method. This method is also used for messages originating from the world
        /// of effectful computations. In a way, this class also belongs to that world...
        /// </summary>
        /// <param name="message"></param>
        internal void SendMessage(Message message)
        {
            // Invoke the dispatching function with current model, current view model and the message.
            var newMandVm = Dispatching.dispatch(this.model, this.viewModel, message);

            // Remember new model and view model as current model and view model, respectively. Observe, that this
            // class doesn't care whether the model or view model actually changed.
            this.model     = newMandVm.Item1;
            this.viewModel = newMandVm.Item2;

            // If the model requested an effectful computation, perform it and route the message back to this function,
            // such that it will be passed to the dispatcher function, exactly the same way as for messages coming from
            // the view.
            var effect = newMandVm.Item3;

            if (effect.IsEffect)
            {
                var e = effect as Effect <Message> .Effect;
                ExecuteEffect(e.Item, this.SendMessage); // executes asynchronously (AE)
            }

            // Send the updated view model to the view. Property (AE) is crucial, because the GUI will not be blocked
            // and the view can assume any intermediate state defined by the view model, until the computation (if any)
            // is done. The example in this demo is simulated verification of stamp rareness, where the view displays a
            // "working on it" feed-back.
            this.viewModelSubject.OnNext(this.viewModel);
        }
        /// <summary>
        /// Initializes the initial state of the application, consisting of the initial model and initial view model.        
        /// </summary>
        /// <remarks>
        /// Note, that as this class is merely a "state holder", it does not create the initial model and view model
        /// itself. This happens in the "main" function of the application.
        /// </remarks>
        /// <param name="initialModel">
        /// The initial model.
        /// </param>
        /// <param name="initialViewModel">
        /// The initial view model.
        /// </param>
        internal ApplicationModel(StampCollection initialModel, StampCollectionViewModel initialViewModel)
        {
            this.model = initialModel;
            this.viewModel = initialViewModel;

            this.viewModelSubject = new Subject<StampCollectionViewModel>();
        }
Example #5
0
        /// <summary>
        /// Initializes the initial state of the application, consisting of the initial model and initial view model.
        /// </summary>
        /// <remarks>
        /// Note, that as this class is merely a "state holder", it does not create the initial model and view model
        /// itself. This happens in the "main" function of the application.
        /// </remarks>
        /// <param name="initialModel">
        /// The initial model.
        /// </param>
        /// <param name="initialViewModel">
        /// The initial view model.
        /// </param>
        internal ApplicationModel(StampCollection initialModel, StampCollectionViewModel initialViewModel)
        {
            this.model     = initialModel;
            this.viewModel = initialViewModel;

            this.viewModelSubject = new Subject <StampCollectionViewModel>();
        }
Example #6
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List <StampInfo> pList, StampCollection pCollection)
 {
     foreach (Stamp stamp in pCollection)
     {
         StampInfo stampInfo = new StampInfo();
         LoadFromDAL(stampInfo, stamp);
         pList.Add(stampInfo);
     }
 }
Example #7
0
    void MakeImpassableStamp(Vector3 location, float width, float height, StampCollection rootStampCollection)
    {
        width  = width + 0.1f;
        height = height + 0.1f;
        GameObject newRectStamp = Instantiate(impassableStampPrefab, location, Quaternion.identity);

        newRectStamp.transform.localScale = new Vector3(width, height, 1f);
        rootStampCollection.AddChildStamp(newRectStamp);
    }
Example #8
0
 public void ApplyStampCollection(StampCollection stampCollection)
 {
     if (stampCollection != null)           //May not have a stamp collection to apply to this topography
     {
         stampCollection.ApplyStamp(marchingGrid, oreGrid);
         destructableArray = oreGrid.GetDestructableArray();               //Refresh the stored destructable array
         marchingGrid.InterpolateAll();
     }
 }
Example #9
0
    void ConvertLabyrinthToStampCollection()
    {
        arenaCollection = GetComponent <ArenaCollection> () as ArenaCollection;

        StampCollection rootStampCollection = this.transform.parent.GetComponentInChildren <StampCollection> () as StampCollection;

        foreach (LabyrinthRoom room in finishedRoomList)
        {
            //GameObject newCircleStamp = Instantiate (circleHoleStampPrefab, room.GetPosition(), Quaternion.identity);
            GameObject newArenaStamp = Instantiate(arenaCollection.GetRandomArena(), room.GetPosition(), Quaternion.identity);

            float horFlip  = 1;
            float vertFlip = 1;
            //Flip horizontally or vertically randomly.
            if (Random.Range(0, 1) > 0.5f)
            {
                horFlip = -1;
            }
            if (Random.Range(0, 1) > 0.5f)
            {
                vertFlip = -1;
            }
            newArenaStamp.transform.localScale = new Vector3(room.GetDiameter() * horFlip, room.GetDiameter() * vertFlip, 1f);

            //Rotate 90 degrees half the time
            if (Random.Range(0, 1) > 0.5f)
            {
                newArenaStamp.transform.rotation = Quaternion.LookRotation(transform.forward, room.GetUpVector());
            }
            else
            {
                newArenaStamp.transform.rotation = Quaternion.LookRotation(transform.forward, room.GetRightVector());
            }
            rootStampCollection.AddChildStamp(newArenaStamp);
        }

        foreach (LabyrinthTunnel tunnel in tunnelList)
        {
            GameObject newRectStamp = Instantiate(rectHoleStampPrefab, tunnel.GetPosition(), Quaternion.identity);
            newRectStamp.transform.localScale = new Vector3(tunnel.GetWidth(), tunnel.GetLength(), 1f);
            newRectStamp.transform.rotation   = Quaternion.LookRotation(transform.forward, (tunnel.GetStart() - tunnel.GetEnd()));
            rootStampCollection.AddChildStamp(newRectStamp);
        }

        AddBoundingStamps(rootStampCollection);
    }
Example #10
0
    public void Initialise(float vesselSize)
    {
        this.vesselRadius = vesselSize / 2f;

        //Ensure enough chunks to contain vessel. Could add a buffer to build above this level.
        numChunks    = (int)Mathf.Ceil(vesselSize / chunkSize);
        worldSizeX   = numChunks * chunkSize;
        worldSizeY   = numChunks * chunkSize;
        vesselCenter = new Vector3((float)worldSizeX / 2f, (float)worldSizeY / 2f, 0f);

        GameObject marchingGridGO = Instantiate(marchingGridPrefab, this.transform.position, Quaternion.identity) as GameObject;

        marchingGrid = marchingGridGO.GetComponent <MarchingSquaresGrid> () as MarchingSquaresGrid;
        marchingGrid.Initialise(worldSizeX, worldSizeY, isSolid);

        oreGrid = new OreGrid();
        oreGrid.GenerateMap(worldSizeX, worldSizeY);

        destructableArray = oreGrid.GetDestructableArray();

        LabyrinthBuilder labyrinthBuilder = GetComponentInChildren <LabyrinthBuilder> () as LabyrinthBuilder;

        if (labyrinthBuilder != null)
        {
            labyrinthBuilder.GenerateLabyrinth();
        }

        rootStampCollection = this.transform.GetComponentInChildren <StampCollection> () as StampCollection;
        ApplyStampCollection(rootStampCollection);

        renderChunkPool                = new Stack <RenderChunk> ();
        renderChunkUpdateQueue         = new Queue <RenderChunk> ();
        renderChunkPriorityUpdateQueue = new Queue <RenderChunk> ();
        renderChunkArray               = new RenderChunk[numChunks, numChunks];

        collisionChunkPool                = new Stack <CollisionChunk> ();
        collisionChunkUpdateQueue         = new Queue <CollisionChunk> ();
        collisionChunkPriorityUpdateQueue = new Queue <CollisionChunk> ();
        collisionChunkArray               = new CollisionChunk[numChunks, numChunks];

        this.faceGO = Instantiate(facePrefab, new Vector3(0f, 0f, 0f), Quaternion.identity) as GameObject;

        this.interiorGO = Instantiate(interiorPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity) as GameObject;

        renderFoci = new List <GameObject> ();
    }
Example #11
0
    void AddBoundingStamps(StampCollection rootStampCollection)
    {
        Vector3 topPos = new Vector3(0f, worldHeight / 2f, 0f);

        MakeRectStamp(topPos, worldWidth, 3f, rootStampCollection);
        MakeImpassableStamp(topPos, worldWidth, 5f, rootStampCollection);

        Vector3 botPos = new Vector3(0f, -worldHeight / 2f, 0f);

        MakeRectStamp(botPos, worldWidth, 3f, rootStampCollection);
        MakeImpassableStamp(botPos, worldWidth, 5f, rootStampCollection);

        Vector3 rightPos = new Vector3(worldWidth / 2f, 0f, 0f);

        MakeRectStamp(rightPos, 3f, worldHeight, rootStampCollection);
        MakeImpassableStamp(rightPos, 10f, worldHeight, rootStampCollection);

        Vector3 leftPos = new Vector3(-worldWidth / 2f, 0f, 0f);

        MakeRectStamp(leftPos, 3f, worldHeight, rootStampCollection);
        MakeImpassableStamp(leftPos, 10f, worldHeight, rootStampCollection);
    }
        /// <summary>
        /// The view sends messages using this method. This method is also used for messages originating from the world
        /// of effectful computations. In a way, this class also belongs to that world...
        /// </summary>
        /// <param name="message"></param>
        internal void SendMessage(Message message)
        {
            // Invoke the dispatching function with current model, current view model and the message.
            var newMandVm = Dispatching.dispatch(this.model,this.viewModel, message);

            // Remember new model and view model as current model and view model, respectively. Observe, that this
            // class doesn't care whether the model or view model actually changed.
            this.model = newMandVm.Item1;
            this.viewModel = newMandVm.Item2;

            // If the model requested an effectful computation, perform it and route the message back to this function,
            // such that it will be passed to the dispatcher function, exactly the same way as for messages coming from
            // the view.
            var effect = newMandVm.Item3;
            if (effect.IsEffect)
            {
                var e = effect as Effect<Message>.Effect;
                ExecuteEffect(e.Item, this.SendMessage); // executes asynchronously (AE)
            }

            // Send the updated view model to the view. Property (AE) is crucial, because the GUI will not be blocked
            // and the view can assume any intermediate state defined by the view model, until the computation (if any)
            // is done. The example in this demo is simulated verification of stamp rareness, where the view displays a
            // "working on it" feed-back.
            this.viewModelSubject.OnNext(this.viewModel);
        }
Example #13
0
 /// <summary>
 /// 批量装载
 /// </summary>
 internal static void LoadFromDALPatch(List< StampInfo> pList, StampCollection pCollection)
 {
     foreach (Stamp stamp in pCollection)
     {
         StampInfo stampInfo = new StampInfo();
         LoadFromDAL(stampInfo, stamp );
         pList.Add(stampInfo);
     }
 }
Example #14
0
        /// <summary>
        /// 获得分页列表,无论是否是缓存实体都从数据库直接拿取数据
        /// </summary>
        /// <param name="pPageIndex">页数</param>
        /// <param name="pPageSize">每页列表</param>
        /// <param name="pOrderBy">排序</param>
        /// <param name="pSortExpression">排序字段</param>
        /// <param name="pRecordCount">列表行数</param>
        /// <returns>数据分页</returns>
        public static List<StampInfo> GetPagedList(int pPageIndex,int pPageSize,SortDirection pOrderBy,string pSortExpression,out int pRecordCount)
        {
            if(pPageIndex<=1)
            pPageIndex=1;
            List< StampInfo> list = new List< StampInfo>();

            Query q = Stamp .CreateQuery();
            q.PageIndex = pPageIndex;
            q.PageSize = pPageSize;
            q.ORDER_BY(pSortExpression,pOrderBy.ToString());
            StampCollection  collection=new  StampCollection();
             	collection.LoadAndCloseReader(q.ExecuteReader());

            foreach (Stamp  stamp  in collection)
            {
                StampInfo stampInfo = new StampInfo();
                LoadFromDAL(stampInfo,   stamp);
                list.Add(stampInfo);
            }
            pRecordCount=q.GetRecordCount();

            return list;
        }
Example #15
0
 /// <summary>
 /// 获得数据列表
 /// </summary>
 /// <returns></returns>
 public static List<StampInfo> GetList()
 {
     string cacheKey = GetCacheKey();
     //本实体已经注册成缓存实体,并且缓存存在的时候,直接从缓存取
     if (CachedEntityCommander.IsTypeRegistered(typeof(StampInfo)) && CachedEntityCommander.GetCache(cacheKey) != null)
     {
         return CachedEntityCommander.GetCache(cacheKey) as List< StampInfo>;
     }
     else
     {
         List< StampInfo>  list =new List< StampInfo>();
         StampCollection  collection=new  StampCollection();
         Query qry = new Query(Stamp.Schema);
         collection.LoadAndCloseReader(qry.ExecuteReader());
         foreach(Stamp stamp in collection)
         {
             StampInfo stampInfo= new StampInfo();
             LoadFromDAL(stampInfo,stamp);
             list.Add(stampInfo);
         }
       	//生成缓存
         if (CachedEntityCommander.IsTypeRegistered(typeof(StampInfo)))
         {
             CachedEntityCommander.SetCache(cacheKey, list);
         }
         return list;
     }
 }