예제 #1
0
        public List <T> QueryBounds(Bounds bounds, bool EdgeTouchIsIntersection)
        {
            List <T> results = new List <T>();

            if (!Bounds.IntersectsWith(bounds, EdgeTouchIsIntersection))
            {
                return(results); // return empty list
            }
            // else check our members
            foreach (BoundsLink <T> member in Members)
            {
                if (member.bounds.IntersectsWith(bounds, EdgeTouchIsIntersection))
                {
                    results.Add(member.link);
                }
            }
            // check our leaves as well
            if (IsDivided)
            {
                results.AddRange(NW.QueryBounds(bounds, EdgeTouchIsIntersection));
                results.AddRange(NE.QueryBounds(bounds, EdgeTouchIsIntersection));
                results.AddRange(SW.QueryBounds(bounds, EdgeTouchIsIntersection));
                results.AddRange(SE.QueryBounds(bounds, EdgeTouchIsIntersection));
            }
            // return the compounded list
            return(results);
        }
예제 #2
0
        public static IRace CreateInstance(RaceType type)
        {
            IRace iRace = null;

            switch (type)
            {
            case RaceType.Human:
                iRace = new Human("123");
                break;

            case RaceType.NE:
                iRace = new NE();
                break;

            case RaceType.ORC:
                iRace = new ORC();
                break;

            case RaceType.Undead:
                iRace = new Undead();
                break;

            case RaceType.Five:
                iRace = new Five();
                break;

            default:
                throw new Exception("wrong RaceType");
            }
            return(iRace);
        }
예제 #3
0
        public static void Update(GameTime gameTime)
        {
            CameraHandler(gameTime);
            UpdateInput(gameTime);

            UpdateEntities(gameTime);

            if (loading)
            {
                loadAlgorithm.Update(gameTime);
                if (loadAlgorithm.Done)
                {
                    StartTraining();
                    loadAlgorithm.Reset();
                }
            }

            if (start && NE.NextGeneration(Players))
            {
                foreach (Player p in Players)
                {
                    p.SetLocation(RaceTrack.Start.X, RaceTrack.Start.Y);
                }
                generationsNumber.Set(NE.Generations + 1);
            }

            NE.CalculateFitness(Players);

            if (NE.BestPlayer != null && showNetwork)
            {
                NE.BestPlayer.Brain.VisualizeDecisions();
            }
        }
예제 #4
0
        public List <Node> FindNodesWithinRadius(UV location, double radius)
        {
            var nodes  = new List <Node>();
            var circle = Circle.ByCenterPointRadius(
                Autodesk.DesignScript.Geometry.Point.ByCoordinates(location.U, location.V),
                radius);

            if (!Intersects(circle))
            {
                return(nodes);
            }

            if (IsLeafNode)
            {
                nodes.Add(this);
                return(nodes);
            }

            nodes.AddRange(NW.FindNodesWithinRadius(location, radius));
            nodes.AddRange(NE.FindNodesWithinRadius(location, radius));
            nodes.AddRange(SW.FindNodesWithinRadius(location, radius));
            nodes.AddRange(SE.FindNodesWithinRadius(location, radius));

            return(nodes);
        }
예제 #5
0
        public static void Reset()
        {
            GameOver = false;

            totalPlayers = 250;

            Entities.Clear();
            Players.Clear();

            input = new Input(PlayerIndex.One);

            RaceTrack = new Track(Camera.ScreenBounds.Width / 2, Camera.ScreenBounds.Height / 2, 20);
            Entities.Add(RaceTrack);

            generationsText   = new Text(8, 8, "Generation", Sprite.Type.Text8x8);
            generationsNumber = new Number(8, 8 + 2 + 8, 1, 4, 9999, Sprite.Type.Text8x8);

            startPrompt   = new Text(8, Camera.ScreenBounds.Height - 8 - 8 - 2 - 8 - 2 - 8 - 2 - 8, "Start", 1, Sprite.Type.Text8x8, new Color(Color.White, 255));
            resetPrompt   = new Text(8, Camera.ScreenBounds.Height - 8 - 8 - 2 - 8 - 2 - 8, "Reset", 1, Sprite.Type.Text8x8, new Color(Color.White, 255));
            editPrompt    = new Text(8, Camera.ScreenBounds.Height - 8 - 8 - 2 - 8, "Edit Track", 1, Sprite.Type.Text8x8, new Color(Color.White, 255));
            networkPrompt = new Text(8, Camera.ScreenBounds.Height - 8 - 8, "Draw Neural Network", 1, Sprite.Type.Text8x8, new Color(Color.White, 255));
            loadingPrompt = new Text(Camera.ScreenBounds.Width - 8 - 7 * 8, Camera.ScreenBounds.Height - 8 - 8, "Loading...", Sprite.Type.Text8x8);

            start       = false;
            EditTrack   = true;
            showNetwork = false;

            loading       = false;
            loadAlgorithm = new Timer(500);

            HUD.Reset();
            NE.Reset();
        }
예제 #6
0
        public Node FindNodeWhichContains(UV point)
        {
            Node n = null;

            if (IsLeafNode)
            {
                if (Contains(point))
                {
                    return(this);
                }
            }
            else
            {
                if (NW.Contains(point))
                {
                    n = NW.FindNodeWhichContains(point);
                }
                else if (NE.Contains(point))
                {
                    n = NE.FindNodeWhichContains(point);
                }
                else if (SW.Contains(point))
                {
                    n = SW.FindNodeWhichContains(point);
                }
                else if (SE.Contains(point))
                {
                    n = SE.FindNodeWhichContains(point);
                }
            }

            return(n);
        }
        public static IRace CreateInstance(RaceType raceType)
        {
            IRace race = null;

            switch (raceType)
            {
            case RaceType.Human:
                race = new Human();
                break;

            case RaceType.NE:
                race = new NE();
                break;

            case RaceType.ORC:
                race = new ORC();
                break;

            case RaceType.Undead:
                race = new Undead();
                break;

            default:
                throw new Exception("wrong raceType");
            }

            return(race);
        }
예제 #8
0
        /// <summary>
        /// 通过传递参数创建实例类型
        /// </summary>
        /// <param name="raceType"></param>
        /// <returns></returns>
        public static IRace GetRace(RaceType raceType)
        {
            IRace race = null;

            switch (raceType)
            {
            case RaceType.Human:
                race = new Human();
                break;

            case RaceType.NE:
                race = new NE();
                break;

            case RaceType.ORC:
                race = new ORC();
                break;

            case RaceType.Undead:
                race = new Undead();
                break;

            default:
                throw new Exception($"种族{raceType}不存在");
            }
            return(race);
        }
        public static IRace CreateInstanceConfig()
        {
            RaceType raceType = (RaceType)Enum.Parse(typeof(RaceType), IRaceTypeConfig);

            IRace race = null;

            switch (raceType)
            {
            case RaceType.Human:
                race = new Human();
                break;

            case RaceType.NE:
                race = new NE();
                break;

            case RaceType.ORC:
                race = new ORC();
                break;

            case RaceType.Undead:
                race = new Undead();
                break;

            default:
                throw new Exception("wrong raceType");
            }

            return(race);
        }
예제 #10
0
        public bool TryFind(UV uv, out Node node)
        {
            if (!Contains(uv))
            {
                node = null;
                return(false);
            }

            if (IsLeafNode)
            {
                if (Point.IsAlmostEqualTo(uv))
                {
                    node = this;
                    return(true);
                }
                else
                {
                    node = null;
                    return(false);
                }
            }

            if (NW.Contains(uv))
            {
                if (NW.TryFind(uv, out node))
                {
                    return(true);
                }
            }

            else if (NE.Contains(uv))
            {
                if (NE.TryFind(uv, out node))
                {
                    return(true);
                }
            }


            else if (SW.Contains(uv))
            {
                if (SW.TryFind(uv, out node))
                {
                    return(true);
                }
            }

            else if (SE.Contains(uv))
            {
                if (SE.TryFind(uv, out node))
                {
                    return(true);
                }
            }

            node = null;
            return(false);
        }
예제 #11
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班公开课之设计模式特训,今天是Eleven老师为大家带来的简单工厂模式");

                Player uu = new Player()
                {
                    Id   = 11,
                    Name = "Nine(479-悠悠吾心-女-合肥)"
                };
                {
                    Human  human  = new Human();
                    Undead undead = new Undead();
                    NE     ne     = new NE();
                    ORC    orc    = new ORC();

                    uu.PlayHuman(human);
                    uu.PlayUndead(undead);

                    uu.PlayWar3(human);
                    uu.PlayWar3(undead);
                    uu.PlayWar3(ne);
                    uu.PlayWar3(orc);
                }
                Console.WriteLine("*******************CreateInstance********************");
                {
                    IRace human  = ObjectFactory.CreateInstance(RaceType.Human);  // new Human();
                    IRace undead = ObjectFactory.CreateInstance(RaceType.Undead); // new Undead();
                    IRace ne     = ObjectFactory.CreateInstance(RaceType.NE);     // new NE();
                    IRace orc    = ObjectFactory.CreateInstance(RaceType.ORC);    //new ORC();


                    uu.PlayWar3(human);
                    uu.PlayWar3(undead);
                    uu.PlayWar3(ne);
                    uu.PlayWar3(orc);
                }
                Console.WriteLine("*****************CreateInstanceConfig********************");
                {
                    IRace race = ObjectFactory.CreateInstanceConfig();
                    uu.PlayWar3(race);
                }
                Console.WriteLine("*****************CreateInstanceConfigReflection********************");
                {
                    IRace race = ObjectFactory.CreateInstanceConfigReflection();
                    uu.PlayWar3(race);
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
예제 #12
0
 public void DrawInGizmos()
 {
     Gizmos.Color = Color.White;
     Gizmos.DrawRectangle(Bounds.Center, Bounds.HalfDimensions.X, Bounds.HalfDimensions.Y, 10);
     if (IsDivided)
     {
         NW.DrawInGizmos();
         NE.DrawInGizmos();
         SW.DrawInGizmos();
         SE.DrawInGizmos();
     }
 }
예제 #13
0
 public void Flash(int turnNumber)
 {
     LastFlashTurn = turnNumber;
     FlashCount++;
     NW?.DoTurn(turnNumber, true);
     N?.DoTurn(turnNumber, true);
     NE?.DoTurn(turnNumber, true);
     W?.DoTurn(turnNumber, true);
     E?.DoTurn(turnNumber, true);
     SW?.DoTurn(turnNumber, true);
     S?.DoTurn(turnNumber, true);
     SE?.DoTurn(turnNumber, true);
 }
예제 #14
0
 public void Reset()
 {
     if (IsDivided)
     {
         NW.Reset();
         NE.Reset();
         SW.Reset();
         SE.Reset();
     }
     Members.Clear();
     AllMembers.Clear();
     NW        = NE = SW = SE = null;
     IsDivided = false;
 }
예제 #15
0
        public void Insert(UV uv)
        {
            if (!Contains(uv))
            {
                return;
            }

            if (IsLeafNode)
            {
                // If the node that is being inserted is
                // the same as one that exists, then return
                // true;

                if (Point == null)
                {
                    Point = uv;
                    return;
                }

                if (uv.IsAlmostEqualTo(Point))
                {
                    return;
                }

                Split();

                // Move the existing point into a new cell
                NW.Insert(UV.ByCoordinates(Point.U, Point.V));
                NE.Insert(UV.ByCoordinates(Point.U, Point.V));
                SE.Insert(UV.ByCoordinates(Point.U, Point.V));
                SW.Insert(UV.ByCoordinates(Point.U, Point.V));

                Point = null;

                // Insert the new UV into the correct cell
                NW.Insert(uv);
                NE.Insert(uv);
                SW.Insert(uv);
                SE.Insert(uv);
            }
            else
            {
                NW.Insert(uv);
                NE.Insert(uv);
                SW.Insert(uv);
                SE.Insert(uv);
            }
        }
예제 #16
0
        public List <Node> GetAllNodes()
        {
            var nodes = new List <Node>();

            if (IsLeafNode)
            {
                nodes.Add(this);
                return(nodes);
            }

            nodes.AddRange(NW.GetAllNodes());
            nodes.AddRange(NE.GetAllNodes());
            nodes.AddRange(SW.GetAllNodes());
            nodes.AddRange(SE.GetAllNodes());

            return(nodes);
        }
예제 #17
0
    private void ResetAll()
    {
        N.GetComponent <Renderer>().enabled = false;

        NE.GetComponent <Renderer>().enabled = false;

        E.GetComponent <Renderer>().enabled = false;

        SE.GetComponent <Renderer>().enabled = false;

        S.GetComponent <Renderer>().enabled = false;

        SW.GetComponent <Renderer>().enabled = false;

        W.GetComponent <Renderer>().enabled = false;

        NW.GetComponent <Renderer>().enabled = false;
    }
예제 #18
0
            /// <summary>
            /// Returns all objects stored in this node/nodes under this node.
            /// </summary>
            /// <returns>A list of objects that are stored under this node.</returns>
            private List <T> GetAllObjectsUnder()
            {
                if (isLeaf)
                {
                    return(nodeBucket.Where(x => x != null).ToList());
                }
                else
                {
                    List <T> allObjects = new List <T>();

                    allObjects.AddRange(NE.GetAllObjectsUnder());
                    allObjects.AddRange(NW.GetAllObjectsUnder());
                    allObjects.AddRange(SE.GetAllObjectsUnder());
                    allObjects.AddRange(SW.GetAllObjectsUnder());

                    return(allObjects);
                }
            }
예제 #19
0
        private async void ShowMenuOptions()
        {
            Device.BeginInvokeOnMainThread(() =>
            {
                circle.ScaleTo(120, animationDelay * 5, Easing.BounceOut);
                bmiLabel.FadeTo(1, animationDelay * 5);
            });

            await N.ScaleTo(scaleSize, animationDelay, Easing.BounceOut);

            await NE.ScaleTo(scaleSize, animationDelay, Easing.BounceOut);

            await SE.ScaleTo(scaleSize, animationDelay, Easing.BounceOut);

            await SW.ScaleTo(scaleSize, animationDelay, Easing.BounceOut);

            await NW.ScaleTo(scaleSize, animationDelay, Easing.BounceOut);
        }
예제 #20
0
        private async Task HideButtons()
        {
            var speed = 25U;
            await N.FadeTo(0, speed);

            await NE.FadeTo(0, speed);

            await E.FadeTo(0, speed);

            await SE.FadeTo(0, speed);

            await S.FadeTo(0, speed);

            await SW.FadeTo(0, speed);

            await W.FadeTo(0, speed);

            await NW.FadeTo(0, speed);
        }
예제 #21
0
        private async Task ShowButtons()
        {
            var speed = 25U;
            await N.FadeTo(1, speed);

            await NE.FadeTo(1, speed);

            await E.FadeTo(1, speed);

            await SE.FadeTo(1, speed);

            await S.FadeTo(1, speed);

            await SW.FadeTo(1, speed);

            await W.FadeTo(1, speed);

            await NW.FadeTo(1, speed);
        }
예제 #22
0
파일: Form1.cs 프로젝트: jay206/mined
        public override string ToString()
        {
            StringBuilder sb = new StringBuilder();

            //	sb.AppendFormat("{{X={0},Y={1},Z={2}", X, Y, Z);
            sb.AppendFormat("{{Row={0},Column={1},Count={2}", Row, Column, Count);
            if (E != null)
            {
                sb.AppendFormat(",E={0}", E.GetHashCode());
            }
            if (W != null)
            {
                sb.AppendFormat(",W={0}", W.GetHashCode());
            }
            if (N != null)
            {
                sb.AppendFormat(",N={0}", N.GetHashCode());
                if (NE != null)
                {
                    sb.AppendFormat(",NE={0}", NE.GetHashCode());
                }
                if (NW != null)
                {
                    sb.AppendFormat(",NW={0}", NW.GetHashCode());
                }
            }
            if (S != null)
            {
                sb.AppendFormat(",S={0}", S.GetHashCode());
                if (SE != null)
                {
                    sb.AppendFormat(",SE={0}", SE.GetHashCode());
                }
                if (SW != null)
                {
                    sb.AppendFormat(",SW={0}", SW.GetHashCode());
                }
            }
            sb.Append("}");
            return(sb.ToString());
        }
예제 #23
0
        public List <Node> FindNodesIntersectingRectangle(UVRect rectangle)
        {
            var nodes = new List <Node>();

            if (!Intersects(rectangle))
            {
                return(nodes);
            }

            if (IsLeafNode)
            {
                nodes.Add(this);
                return(nodes);
            }

            nodes.AddRange(NW.FindNodesIntersectingRectangle(rectangle));
            nodes.AddRange(NE.FindNodesIntersectingRectangle(rectangle));
            nodes.AddRange(SW.FindNodesIntersectingRectangle(rectangle));
            nodes.AddRange(SE.FindNodesIntersectingRectangle(rectangle));

            return(nodes);
        }
예제 #24
0
        private bool Insert(BoundsLink <T> member)
        {
            // make sure we intersect with the bounds of this object
            if (!Bounds.IntersectsWith(member.bounds, true))
            {
                return(false);
            }
            if (Members.Count < MaxReferencesPerTree)
            {
                Members.Add(member);
                return(true);
            }

            // else we are full, but need to store this object
            if (!IsDivided)
            {
                Subdivide();
            }

            bool Inserted = false;

            if (SW.Insert(member))
            {
                Inserted = true;
            }
            if (NW.Insert(member))
            {
                Inserted = true;
            }
            if (NE.Insert(member))
            {
                Inserted = true;
            }
            if (SE.Insert(member))
            {
                Inserted = true;
            }
            return(Inserted);
        }
예제 #25
0
        static void Main(string[] args)
        {
            try
            {
                Console.WriteLine("欢迎来到.net高级班公开课之设计模式特训,今天是Eleven老师为大家带来的工厂方法设计模式");
                {
                    Human  human  = new Human();
                    Undead undead = new Undead();
                    NE     ne     = new NE();
                    ORC    orc    = new ORC();

                    //Six six=new Six()//参数信息很麻烦
                }
                {
                    IRace human  = new Human();
                    IRace undead = new Undead();
                    IRace ne     = new NE();
                    IRace orc    = new ORC();
                }
                {
                    IFactory humanFactory = new HumanFactory();
                    IRace    human        = humanFactory.CreateInstance();

                    IFactory fiveFactory = new FiveFactory();
                    IRace    five        = fiveFactory.CreateInstance();

                    IFactory sixFactory = new SixFactoryExtend();// new SixFactory();

                    IRace six = sixFactory.CreateInstance();
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
            }
            Console.Read();
        }
예제 #26
0
        // Module defining this command


        // Optional custom code for this activity


        /// <summary>
        /// Returns a configured instance of System.Management.Automation.PowerShell, pre-populated with the command to run.
        /// </summary>
        /// <param name="context">The NativeActivityContext for the currently running activity.</param>
        /// <returns>A populated instance of Sytem.Management.Automation.PowerShell</returns>
        /// <remarks>The infrastructure takes responsibility for closing and disposing the PowerShell instance returned.</remarks>
        protected override ActivityImplementationContext GetPowerShell(NativeActivityContext context)
        {
            System.Management.Automation.PowerShell invoker       = global::System.Management.Automation.PowerShell.Create();
            System.Management.Automation.PowerShell targetCommand = invoker.AddCommand(PSCommandName);

            // Initialize the arguments

            if (InputObject.Expression != null)
            {
                targetCommand.AddParameter("InputObject", InputObject.Get(context));
            }

            if (FilterScript.Expression != null)
            {
                targetCommand.AddParameter("FilterScript", FilterScript.Get(context));
            }

            if (Property.Expression != null)
            {
                targetCommand.AddParameter("Property", Property.Get(context));
            }

            if (Value.Expression != null)
            {
                targetCommand.AddParameter("Value", Value.Get(context));
            }

            if (EQ.Expression != null)
            {
                targetCommand.AddParameter("EQ", EQ.Get(context));
            }

            if (CEQ.Expression != null)
            {
                targetCommand.AddParameter("CEQ", CEQ.Get(context));
            }

            if (NE.Expression != null)
            {
                targetCommand.AddParameter("NE", NE.Get(context));
            }

            if (CNE.Expression != null)
            {
                targetCommand.AddParameter("CNE", CNE.Get(context));
            }

            if (GT.Expression != null)
            {
                targetCommand.AddParameter("GT", GT.Get(context));
            }

            if (CGT.Expression != null)
            {
                targetCommand.AddParameter("CGT", CGT.Get(context));
            }

            if (LT.Expression != null)
            {
                targetCommand.AddParameter("LT", LT.Get(context));
            }

            if (CLT.Expression != null)
            {
                targetCommand.AddParameter("CLT", CLT.Get(context));
            }

            if (GE.Expression != null)
            {
                targetCommand.AddParameter("GE", GE.Get(context));
            }

            if (CGE.Expression != null)
            {
                targetCommand.AddParameter("CGE", CGE.Get(context));
            }

            if (LE.Expression != null)
            {
                targetCommand.AddParameter("LE", LE.Get(context));
            }

            if (CLE.Expression != null)
            {
                targetCommand.AddParameter("CLE", CLE.Get(context));
            }

            if (Like.Expression != null)
            {
                targetCommand.AddParameter("Like", Like.Get(context));
            }

            if (CLike.Expression != null)
            {
                targetCommand.AddParameter("CLike", CLike.Get(context));
            }

            if (NotLike.Expression != null)
            {
                targetCommand.AddParameter("NotLike", NotLike.Get(context));
            }

            if (CNotLike.Expression != null)
            {
                targetCommand.AddParameter("CNotLike", CNotLike.Get(context));
            }

            if (Match.Expression != null)
            {
                targetCommand.AddParameter("Match", Match.Get(context));
            }

            if (CMatch.Expression != null)
            {
                targetCommand.AddParameter("CMatch", CMatch.Get(context));
            }

            if (NotMatch.Expression != null)
            {
                targetCommand.AddParameter("NotMatch", NotMatch.Get(context));
            }

            if (CNotMatch.Expression != null)
            {
                targetCommand.AddParameter("CNotMatch", CNotMatch.Get(context));
            }

            if (Contains.Expression != null)
            {
                targetCommand.AddParameter("Contains", Contains.Get(context));
            }

            if (CContains.Expression != null)
            {
                targetCommand.AddParameter("CContains", CContains.Get(context));
            }

            if (NotContains.Expression != null)
            {
                targetCommand.AddParameter("NotContains", NotContains.Get(context));
            }

            if (CNotContains.Expression != null)
            {
                targetCommand.AddParameter("CNotContains", CNotContains.Get(context));
            }

            if (In.Expression != null)
            {
                targetCommand.AddParameter("In", In.Get(context));
            }

            if (CIn.Expression != null)
            {
                targetCommand.AddParameter("CIn", CIn.Get(context));
            }

            if (NotIn.Expression != null)
            {
                targetCommand.AddParameter("NotIn", NotIn.Get(context));
            }

            if (CNotIn.Expression != null)
            {
                targetCommand.AddParameter("CNotIn", CNotIn.Get(context));
            }

            if (Is.Expression != null)
            {
                targetCommand.AddParameter("Is", Is.Get(context));
            }

            if (IsNot.Expression != null)
            {
                targetCommand.AddParameter("IsNot", IsNot.Get(context));
            }


            return(new ActivityImplementationContext()
            {
                PowerShellInstance = invoker
            });
        }
예제 #27
0
 public override int GetHashCode()
 {
     return(NE.GetHashCode() ^ SW.GetHashCode());
 }
예제 #28
0
        static void Main(string[] args)
        {
            //Memoria memoria = new Memoria();
            //Pilha pilha = new Pilha();
            Processador processador = new Processador();
            tipo        num1        = new Inteiro(3);
            tipo        num2        = new Inteiro(5);
            tipo        num3        = new Inteiro(8);


            //Instrucoes instruc = new Push(processador.pilha,num1);
            //instruc.executar();

            //Instrucoes instruc5 = new Store(processador.memoria, processador.pilha, "opa");
            //instruc5.executar();

            //Instrucoes instruc4 = new Pop(processador.pilha);
            //instruc4.executar();

            string[] programa = System.IO.File.ReadAllLines(@"C:/Users/dougl/Desktop/Teste.txt");
            for (int i = 0; i < programa.Length; i++)
            {
                string[] linha = programa[i].Split(' ');
                if (linha[0] == "Label")
                {
                    Instrucoes intruc3 = new Label(processador.pilha, linha[1], i, processador.labels);
                    intruc3.executar();
                }
            }
            for (int i = 0; i < programa.Length; i++)
            {
                string[] linha = programa[i].Split(' ');
                if (linha.Length == 2)
                {
                    switch (linha[0])
                    {
                    case "Push":
                        if (linha[1] == "true")
                        {
                            tipo       parametro = new Booleano(true);
                            Instrucoes intruc    = new Push(processador.pilha, parametro);
                            intruc.executar();
                        }
                        else if (linha[1] == "false")
                        {
                            tipo       parametro = new Booleano(false);
                            Instrucoes intruc1   = new Push(processador.pilha, parametro);
                            intruc1.executar();
                        }
                        else
                        {
                            tipo       parametro = new Inteiro(int.Parse(linha[1]));
                            Instrucoes intruc2   = new Push(processador.pilha, parametro);
                            intruc2.executar();
                        }
                        break;

                    case "Load":
                        Instrucoes intruc4 = new Load(processador.memoria, processador.pilha, linha[1]);
                        intruc4.executar();
                        break;

                    case "Store":
                        Instrucoes intruc5 = new Store(processador.memoria, processador.pilha, linha[1]);
                        intruc5.executar();
                        break;

                    case "GoTo":
                        GoTo intruc6 = new GoTo(processador.labels, linha[1], processador.pilha);
                        intruc6.executar(i);
                        i = intruc6.index;
                        break;

                    case "GoTof":
                        GoTof intruc7 = new GoTof(processador.labels, linha[1], processador.pilha);
                        intruc7.executar(i);
                        i = intruc7.index;
                        break;
                    }
                }
                else if (linha.Length == 1)
                {
                    switch (linha[0])
                    {
                    case "Pop":
                        Instrucoes intruc = new Pop(processador.pilha);
                        intruc.executar();
                        break;

                    case "Add":
                        Instrucoes intruc2 = new Add(processador.pilha);
                        intruc2.executar();
                        break;

                    case "Sub":
                        Instrucoes intruc3 = new Sub(processador.pilha);
                        intruc3.executar();
                        break;

                    case "EQ":
                        Instrucoes intruc4 = new EQ(processador.pilha);
                        intruc4.executar();
                        break;

                    case "GE":
                        Instrucoes intruc5 = new GE(processador.pilha);
                        intruc5.executar();
                        break;

                    case "GT":
                        Instrucoes intruc6 = new GT(processador.pilha);
                        intruc6.executar();
                        break;

                    case "LE":
                        Instrucoes intruc7 = new LE(processador.pilha);
                        intruc7.executar();
                        break;

                    case "LT":
                        Instrucoes intruc8 = new LT(processador.pilha);
                        intruc8.executar();
                        break;

                    case "NE":
                        Instrucoes intruc9 = new NE(processador.pilha);
                        intruc9.executar();
                        break;

                    case "Print":
                        Instrucoes intruc10 = new Print(processador.pilha);
                        intruc10.executar();
                        break;

                    case "Read":
                        Instrucoes intruc11 = new Read(processador.pilha);
                        intruc11.executar();
                        break;

                    case "end":
                        i = programa.Length;
                        break;
                    }
                }
            }

            //Instrucoes instruc3 = new Push(processador.pilha, num2);
            //instruc3.executar();

            //Instrucoes instruc6 = new Load(processador.memoria, processador.pilha, "opa");
            //instruc6.executar();

            //Instrucoes instruc7 = new Add(processador.pilha);
            //instruc7.executar();

            //Instrucoes instruc9 = new Push(processador.pilha, num3);
            //instruc9.executar();

            //Instrucoes instruc8 = new EQ(processador.pilha);
            //instruc8.executar();

            //Instrucoes instruc2 = new Print(processador.pilha);
            //instruc2.executar();

            Console.ReadKey();
        }
예제 #29
0
        public IRace CreateInstance()
        {
            IRace race = new NE();

            return(race);
        }
예제 #30
0
        // TODO: Icons
        void OnLoadComplete(object sender, EventArgs eventArgs)
        {
            if (Context.Executables?.Count > 0)
            {
                lblPanelName.Text    = "Please wait while reading executables found";
                prgProgress.MaxValue = Context.Executables.Count;
                prgProgress.MinValue = 0;
                prgProgress.Value    = 0;

                foreach (string file in Context.Executables)
                {
                    var         exeStream = new FileStream(file, FileMode.Open, FileAccess.Read);
                    var         mzExe     = new MZ(exeStream);
                    var         neExe     = new NE(exeStream);
                    var         stExe     = new AtariST(exeStream);
                    var         lxExe     = new LX(exeStream);
                    var         coffExe   = new COFF(exeStream);
                    var         peExe     = new PE(exeStream);
                    var         geosExe   = new Geos(exeStream);
                    var         elfExe    = new ELF(exeStream);
                    IExecutable recognizedExe;

                    if (neExe.Recognized)
                    {
                        recognizedExe = neExe;
                    }
                    else if (lxExe.Recognized)
                    {
                        recognizedExe = lxExe;
                    }
                    else if (peExe.Recognized)
                    {
                        recognizedExe = peExe;
                    }
                    else if (mzExe.Recognized)
                    {
                        recognizedExe = mzExe;
                    }
                    else if (coffExe.Recognized)
                    {
                        recognizedExe = coffExe;
                    }
                    else if (stExe.Recognized)
                    {
                        recognizedExe = stExe;
                    }
                    else if (elfExe.Recognized)
                    {
                        recognizedExe = elfExe;
                    }
                    else if (geosExe.Recognized)
                    {
                        recognizedExe = geosExe;
                    }
                    else
                    {
                        exeStream.Close();

                        continue;
                    }

                    if (recognizedExe.Strings != null)
                    {
                        strings.AddRange(recognizedExe.Strings);
                    }

                    foreach (Architecture exeArch in recognizedExe.Architectures)
                    {
                        ArchitecturesTypeArchitecture?arch = ExeArchToSchemaArch(exeArch);

                        if (arch.HasValue &&
                            !architectures.Contains($"{arch.Value}"))
                        {
                            architectures.Add($"{arch.Value}");
                        }
                    }

                    operatingSystems.Add(new TargetOsEntry
                    {
                        name    = recognizedExe.RequiredOperatingSystem.Name,
                        version =
                            $"{recognizedExe.RequiredOperatingSystem.MajorVersion}.{recognizedExe.RequiredOperatingSystem.MinorVersion}"
                    });

                    switch (recognizedExe)
                    {
                    case NE _:
                        if (neExe.Versions != null)
                        {
                            foreach (NE.Version exeVersion in neExe.Versions)
                            {
                                versions.Add(exeVersion.FileVersion);
                                versions.Add(exeVersion.ProductVersion);
                                version = exeVersion.ProductVersion;

                                foreach (KeyValuePair <string, Dictionary <string, string> > kvp in exeVersion.
                                         StringsByLanguage)
                                {
                                    if (kvp.Value.TryGetValue("CompanyName", out string tmpValue))
                                    {
                                        developer = tmpValue;
                                    }

                                    if (kvp.Value.TryGetValue("ProductName", out string tmpValue2))
                                    {
                                        product = tmpValue2;
                                    }
                                }
                            }
                        }

                        break;

                    case PE _:
                        if (peExe.Versions != null)
                        {
                            foreach (PE.Version exeVersion in peExe.Versions)
                            {
                                versions.Add(exeVersion.FileVersion);
                                versions.Add(exeVersion.ProductVersion);
                                version = exeVersion.ProductVersion;

                                foreach (KeyValuePair <string, Dictionary <string, string> > kvp in exeVersion.
                                         StringsByLanguage)
                                {
                                    if (kvp.Value.TryGetValue("CompanyName", out string tmpValue))
                                    {
                                        developer = tmpValue;
                                    }

                                    if (kvp.Value.TryGetValue("ProductName", out string tmpValue2))
                                    {
                                        product = tmpValue2;
                                    }
                                }
                            }
                        }

                        break;

                    case LX _:
                        if (lxExe.WinVersion != null)
                        {
                            versions.Add(lxExe.WinVersion.FileVersion);
                            versions.Add(lxExe.WinVersion.ProductVersion);
                            version = lxExe.WinVersion.ProductVersion;

                            foreach (KeyValuePair <string, Dictionary <string, string> > kvp in lxExe.WinVersion.
                                     StringsByLanguage)
                            {
                                if (kvp.Value.TryGetValue("CompanyName", out string tmpValue))
                                {
                                    developer = tmpValue;
                                }

                                if (kvp.Value.TryGetValue("ProductName", out string tmpValue2))
                                {
                                    product = tmpValue2;
                                }
                            }
                        }

                        break;
                    }

                    exeStream.Close();
                    prgProgress.Value++;
                }

                strings = strings.Distinct().ToList();
                strings.Sort();

                if (strings.Count == 0 &&
                    minimumPanel == Panels.Strings)
                {
                    minimumPanel = Panels.Versions;
                }
                else
                {
                    maximumPanel = Panels.Strings;
                }

                panelStrings.treeStrings.DataStore = strings;
                versions = versions.Distinct().ToList();
                versions.Sort();
                panelVersions.treeVersions.DataStore = versions;
                architectures = architectures.Distinct().ToList();
                architectures.Sort();
                panelVersions.treeArchs.DataStore = architectures;

                Dictionary <string, List <string> > osEntriesDictionary = new Dictionary <string, List <string> >();

                foreach (TargetOsEntry osEntry in operatingSystems)
                {
                    if (string.IsNullOrEmpty(osEntry.name))
                    {
                        continue;
                    }

                    osEntriesDictionary.TryGetValue(osEntry.name, out List <string> osvers);

                    if (osvers == null)
                    {
                        osvers = new List <string>();
                    }

                    osvers.Add(osEntry.version);
                    osEntriesDictionary.Remove(osEntry.name);
                    osEntriesDictionary.Add(osEntry.name, osvers);
                }

                operatingSystems = new List <TargetOsEntry>();

                foreach (KeyValuePair <string, List <string> > kvp in osEntriesDictionary.OrderBy(t => t.Key))
                {
                    kvp.Value.Sort();

                    foreach (string s in kvp.Value.Distinct())
                    {
                        operatingSystems.Add(new TargetOsEntry
                        {
                            name    = kvp.Key,
                            version = s
                        });
                    }
                }

                panelVersions.treeOs.DataStore = operatingSystems;

                if (versions.Count > 0 ||
                    architectures.Count > 0 ||
                    operatingSystems.Count > 0)
                {
                    maximumPanel = Panels.Versions;
                }
            }

            prgProgress.Visible = false;
            btnPrevious.Enabled = false;

            switch (minimumPanel)
            {
            case Panels.Description:
                pnlPanel.Content = panelDescription;
                currentPanel     = Panels.Description;

                break;

            case Panels.Strings:
                pnlPanel.Content = panelStrings;
                currentPanel     = Panels.Strings;

                break;

            case Panels.Versions:
                pnlPanel.Content = panelVersions;
                currentPanel     = Panels.Versions;

                break;
            }

            if (currentPanel == maximumPanel)
            {
                btnNext.Text = "Finish";
            }

            lblPanelName.Visible = false;
        }