Exemplo n.º 1
0
        void generate3v3Positions(eMapType type, int width, int height, ref List <Point> startingLocations, ref List <Point> battleLocations, ref List <Point> interestLocations)
        {
            int midX  = width >> 1;
            int qtrX  = width >> 2;
            int qtr3X = width - qtrX;

            int midY  = height >> 1;
            int qtrY  = height >> 2;
            int qtr3Y = height - qtrY;

            Point[] positions = new Point[] {
                //p1                        //p2                        //p3                        //p4                        //p5                        //p6
                new Point(qtrX, qtrY), new Point(midX, qtrY), new Point(qtr3X, qtrY), new Point(qtrX, qtr3Y), new Point(midX, qtr3Y), new Point(qtr3X, qtr3Y),
            };

            int layoutType = mRand.Next(positions.Length / 6);

            startingLocations.Add(positions[layoutType * 6]);
            startingLocations.Add(positions[layoutType * 6 + 1]);
            startingLocations.Add(positions[layoutType * 6 + 2]);
            startingLocations.Add(positions[layoutType * 6 + 3]);
            startingLocations.Add(positions[layoutType * 6 + 4]);
            startingLocations.Add(positions[layoutType * 6 + 5]);

            //transpose points?
            if (mRand.Next(2) != 0)
            {
                for (int i = 0; i < startingLocations.Count; i++)
                {
                    startingLocations[i] = new Point(startingLocations[i].Y, startingLocations[i].X);
                }
            }

            battleLocations.Add(new Point(midX, midY));
        }
Exemplo n.º 2
0
        public byte[] generateMap(generationOptions options, int width, int height)
        {
            mRand = new Random(options.RandomSeed);

            mMapType = options.LayoutType;
            mWidth   = width;
            mHeight  = height;

            byte[] b = new byte[width * height];

            List <Point> startingLocations = new List <Point>();
            List <Point> battleLocations   = new List <Point>();
            List <Point> interestLocations = new List <Point>();

            generateLocations(mMapType, width, height, ref startingLocations, ref battleLocations, ref interestLocations);
            generateConnectivityGraph(startingLocations, battleLocations, interestLocations);


            for (int i = 0; i < startingLocations.Count; i++)
            {
                drawCircle(startingLocations[i], options.BaseAreaWidth, options.BaseAreaWidth, ref b);
                for (int k = 0; k < battleLocations.Count; k++)
                {
                    drawLine(startingLocations[i], battleLocations[k], options.MainPathWidth, ref b);
                }
            }
            for (int i = 0; i < interestLocations.Count; i++)
            {
                drawCircle(interestLocations[i], options.InterestAreaWidth, options.InterestAreaWidth, ref b);
            }
            for (int i = 0; i < battleLocations.Count; i++)
            {
                drawCircle(battleLocations[i], options.InterestAreaWidth, options.InterestAreaWidth, ref b);
            }



            addNoiseToMap(ref b, options.RandomSeed, options.ClampStep);
            peterbMap(ref b, options.RandomSeed);


            flipMap(options, ref b);

            int smoothAmt = 4;

            for (int i = 0; i < smoothAmt; i++)
            {
                smoothFilter(ref b, mWidth, mHeight);
            }

            mRand = null;

            return(b);
        }
Exemplo n.º 3
0
        Sparse2DBlockArray <bool> mPathsMap          = null;    //TRUE if path should be here.
        #endregion

        #region Starting Locations
        void generateLocations(eMapType type, int width, int height, ref List <Point> startingLocations, ref List <Point> battleLocations, ref List <Point> interestLocations)
        {
            if (type == eMapType.e1v1)
            {
                generate1v1Positions(type, width, height, ref startingLocations, ref battleLocations, ref interestLocations);
            }
            else if (type == eMapType.e2v2)
            {
                generate2v2Positions(type, width, height, ref startingLocations, ref battleLocations, ref interestLocations);
            }
            else if (type == eMapType.e3v3)
            {
                generate3v3Positions(type, width, height, ref startingLocations, ref battleLocations, ref interestLocations);
            }
        }
Exemplo n.º 4
0
        void generate2v2Positions(eMapType type, int width, int height, ref List <Point> startingLocations, ref List <Point> battleLocations, ref List <Point> interestLocations)
        {
            int midX  = width >> 1;
            int qtrX  = width >> 2;
            int qtr3X = width - qtrX;
            int ethX  = width >> 3;
            int eth7X = ethX * 7;

            int midY  = height >> 1;
            int qtrY  = height >> 2;
            int qtr3Y = height - qtrY;
            int ethY  = height >> 3;
            int eth7Y = ethY * 7;

            Point[] positions = new Point[] {
                //p1                        //p2                        //p3                        //p4
                new Point(ethX, ethY), new Point(eth7X, ethY), new Point(ethX, eth7Y), new Point(eth7X, eth7Y),              //square wide

                new Point(midX, ethY), new Point(ethX, midY), new Point(eth7X, midY), new Point(midX, eth7Y),                //diagonal wide
                new Point(qtrX, ethY), new Point(ethX, qtrY), new Point(qtr3X, eth7Y), new Point(eth7X, qtr3Y),              //diagonal tight lt->rb
                new Point(qtr3X, ethY), new Point(eth7X, qtrY), new Point(qtrX, eth7Y), new Point(ethX, qtr3Y),              //diagonal tight lt->rb
            };

            int layoutType = mRand.Next(positions.Length / 4);

            startingLocations.Add(positions[layoutType * 4]);
            startingLocations.Add(positions[layoutType * 4 + 1]);
            startingLocations.Add(positions[layoutType * 4 + 2]);
            startingLocations.Add(positions[layoutType * 4 + 3]);

            //transpose points?
            if (mRand.Next(2) != 0)
            {
                for (int i = 0; i < startingLocations.Count; i++)
                {
                    startingLocations[i] = new Point(startingLocations[i].Y, startingLocations[i].X);
                }
            }

            battleLocations.Add(new Point(midX, midY));
        }
Exemplo n.º 5
0
        public AbstractGame(int id, eRoomType roomType, eGameType gameType, int timeType)
        {
            m_id       = id;
            m_roomType = roomType;
            m_gameType = gameType;
            m_timeType = timeType;
            switch (m_roomType)
            {
            case eRoomType.Freedom:
                m_mapType = eMapType.Normal;
                break;

            case eRoomType.Match:
                m_mapType = eMapType.PairUp;
                break;

            default:
                m_mapType = eMapType.Normal;
                break;
            }
        }
Exemplo n.º 6
0
        public AbstractGame(int id, eRoomType roomType, eGameType gameType, int timeType)
        {
            this.m_id       = id;
            this.m_roomType = roomType;
            this.m_gameType = gameType;
            this.m_timeType = timeType;
            switch (this.m_roomType)
            {
            case eRoomType.Match:
                this.m_mapType = eMapType.PairUp;
                return;

            case eRoomType.Freedom:
                this.m_mapType = eMapType.Normal;
                return;

            default:
                this.m_mapType = eMapType.Normal;
                return;
            }
        }
Exemplo n.º 7
0
        void generate1v1Positions(eMapType type, int width, int height, ref List <Point> startingLocations, ref List <Point> battleLocations, ref List <Point> interestLocations)
        {
            int midX  = width >> 1;
            int qtrX  = width >> 2;
            int qtr3X = width - qtrX;
            int ethX  = width >> 3;
            int eth7X = ethX * 7;

            int midY  = height >> 1;
            int qtrY  = height >> 2;
            int qtr3Y = height - qtrY;
            int ethY  = height >> 3;
            int eth7Y = ethY * 7;

            Point[] positions = new Point[] {
                //p1                        //p2
                new Point(midX, ethY), new Point(midX, eth7Y),          //center
                new Point(ethX, ethY), new Point(ethX, eth7Y),          //left
                new Point(eth7X, ethY), new Point(eth7X, eth7Y),        //right
                new Point(ethX, eth7Y), new Point(eth7X, ethY),         //diag lb->rt
                new Point(ethX, ethY), new Point(eth7X, eth7Y),         //diag lt->rb
            };


            int layoutType = mRand.Next(positions.Length / 2);

            startingLocations.Add(positions[layoutType * 2]);
            startingLocations.Add(positions[layoutType * 2 + 1]);

            //transpose points?
            if (mRand.Next(2) != 0)
            {
                for (int i = 0; i < startingLocations.Count; i++)
                {
                    startingLocations[i] = new Point(startingLocations[i].Y, startingLocations[i].X);
                }
            }

            battleLocations.Add(new Point(midX, midY));
        }
Exemplo n.º 8
0
 /// <summary>
 /// 移除某个枚举
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool RemoveMapType(eMapType value)
 {
     if(IsContainMapType(value))
     {
         mapType ^= value;
         return true;
     }
     return false;
 }
Exemplo n.º 9
0
 /// <summary>
 /// 是否包含某种类型
 /// </summary>
 /// <param name="value"></param>
 /// <returns></returns>
 public bool IsContainMapType(eMapType value)
 {
     bool bl = (mapType & value) == value;
     //Debug.Log(string.Format("是否包含type:{0} == {1}, type= {2}",value.ToString(),bl,mapType.ToString()));
     return bl;
 }
Exemplo n.º 10
0
 /// <summary>
 /// 清空之前的枚举 重新定义
 /// </summary>
 /// <param name="value"></param>
 public void ClearAndAddMaptType(eMapType value)
 {
     mapType = value;
 }
Exemplo n.º 11
0
 /// <summary>
 /// 地图格子类型
 /// </summary>
 public void AddMapType(eMapType value)
 {
     //增加
         mapType |= value;
 }
Exemplo n.º 12
0
 public GridBase(int rowid, int cloumnid, eMapType maptype)
 {
     this.rowId = rowid;
     this.cloumnId = cloumnid;
     this.mapType = maptype;
 }
Exemplo n.º 13
0
        public BaseGame(List<GamePlayer> red, List<GamePlayer> blue, Map map,eRoomType roomType,eTeamType teamType, eGameType gameType, int timeType)
        {
            m_players = new Dictionary<GamePlayer, Player>();
            m_redTeam = new List<Player>();
            m_blueTeam = new List<Player>();
            m_roomType = roomType;
            m_gameType = gameType;
            m_teamType = teamType;
            m_random = new Random();

            m_redAvgLevel = 0;
            foreach (GamePlayer player in red)
            {
                Player fp = new Player(player, this, 1);
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                m_players.Add(player, fp);
                m_redTeam.Add(fp);
                player.CurrentGame = this;
                m_redAvgLevel += player.PlayerCharacter.Grade;

                fp.Died += new PlayerEventHandle(Player_Died);
            }
            m_redAvgLevel = m_redAvgLevel / m_redTeam.Count;

            m_blueAvgLevel = 0;
            foreach (GamePlayer player in blue)
            {
                Player fp = new Player(player, this, 2);
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                m_players.Add(player, fp);
                m_blueTeam.Add(fp);
                player.CurrentGame = this;
                m_blueAvgLevel += player.PlayerCharacter.Grade;

                fp.Died += new PlayerEventHandle(Player_Died);
            }
            m_blueAvgLevel = m_blueAvgLevel / blue.Count;

            m_map = map;
            m_actions = new ArrayList();
            PhysicalId = 0;

            switch (m_roomType)
            {
                case eRoomType.Freedom:
                    m_mapType = eMapType.Normal;
                    break;
                case eRoomType.Match:
                    m_mapType = eMapType.PairUp;
                    break;
                default:
                    m_mapType = eMapType.Normal;
                    break;
            }
            
           
            m_timeType = timeType;
            m_tempBox = new List<Box>();
            m_tempPoints = new List<Point>();
            Cards = new int[8];
            GameState = eGameState.Inited;
        }
Exemplo n.º 14
0
        public BaseGame(List <GamePlayer> red, List <GamePlayer> blue, Map map, eRoomType roomType, eTeamType teamType, eGameType gameType, int timeType)
        {
            m_players  = new Dictionary <GamePlayer, Player>();
            m_redTeam  = new List <Player>();
            m_blueTeam = new List <Player>();
            m_roomType = roomType;
            m_gameType = gameType;
            m_teamType = teamType;
            m_random   = new Random();

            m_redAvgLevel = 0;
            foreach (GamePlayer player in red)
            {
                Player fp = new Player(player, this, 1);
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                m_players.Add(player, fp);
                m_redTeam.Add(fp);
                player.CurrentGame = this;
                m_redAvgLevel     += player.PlayerCharacter.Grade;

                fp.Died += new PlayerEventHandle(Player_Died);
            }
            m_redAvgLevel = m_redAvgLevel / m_redTeam.Count;

            m_blueAvgLevel = 0;
            foreach (GamePlayer player in blue)
            {
                Player fp = new Player(player, this, 2);
                fp.Direction = m_random.Next(0, 1) == 0 ? 1 : -1;
                m_players.Add(player, fp);
                m_blueTeam.Add(fp);
                player.CurrentGame = this;
                m_blueAvgLevel    += player.PlayerCharacter.Grade;

                fp.Died += new PlayerEventHandle(Player_Died);
            }
            m_blueAvgLevel = m_blueAvgLevel / blue.Count;

            m_map      = map;
            m_actions  = new ArrayList();
            PhysicalId = 0;

            switch (m_roomType)
            {
            case eRoomType.Freedom:
                m_mapType = eMapType.Normal;
                break;

            case eRoomType.Match:
                m_mapType = eMapType.PairUp;
                break;

            default:
                m_mapType = eMapType.Normal;
                break;
            }


            m_timeType   = timeType;
            m_tempBox    = new List <Box>();
            m_tempPoints = new List <Point>();
            Cards        = new int[8];
            GameState    = eGameState.Inited;
        }
Exemplo n.º 15
0
 public AbstractGame(int id, eRoomType roomType, eGameType gameType, int timeType)
 {
     m_id = id;
     m_roomType = roomType;
     m_gameType = gameType;
     m_timeType = timeType;
     switch (m_roomType)
     {
         case eRoomType.Freedom:
             m_mapType = eMapType.Normal;
             break;
         case eRoomType.Match:
             m_mapType = eMapType.PairUp;
             break;
         default:
             m_mapType = eMapType.Normal;
             break;
     }
 }
Exemplo n.º 16
0
 public void SetMapType(eMapType type)
 {
     _mapType = type;
 }
Exemplo n.º 17
0
 public Set GetTuningSet(eMapType map_type)
 {
     return(mSets[(int)map_type]);
 }