示例#1
0
        internal static SquarePoint GetNextStep(int pUserX, int pUserY, double pUserZ,
            int pUserTargetX, int pUserTargetY,
            byte[,] pGameMap, Stackmap pHeight, short[,] pHeightmap,
            int MaxX, int MaxY,
            bool pUserOverride, bool pDiagonal, Gamemap gamemap)
        {
            ModelInfo MapInfo = new ModelInfo(MaxX, MaxY, pGameMap);
            SquarePoint TargetPoint = new SquarePoint(pUserTargetX, pUserTargetY, pUserZ, pUserTargetX, pUserTargetY, MapInfo.GetState(pUserTargetX, pUserTargetY), pUserOverride, pHeight);
            if (pUserX == pUserTargetX && pUserY == pUserTargetY)
                return TargetPoint;

            SquareInformation SquareOnUser = new SquareInformation(pUserX, pUserY, pUserZ, TargetPoint, MapInfo, pUserOverride, pDiagonal, pHeight);

            return GetClosetSqare(SquareOnUser, new HeightInfo(MaxX, MaxY, pHeight, pHeightmap), pUserZ, gamemap, pUserOverride);
        }
示例#2
0
 internal HeightInfo(int MaxX, int MaxY, Stackmap Map, short[,] heightmap)
 {
     mMap = Map;
     mMaxX = MaxX;
     mMaxY = MaxY;
     this.mRoomHeightmap = heightmap;
 }
示例#3
0
        internal SquarePoint(int pX, int pY, double pZ, int pTargetX, int pTargetY, byte SquareData, bool pOverride, Stackmap map)
        {
            mX = pX;
            mY = pY;
            mZ = pZ;
            //mSquareData = SquareData;
            mSquareData = SquareData;
            this.map = map;
            //map.TryGetSquareStatus(pX, pY, ref mSquareData);
                
            mInUse = true;
            mOverride = pOverride;

            mDistance = 0.0;
            mLastStep = (pX == pTargetX && pY == pTargetY);

            mDistance = DreamPathfinder.GetDistance(pX, pY, pTargetX, pTargetY);

        }
示例#4
0
        internal SquareInformation(int pX, int pY, double pZ, SquarePoint pTarget, ModelInfo pMap, bool pUserOverride, bool CalculateDiagonal, Stackmap map)
        {
            mX = pX;
            mY = pY;
            mZ = pZ;
            mTarget = pTarget;

            mPoint = new SquarePoint(pX, pY, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX, pY), pUserOverride, map);

            //Analyze all the squares arround the user
            mPos = new SquarePoint[8];

            if (CalculateDiagonal)
            {
                mPos[1] = new SquarePoint(pX - 1, pY - 1, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX - 1, pY - 1), pUserOverride, map);
                mPos[3] = new SquarePoint(pX - 1, pY + 1, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX - 1, pY + 1), pUserOverride, map);
                mPos[5] = new SquarePoint(pX + 1, pY + 1, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX + 1, pY + 1), pUserOverride, map);
                mPos[7] = new SquarePoint(pX + 1, pY - 1, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX + 1, pY - 1), pUserOverride, map);
            }

            mPos[0] = new SquarePoint(pX, pY - 1, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX, pY - 1), pUserOverride, map);
            mPos[2] = new SquarePoint(pX - 1, pY, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX - 1, pY), pUserOverride, map);
            mPos[4] = new SquarePoint(pX, pY + 1, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX, pY + 1), pUserOverride, map);
            mPos[6] = new SquarePoint(pX + 1, pY, pZ, pTarget.X, pTarget.Y, pMap.GetState(pX + 1, pY), pUserOverride, map);

            ///456
            //Y3X7
            ///218
            ////X
        }
示例#5
0
文件: Gamemap.cs 项目: BjkGkh/R106
		internal void GenerateMaps(bool checkLines = true)
		{
			int MaxX = 0;
			int MaxY = 0;
			mCoordinatedItems.Clear();

			if (checkLines)
			{
				RoomItem[] items = room.GetRoomItemHandler().mFloorItems.Values.ToArray();
				foreach (RoomItem item in items)
				{
					if (item.GetX > Model.MapSizeX && item.GetX > MaxX)
						MaxX = item.GetX;
					if (item.GetY > Model.MapSizeY && item.GetY > MaxY)
						MaxY = item.GetY;
				}

				Array.Clear(items, 0, items.Length);
				items = null;
			}

			#region Dynamic game map handling
			if (MaxY > (Model.MapSizeY - 1) || MaxX > (Model.MapSizeX - 1))
			{
				if (MaxX < Model.MapSizeX)
					MaxX = Model.MapSizeX;
				if (MaxY < Model.MapSizeY)
					MaxY = Model.MapSizeY;

				Model.SetMapsize(MaxX + 7, MaxY + 7);
				GenerateMaps(false);
				return;
			}

			if (MaxX != StaticModel.MapSizeX || MaxY != StaticModel.MapSizeY)
			{
				this.mUserItemEffect = new byte[Model.MapSizeX, Model.MapSizeY];
				this.mGameMap = new byte[Model.MapSizeX, Model.MapSizeY];


				this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
                this.stackmap = new Stackmap(Model.MapSizeX, Model.MapSizeY);
				//if (modelRemap)
				//    Model.Generate(); //Clears model

				for (int line = 0; line < Model.MapSizeY; line++)
				{
					for (int chr = 0; chr < Model.MapSizeX; chr++)
					{
						mGameMap[chr, line] = 0;
						mUserItemEffect[chr, line] = 0;

						if (chr == Model.DoorX && line == Model.DoorY)
						{
							mGameMap[chr, line] = 3;
						}
						else if (Model.SqState[chr, line] == SquareState.OPEN)
						{
							mGameMap[chr, line] = 1;
						}
						else if (Model.SqState[chr, line] == SquareState.SEAT)
						{
							mGameMap[chr, line] = 2;
						}
						else if (Model.SqState[chr, line] == SquareState.POOL)
						{
							mUserItemEffect[chr, line] = 6;
						}
					}
				}

                //if (gotPublicPool)
                //{
                //    for (int y = 0; y < StaticModel.MapSizeY; y++)
                //    {
                //        for (int x = 0; x < StaticModel.MapSizeX; x++)
                //        {
                //            if (StaticModel.mRoomModelfx[x, y] != 0)
                //            {
                //                mUserItemEffect[x, y] = StaticModel.mRoomModelfx[x, y];
                //            }
                //        }
                //    }
                //}
			}
			#endregion

			#region Static game map handling
			else
			{
				//mGameMap
				//mUserItemEffect
				this.mUserItemEffect = new byte[Model.MapSizeX, Model.MapSizeY];
				this.mGameMap = new byte[Model.MapSizeX, Model.MapSizeY];


				this.mItemHeightMap = new double[Model.MapSizeX, Model.MapSizeY];
                this.stackmap = new Stackmap(Model.MapSizeX, Model.MapSizeY);
				//if (modelRemap)
				//    Model.Generate(); //Clears model

				for (int line = 0; line < Model.MapSizeY; line++)
				{
					for (int chr = 0; chr < Model.MapSizeX; chr++)
					{
						mGameMap[chr, line] = 0;
						mUserItemEffect[chr, line] = 0;

						if (chr == Model.DoorX && line == Model.DoorY)
						{
							mGameMap[chr, line] = 3;
						}
						else if (Model.SqState[chr, line] == SquareState.OPEN)
						{
							mGameMap[chr, line] = 1;
						}
						else if (Model.SqState[chr, line] == SquareState.SEAT)
						{
							mGameMap[chr, line] = 2;
						}
						else if (Model.SqState[chr, line] == SquareState.POOL)
						{
							mUserItemEffect[chr, line] = 6;
						}
					}
				}

                //if (gotPublicPool)
                //{
                //    for (int y = 0; y < StaticModel.MapSizeY; y++)
                //    {
                //        for (int x = 0; x < StaticModel.MapSizeX; x++)
                //        {
                //            if (StaticModel.mRoomModelfx[x, y] != 0)
                //            {
                //                mUserItemEffect[x, y] = StaticModel.mRoomModelfx[x, y];
                //            }
                //        }
                //    }
                //}
			}
			#endregion

			RoomItem[] tmpItems = room.GetRoomItemHandler().mFloorItems.Values.ToArray();
			foreach (RoomItem Item in tmpItems)
			{
				if (!AddItemToMap(Item))
					break;
			}
			tmpItems = null;

			if (!room.AllowWalkthrough)
			{
				foreach (RoomUser user in room.GetRoomUserManager().UserList.Values)
				{
					user.SqState = mGameMap[user.X, user.Y];
					mGameMap[user.X, user.Y] = 0;
				}
			}

			mGameMap[Model.DoorX, Model.DoorY] = 3;
		}
示例#6
0
文件: Gamemap.cs 项目: BjkGkh/R106
		internal void Destroy()
		{
			userMap.Clear();
			mDynamicModel.Destroy();
			mCoordinatedItems.Clear();

			Array.Clear(mGameMap, 0, mGameMap.Length);
			Array.Clear(mUserItemEffect, 0, mUserItemEffect.Length);
			Array.Clear(mItemHeightMap, 0, mItemHeightMap.Length);

			userMap = null;
			mGameMap = null;
			mUserItemEffect = null;
			mItemHeightMap = null;
            stackmap = null;
			mCoordinatedItems = null;
			mDynamicModel = null;
			room = null;
			mStaticModel = null;
		}