Beispiel #1
0
        static void Main(string[] args)
        {
            MyWorld          w          = new MyWorld();
            CommandProcessor c          = new CommandProcessor();
            Thread           mainThread = new Thread(new ParameterizedThreadStart(Run));

            mainThread.Start(w);
            //Game.Run(new MyWorld());
            while (true)
            {
                c.ProcessCommand(Console.ReadLine(), w);
            }
        }
Beispiel #2
0
        public void ProcessCommand(string commandRaw, MyWorld w)
        {
            string[] commandStructure = commandRaw.Split(new char[] { ' ' });
            string   command          = commandStructure[0];

            string[] arguments = new string[commandStructure.Length - 1];
            for (int i = 1; i < commandStructure.Length; i++)
            {
                arguments[i - 1] = commandStructure[i];
            }

            switch (command)
            {
            case "ShowPaths":
                ProcessShowPaths(arguments);
                break;

            case "ShowSensingRadius":
                ProcessShowSensingRadius(arguments);
                break;

            case "ShowPathsToFood":
                ProcessShowPathsToFood(arguments);
                break;

            case "ShowSenseLines":
                ProcessShowSenseLines(arguments);
                break;

            case "Spawn":
                ProcessSpawn(arguments, w);
                break;

            case "var":
                ProcessVar(arguments);
                break;

            case "ClearActors":
                w.ClearActors();
                break;

            default:
                outputString("Unknown command");
                break;
            }
        }
Beispiel #3
0
        //Spawn
        private static void ProcessSpawn(string[] arguments, MyWorld w)
        {
            if (arguments.Length > 0)
            {
                if (arguments.Length >= 3)
                {
                    int x, y;
                    if (!int.TryParse(arguments[1], out x) || !int.TryParse(arguments[2], out y))
                    {
                        outputString("Unknown structure of command Spawn");
                    }
                    else
                    {
                        switch (arguments[0])
                        {
                        case "Food":
                            w.AddActor(new Actors.Food()
                            {
                                position = new Ants.Vector2(x, y)
                            });
                            break;

                        case "Anthill":
                            w.AddActor(new Actors.Anthill()
                            {
                                position = new Ants.Vector2(x, y)
                            });
                            break;

                        default:
                            outputString("Unknown actor");
                            break;
                        }
                    }
                }
            }
        }
Beispiel #4
0
 public ReturnToAnthill(Actors.Ant me, MyWorld world)
 {
     this.me    = me;
     this.world = world;
 }
Beispiel #5
0
 public Forage(Actors.Ant me, MyWorld world)
 {
     this.me    = me;
     this.world = world;
 }
Beispiel #6
0
 public FetchFood(Actors.Ant me, MyWorld world)
 {
     this.me    = me;
     this.world = world;
 }