Exemplo n.º 1
0
 internal static bool LoadMaps(Land land)
 {
     using (var conn = DataAccess.GetSQLConnection())
     {
         try
         {
             SqlStoredProcedure sp = new SqlStoredProcedure("prApp_Map_Select", conn);
             sp.AddParameter("@landID", SqlDbType.SmallInt, 2, ParameterDirection.Input, land.LandID);
             DataTable dtMaps = sp.ExecuteDataTable();
             foreach (DataRow dr in dtMaps.Rows)
             {
                 //if (dr["name"].ToString() != "Innkadi")
                 //{
                 land.Add(new Map(land.FacetID, dr));
                 Utils.Log("Loaded Map: " + dr["name"].ToString(), Utils.LogType.SystemGo);
                 //}
             }
             return(true);
         }
         catch (Exception e)
         {
             Utils.LogException(e);
             return(false);
         }
     }
 }
Exemplo n.º 2
0
    static void Main(string[] args)
    {
        land = new Land();
        string[] inputs; int surfaceN = int.Parse(Console.ReadLine()); // the number of points used to draw the surface of Mars.        
        for (int i = 0; i < surfaceN; i++)
        {
            inputs = Console.ReadLine().Split(' ');
            //int landX = int.Parse(inputs[0]); // X coordinate of a surface point. (0 to 6999)
            //int landY = int.Parse(inputs[1]); // Y coordinate of a surface point. By linking all the points together in a sequential fashion, you form the surface of Mars.
            land.Add(new Point(int.Parse(inputs[0]), int.Parse(inputs[1])));
        }

        double modhSpeed = 0;
        double modvSpeed = 0;
        double modX      = 0;
        double modY      = 0;
        int    loop      = 0;

        // game loop       
        while (true)
        {
            inputs = Console.ReadLine().Split(' ');
            int X      = int.Parse(inputs[0]);
            int Y      = int.Parse(inputs[1]);
            int hSpeed = int.Parse(inputs[2]); // the horizontal speed (in m/s), can be negative.
            int vSpeed = int.Parse(inputs[3]); // the vertical speed (in m/s), can be negative.
            int fuel   = int.Parse(inputs[4]); // the quantity of remaining fuel in liters.
            int rotate = int.Parse(inputs[5]); // the rotation angle in degrees (-90 to 90).
            int power  = int.Parse(inputs[6]);

            if (loop == 0)
            {
                modhSpeed = hSpeed;
                modvSpeed = vSpeed;
                modX      = X;
                modY      = Y;
            }
            loop++;

            int modRotate = 0;
            int modPower  = 0;
            // Write an action using Console.WriteLine()            
            // To debug: Console.Error.WriteLine("Debug messages...");         

            modRotate = GetNextRotate(rotate, gene.Rotate);
            modPower  = GetNextPower(power, gene.Power);
            double modRad = (System.Math.PI / 180) * (90 + modRotate);

            modX      = modX + modhSpeed + System.Math.Cos(modRad) * modPower / 2;
            modhSpeed = modhSpeed + System.Math.Cos(modRad) * modPower;
            modY      = modY + modvSpeed + (System.Math.Sin(modRad) * modPower + Land.G) / 2;
            modvSpeed = modvSpeed + System.Math.Sin(modRad) * modPower + Land.G;

            // rotate power. rotate is the desired rotation angle. power is the desired thrust power.            
            Console.WriteLine(modRotate + " " + modPower);
        }
    }
        public override void Visit(Node node)
        {
            if (node.Options.IsLand)
            {
                Land.Add(new TypeValuePair()
                {
                    Type  = node.Type,
                    Value = String.Join(" ", node.Children.Where(c => ChildrenWithValues.Contains(c.Type))
                                        .Select(c => String.Join("", c.Value.Select(e => System.Text.RegularExpressions.Regex.Replace(e, "[\n\r\t\f]+", " ")))))
                });
            }

            base.Visit(node);
        }