Exemplo n.º 1
0
        /// <summary>
        /// Create an XmlElement representation of the fleet report for saving.
        /// </summary>
        /// <param name="xmldoc">The parent XmlDocument.</param>
        /// <returns>An XmlElement representation of the report.</returns>
        public new XmlElement ToXml(XmlDocument xmldoc)
        {
            XmlElement xmlelFleetIntel = xmldoc.CreateElement("FleetIntel");

            // include inherited Item properties
            xmlelFleetIntel.AppendChild(base.ToXml(xmldoc));

            Global.SaveData(xmldoc, xmlelFleetIntel, "Year", Year.ToString(System.Globalization.CultureInfo.InvariantCulture));

            Global.SaveData(xmldoc, xmlelFleetIntel, "Icon", Icon.Source);

            Global.SaveData(xmldoc, xmlelFleetIntel, "Bearing", Bearing.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Global.SaveData(xmldoc, xmlelFleetIntel, "Speed", Speed.ToString(System.Globalization.CultureInfo.InvariantCulture));
            Global.SaveData(xmldoc, xmlelFleetIntel, "InOrbit", InOrbit.ToString());
            Global.SaveData(xmldoc, xmlelFleetIntel, "IsStarbase", IsStarbase.ToString());

            // Store the composition
            XmlElement xmlelComposition = xmldoc.CreateElement("Composition");

            foreach (ShipToken token in Composition.Values)
            {
                xmlelComposition.AppendChild(token.ToXml(xmldoc));
            }
            xmlelFleetIntel.AppendChild(xmlelComposition);

            return(xmlelFleetIntel);
        }
Exemplo n.º 2
0
        public bool TryIncreaseSpeed()
        {
            Speed++;

            string bearingString = Bearing.ToString();
            string speedString   = Speed.ToString().Replace("Speed", "");

            TemplatePrefabName = bearingString + speedString + ((IsSideTemplate) ? "Alt" : "");

            if (IsValidTemplate())
            {
                return(true);
            }
            else
            {
                Speed--;

                bearingString      = Bearing.ToString();
                speedString        = Speed.ToString().Replace("Speed", "");
                TemplatePrefabName = bearingString + speedString + ((IsSideTemplate) ? "Alt" : "");

                return(false);
            }
        }
Exemplo n.º 3
0
        public override void move(Key[] keysDownMomentary)
        {
            xVelocity *= 0.995;
            yVelocity *= 0.995;

            worldX += xVelocity;
            worldY += yVelocity;

            if (!isPuter)
            {
                foreach (Key key in keysDownMomentary)
                {
                    if (key == keyActions[0])
                    {
                        accelerate();
                    }
                    if (key == keyActions[1])
                    {
                        turnleft();
                    }
                    if (key == keyActions[2])
                    {
                        brake();
                    }
                    if (key == keyActions[3])
                    {
                        turnright();
                    }
                }
            }

            if (script != null && playerScriptON)
            {
                double[] checkPointTop = checkPoint.getCornerCoords(Face.front);
                double[] thisTop       = getCornerCoords(Face.front);
                bearingToCheckPoint = bearingToCheckPoint.toPointUpdateOnce(checkPointTop[0] - thisTop[0], checkPointTop[1] - thisTop[1], -xVelocity, -yVelocity);
                double distanceToCheckPoint = Math.Sqrt((checkPointTop[0] - thisTop[0]) * (checkPointTop[0] - thisTop[0]) + (checkPointTop[1] - thisTop[1]) * (checkPointTop[1] - thisTop[1]));

                string input  = bearingToCheckPoint.ToString() + "," + Math.Floor(distanceToCheckPoint);
                string output = string.Empty;

                try
                {
                    output = script(input);
                }
                catch
                {
                    playerScriptON = false;
                }

                if (!string.IsNullOrEmpty(output))
                {
                    if (output.Contains("L"))
                    {
                        turnleft();
                    }
                    if (output.Contains("R"))
                    {
                        turnright();
                    }
                    if (output.Contains("A"))
                    {
                        accelerate();
                    }
                    if (output.Contains("B"))
                    {
                        brake();
                    }
                }
            }

            updateRotation();
        }