ToArray() public method

public ToArray ( ) : Object[]
return Object[]
        private CodeElement FindType(ProjectItems projectItems, string typename)
        {
            var tokens = typename.Split('.');
            var path =new Queue<string>(tokens.ToList());
         

            while ( path.Count>0)
            {
                var itemName = path.Dequeue();
                var  found = false;
                Debug.WriteLine("Searching for " + itemName );
                if (projectItems == null) break;

                foreach (ProjectItem projectItem in projectItems)
                {
                    Debug.WriteLine("Checking " + projectItem.Name );
                    if (projectItem.Name.Equals(itemName, StringComparison.CurrentCultureIgnoreCase))
                    {
                        Debug.WriteLine("Found the project Item!!!");
                        found = true;

                        if (projectItem.ProjectItems != null && projectItem.ProjectItems.Count > 0)
                        {
                            Debug.WriteLine("Searching children");
                            // search the children of this projectitem
                            var foundHere = FindType(projectItem.ProjectItems, string.Join(".", path.ToArray()));

                            if (foundHere != null)
                            {
                                Debug.WriteLine("Found in children of " + projectItem.Name );

                                return foundHere;
                            }
                            Debug.WriteLine("Continuing looking");
                            
                            break;
                        }
                    }
                    else
                    {
                       var theType = FindType(projectItem, typename);

                        if (theType != null)
                        {
                            Debug.WriteLine("Found it!!!!" + theType.FullName );
                            return theType;
                        }
                    }
                    
                }
                if (!found)
                {
                    Debug.WriteLine("Didnt find this token" + itemName );
                    break;
                }
            }
            return null;
        }
 static public int ToArray(IntPtr l)
 {
     try {
         System.Collections.Queue self = (System.Collections.Queue)checkSelf(l);
         var ret = self.ToArray();
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
 }
示例#3
0
 static int ToArray(IntPtr L)
 {
     try
     {
         ToLua.CheckArgsCount(L, 1);
         System.Collections.Queue obj = (System.Collections.Queue)ToLua.CheckObject(L, 1, typeof(System.Collections.Queue));
         object[] o = obj.ToArray();
         ToLua.Push(L, o);
         return(1);
     }
     catch (Exception e)
     {
         return(LuaDLL.toluaL_exception(L, e));
     }
 }
示例#4
0
            public override void execute3(RunTimeValueBase thisObj,FunctionDefine functionDefine,SLOT returnSlot,SourceToken token,StackFrame stackframe,out bool success)
            {
                System.Collections.Queue queue =
                    (System.Collections.Queue)((LinkObj <object>)((ASBinCode.rtData.rtObjectBase)thisObj).value).value;

                try
                {
                    object obj = queue.ToArray();

                    stackframe.player.linktypemapper.storeLinkObject_ToSlot(obj,functionDefine.signature.returnType,returnSlot,bin,stackframe.player);
                    //returnSlot.setValue((int)array.GetValue(index));
                    success = true;
                }
                catch (RuntimeLinkTypeMapper.TypeLinkClassException tlc)
                {
                    success = false;
                    stackframe.throwAneException(token,tlc.Message);
                }
                catch (KeyNotFoundException)
                {
                    success = false;
                    stackframe.throwAneException(token,"Queue.toArray()的结果没有链接到脚本");
                }
                catch (ArgumentException a)
                {
                    success = false;
                    stackframe.throwAneException(token,a.Message);
                }
                catch (IndexOutOfRangeException i)
                {
                    success = false;
                    stackframe.throwAneException(token,i.Message);
                }
                catch (InvalidOperationException io)
                {
                    success = false;
                    stackframe.throwAneException(token,io.Message);
                }
            }
示例#5
0
文件: Ports.cs 项目: Prizmer/ps
        public int WriteReadData(FindPacketSignature func, byte[] out_buffer, ref byte[] in_buffer, int out_length, int target_in_length, uint pos_count_data_size = 0, uint size_data = 0, uint header_size = 0)
        {
            int reading_size = 0;
            using (TcpClient tcp = new TcpClient())
            {
                Queue<byte> reading_queue = new Queue<byte>(8192);

                try
                {
                    Thread.Sleep(m_delay_between_sending);
                    tcp.SendTimeout = 500;
                    tcp.ReceiveTimeout = 500;

                    IAsyncResult ar = tcp.BeginConnect(m_address, m_port, null, null);
                    using (WaitHandle wh = ar.AsyncWaitHandle)
                    {
                        if (!ar.AsyncWaitHandle.WaitOne(TimeSpan.FromSeconds(10), false))
                        {
                            throw new TimeoutException();
                        }
                        else
                        {
                            if (tcp.Client.Connected)
                            {
                                tcp.Client.ReceiveTimeout = m_read_timeout;
                                tcp.Client.SendTimeout = m_write_timeout;

                                // посылка данных
                                if (tcp.Client.Send(out_buffer, out_length, SocketFlags.None) == out_length)
                                {
                                    uint elapsed_time_count = 0;

                                    Thread.Sleep(50);

                                    // чтение данных
                                    while (elapsed_time_count < m_read_timeout)
                                    {
                                        if (tcp.Client.Available > 0)
                                        {
                                            try
                                            {
                                                byte[] tmp_buff = new byte[tcp.Available];
                                                int readed_bytes = tcp.Client.Receive(tmp_buff, 0, tmp_buff.Length, SocketFlags.None);

                                                for (int i = 0; i < readed_bytes; i++)
                                                {
                                                    reading_queue.Enqueue(tmp_buff[i]);
                                                }
                                            }
                                            catch (Exception ex)
                                            {
                                                WriteToLog("Receive: " + ex.Message);
                                            }
                                        }
                                        elapsed_time_count += 50;
                                        Thread.Sleep(50);
                                    }

                                    int pos = -1;
                                    if ((pos = func(reading_queue)) >= 0)
                                    {
                                        for (int i = 0; i < pos; i++)
                                        {
                                            reading_queue.Dequeue();
                                        }

                                        byte[] temp_buffer = new byte[reading_size = reading_queue.Count];
                                        temp_buffer = reading_queue.ToArray();

                                        if (target_in_length == 0)
                                        {
                                            if (reading_size > pos_count_data_size)
                                            {
                                                target_in_length = Convert.ToInt32(temp_buffer[pos_count_data_size] * size_data + header_size);
                                            }
                                        }

                                        if (target_in_length > 0)
                                        {
                                            if (reading_size >= target_in_length)
                                            {
                                                reading_size = target_in_length;
                                                for (int i = 0; i < target_in_length && i < in_buffer.Length; i++)
                                                {
                                                    in_buffer[i] = temp_buffer[i];
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    WriteToLog(ex.Message);
                    return -1;
                }
                finally
                {
                    reading_queue.Clear();
                }
            }

            return reading_size;
        }
        private static string[] LexicalParse(string mathString)
        {
            mathString = mathString.Replace(" ", "");

            Queue<string> queueTokens = new Queue<string>();
            Queue<string> queueOperand = new Queue<string>();

            foreach (char symbol in mathString)
            {

                if (Operators.ContainsKey(symbol.ToString()))
                {
                    if (queueOperand.Count != 0)
                    {
                        JoinOperandSymbols(queueOperand, queueTokens);
                    }

                    queueTokens.Enqueue(symbol.ToString());
                }
                else
                {
                    queueOperand.Enqueue(symbol.ToString());
                }
            }
            if (queueOperand.Count != 0)
                JoinOperandSymbols(queueOperand, queueTokens);

            return queueTokens.ToArray();
        }
示例#7
0
文件: Core.cs 项目: WildGenie/uo-ext
        static Dll()
        {
            m_md5Provider = new MD5CryptoServiceProvider();
            if (Config.Is64Bit || Config.IsUnix)
            {
                Console.WriteLine("UOExt: 64bit or Unix env. Plugins info will be loaded from XML.");
            }


            if (!Directory.Exists(Config.ClientPluginsPath))
            {
                Dlls = new Dll[0];
                m_loadingOrder = new Plugin[0];
                return;
            }
            if (!File.Exists(Config.PluginInitOrderFile))
            {
                ConsoleColor cc = Console.ForegroundColor;
                Console.ForegroundColor = ConsoleColor.Yellow;
                Console.WriteLine("UOExt: Warning: No plugin init order file found. Loading all plugins.");
                Console.WriteLine("UOExt:           Path '{0}'", Config.PluginInitOrderFile);
                Console.ForegroundColor = cc;

                string[] files = Directory.GetFiles(Config.ClientPluginsPath, "*.plg");

                Dlls = new Dll[files.Length];
                for (int i = 0; i < files.Length; i++)
                {
                    Dlls[i] = new Dll(files[i], (ushort)i);
                }

                Queue<Plugin> order = new Queue<Plugin>();
                for (int i = 0; i < Dlls.Length; i++)
                {
                    for (int j = 0; j < Dlls[i].Plugins.Length; j++) order.Enqueue(Dlls[i].Plugins[j]);
                }
                m_loadingOrder = order.ToArray();

            }
            else
            {
                string[] info = File.ReadAllLines(Config.PluginInitOrderFile);

                Dictionary<string, Dll> dlls = new Dictionary<string,Dll>();
                Queue<Plugin> order = new Queue<Plugin>();

                ushort dll_id = 0;

                char[] splitter = new char[1];
                splitter[0] = ',';
                for (int i = 0; i < info.Length; i++)
                {
                    string[] row = info[i].Split(splitter, 2);
                    row[0] = row[0].Trim().ToUpper();

                    if (row[0][0] == ';') continue;
                    if (row.Length < 2)
                    {
                        ConsoleColor cc = Console.ForegroundColor;
                        Console.ForegroundColor = ConsoleColor.Yellow;
                        Console.WriteLine("UOExt: Warning: Illegal string found in plugin init order file. Skipping.");
                        Console.WriteLine("UOExt:           String: '{0}'", info[i]);
                        Console.ForegroundColor = cc;
                        continue;
                    }

                    row[1] = row[1].Trim();
                    ushort current_id;
                    if (!dlls.ContainsKey(row[0]))
                        dlls[row[0]] = new Dll(row[0], dll_id++);

                    current_id = dlls[row[0]].Id;

                    int number;
                    bool is_number = int.TryParse(row[1], out number);
                    for (int j = 0; j < dlls[row[0]].Plugins.Length; j++)
                        if (((is_number) && (number == dlls[row[0]].Plugins[j].Id)) || ((!is_number) && (dlls[row[0]].Plugins[j].Name == row[1])))
                        {
                            order.Enqueue(dlls[row[0]].Plugins[j]);
                            break;
                        }
                        
                }

                Dlls = new Dll[dlls.Count];
                foreach (Dll dll in dlls.Values)
                    Dlls[dll.Id] = dll;

                m_loadingOrder = order.ToArray();
            }
        }
示例#8
0
        public static void Count(Stack<CmdBase> instructions, bool forwarding, int hazardBubbels, int jumpBubbels, int branchBubbels, bool perCycleOutput)
        {
            //Pipline Stages: IF, ID, EX, MEM, WB
            /*
             * Ansatz:
             * Stack der die fünf Stages darstellen soll. solange ausführen bis initale Liste leer is, runden zurückgeben
             */
            Queue<CmdBase> stages = new Queue<CmdBase>(); 
            List<CmdBase> controlHazards = new List<CmdBase>();
            List<CmdBase> dataHazards = new List<CmdBase>();

            int cycle = 0;
            while (instructions.Count != 0 || stages.Count > 0)
            {       
                cycle++;
                if (perCycleOutput) printStages(stages, cycle - 1);

                if (stages.Count > 5 || instructions.Count == 0) 
                    stages.Dequeue(); //remove last wb stage
                if (stages.Count > 5) 
                    continue; //bubbels

                if (instructions.Count == 0) continue; //skip enqueue part

                CmdBase nextCmd = instructions.Pop();
               
                //Data Hazards, let our cmd WAIT if we need from a cmd before
                var array = stages.ToArray();
                var usedRegs = new List<byte>();
                if (array.Length > 0)
                {
                    usedRegs.AddRange(array[array.Length - 1].getDstRegisters());
                    if (array.Length > 1)
                    {
                        usedRegs.AddRange(array[array.Length - 2].getDstRegisters());
                    }
                }
                var actualRegs = nextCmd.getSourceRegisters();

                bool match = false;
                actualRegs.ForEach(ourReg => usedRegs.ForEach(prevReg => { if (ourReg == prevReg) match = true; }));

                if (match && !(forwarding))
                {
                    //hazard dete
                    for (int i = 0; i < hazardBubbels; i++)
                    {
                        stages.Enqueue(new CmdBubble(""));
                    }
                    dataHazards.Add(nextCmd);
                }

                stages.Enqueue(nextCmd);

                //let the next instruction AFTER our wait
                if (nextCmd is CmdBranch && instructions.Count > 0)
                {
                    //branch penalty
                    for (int i = 0; i < branchBubbels; i++)
                    {
                        stages.Enqueue(new CmdBubble(""));
                    }
                    controlHazards.Add(nextCmd);
                }
                else if (nextCmd is CmdJ && instructions.Count > 0)
                {
                    //Jump penealty
                    for (int i = 0; i < jumpBubbels; i++)
                    {
                        stages.Enqueue(new CmdBubble(""));
                    }
                    controlHazards.Add(nextCmd);
                }
            }


            Console.WriteLine("=======================");
            Console.WriteLine("Data Hazards: ");
            dataHazards.ForEach(e => Console.WriteLine("At: " + e));
            Console.WriteLine("Control Hazards: ");
            controlHazards.ForEach(e => Console.WriteLine("At: " + e));
            Console.WriteLine("=======================");
            Console.WriteLine("Cycle count: " + cycle);
        }
        public static string[] getActionToolTipStrings(string spriteName, Player player)
        {
            string name = spriteName.Substring(0,spriteName.IndexOf("("));
            name = name.Trim();
            //name = spriteName.Remove(spriteName.Length-1);

            //Research Variables
            int[] researchInts = new int[5];
            float[] researchFloats = new float[2];

            Unit unitObject = null;
            Building buildingObject = null;
            if (isUnit(name))
                unitObject = GetUnit(name).GetComponent<Unit>() as Unit;
            else if (isBuilding(name)) {
                buildingObject = GetBuilding(name).GetComponent<Building>() as Building;
            } else {
                researchInts = player.upgradeManager.GetResearchInts(name);
                researchFloats = player.upgradeManager.GetResearchFloats(name);
            }
            name = name.ToLower();
            Queue<string> text = new Queue<string>();
            switch (name) {
            case "pantry":
                text.Enqueue("Build Pantry");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A Pantry allows you to build workers and heroes.");
                break;
            case "mixer":
                text.Enqueue("Build Mixer");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A Mixer allows you to research your units and buildings to make them better.");
                break;
            case "warcooker":
                text.Enqueue("Build War Cooker");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A War Cooker allows you to produce new combat units.");
                break;
            case "spicehouse":
                text.Enqueue("Build Spice House");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A Spice House allows you to increase your spice limit.");
                break;
            case "sugargrinder":
                text.Enqueue("Build Sugar Grinder");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A Sugar Grinder allows you to construct harvesters to gather sugar and drop it off a Sugar Grinder.");
                break;
            case "doughroller":
                text.Enqueue("Build Dough Roller");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A Dough Roller allows you to construct harvesters to gather dough and drop it off a Dough Roller.");
                break;
            case "tower":
                text.Enqueue("Build Tower");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + buildingObject.costDough);
                text.Enqueue("Sugar Cost: " + buildingObject.costSugar);
                text.Enqueue("Build Time: " + buildingObject.timeToBuild);
                text.Enqueue("A Tower that will seek out enemies and shoot at them until destroyed.");
                break;
            case "stopcommand":
                text.Enqueue("Stop Command");
                text.Enqueue("");
                text.Enqueue("Stop all units from moving");
                break;
            case "harvestcommand":
                text.Enqueue("Harvest Command");
                text.Enqueue("");
                text.Enqueue("Harvest resources or recyclable units / buildings");
                break;
            case "rallypointflag":
                text.Enqueue("Rally Point Command");
                text.Enqueue("");
                text.Enqueue("Set a rally point for units to move to once created");
                break;
            case "sellicon":
                text.Enqueue("Sell Command");
                text.Enqueue("");
                text.Enqueue("Sell this building for " + player.sellPercentage*100 + "% of building materials");
                break;
            case "doughball":
                text.Enqueue("Build Dough Ball");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + unitObject.costDough);
                text.Enqueue("Sugar Cost: " + unitObject.costSugar);
                text.Enqueue("Spice Cost: " + unitObject.costSpice);
                text.Enqueue("Build Time: " + unitObject.timeToBuild);
                text.Enqueue("Dough Ball is a ranged combat unit");
                break;
            case "meleeunit":
                text.Enqueue("Build Melee Unit");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + unitObject.costDough);
                text.Enqueue("Sugar Cost: " + unitObject.costSugar);
                text.Enqueue("Spice Cost: " + unitObject.costSpice);
                text.Enqueue("Build Time: " + unitObject.timeToBuild);
                text.Enqueue("Melee Unit is a melee combat unit.");
                break;
            case "worker":
                text.Enqueue("Build Worker");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + unitObject.costDough);
                text.Enqueue("Sugar Cost: " + unitObject.costSugar);
                text.Enqueue("Spice Cost: " + unitObject.costSpice);
                text.Enqueue("Build Time: " + unitObject.timeToBuild);
                text.Enqueue("Worker is a non combat unit that can build structures");
                break;
            case "harvester":
                text.Enqueue("Build Harvester");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + unitObject.costDough);
                text.Enqueue("Sugar Cost: " + unitObject.costSugar);
                text.Enqueue("Spice Cost: " + unitObject.costSpice);
                text.Enqueue("Build Time: " + unitObject.timeToBuild);
                text.Enqueue("Harvester is a non combat unit that can harvest resources");
                break;
            case "observer":
                text.Enqueue("Build Observer");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + unitObject.costDough);
                text.Enqueue("Sugar Cost: " + unitObject.costSugar);
                text.Enqueue("Spice Cost: " + unitObject.costSpice);
                text.Enqueue("Build Time: " + unitObject.timeToBuild);
                text.Enqueue("Observer is a non combat unit that the camera can bind in order to navigate and explore the map.");
                break;
            case "faster attack":
                text.Enqueue("Research Faster Attack");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the attack speed of the Dough Ball units by " +  researchFloats[1]*-1 +
                             " for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            case "more hp":
                text.Enqueue("Research More HP");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the Health Points of the Melee Units by " + researchFloats[1] +
                             " for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            case "more speed":
                text.Enqueue("Research More Speed");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the speed of the Harvester units by " + researchFloats[1] +
                             " for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            case "faster building":
                text.Enqueue("Research Faster Building");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the building speed of the Worker units by " + researchFloats[1] +
                             " for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            case "faster construction":
                text.Enqueue("Research Faster Construction");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the construction speed of the War Cooker buildings by " + researchFloats[1] +
                             " for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            case "stronger attack":
                text.Enqueue("Research Stronger Attack");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the damage of the Tower buildings by " + researchFloats[1] +
                             " for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            case "better salvage":
                text.Enqueue("Research Better Salvage");
                text.Enqueue("");
                text.Enqueue("Dough Cost: " + researchInts[0]);
                text.Enqueue("Sugar Cost: " + researchInts[1]);
                text.Enqueue("Chocolate Cost: " + researchInts[2]);
                text.Enqueue("Build Time: " + researchFloats[0]);
                text.Enqueue("This research will increase the selling rate of buildings by " + researchFloats[1]*100 +
                             "% for every time it has been researched. Researched " + researchInts[3] + "/" + researchInts[4] + " times.");
                break;
            default:
                return null;
            }
            return text.ToArray();
        }
示例#10
0
 SColor[] GetPixelsForTargetPixel(int _x, int _y)
 {
     Queue<SColor> outArray = new Queue<SColor>(m_scaleSizeX * m_scaleSizeY);
     int idx =0;
     for(int y = -m_scaleSizeY;y < (m_scaleSizeY +1);y++)
     {
         for(int x = -m_scaleSizeX;x < (m_scaleSizeX +1);x++)
         {
             int pX = (int)System.Math.Round( _x * m_scaleX + x);
             int pY = (int)System.Math.Round( _y * m_scaleY + y);
             //image bounds check
             if(pX >= 0 && pY >= 0)
             {
                 if(pX < m_width && pY < m_height)
                 {
                     idx = pX + pY * m_width;
                     outArray.Enqueue( m_originalColors[idx] );
                 }
             }
         }
     }
     return outArray.ToArray();
 }
        /// <summary>
        /// Load graphics content for the game.
        /// </summary>
        public override void LoadContent()
        {
            if (content == null)
                content = new ContentManager(ScreenManager.Game.Services, "Content");

            gameFont = content.Load<SpriteFont>("gamefont");

            // Initialize camera controls
            _view = Matrix.Identity;
            _cameraPosition = new Vector2(0f, 0f);

            _screenCenter = new Vector2(GameStateManagementGame.graphics.GraphicsDevice.Viewport.Width / 2f,
                                                GameStateManagementGame.graphics.GraphicsDevice.Viewport.Height / 2f);

            _batch = new SpriteBatch(GameStateManagementGame.graphics.GraphicsDevice);
            _font = content.Load<SpriteFont>("font");
            bigFont = content.Load<SpriteFont>("bigFont");

            // Load sprites
            player = content.Load<Texture2D>("player1"); // 95px x 80px =>   1m x 1.25m
            armgun = content.Load<Texture2D>("armgun"); // 28px x 67px =>   1m x 1.25m
            head = content.Load<Texture2D>("head"); // 41px x 37px
            bulletTex = content.Load<Texture2D>("bullet");
            bulletTex2 = content.Load<Texture2D>("bullet2");
            squareTex = content.Load<Texture2D>("square");

            playerJump = content.Load<Texture2D>("jumping");
            playerDead = content.Load<Texture2D>("dead");
            playerKnife = content.Load<Texture2D>("knife");

            //editing textures
            crosshair = content.Load<Texture2D>("crosshair");
            marker = content.Load<Texture2D>("marker");

            //background
            bg = content.Load<Texture2D>("level1bg");
            mg = content.Load<Texture2D>("level1mg");
            bgPosB = bgPos + new Vector2(bg.Width, 0f);
            mgPos = Vector2.Zero;
            mgPosB = Vector2.Zero;        //to be changed

            //level tiles
            A_0_0 = content.Load<Texture2D>("level tiles/A_0_0");
            A_0_720 = content.Load<Texture2D>("level tiles/A_0_720");
            A_1280_0 = content.Load<Texture2D>("level tiles/A_1280_0");
            A_1280_720 = content.Load<Texture2D>("level tiles/A_1280_720");
            A_2560_1440 = content.Load<Texture2D>("level tiles/A_2560_1440");
            A_2560_720 = content.Load<Texture2D>("level tiles/A_2560_720");
            A_3840_1440 = content.Load<Texture2D>("level tiles/A_3840_1440");
            A_3840_720 = content.Load<Texture2D>("level tiles/A_3840_720");
            A_5120_1440 = content.Load<Texture2D>("level tiles/A_5120_1440");
            A_5120_720 = content.Load<Texture2D>("level tiles/A_5120_720");
            A_M1280_0 = content.Load<Texture2D>("level tiles/A_M1280_0");
            A_M1280_720 = content.Load<Texture2D>("level tiles/A_M1280_720");
            A_5120_2160 = content.Load<Texture2D>("level tiles/A_5120_2160");
            A_6400_1440 = content.Load<Texture2D>("level tiles/A_6400_1440");
            A_6400_2160 = content.Load<Texture2D>("level tiles/A_6400_2160");
            A_7680_1440 = content.Load<Texture2D>("level tiles/A_7680_1440");
            A_7680_2160 = content.Load<Texture2D>("level tiles/A_7680_2160");

            //flashing bullet colors
            playerBulletColors = new List<Color> { Color.Red, Color.WhiteSmoke };
            enemyBulletColors = new List<Color> { Color.Red, Color.Black };

            //armgun stuff init
            armgunXOffset = 0;
            armgunOrigin = Vector2.Zero;

            //markers
            markers = new List<Vector2>();

            //setup main guy
            playerTexture = content.Load<Texture2D>("run");
            playerAnimation = new Animation();
            playerAnimation.Initialize(playerTexture, Vector2.Zero, 86, 119, 25, 30, Color.White, 1f, true, new Vector2(0, 0));

            box = new CompositeCharacter(_world, new Vector2(300f, 600f), 64, 128, 0.3f, squareTex);
            box.forcePower = 100;

            //create enemies
            enemies = new List<EnemyCompositeCharacter>();

            //knifebear 1 - at start
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(600f, 600f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            //knifebear 1 - at start
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(800f, 600f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            //knifebear 2 - on top of first hill
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(1430f, 600f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            //knifebear 2 - on top of first hill
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(1630f, 600f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            //knifebear 3 - just after second rock
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(3470f, 980f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            //knifebear 3 - just after second rock
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(5560f, 1800f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            //knifebear 4 - before first sea platform
            bearBox = new EnemyCompositeCharacter(_world, new Vector2(6000f, 1580f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies.Add(bearBox);

            enemies2 = new List<EnemyCompositeCharacter2>();

            //shootbear 1 - just after the first stump
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(3925f, 1010f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //shootbear 1 - just after the first stump
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(800f, 500f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //shootbear 2 - in front of the large tree
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(5460f, 1800f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //shootbear 1 - just after the first stump
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(3670f, 980f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //shootbear 3 - 3rd sea platform
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(6920f, 1580f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //shootbear 3 - 2d sea platform
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(7520f, 1580f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //shootbear 3 - 3rd sea platform
            bear2Box = new EnemyCompositeCharacter2(_world, new Vector2(8170f, 1880f), 93, 183, 0.15f, squareTex);
            bearBox.forcePower = 100;
            enemies2.Add(bear2Box);

            //player ignore collisions with enemies
            box.body.CollisionGroup = -1;
            box.wheel.CollisionGroup = -1;

            for (int i = 0; i < enemies.Count; i++)
            {
                enemies[i].body.CollisionGroup = -1;
                enemies[i].wheel.CollisionGroup = -1;
            }

            for (int i = 0; i < enemies2.Count; i++)
            {
                enemies2[i].body.CollisionGroup = -1;
                enemies2[i].wheel.CollisionGroup = -1;
            }

            //setup 3d sound
            audioListener = new AudioListener();

            //init bullet stuff
            //bulletDirection = new Vector2(0, 0);
            bulletQueue = new Queue<Bullet>();
            tempBulletArray = bulletQueue.ToArray();

            //setup deadzones
            deadZones = new List<Rectangle>();

            deadZones.Add(new Rectangle(2552, 1040, 402, 115));      //first pit
            deadZones.Add(new Rectangle(6497, 1989, 402, 115));      //2nd
            deadZones.Add(new Rectangle(7013, 1992, 502, 115));      //3rd pit
            deadZones.Add(new Rectangle(7654, 2196, 702, 115));      //last pit

            // Create the ground fixture
            Body impassableEdge = BodyFactory.CreateEdge(_world, new Vector2(0f, 3f), new Vector2(0.25f, 3f));
            impassableEdge.IsStatic = true;
            impassableEdge.Restitution = 0.1f;
            impassableEdge.Friction = 0.7f;

            //From top of first cliff---------------------------------------------------------------------------------------
            FixtureFactory.AttachEdge(new Vector2(-2.06f, 1.215f), new Vector2(-0.32f, 1.185f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(-0.32f, 1.185f), new Vector2(1.29f, 1.285f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.29f, 1.285f), new Vector2(2.37f, 1.315f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.37f, 1.315f), new Vector2(2.2f, 1.585f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.2f, 1.585f), new Vector2(2.08f, 1.645f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.08f, 1.645f), new Vector2(2.03f, 1.885f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.03f, 1.885f), new Vector2(1.69f, 2.005f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.69f, 2.005f), new Vector2(1.47f, 2.225f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.47f, 2.225f), new Vector2(1.44f, 2.425f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.44f, 2.425f), new Vector2(1.34f, 2.735f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.34f, 2.735f), new Vector2(1.41f, 2.965f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.41f, 2.965f), new Vector2(1.38f, 3.225f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.38f, 3.225f), new Vector2(1.35f, 3.585f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.35f, 3.585f), new Vector2(1.36f, 3.885f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.36f, 3.885f), new Vector2(1.42f, 4.155f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.42f, 4.155f), new Vector2(1.56f, 4.405f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.56f, 4.405f), new Vector2(1.68f, 4.585f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.68f, 4.585f), new Vector2(1.56f, 4.825f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.56f, 4.825f), new Vector2(1.71f, 5.275f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.71f, 5.275f), new Vector2(1.81f, 5.405f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.81f, 5.405f), new Vector2(1.86f, 5.575f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.86f, 5.575f), new Vector2(1.98f, 5.755f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(1.98f, 5.755f), new Vector2(2.16f, 6.015f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.16f, 6.015f), new Vector2(2.26f, 6.085f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.26f, 6.085f), new Vector2(2.28f, 6.185f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.28f, 6.185f), new Vector2(2.35f, 6.325f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.35f, 6.325f), new Vector2(2.43f, 6.465f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(2.43f, 6.465f), new Vector2(16.38f, 6.465f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(16.38f, 6.465f), new Vector2(22.68f, 8.915f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(22.68f, 8.915f), new Vector2(23.85f, 8.125f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(23.85f, 8.125f), new Vector2(26.29f, 8.065f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.29f, 8.065f), new Vector2(26.48f, 8.165f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.48f, 8.165f), new Vector2(26.43f, 8.825f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.43f, 8.825f), new Vector2(26.24f, 9.395f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.24f, 9.395f), new Vector2(26.38f, 9.885f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.38f, 9.885f), new Vector2(26.15f, 10.215f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.15f, 10.215f), new Vector2(25.67f, 10.425f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.67f, 10.425f), new Vector2(25.95f, 10.945f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.95f, 10.945f), new Vector2(26.03f, 11.505f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(26.03f, 11.505f), new Vector2(25.8f, 12.015f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.8f, 12.015f), new Vector2(25.65f, 12.775f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.65f, 12.775f), new Vector2(25.66f, 13.225f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.66f, 13.225f), new Vector2(25.65f, 13.845f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.65f, 13.845f), new Vector2(25.62f, 14.405f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.62f, 14.405f), new Vector2(25.74f, 14.115f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(25.74f, 14.115f), new Vector2(21.72f, 16.385f), impassableEdge);
            //To bottom of rock jump on the left---------------------------------------------------------------------------------------

            //From bottom of rock jump on right----------------------------------------------------------------------------------
            FixtureFactory.AttachEdge(new Vector2(29.19f, 14.08f), new Vector2(29.19f, 13.36f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.19f, 13.36f), new Vector2(29.01f, 12.87f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.01f, 12.87f), new Vector2(28.92f, 12.63f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(28.92f, 12.63f), new Vector2(29.11f, 11.9f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.11f, 11.9f), new Vector2(29.18f, 11.23f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.18f, 11.23f), new Vector2(29.39f, 11.11f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.39f, 11.11f), new Vector2(29.28f, 10.72f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.28f, 10.72f), new Vector2(29.4f, 10.14f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.4f, 10.14f), new Vector2(29.55f, 9.99f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(29.55f, 9.99f), new Vector2(30.07f, 9.96f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(30.07f, 9.96f), new Vector2(30.61f, 10.03f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(30.61f, 10.03f), new Vector2(31.33f, 10.06f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(31.33f, 10.06f), new Vector2(31.9f, 10.05f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(31.9f, 10.05f), new Vector2(32.32f, 10.12f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(32.32f, 10.12f), new Vector2(32.67f, 10.29f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(32.67f, 10.29f), new Vector2(32.94f, 10.46f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(32.94f, 10.46f), new Vector2(33.18f, 10.68f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(33.18f, 10.68f), new Vector2(33.63f, 10.69f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(33.63f, 10.69f), new Vector2(34.57f, 10.7f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(34.57f, 10.7f), new Vector2(35.5f, 10.63f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(35.5f, 10.63f), new Vector2(36.26f, 10.67f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(36.26f, 10.67f), new Vector2(36.83f, 10.62f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(36.83f, 10.62f), new Vector2(36.96f, 10.42f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(36.96f, 10.42f), new Vector2(37.04f, 10.33f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(37.04f, 10.33f), new Vector2(37.07f, 10.21f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(37.07f, 10.21f), new Vector2(37.34f, 10.19f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(37.34f, 10.19f), new Vector2(37.77f, 10.23f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(37.77f, 10.23f), new Vector2(38.19f, 10.27f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(38.19f, 10.27f), new Vector2(38.36f, 10.29f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(38.36f, 10.29f), new Vector2(38.41f, 10.59f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(38.41f, 10.59f), new Vector2(38.61f, 10.77f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(38.61f, 10.77f), new Vector2(39f, 10.87f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(39f, 10.87f), new Vector2(42.73f, 11f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(42.73f, 11f), new Vector2(43.95f, 11f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(43.95f, 11f), new Vector2(43.79f, 11.63f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(43.79f, 11.63f), new Vector2(43.72f, 12.17f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(43.72f, 12.17f), new Vector2(43.68f, 12.78f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(43.68f, 12.78f), new Vector2(43.66f, 13.58f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(43.66f, 13.58f), new Vector2(43.7f, 13.87f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(43.7f, 13.87f), new Vector2(43.51f, 14.35f), impassableEdge);
            //To just above the cave, on the cliff vertical edge

            //from tip of big tree branch platform
            FixtureFactory.AttachEdge(new Vector2(45.928f, 13.036f), new Vector2(46.718f, 13.016f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(46.718f, 13.016f), new Vector2(47.618f, 12.976f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(47.618f, 12.976f), new Vector2(48.728f, 12.796f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(48.728f, 12.796f), new Vector2(48.988f, 12.616f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(48.988f, 12.616f), new Vector2(49.368f, 12.676f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(49.368f, 12.676f), new Vector2(49.348f, 12.306f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(49.348f, 12.306f), new Vector2(49.228f, 11.796f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(49.228f, 11.796f), new Vector2(49.238f, 11.116f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(49.238f, 11.116f), new Vector2(49.078f, 10.146f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(49.078f, 10.146f), new Vector2(48.808f, 9.256f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(48.808f, 9.256f), new Vector2(48.388f, 8.296f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(48.388f, 8.296f), new Vector2(47.718f, 7.056f), impassableEdge);
            //to above big tree

            //from top of cave
            FixtureFactory.AttachEdge(new Vector2(42.92f, 14.67f), new Vector2(42.47f, 14.98f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(42.47f, 14.98f), new Vector2(42.34f, 15.52f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(42.34f, 15.52f), new Vector2(42.26f, 16.11f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(42.26f, 16.11f), new Vector2(42.28f, 16.56f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(42.28f, 16.56f), new Vector2(44.93f, 16.56f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(44.93f, 16.56f), new Vector2(45.98f, 16.8f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(45.98f, 16.8f), new Vector2(50.18f, 18.92f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(50.18f, 18.92f), new Vector2(57.04f, 19.23f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(57.04f, 19.23f), new Vector2(57f, 18.9f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(57f, 18.9f), new Vector2(57.13f, 18.35f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(57.13f, 18.35f), new Vector2(57.47f, 18.06f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(57.47f, 18.06f), new Vector2(58.06f, 18f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(58.06f, 18f), new Vector2(58.51f, 18.28f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(58.51f, 18.28f), new Vector2(58.69f, 18.39f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(58.69f, 18.39f), new Vector2(58.84f, 18.61f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(58.84f, 18.61f), new Vector2(58.99f, 18.91f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(58.99f, 18.91f), new Vector2(58.96f, 19.21f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(58.96f, 19.21f), new Vector2(63.11f, 19.00f), impassableEdge);
            //To the ground just past the big tree

            //from log to end of the nearest cliff and all ending collisions
            FixtureFactory.AttachEdge(new Vector2(63.11f, 19.00f), new Vector2(65.26f, 18.87f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(65.26f, 18.87f), new Vector2(65.21f, 19.2f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(65.21f, 19.2f), new Vector2(65.23f, 19.5f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(65.23f, 19.5f), new Vector2(65.11f, 19.83f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(65.11f, 19.83f), new Vector2(65.05f, 20.19f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(65.05f, 20.19f), new Vector2(65.03f, 20.48f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(65.03f, 20.48f), new Vector2(64.9f, 20.69f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.9f, 20.69f), new Vector2(64.78f, 21.03f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.78f, 21.03f), new Vector2(64.79f, 21.18f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.79f, 21.18f), new Vector2(64.71f, 21.4f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.71f, 21.4f), new Vector2(64.47f, 22.44f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.47f, 22.44f), new Vector2(64.17f, 23.53f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.17f, 23.53f), new Vector2(64.09f, 23.98f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.09f, 23.98f), new Vector2(64.19f, 24.48f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.19f, 24.48f), new Vector2(64.11f, 24.92f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(64.11f, 24.92f), new Vector2(67.52f, 24.04f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.52f, 24.04f), new Vector2(67.55f, 23.69f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.55f, 23.69f), new Vector2(67.54f, 23.17f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.54f, 23.17f), new Vector2(67.63f, 22.94f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.63f, 22.94f), new Vector2(67.59f, 22.65f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.59f, 22.65f), new Vector2(67.62f, 22.1f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.62f, 22.1f), new Vector2(67.57f, 21.86f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.57f, 21.86f), new Vector2(67.64f, 21.22f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.64f, 21.22f), new Vector2(67.74f, 20.8f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.74f, 20.8f), new Vector2(67.69f, 20.47f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.69f, 20.47f), new Vector2(67.76f, 19.96f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.76f, 19.96f), new Vector2(67.74f, 19.49f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.74f, 19.49f), new Vector2(67.72f, 19.35f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.72f, 19.35f), new Vector2(67.69f, 19.16f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(67.69f, 19.16f), new Vector2(68.65f, 19.19f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(68.65f, 19.19f), new Vector2(69.49f, 19.17f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(69.49f, 19.17f), new Vector2(70.38f, 19.14f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.38f, 19.14f), new Vector2(70.29f, 19.4f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.29f, 19.4f), new Vector2(70.22f, 19.93f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.22f, 19.93f), new Vector2(70.27f, 20.3f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.27f, 20.3f), new Vector2(70.24f, 20.69f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.24f, 20.69f), new Vector2(70.13f, 21.25f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.13f, 21.25f), new Vector2(70.09f, 21.88f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.09f, 21.88f), new Vector2(70.15f, 22.33f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.15f, 22.33f), new Vector2(70.09f, 22.64f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.09f, 22.64f), new Vector2(70.13f, 23.02f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.13f, 23.02f), new Vector2(70.03f, 23.39f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.03f, 23.39f), new Vector2(70.06f, 23.95f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.06f, 23.95f), new Vector2(70.05f, 24.34f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(70.05f, 24.34f), new Vector2(72.79f, 25.69f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.79f, 25.69f), new Vector2(72.87f, 25.48f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.87f, 25.48f), new Vector2(72.86f, 25.18f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.86f, 25.18f), new Vector2(72.87f, 24.99f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.87f, 24.99f), new Vector2(72.86f, 24.46f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.86f, 24.46f), new Vector2(72.85f, 24.25f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.85f, 24.25f), new Vector2(73.14f, 23.35f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.14f, 23.35f), new Vector2(73.04f, 22.64f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.04f, 22.64f), new Vector2(72.92f, 22.17f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.92f, 22.17f), new Vector2(73.01f, 21.91f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.01f, 21.91f), new Vector2(72.95f, 21.7f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(72.95f, 21.7f), new Vector2(73.08f, 21.36f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.08f, 21.36f), new Vector2(73.09f, 20.29f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.09f, 20.29f), new Vector2(73.07f, 20.08f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.07f, 20.08f), new Vector2(73.19f, 19.13f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.19f, 19.13f), new Vector2(73.23f, 18.92f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.23f, 18.92f), new Vector2(73.16f, 18.67f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.16f, 18.67f), new Vector2(73.12f, 18.3f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(73.12f, 18.3f), new Vector2(76.87f, 18.34f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.87f, 18.34f), new Vector2(76.76f, 18.79f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.76f, 18.79f), new Vector2(76.69f, 18.9f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.69f, 18.9f), new Vector2(76.75f, 19.8f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.75f, 19.8f), new Vector2(76.82f, 20.19f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.82f, 20.19f), new Vector2(76.77f, 20.72f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.77f, 20.72f), new Vector2(76.74f, 21.35f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.74f, 21.35f), new Vector2(76.62f, 21.86f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.62f, 21.86f), new Vector2(76.53f, 22.37f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.53f, 22.37f), new Vector2(76.5f, 22.8f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.5f, 22.8f), new Vector2(76.56f, 23f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.56f, 23f), new Vector2(76.59f, 23.27f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.59f, 23.27f), new Vector2(76.63f, 23.41f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.63f, 23.41f), new Vector2(76.59f, 23.58f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.59f, 23.58f), new Vector2(76.6f, 23.86f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.6f, 23.86f), new Vector2(76.62f, 24.36f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.62f, 24.36f), new Vector2(76.58f, 24.48f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.58f, 24.48f), new Vector2(76.56f, 24.78f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.56f, 24.78f), new Vector2(76.53f, 25.29f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.53f, 25.29f), new Vector2(76.52f, 25.69f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.52f, 25.69f), new Vector2(76.47f, 26.12f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.47f, 26.12f), new Vector2(76.47f, 26.45f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.47f, 26.45f), new Vector2(76.41f, 26.79f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.41f, 26.79f), new Vector2(76.47f, 27.1f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.47f, 27.1f), new Vector2(76.46f, 27.38f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(76.46f, 27.38f), new Vector2(80.6f, 26.87f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.6f, 26.87f), new Vector2(80.55f, 26.71f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.55f, 26.71f), new Vector2(80.59f, 26.55f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.59f, 26.55f), new Vector2(80.6f, 26.21f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.6f, 26.21f), new Vector2(80.71f, 25.79f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.71f, 25.79f), new Vector2(80.67f, 25.39f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.67f, 25.39f), new Vector2(80.71f, 24.99f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.71f, 24.99f), new Vector2(80.69f, 24.55f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.69f, 24.55f), new Vector2(80.76f, 24.1f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.76f, 24.1f), new Vector2(80.7f, 23.62f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.7f, 23.62f), new Vector2(80.72f, 23.26f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.72f, 23.26f), new Vector2(80.76f, 22.79f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.76f, 22.79f), new Vector2(80.79f, 22.25f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.79f, 22.25f), new Vector2(80.78f, 21.79f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.78f, 21.79f), new Vector2(80.72f, 21.47f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.72f, 21.47f), new Vector2(80.67f, 21.13f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(80.67f, 21.13f), new Vector2(81.8f, 21.16f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(81.8f, 21.16f), new Vector2(82.78f, 21.22f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(82.78f, 21.22f), new Vector2(83.65f, 21.21f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(83.65f, 21.21f), new Vector2(84.7f, 21.23f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(84.7f, 21.23f), new Vector2(84.57f, 21.98f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(84.57f, 21.98f), new Vector2(84.6f, 22.76f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(84.6f, 22.76f), new Vector2(84.45f, 23.58f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(84.45f, 23.58f), new Vector2(84.42f, 24.41f), impassableEdge);
            FixtureFactory.AttachEdge(new Vector2(84.42f, 24.41f), new Vector2(84.46f, 25.37f), impassableEdge);

            //play game music
            if (GameStateManagementGame.music == 0)
            {
                GameStateManagementGame.gameSongsCue = GameStateManagementGame.soundBank.GetCue("gamesongs");
                GameStateManagementGame.gameSongsCue.Play();

                GameStateManagementGame.music = 2;
            }

            firstGameUpdate = true;

            ScreenManager.Game.ResetElapsedTime();
        }
 private void TrimQueueToTime(Queue<Sample> q, double secs)
 {
     while (SumTimes(new List<Sample>(q.ToArray())) > (secs+5)) {
     Sample tmp = q.Dequeue();
     }
 }
示例#13
0
 public override object[] ToArray()
 {
     lock (queue) {
         return(queue.ToArray());
     }
 }
示例#14
0
 public override Object[] ToArray()
 {
     lock (root) {
         return(_q.ToArray());
     }
 }
示例#15
0
			void CompleteAllOnDispose (Queue queue)
			{
				object [] pending = queue.ToArray ();
				queue.Clear ();

				WaitCallback cb;
				for (int i = 0; i < pending.Length; i++) {
					SocketAsyncResult ares = (SocketAsyncResult) pending [i];
					cb = new WaitCallback (ares.CompleteDisposed);
					ThreadPool.QueueUserWorkItem (cb, null);
				}
			}
示例#16
0
文件: AdKats.cs 项目: BP4U/AdKats
 //Whether a move queue contains a given player
 private bool containsCPlayerInfo(Queue<CPlayerInfo> queueList, String player)
 {
     CPlayerInfo[] playerArray = queueList.ToArray();
     for (Int32 index = 0; index < queueList.Count; index++)
     {
         if (((CPlayerInfo)playerArray[index]).SoldierName.Equals(player))
         {
             return true;
         }
     }
     return false;
 }
示例#17
0
        /* -----------------------------------------------------*/



		/// <summary>
		/// Trebaju mi static fje koje barataju i rade sa 
		/// prebacivanjem tag i length integera u pripadajuce
		/// oktete.
		/// </summary>
		/// <returns>Vraca odgovarajuce polje byte-va koje
		/// sadrzi tag oktete</returns>
		public static byte[] MakeTagOctets(int ulazTagNumber) 
		{
			/// treba odrediti koliki je int.
			/// Za ("tagnumber<32") dovoljan je prvi oktet,
			/// (to je 5 raspolozivih bitova)
			/// 
			/// Za veci tagNumber prelazi se u highTagNumber 
			/// format.
			if (ulazTagNumber < 0 ) 
			{
				throw new Exception("Nema negativnih tag numbera..");
			}
			
			if (ulazTagNumber < 0x1f) 
			{
				return new byte[]{Convert.ToByte(ulazTagNumber)};
			}
			else
			{	/// high tag number form
				/// zapisan u bazi 128, pocevsi od drugog byte-a.
				/// Prvi byte je oblika ???11111
				/// Svi osim zadnjeg od drugog nadalje su oblika
				/// 0???????
				/// Zadnji je oblika
				/// 1???????
				/// 

				/// Zasad pretpostavljam da je tag number MaxInt
				Byte[] b = new Byte[5];

				b[0] = Convert.ToByte((ulazTagNumber & 0x0000007f) | 0x80); // ovo je zadnji...
				b[1] = Convert.ToByte((ulazTagNumber & 0x00003f80) >>  7);
				b[2] = Convert.ToByte((ulazTagNumber & 0x001fb000) >> 14);
				b[3] = Convert.ToByte((ulazTagNumber & 0x0fe00000) >> 21);
				b[4] = Convert.ToByte((ulazTagNumber & 0xf0000000) >> 28);
				
				Queue q = new Queue();
				q.Enqueue((Byte)0x1f);

				int i=4;
				while (b[i]==0) i--;
				
				while ( i >= 0 ) 
				{
					q.Enqueue( b[i] );
					i--;
				}

				Byte[] tmpArray = new Byte[q.ToArray().Length];
				for ( i=0; i< q.ToArray().Length; i++) 
				{
					tmpArray[i] = (Byte)((q.ToArray())[i]);
				}

				return (  tmpArray  );
			}
		}
示例#18
0
 /// <summary>
 /// Returns string from list of bits, used to debugging.
 /// </summary>
 /// <param name="bits">
 /// Queue of bits.
 /// </param>
 /// <returns>
 /// Binary string.
 /// </returns>
 public static string BinaryToString(Queue<bool> bits)
 {
     return BinaryToString(bits.ToArray());
 }
示例#19
0
		/// <summary>
		/// Rutina za razbijanje duljine u pripadne byteove
		/// za LENGTH OCTETS.
		/// 
		/// FIXME: Ovo je vec sad obsolete...
		/// </summary>
		/// <param name="ulazLenNumber">uzimam da duljina moze 
		/// biti navise MaxInteger</param>
		/// <returns>polje byteova, Length Octets za zadanu duljinu</returns>
		public static byte[] MakeLenOctets(int ulazLenNumber)
		{
			/// za konkretnu duljinu postoje dva oblika:
			/// short form    i      long form.
			/// Short form pokriva duljine od 0..127, 
			/// Long form pokriva dovoljno velike brojeve..
		
			if (ulazLenNumber < 128) 
			{
				return new byte[]{Convert.ToByte(ulazLenNumber)};
			}
			else
			{
				// long form
				// prvi oktet je broj dodatnih okteta za zapis, 
				// preostali daju duljinu u bazi 256, sa MostSig..
				// bitom prvim.

				int tmp = ulazLenNumber;
				
				Queue q = new Queue();
				
				int i=0;
				while ((tmp & 0xff000000)==0) 
				{
					tmp = tmp << 8;
					i++;
				}
				
				while ( i<4 ) 
				{
					q.Enqueue( Convert.ToByte( (tmp & 0xff000000) >> 24 ) );
					tmp = tmp << 8;
					i++;
				}

				int len = q.ToArray().Length;
				Byte[] tmpArray = new Byte[len+1];
				
				tmpArray[0]=Convert.ToByte(len + 128);

				for ( i=0; i < len; i++) 
				{
					tmpArray[i+1] = (Byte)(q.Dequeue());
				}

				return (  tmpArray  );
			}
		}
示例#20
0
 public static string[] getMiniMapToolTipStrings(string spriteName, Player player)
 {
     string name = spriteName.ToLower().Substring(0, spriteName.IndexOf(" "));
     Queue<string> text = new Queue<string>();
     switch (name) {
     case "observer":
         text.Enqueue("Observer");
         text.Enqueue("");
         text.Enqueue("Click to focus on this Hero");
         break;
     default:
         return null;
     }
     return text.ToArray();
 }
示例#21
0
 //The index of a player in the move queue
 private Int32 IndexOfCPlayerInfo(Queue<CPlayerInfo> queueList, String player)
 {
     this.DebugWrite("Entering getCPlayerInfo", 7);
     try {
         CPlayerInfo[] playerArray = queueList.ToArray();
         for (Int32 i = 0; i < queueList.Count; i++) {
             if (playerArray[i].SoldierName == player) {
                 return i;
             }
         }
     }
     catch (Exception e) {
         this.HandleException(new AdKatsException("Error while getting index of player in teamswap queue.", e));
     }
     this.DebugWrite("Exiting getCPlayerInfo", 7);
     return -1;
 }
示例#22
0
 private static void printStages(Queue<CmdBase> stages, int cycle)
 {
     CmdBase[] array = stages.ToArray();
     Console.WriteLine("=======================");
     Console.WriteLine("Cycle: " + cycle);
     foreach (CmdBase t in array)
     {
         Console.WriteLine(t);
     }
 }
示例#23
0
 //Whether a move queue contains a given player
 private bool ContainsCPlayerInfo(Queue<CPlayerInfo> queueList, String player)
 {
     this.DebugWrite("Entering containsCPlayerInfo", 7);
     try {
         CPlayerInfo[] playerArray = queueList.ToArray();
         for (Int32 index = 0; index < queueList.Count; index++) {
             if (playerArray[index].SoldierName == player) {
                 return true;
             }
         }
         return false;
     }
     catch (Exception e) {
         this.HandleException(new AdKatsException("Error while checking for player in teamswap queue.", e));
     }
     this.DebugWrite("Exiting containsCPlayerInfo", 7);
     return false;
 }
 private static void JoinOperandSymbols(Queue<string> queueOperand, Queue<string> queueTokens)
 {
     queueTokens.Enqueue(String.Join("", queueOperand.ToArray()));
     queueOperand.Clear();
 }
示例#25
0
 //Helper method to find a player's information in the move queue
 private CPlayerInfo GetCPlayerInfo(Queue<CPlayerInfo> queueList, String player)
 {
     this.DebugWrite("Entering getCPlayerInfo", 7);
     CPlayerInfo playerInfo = null;
     try {
         CPlayerInfo[] playerArray = queueList.ToArray();
         for (Int32 index = 0; index < queueList.Count; index++) {
             if (playerArray[index].SoldierName == player) {
                 playerInfo = playerArray[index];
             }
         }
     }
     catch (Exception e) {
         this.HandleException(new AdKatsException("Error while getting player info from teamswap queue.", e));
     }
     this.DebugWrite("Exiting getCPlayerInfo", 7);
     return playerInfo;
 }
        public override IEnumerator<OtpActor.Continuation> GetEnumerator()
        {
            m_log.Info("[Distributed PC] New PCVM is ready: " + m_mbox.Self);

            while (true)
            {
                OtpMsg msg = null;

                yield return (delegate(OtpMsg received) { msg = received; });

                OtpErlangObject obj = msg.getMsg();

                if (obj is OtpErlangAtom)
                {
                    string atom = ((OtpErlangAtom)obj).atomValue();
                    if (!String.IsNullOrEmpty(atom) && atom == "noconnection")
                    {
                        break;
                    }
                }

                OtpErlangPid sender = null;
                OtpErlangObject[] reply = new OtpErlangObject[3];

                try
                {
                    OtpErlangTuple t = (OtpErlangTuple)obj;
                    sender = (OtpErlangPid)t.elementAt(0);

                    reply[0] = sender;
                    reply[1] = new OtpErlangAtom("ok");

                    string instr = ((OtpErlangAtom)t.elementAt(1)).ToString();

                    if (instr == "load")
                    {
                        Parser parser = PCVM.MakeParser();
                        string script = String.Empty;
                        if (t.elementAt(2) is OtpErlangString)
                        {
                            script = ((OtpErlangString)t.elementAt(2)).stringValue();
                        }
                        else
                        {
                            script = OtpErlangString.newString(((OtpErlangBinary)t.elementAt(2)).binaryValue());
                        }
                        bool debug = ((OtpErlangAtom)t.elementAt(3)).boolValue();

                        SYMBOL ast = parser.Parse(script);

                        m_vm.Call((Compiler.ExpPair)ast);

                        if (debug)
                        {
                            reply[2] = new OtpErlangAtom("continue");
                        }
                        else
                        {
                            Queue<PCObj> popped = new Queue<PCObj>();
                            try
                            {
                                m_vm.Finish(popped);
                            }
                            finally
                            {
                                reply = new OtpErlangObject[] {
                                    reply[0],
                                    reply[1],
                                    new OtpErlangAtom("finished"),
                                    ErlangObjectFromPCVMObject(popped.ToArray())
                                };
                            }
                        }
                    }
                    else if (instr == "step")
                    {
                        bool cont = true;
                        Queue<PCObj> popped = new Queue<PCObj>();
                        try
                        {
                            cont = m_vm.Step(popped);
                        }
                        finally
                        {
                            reply = new OtpErlangObject[] {
                                reply[0],
                                reply[1],
                                new OtpErlangAtom(cont ? "continue" : "finished"),
                                ErlangObjectFromPCVMObject(popped.ToArray())
                            };
                        }
                    }
                    else if (instr == "finish")
                    {
                        Queue<PCObj> popped = new Queue<PCObj>();
                        try
                        {
                            m_vm.Finish(popped);
                        }
                        finally
                        {
                            reply = new OtpErlangObject[] {
                                reply[0],
                                reply[1],
                                new OtpErlangAtom("finished"),
                                ErlangObjectFromPCVMObject(popped.ToArray())
                            };
                        }
                    }
                    else if (instr == "echo")
                    {
                        reply[2] = t.elementAt(2);
                    }
                    else if (instr == "exit")
                    {
                        reply[2] = new OtpErlangAtom("bye");
                        break;
                    }
                }
                catch (Exception e)
                {
                    m_log.Debug("[Distributed PC] Invalid message format: " + msg.getMsg());

                    reply[1] = new OtpErlangAtom("error");
                    reply[2] = new OtpErlangString(e.Message);
                }
                finally
                {
                    if (sender != null)
                    {
                        m_mbox.send(sender, new OtpErlangTuple(reply));
                    }
                }
            }

            m_log.Info("[Distributed PC] Delete PCVM instance: " + m_mbox.Self);
            m_vm.Dispose();
        }
        public virtual void Write()
        {
            lock (rwlock)
            {
                if (!modified) return;
                modified = false;
                headers["Version"] = FORMAT_VERSION;

                Runtime.LoggingService.Info ("Writing " + dataFile);

                string tmpDataFile = dataFile + ".tmp";
                FileStream dfile = new FileStream (tmpDataFile, FileMode.Create, FileAccess.Write, FileShare.Write);

                BinaryFormatter bf = new BinaryFormatter ();
                BinaryWriter bw = new BinaryWriter (dfile);

                // The headers are the first thing to write, so they can be read
                // without deserializing the whole file.
                bf.Serialize (dfile, headers);

                // The position of the index will be written here
                long indexOffsetPos = dfile.Position;
                bw.Write ((long)0);

                MemoryStream buffer = new MemoryStream ();
                BinaryWriter bufWriter = new BinaryWriter (buffer);

                // Write all class data
                foreach (FileEntry fe in files.Values)
                {
                    ClassEntry ce = fe.FirstClass;
                    while (ce != null)
                    {
                        IClass c = ce.Class;
                        byte[] data;
                        int len;

                        if (c == null) {
                            // Copy the data from the source file
                            if (datareader == null) {
                                datafile = new FileStream (dataFile, FileMode.Open, FileAccess.Read, FileShare.Read);
                                datareader = new BinaryReader (datafile);
                            }
                            datafile.Position = ce.Position;
                            len = datareader.ReadInt32 ();
                            data = new byte[len];
                            datafile.Read (data, 0, len);
                        }
                        else {
                            buffer.Position = 0;
                            PersistentClass.WriteTo (c, bufWriter, parserDatabase.DefaultNameEncoder);
                            data = buffer.GetBuffer ();
                            len = (int)buffer.Position;
                        }

                        ce.Position = dfile.Position;
                        bw.Write (len);
                        bw.Write (data, 0, len);
                        ce = ce.NextInFile;
                    }
                }

                // Write the index
                long indexOffset = dfile.Position;

                Queue dataQueue = new Queue ();
                dataQueue.Enqueue (references);
                dataQueue.Enqueue (rootNamespace);
                dataQueue.Enqueue (files);
                SerializeData (dataQueue);
                bf.Serialize (dfile, dataQueue.ToArray ());

                dfile.Position = indexOffsetPos;
                bw.Write (indexOffset);

                bw.Close ();
                dfile.Close ();

                CloseReader ();

                if (File.Exists (dataFile))
                    File.Delete (dataFile);

                File.Move (tmpDataFile, dataFile);
            }
        }
示例#28
0
        private void loadSequence(ISequence sequence)
        {
            var taskQueue = new Queue<Task>();

            if (loadTimer == null)
            {
                loadTimer = new System.Timers.Timer();
                loadTimer.Elapsed += loadTimer_Elapsed;
                loadTimer.Interval = 250;
            }
            loadingWatch = Stopwatch.StartNew();
            loadTimer.Enabled = true;
            TimelineControl.SequenceLoading = true;

            // Let's get the window on the screen. Make it appear to instantly load.
            Invalidate(true);
            Update();

            try
            {
                // default the sequence to 1 minute if it's not set
                if (_sequence.Length == TimeSpan.Zero)
                    _sequence.Length = _defaultSequenceTime;

                SequenceLength = _sequence.Length;
                setTitleBarText();

                // update our program context with this sequence
                OpenSequenceContext(sequence);

                // clear out all the old data
                loadSystemNodesToRows();

                // load the new data: get all the commands in the sequence, and make a new element for each of them.
                _effectNodeToElement = new Dictionary<EffectNode, Element>();

                TimelineControl.grid.SuppressInvalidate = true; //Hold off invalidating the grid while we bulk load.
                TimelineControl.grid.SupressRendering = true; //Hold off rendering while we load elements.
                // This takes quite a bit of time so queue it up
                taskQueue.Enqueue(Task.Factory.StartNew(() => addElementsForEffectNodes(_sequence.SequenceData.EffectData)));

                // Now that it is queued up, let 'er rip and start background rendering when complete.
                Task.Factory.ContinueWhenAll(taskQueue.ToArray(), completedTasks =>
                                                                    {
                                                                        // Clear the loading toolbar
                                                                        loadingWatch.Stop();
                                                                        TimelineControl.SequenceLoading = false;
                                                                        loadTimer.Enabled = false;
                                                                        updateToolStrip4(string.Empty);
                                                                        TimelineControl.grid.SupressRendering = false;
                                                                        TimelineControl.grid.SuppressInvalidate = false;
                                                                        TimelineControl.grid.RenderAllRows();
                                                                    });

                //This path is followed for new and existing sequences so we need to determine which we have and set modified accordingly.
                //Added logic to determine if the sequence has a filepath to set modified JU 8/1/2012.
                PopulateAudioDropdown();
                _SetTimingToolStripEnabledState();

                if (String.IsNullOrEmpty(_sequence.FilePath))
                {
                    sequenceModified();
                }
                else
                {
                    sequenceNotModified();
                }

                MarksForm.Sequence = _sequence;
                MarksForm.PopulateMarkCollectionsList(null);
                PopulateMarkSnapTimes();

                if (_sequence.TimePerPixel > TimeSpan.Zero )
                {
                    TimelineControl.TimePerPixel = _sequence.TimePerPixel;
                }

                Logging.Debug(string.Format("Sequence {0} took {1} to load. ", sequence.Name, loadingWatch.Elapsed));
            }
            catch (Exception ee)
            {
                Logging.ErrorException("Error loading sequence.", ee);
            }
        }
示例#29
0
			void CompleteAllOnDispose (Queue queue)
			{
				object [] pending = queue.ToArray ();
				queue.Clear ();

				WaitCallback cb;
				for (int i = 0; i < pending.Length; i++) {
					Worker worker = (Worker) pending [i];
					SocketAsyncResult ares = worker.result;
					cb = new WaitCallback (ares.CompleteDisposed);
#if MOONLIGHT
					ThreadPool.QueueUserWorkItem (cb, null);
#else
					ThreadPool.UnsafeQueueUserWorkItem (cb, null);
#endif
				}
			}
示例#30
0
文件: Ports.cs 项目: Prizmer/ps
        public int WriteReadData(FindPacketSignature func, byte[] out_buffer, ref byte[] in_buffer, int out_length, int target_in_length,
            uint pos_count_data_size = 0, uint size_data = 0, uint header_size = 0)
        {
            int reading_size = 0;

            if (OpenPort())
            {
                //очередь для поддержки делегатов в старых драйверах
                Queue<byte> reading_queue = new Queue<byte>(8192);
                List<byte> readBytesList = new List<byte>(8192);

                try
                {
                    //пишем в порт команду, ограниченную out_length
                    m_Port.Write(out_buffer, 0, out_length);
                }
                catch (Exception ex)
                {
                    WriteToLog("WriteReadData: Write to port error: " + ex.Message);
                }

                Thread.Sleep(100);
                uint elapsed_time_count = 100;

                while (elapsed_time_count <= m_read_timeout)
                {
                    if (m_Port.BytesToRead > 0)
                    {
                        try
                        {
                            byte[] tmp_buff = new byte[m_Port.BytesToRead];
                            int readed_bytes = m_Port.Read(tmp_buff, 0, tmp_buff.Length);

                            readBytesList.AddRange(tmp_buff);
                        }
                        catch (Exception ex)
                        {
                            WriteToLog("WriteReadData: Read from port error: " + ex.Message);
                        }
                    }

                    elapsed_time_count += 100;
                    Thread.Sleep(100);
                }

                /*TODO: Откуда взялась константа 4, почему 4?*/
                if (readBytesList.Count >= 4)
                {
                    /*попытаемся определить начало полезных данных в буфере-на-вход
                        при помощи связанного делегата*/
                    for (int i = 0; i < readBytesList.Count; i++)
                        reading_queue.Enqueue(readBytesList[i]);

                    int pos = func(reading_queue);
                    if (pos >= 0)
                    {
                        //избавимся от лишних данных спереди
                        for (int i = 0; i < pos; i++)
                        {
                            reading_queue.Dequeue();
                        }

                        //оставшиеся данные преобразуем обратно в массив
                        byte[] temp_buffer = new byte[reading_size = reading_queue.Count];

                        //WriteToLog("reading_queue.Count: " + reading_size.ToString());

                        temp_buffer = reading_queue.ToArray();
                        //WriteToLog(BitConverter.ToString(temp_buffer));

                        //если длина полезных данных ответа определена как 0, произведем расчет по необязательнм параметрам
                        if (target_in_length == 0)
                        {
                            if (reading_size > pos_count_data_size)
                                target_in_length = Convert.ToInt32(temp_buffer[pos_count_data_size] * size_data + header_size);
                        }

                        if (target_in_length == -1)
                        {
                            target_in_length = reading_queue.Count;
                            reading_size = target_in_length;
                            in_buffer = new byte[reading_size];

                            for (int i = 0; i < in_buffer.Length; i++)
                                in_buffer[i] = temp_buffer[i];

                            ClosePort();
                            return reading_size;
                        }

                        if (target_in_length > 0 && reading_size >= target_in_length)
                        {
                            reading_size = target_in_length;
                            for (int i = 0; i < target_in_length && i < in_buffer.Length; i++)
                            {
                                in_buffer[i] = temp_buffer[i];
                            }
                        }
                    }
                }
            }
            else
            {
                WriteToLog("Open port Error");
            }

            ClosePort();
            return reading_size;
        }
        private bool IsURIInQueue(Queue<List<SIPCallDescriptor>> callQueue, string callURI)
        {
            try
            {
                if (callQueue == null || callQueue.Count == 0 || callURI.IsNullOrBlank())
                {
                    return false;
                }
                else
                {
                    List<SIPCallDescriptor>[] callLegs = callQueue.ToArray();
                    if (callLegs == null || callLegs.Length == 0)
                    {
                        return false;
                    }
                    else
                    {
                        for (int index = 0; index < callLegs.Length; index++)
                        {
                            List<SIPCallDescriptor> callList = callLegs[index];
                            foreach (SIPCallDescriptor callDescriptor in callList)
                            {
                                if (callDescriptor.Uri == null)
                                {
                                    return false;
                                }
                                else if (callDescriptor.Uri.ToString() == callURI)
                                {
                                    return true;
                                }
                            }
                        }

                        return false;
                    }
                }
            }
            catch (Exception excp)
            {
                logger.Error("Exception isURIInQueue. " + excp.Message);
                return false;
            }
        }
示例#32
0
        void ReadUntilToken(string token)
        {
            StringBuilder output = new StringBuilder();
            Queue<char> queue = new Queue<char>();

            bool keepProcessing = true;
            while (keepProcessing && keepAlive)
            {
                if (process == null || process.HasExited)
                    keepProcessing = false;
                else
                {
                    char c = (char)process.StandardOutput.Read();
                    output.Append(c);
                    if (c == '\n')
                    {
                        MatchLine(output.ToString().Trim());
                        output = new StringBuilder();
                    }

                    queue.Enqueue(c);
                    if (queue.Count > token.Length)
                        queue.Dequeue();

                    if (new string(queue.ToArray()).Equals(token))
                    {
                        interactive = keepProcessing;
                        return;
                    }
                }
            }
        }
        static List<string> getCommandLineArgs()
        {
            try
            {
                Queue<string> args = new Queue<string>(Environment.GetCommandLineArgs());

                args.Dequeue(); // args[0] is always exe path/filename
                //return string.Join(" ", args.ToArray());
                return new List<string>(args.ToArray());
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
示例#34
0
文件: AdKats.cs 项目: BP4U/AdKats
 //The index of a player in the move queue
 private Int32 indexOfCPlayerInfo(Queue<CPlayerInfo> queueList, String player)
 {
     CPlayerInfo[] playerArray = queueList.ToArray();
     for (Int32 index = 0; index < queueList.Count; index++)
     {
         if (((CPlayerInfo)playerArray[index]).SoldierName.Equals(player))
         {
             return index;
         }
     }
     return -1;
 }
示例#35
0
 /// <summary>
 /// Converts queue of booleans to decimal number.
 /// </summary>
 /// <param name="bin">
 /// Queue of booleans.
 /// </param>
 /// <returns>
 /// Decimal number.
 /// </returns>
 public static int BinToDec(Queue<bool> bin)
 {
     return BinToDec(bin.ToArray());
 }