Esempio n. 1
0
        public CEntityTransition(CMap map, XmlAttributeCollection attributes, XmlNodeList properties)
        {
            m_map = map;

            int l = Convert.ToInt16(attributes["x"].Value);
            int t = Convert.ToInt16(attributes["y"].Value);
            int w = Convert.ToInt16(attributes["width"].Value);
            int h = Convert.ToInt16(attributes["height"].Value);
            m_rect = new Rectangle(l, t, w, h);

            foreach (XmlNode node in properties) {
                switch (node.Attributes["name"].Value) {
                    case "Map":
                        newmap = node.InnerText.Trim();
                        break;
                    case "X":
                        newx = Convert.ToInt16(node.InnerText.Trim());
                        break;
                    case "Y":
                        newy = Convert.ToInt16(node.InnerText.Trim());
                        break;
                }
            }
            map.Entities.AddLast(this);
        }
Esempio n. 2
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="map"></param>
 /// <param name="x">X Coord in World Units</param>
 /// <param name="y">Y Coord in World Units</param>
 public CActorBullet(CMap map, int x, int y)
 {
     m_tileset = new Surface("Data/bullet.png");
     m_rect = new Rectangle(x, y, m_tileset.Width / 3, m_tileset.Height / 4);
     m_tileset.Transparent = true;
     m_tileset.TransparentColor = Color.FromArgb(255, 0, 255);
     m_moveup = m_movedown = m_moveleft = m_moveright = false;
     m_movespeed = 5;
     m_map = map;
 }
Esempio n. 3
0
 /// <summary>
 /// Create a new monster
 /// </summary>
 /// <param name="map">Reference to the map (to be able to load certain values)</param>
 /// <param name="x">Starting X Coord in Tile units</param>
 /// <param name="y">Starting Y Coord in Tile units</param>
 public CActorMonster(CMap map, int x, int y)
 {
     m_tileset = new Surface("Data/white.png");
     m_rect = m_rect = map.ConvertToWorldUnits(x, y, m_tileset.Width / 3, m_tileset.Height / 4);
     MoveSpeed = 1;
     m_tileset.Transparent = true;
     m_tileset.TransparentColor = Color.FromArgb(255, 0, 255);
     m_player = map.Avatar;
     m_map = map;
     m_collidable = true;
 }
Esempio n. 4
0
        public CActorPlayer(CMap map)
        {
            m_tileset = new Surface("Data/avatar.png");
            m_rect = map.ConvertToWorldUnits(0, 0, m_tileset.Width / 3, m_tileset.Height / 4);
            m_tileset.Transparent = true;
            m_tileset.TransparentColor = Color.FromArgb(255, 0, 255);

            m_moveup = m_movedown = m_moveleft = m_moveright = false;
            m_movespeed = 2;
            m_map = map;
            m_collidable = true;
        }
        private void cboSettingsLevels_DrawItem(object sender, DrawItemEventArgs e)
        {
            if (e.Index != -1)
            {
                CMap mapDraw = ((CMap)cboSettingsLevels.Items[e.Index]);

                e.Graphics.FillRectangle(SystemBrushes.Window, e.Bounds);
                e.DrawBackground();
                e.DrawFocusRectangle();

                e.Graphics.DrawString(String.Format("{0} - {1}", mapDraw.GameMode, mapDraw.PublicLevelName), this.Font, SystemBrushes.WindowText, e.Bounds.Left + 5, e.Bounds.Top);
            }
        }
Esempio n. 6
0
 internal masterСhief()
 {
     map = new CMap();
     //map.Generate();
     rand = new Random();
     TimeToEnd = rand.Next(MinPlayTime, MaxPlayTime);
     CurrentBot = 1;
     Bot1 = new CGameBot(this, 100, 0, map.Bot1);
     Bot2 = new CGameBot(this, 100, 0, map.Bot2);
     BotLose = -1;
     GameEnd = false;
     WhoWin = -1;
 }
Esempio n. 7
0
        public BattlefieldViewModel(CMap map, CHeroBase hero, IGameServiceProvider provider)
        {
            _provider      = provider;
            MyHero         = hero;
            Map            = map;
            MoveCommand    = new CRelayCommand(MoveCommandExecuted);
            TradeCommand   = new CRelayCommand(TradeCommandExecuted, TradeCanExecute);
            BattleCommand  = new CRelayCommand(BattleExecute, BattleCanExecute);
            UseItemCommand = new CRelayCommand(UseItemExecute, UseItemCanExecute);

            provider.ServiceCallback.HeroMoved += OnHeroMoved;
            provider.ServiceCallback.UnitDied  += OnUnitDied;
            MyHeroViewModel = new HeroViewModel(hero);
        }
Esempio n. 8
0
        public Type0Font(NameToken baseFont, ICidFont cidFont, CMap cmap, CMap toUnicodeCMap,
                         CMap ucs2CMap,
                         bool isChineseJapaneseOrKorean)
        {
            this.ucs2CMap = ucs2CMap;
            this.isChineseJapaneseOrKorean = isChineseJapaneseOrKorean;

            BaseFont  = baseFont ?? throw new ArgumentNullException(nameof(baseFont));
            CidFont   = cidFont ?? throw new ArgumentNullException(nameof(cidFont));
            CMap      = cmap ?? throw new ArgumentNullException(nameof(cmap));
            ToUnicode = new ToUnicodeCMap(toUnicodeCMap);
            Details   = cidFont.Details?.WithName(Name.Data)
                        ?? FontDetails.GetDefault(Name.Data);
        }
Esempio n. 9
0
 public async Task Add(CMap map)
 {
     CDebug.Log("something");
     if (!JukedMaps.Contains(map))
     {
         JukedMaps.Add(map);
         await Service_ServerConnection.Events.ChatSendServerMessage("$69f $fff|| Juked $<" + map.Name + "$z$s$>!$");
         await UpdateList();
     }
     else
     {
         await Service_ServerConnection.Events.ChatSendServerMessage("$888 $fff|| Map already juked.");
     }
 }
Esempio n. 10
0
        public Type3Font(NameToken name, PdfRectangle boundingBox, TransformationMatrix fontMatrix,
                         Encoding encoding, int firstChar, int lastChar, decimal[] widths,
                         CMap toUnicodeCMap)
        {
            Name = name;

            this.boundingBox   = boundingBox;
            this.fontMatrix    = fontMatrix;
            this.encoding      = encoding;
            this.firstChar     = firstChar;
            this.lastChar      = lastChar;
            this.widths        = widths;
            this.toUnicodeCMap = new ToUnicodeCMap(toUnicodeCMap);
        }
Esempio n. 11
0
        public override bool AddMap(string mapType)
        {
            if (!base.AddMap(mapType))
                return false;

            CMap map = new CMap(Create.Map(mapType));

            if (IsEmpty())
                SetCurrentMap(map);

            AddMap(map);

            return true;
        }
Esempio n. 12
0
        private CMap GetMap(string strMapFilename)
        {
            CMap cmReturn = null;

            foreach (CMap cMapDefine in this.m_lstMapDefines)
            {
                if (String.Compare(strMapFilename, cMapDefine.FileName) == 0)
                {
                    cmReturn = cMapDefine;
                    break;
                }
            }

            return(cmReturn);
        }
Esempio n. 13
0
        public TrueTypeSimpleFont(CosName name, int firstCharacterCode, int lastCharacterCode, decimal[] widths,
                                  FontDescriptor descriptor,
                                  [CanBeNull] CMap toUnicodeCMap,
                                  [CanBeNull] Encoding encoding)
        {
            this.firstCharacterCode = firstCharacterCode;
            this.lastCharacterCode  = lastCharacterCode;
            this.widths             = widths;
            this.descriptor         = descriptor;
            this.encoding           = encoding;

            Name       = name;
            IsVertical = false;
            ToUnicode  = new ToUnicodeCMap(toUnicodeCMap);
        }
Esempio n. 14
0
        private CMap GetMap(string strFileName)
        {
            CMap returnMap = new CMap(String.Empty, strFileName, String.Empty, strFileName, 0);

            foreach (CMap map in this.m_prcClient.MapListPool)
            {
                if (String.Compare(map.FileName, strFileName, true) == 0)
                {
                    returnMap = map;
                    break;
                }
            }

            return(returnMap);
        }
Esempio n. 15
0
        public IFont Generate(PdfDictionary dictionary, IRandomAccessRead reader, bool isLenientParsing)
        {
            var baseFont = dictionary.GetName(CosName.BASE_FONT);

            var cMap = ReadEncoding(dictionary, out var isCMapPredefined);

            ICidFont cidFont;

            if (TryGetFirstDescendant(dictionary, out var descendantObject))
            {
                var parsed = DirectObjectFinder.Find <PdfDictionary>(descendantObject, pdfObjectParser, reader, isLenientParsing);

                if (parsed is PdfDictionary descendantFontDictionary)
                {
                    cidFont = ParseDescendant(descendantFontDictionary, reader, isLenientParsing);
                }
                else
                {
                    throw new InvalidFontFormatException("Expected to find a Descendant Font dictionary, instead it was: " + parsed);
                }
            }
            else
            {
                throw new InvalidFontFormatException("No descendant font dictionary was declared for this Type 0 font. This dictionary should contain the CIDFont for the Type 0 font. " + dictionary);
            }

            var ucs2CMap = GetUcs2CMap(dictionary, isCMapPredefined, false);

            CMap toUnicodeCMap = null;

            if (dictionary.ContainsKey(CosName.TO_UNICODE))
            {
                var toUnicodeValue = dictionary[CosName.TO_UNICODE];

                var toUnicode = pdfObjectParser.Parse(((CosObject)toUnicodeValue).ToIndirectReference(), reader, isLenientParsing) as PdfRawStream;

                var decodedUnicodeCMap = toUnicode?.Decode(filterProvider);

                if (decodedUnicodeCMap != null)
                {
                    toUnicodeCMap = cMapCache.Parse(new ByteArrayInputBytes(decodedUnicodeCMap), isLenientParsing);
                }
            }

            var font = new Type0Font(baseFont, cidFont, cMap, toUnicodeCMap);

            return(font);
        }
Esempio n. 16
0
        public CharacterBoundingBox GetBoundingBox(int characterCode)
        {
            var matrix = GetFontMatrix();

            var boundingBox = GetBoundingBoxInGlyphSpace(characterCode);

            boundingBox = matrix.Transform(boundingBox);

            var characterIdentifier = CMap.ConvertToCid(characterCode);

            var width = CidFont.GetWidthFromFont(characterIdentifier);

            var advanceWidth = matrix.Transform(new PdfPoint(width, 0)).X;

            return(new CharacterBoundingBox(boundingBox, advanceWidth));
        }
Esempio n. 17
0
 public static void Factory(CMap map, XmlNode entity)
 {
     XmlAttributeCollection attr = entity.Attributes;
     XmlNodeList properties = entity.FirstChild.ChildNodes;
     switch (attr["type"].Value) {
         case "CEntityTransition":
             new CEntityTransition(map, attr, properties);
             break;
         case "CEntityMonsterSpawn":
             new CEntityMonsterSpawn(map, attr, properties);
             break;
         default:
             Console.WriteLine("Unknown Entity Type {0} in LoadMapObjectgroup()", attr["type"].Value);
             break;
     }
 }
    /// <summary>
    /// Can you reach a node by walking
    /// </summary>
    public static bool IsNodeReachable(CMap Map, int PlayerID, Vector2 Position, CNRSearchNode Node)
    {
        // Get two rays that are the width of travel.
        // Create a path 0.4 units wide.
        Vector2 A         = Position;
        Vector2 B         = Node.mPosition;
        Vector2 dir       = (B - A).normalized;
        float   halfWidth = 0.24f;
        Vector2 l1A       = new Vector2(-dir.y * halfWidth + A.x, dir.x * halfWidth + A.y);
        Vector2 l1B       = new Vector2(-dir.y * halfWidth + B.x, dir.x * halfWidth + B.y);
        Vector2 l2A       = new Vector2(dir.y * halfWidth + A.x, -dir.x * halfWidth + A.y);
        Vector2 l2B       = new Vector2(dir.y * halfWidth + B.x, -dir.x * halfWidth + B.y);

        // TODO: Trace nodes uses the mobility set which is not needed for anything else.
        return(Map.TraceNodes(PlayerID, l1A, l1B) && Map.TraceNodes(PlayerID, l2A, l2B));
    }
Esempio n. 19
0
        private CMap ProcessToUnicode()
        {
            CMap      cmapRet = null;
            PdfObject toUni   = PdfReader.GetPdfObjectRelease(this.font.Get(PdfName.TOUNICODE));

            if (toUni is PRStream)
            {
                try {
                    byte[]     touni      = PdfReader.GetStreamBytes((PRStream)toUni);
                    CMapParser cmapParser = new CMapParser();
                    cmapRet = cmapParser.Parse(new MemoryStream(touni));
                } catch {
                }
            }
            return(cmapRet);
        }
Esempio n. 20
0
    // Use this for initialization
    void Start()
    {
        CGameDataMgr.GetInst().Create();
        mCurrentMap = FindObjectOfType <CMap>();
        mCurrentMap.SetScene(this);

        mPlayer = Instantiate(CGameDataMgr.GetInst().PFPlayer, Vector2.zero, Quaternion.identity);
        mPlayer.transform.SetParent(mCurrentMap.mRoomList[0].transform);
        mPlayer.transform.localPosition = Vector3.zero;
        mPlayer.SetScene(this);

        mUIPlayGame = FindObjectOfType <CUIPlayGame>();
        mUIPlayGame.SetScene(this);

        mCurrentMap.mRoomList[0].OnPlayerEnter();
    }
Esempio n. 21
0
    // Use this for initialization
    void Start()
    {
        Instance = this;
        //System.Random random = new System.Random();
        map = new int[map_w, map_h];

        FileStream file = new FileStream("game_Data/Resources/map.data", FileMode.Open);

        StreamReader reader = new StreamReader(file);

        int n1 = 0, n2 = 0;

        while (!reader.EndOfStream)
        {
            string   line = reader.ReadLine();
            string[] word = line.Split(',');
            foreach (string s in word)
            {
                map[n1, n2] = int.Parse(s);

                if (n2 < map_w - 1)
                {
                    n2++;
                }
                else
                {
                    n2 = 0;
                    n1++;
                    if (n1 >= map_h)
                    {
                        break;
                    }
                }
            }
        }
        reader.Close();
        file.Close();

        for (int i = 0; i < map_w; ++i)
        {
            for (int j = 0; j < map_h; ++j)
            {
                GameObject tmp = MonoBehaviour.Instantiate(tileList[map[i, j]]);
                tmp.transform.position = new Vector3((i - map_w / 2) * 0.64f, (j - map_h / 2) * 0.64f, 1);
            }
        }
    }
        /**
         * Parses the ToUnicode entry, if present, and constructs a CMap for it
         * @since 2.1.7
         */
        private void ProcessToUnicode()
        {
            PdfObject toUni = PdfReader.GetPdfObjectRelease(fontDic.Get(PdfName.TOUNICODE));

            if (toUni is PRStream)
            {
                try {
                    byte[] touni = PdfReader.GetStreamBytes((PRStream)toUni);

                    CMapParser cmapParser = new CMapParser();
                    toUnicodeCmap = cmapParser.Parse(new MemoryStream(touni));
                } catch {
                    // technically, we should log this or provide some sort of feedback... but sometimes the cmap will be junk, but it's still possible to get text, so we don't want to throw an exception
                    //throw new IllegalStateException("Unable to process ToUnicode map - " + e.GetMessage(), e);
                }
            }
        }
Esempio n. 23
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="format">See this.GetMapList(string, params string[]) for more information about the format variable</param>
        /// <param name="formattedMapName"></param>
        /// <returns></returns>
        protected CMap GetMapByFormattedName(string format, string formattedMapName)
        {
            CMap returnMap = null;

            foreach (CMap map in this.GetMapDefines())
            {
                string formattedMap = format.Replace("{PublicLevelName}", map.PublicLevelName).Replace("{GameMode}", map.GameMode).Replace("{FileName}", map.FileName);

                if (String.Compare(formattedMap, formattedMapName) == 0)
                {
                    returnMap = map;
                    break;
                }
            }

            return(returnMap);
        }
Esempio n. 24
0
    public void CreateMap(CMap Map)
    {
        Map.Init(100, mBackgroundColor);

        for (int iX = 0; iX < 100; ++iX)
        {
            for (int iY = 0; iY < 100; ++iY)
            {
                Map.mTiles[iX, iY].mTint        = mTileColors[iX, iY];
                Map.mTiles[iX, iY].mWallX.mType = mWallX[iX, iY];
                Map.mTiles[iX, iY].mWallZ.mType = mWallZ[iX, iY];
            }
        }

        Map.GenerateStaticWallCollisions();
        Map.GenerateVisibilitySegments();
    }
Esempio n. 25
0
        protected CMap GetMapByFilenamePlayList(string strMapFileName, string strMapPlayList)
        {
            CMap cmReturn = null;

            List <CMap> mapDefines = GetMapDefines();

            if (mapDefines != null)
            {
                foreach (CMap cmMap in mapDefines.Where(cmMap => String.Compare(cmMap.FileName, strMapFileName, StringComparison.OrdinalIgnoreCase) == 0 && String.Compare(cmMap.PlayList, strMapPlayList, System.StringComparison.OrdinalIgnoreCase) == 0))
                {
                    cmReturn = cmMap;
                    break;
                }
            }

            return(cmReturn);
        }
Esempio n. 26
0
 private void RenderHeightOffsets(CMap controller)
 {
     foreach (var tile in controller.GetMap().GetTiles())
     {
         if (tile.Model.GetHeight() > 1)
         {
             var delta  = (tile.Model.GetHeight() - 1) * ViewParams.HEIGHT_OFFSET;
             var center = tile.Model.Center;
             var y      = center.y + delta;
             center.y = y;
             tile.Model.SetCenter(center);
             var render = tile.Handle.GetComponent <SpriteRenderer>();
             render.transform.position = center;
             render.sortingOrder       = tile.Model.GetHeight();
         }
     }
 }
Esempio n. 27
0
 public void InitTiles(CMap controller, MapInitInfo info, Transform tileHolder)
 {
     this.InitTileSprites();
     foreach (var tile in controller.GetMap().GetTiles())
     {
         this.InitTileType(tile, info);
         if (tile.Model.Liquid)
         {
             this.InitLiquidTile(tile, tileHolder);
         }
         else
         {
             this.InitNonLiquidTile(tile, tileHolder);
         }
     }
     controller.GetMap().InitControllerAdjacent();
 }
Esempio n. 28
0
        public void InitLandmarks(CMap controller, MapInitInfo info)
        {
            var biomeParams = BiomeTable.Instance.Table[info.Biome];

            foreach (var tile in controller.GetMap().GetTiles())
            {
                foreach (var kvp in biomeParams.LandmarkDict)
                {
                    var roll = RNG.Instance.NextDouble();
                    if (roll < kvp.Value)
                    {
                        var factory = new LandmarkFactory();
                        factory.BuildLandmark(kvp.Key, tile);
                    }
                }
            }
        }
Esempio n. 29
0
        public void InitMapEnvironment(CMap controller, MapInitInfo info)
        {
            var decoLoader  = new DecoLoader();
            var biomeParams = BiomeTable.Instance.Table[info.Biome];

            foreach (var decoKVP in biomeParams.DecoDict)
            {
                foreach (var tile in controller.GetMap().GetTiles())
                {
                    var roll = RNG.Instance.NextDouble();
                    if (roll < decoKVP.Value && !FTile.HasFlag(tile.GetFlags().CurFlags, FTile.Flags.Environment))
                    {
                        decoLoader.AttachDeco(tile, decoKVP.Key);
                    }
                }
            }
        }
Esempio n. 30
0
 private void InitAI(CMap map)
 {
     this._ai = new CCombatParticle(map.GetMap().GetTiles());
     foreach (var party in this._combatData.LParties)
     {
         foreach (var agent in party.GetChars())
         {
             this._ai.SetAgentParticlePoints(agent, true);
         }
     }
     foreach (var party in this._combatData.RParties)
     {
         foreach (var agent in party.GetChars())
         {
             this._ai.SetAgentParticlePoints(agent, false);
         }
     }
 }
Esempio n. 31
0
 public CActorBullet(CMap map, int x, int y, ActorDirection direction)
     : this(map, x, y)
 {
     switch (direction) {
         case ActorDirection.Up:
             moveup = true;
             break;
         case ActorDirection.Down:
             movedown = true;
             break;
         case ActorDirection.Left:
             moveleft = true;
             break;
         case ActorDirection.Right:
             moveright = true;
             break;
     }
 }
Esempio n. 32
0
        public CWorld(CMap map, CCamera camera, CSprite[] sprs)
        {
            Map    = map;
            Camera = camera;
            Sprs   = sprs;

            Map.world    = this;
            Camera.world = this;
            for (int i = 0; i < Sprs.length; i++)
            {
                Sprs[i].world = this;
                if (Sprs[i].mapcd == null)
                {
                    Sprs[i].mapcd = CCD.createCDRect(0, -4, -4, 8, 8);
                }
            }
//		ZBuffer = new Vector(sprs.length);
        }
Esempio n. 33
0
        public TrueTypeSimpleFont(NameToken name,
                                  FontDescriptor descriptor,
                                  [CanBeNull] CMap toUnicodeCMap,
                                  [CanBeNull] Encoding encoding,
                                  [CanBeNull] TrueTypeFontProgram fontProgram,
                                  int firstCharacter,
                                  decimal[] widths)
        {
            this.descriptor     = descriptor;
            this.encoding       = encoding;
            this.fontProgram    = fontProgram;
            this.firstCharacter = firstCharacter;
            this.widths         = widths;

            Name       = name;
            IsVertical = false;
            ToUnicode  = new ToUnicodeCMap(toUnicodeCMap);
        }
        public object MarshalNativeToManaged(IntPtr pNativeData)
        {
            CMap map = (CMap)Marshal.PtrToStructure(pNativeData, typeof(CMap));

            int size = map.width * map.height;

            Tile[] tiles = new Tile[size];

            for (int i = 0; i < size; i++)
            {
                IntPtr p    = new IntPtr(map.tiles.ToInt64() + i * Marshal.SizeOf(typeof(CTile)));
                CTile  tile = (CTile)Marshal.PtrToStructure(p, typeof(CTile));
                tiles[i] = new Tile(tile.ter, tile.loc, tile.furn, tile.seen != 0);
            }
            Map res = new Map(map.width, map.height, tiles);

            return(res);
        }
Esempio n. 35
0
        internal async void OnMapLoaded(CMap map)
        {
            if (JukedMaps.Contains(map))
            {
                try
                {
                    if (await CManiaNextControl.ServersConfig[""].GetLiveValue("jukebox_rmp", await CManiaNextControl.GlobalConfig.GetLiveValue("jukebox_rmp", "1"))
                        == "1" &&
                        JukedMaps[0] != map)
                    {
                        return;
                    }
                }
                catch { }
                await Service_ServerConnection.Events.ChatSendServerMessage("$f20 $fff|AUTO| Removing $<" + map.Name + "$z$s$>");

                JukedMaps.Remove(map);
            }
        }
Esempio n. 36
0
 public CEntityMonsterSpawn(CMap map, XmlAttributeCollection attributes, XmlNodeList properties)
 {
     int x, y;
     Dictionary<string, string> props = new Dictionary<string, string>();
     foreach (XmlNode node in properties)
         props.Add(node.Attributes["name"].Value, node.InnerText.Trim());
     switch (props["MonsterType"]) {
         case "CActorCivilian":
             x = Convert.ToInt16(props["X"]);
             y = Convert.ToInt16(props["Y"]);
             map.Actors.AddLast(new CActorCivilian(map, x, y));
             break;
         case "CActorMonster":
             x = Convert.ToInt16(props["X"]);
             y = Convert.ToInt16(props["Y"]);
             map.Actors.AddLast(new CActorMonster(map, x, y));
             break;
     }
 }
Esempio n. 37
0
        public static CMap Quantize(int[][] pixels, int maxcolors)
        {
            // short-circuit
            if (pixels.Length == 0 || maxcolors < 2 || maxcolors > 256)
            {
                return(null);
            }

            var histo = GetHisto(pixels);

            // get the beginning vbox from the colors
            var vbox = VboxFromPixels(pixels, histo);
            var pq   = new List <VBox> {
                vbox
            };

            // Round up to have the same behaviour as in JavaScript
            var target = (int)Math.Ceiling(FractByPopulation * maxcolors);

            // first set of colors, sorted by population
            Iter(pq, ComparatorCount, target, histo);

            // Re-sort by the product of pixel occupancy times the size in color
            // space.
            pq.Sort(ComparatorProduct);

            // next set - generate the median cuts using the (npix * vol) sorting.
            Iter(pq, ComparatorProduct, maxcolors - pq.Count, histo);

            // Reverse to put the highest elements first into the color map
            pq.Reverse();

            // calculate the actual colors
            var cmap = new CMap();

            foreach (var vb in pq)
            {
                cmap.Push(vb);
            }

            return(cmap);
        }
Esempio n. 38
0
        // Get Gamemode List

        protected CMap GetMapByFilename(string strMapFileName)
        {
            CMap cmReturn = null;

            List <CMap> mapDefines = GetMapDefines();

            if (mapDefines != null)
            {
                foreach (CMap cmMap in mapDefines)
                {
                    if (String.Compare(cmMap.FileName, strMapFileName, StringComparison.OrdinalIgnoreCase) == 0)
                    {
                        cmReturn = cmMap;
                        break;
                    }
                }
            }

            return(cmReturn);
        }
Esempio n. 39
0
        protected CMap GetMapByFilenamePlayList(string strMapFileName, string strMapPlayList)
        {
            CMap cmReturn = null;

            List <CMap> mapDefines = this.GetMapDefines();

            if (mapDefines != null)
            {
                foreach (CMap cmMap in mapDefines)
                {
                    if (String.Compare(cmMap.FileName, strMapFileName, true) == 0 && String.Compare(cmMap.PlayList, strMapPlayList, true) == 0)
                    {
                        cmReturn = cmMap;
                        break;
                    }
                }
            }

            return(cmReturn);
        }
Esempio n. 40
0
 public void ChangeMap(CMap map)
 {
     m_CurrentMap = map;
     GC.Collect();
     GC.WaitForPendingFinalizers();
 }
Esempio n. 41
0
 public override void Init()
 {
     m_CurrentMap = new CMap(START_MAP);
 }
Esempio n. 42
0
 public void AddRoundChange(CMap map) {
     this.m_lstRoundChanges.Add(new BattlemapRoundChange(map));
 }
Esempio n. 43
0
 public void SetCurrentMap(CMap map)
 {
     CurrentMap = map;
 }
Esempio n. 44
0
 public BattlemapRoundChange(CMap cmMap, DateTime dtChangeTime) {
     this.Map = cmMap;
     this.ChangeTime = dtChangeTime;
 }
Esempio n. 45
0
 internal void ResetGameFromFile(string path)
 {
     map = new CMap();
     map.ReadFromFile(path);
     TimeToEnd = rand.Next(MinPlayTime, MaxPlayTime);
     CurrentBot = 1;
     Bot1 = new CGameBot(this, 100, 0, map.Bot1);
     Bot2 = new CGameBot(this, 100, 0, map.Bot2);
     BotLose = -1;
     GameEnd = false;
     WhoWin = -1;
     initializ();
 }
Esempio n. 46
0
 internal void ResetGame()
 {
     map = new CMap();
     map.Generate();
     TimeToEnd = rand.Next(MinPlayTime, MaxPlayTime);
     CurrentBot = 1;
     Bot1 = new CGameBot(this, 100, 0, map.Bot1);
     Bot2 = new CGameBot(this, 100, 0, map.Bot2);
     BotLose = -1;
     GameEnd = false;
     WhoWin = -1;
     initializ();
 }
Esempio n. 47
0
 public MapHandler(CMap map)
     : base()
 {
     Map = map;
 }
Esempio n. 48
0
 public BattlemapRoundChange(CMap cmMap) {
     this.Map = cmMap;
     this.ChangeTime = DateTime.Now;
 }
Esempio n. 49
0
        private void RefreshLocalMaplist() {

            if (this.m_client != null && this.m_client.Game != null) {

                if (this.m_client.Game.HasOpenMaplist == false) {

                    CMap[] a_objItems = new CMap[this.cboMaplistPlaylists.Items.Count];
                    this.cboMaplistPlaylists.Items.CopyTo(a_objItems, 0);
                    List<CMap> lstCurrentList = new List<CMap>(a_objItems);

                    foreach (CMap mapPool in this.m_client.MapListPool) {
                        if (lstCurrentList.Find(map => String.Compare(map.PlayList, mapPool.PlayList, true) == 0) == null) {
                            this.cboMaplistPlaylists.Items.Add(mapPool);

                            if (String.Compare(mapPool.PlayList, this.m_client.ListSettings.CurrentPlaylist, true) == 0) {
                                this.cboMaplistPlaylists.SelectedItem = mapPool;
                            }

                            a_objItems = new CMap[this.cboMaplistPlaylists.Items.Count];
                            this.cboMaplistPlaylists.Items.CopyTo(a_objItems, 0);
                            lstCurrentList = new List<CMap>(a_objItems);
                        }
                    }
                }

                if (this.cboMaplistPlaylists.SelectedItem != null || this.m_client.Game.HasOpenMaplist == true) {

                    this.lsvMaplistPool.BeginUpdate();

                    // Update the available maplist pool.
                    this.lsvMaplistPool.Items.Clear();
                    List<CMap> lstMapPool;
                    if (this.m_client.Game.HasOpenMaplist == true) {
                        lstMapPool = new List<CMap>(this.m_client.MapListPool);
                    }
                    else {
                        lstMapPool = this.m_client.MapListPool.FindAll(map => String.Compare(map.PlayList, ((CMap)cboMaplistPlaylists.SelectedItem).PlayList, true) == 0);
                    }

                    foreach (CMap map in lstMapPool) {

                        if (this.lsvMaplistPool.Items.ContainsKey(map.FileName.ToLower()) == false) {
                            ListViewItem mapPoolItem = new ListViewItem();
                            mapPoolItem.Tag = new MaplistEntry(map.PlayList, map.FileName, 0);
                            //mapPoolItem.Tag = new MaplistEntry(map.FileName);
                            mapPoolItem.Text = map.GameMode;
                            mapPoolItem.SubItems.Add(new ListViewItem.ListViewSubItem(mapPoolItem, map.FileName));
                            mapPoolItem.SubItems.Add(new ListViewItem.ListViewSubItem(mapPoolItem, map.PublicLevelName));

                            this.lsvMaplistPool.Items.Add(mapPoolItem);
                        }
                    }

                    #region ColorSameGamemode
                    bool blDoColor = false;
                    for (int i = 0; i < this.lsvMaplistPool.Items.Count; i++ )
                    {
                        if (i == 0) { continue; }
                        if (!this.lsvMaplistPool.Items[i].Text.Equals(this.lsvMaplistPool.Items[i - 1].Text))
                        {
                            if (blDoColor == true) { blDoColor = false; } else { blDoColor = true; }
                        }

                        if (blDoColor == true)
                        {
                            this.lsvMaplistPool.Items[i].BackColor = Color.FromArgb(233, 233, 233);
                        }
                    }
                    #endregion

                    this.lsvMaplistPool.EndUpdate();
                }

                for (int i = 0; i < this.lsvMaplistPool.Columns.Count; i++) {
                    this.lsvMaplistPool.Columns[i].Width = -2;
                }
            }
        }
Esempio n. 50
0
 public override void CollidePlayer()
 {
     Console.WriteLine("Triggered World Transition");
     CMap map = new CMap(newmap, newx, newy);
     CPlayState.Instance().ChangeMap(map);
 }
Esempio n. 51
0
        private CMap GetMap(string strFileName)
        {
            CMap returnMap = new CMap(String.Empty, strFileName, String.Empty, strFileName, 0);

            foreach (CMap map in this.m_prcClient.MapListPool) {
                if (String.Compare(map.FileName, strFileName, true) == 0) {
                    returnMap = map;
                    break;
                }
            }

            return returnMap;
        }
Esempio n. 52
0
 private void MapListPool_ItemAdded(int iIndex, CMap item) {
     this.InvokeIfRequired(this.RefreshLocalMaplist);
 }
Esempio n. 53
0
 private void MapListPool_ItemAdded(int iIndex, CMap item) {
     this.RefreshLocalMaplist();
 }