private void Button3_Click(object sender, EventArgs e) { CarInfo car = appConfig.GetCarInfo(comboBox2.SelectedItem.ToString(), comboBox3.SelectedItem.ToString(), comboBox4.SelectedItem.ToString()); if (!car.Validate()) { MessageBox.Show("验证车型配置文件失败", "提示", MessageBoxButtons.OK, MessageBoxIcon.Error); } CarConfig ccfg = car.GetCarConfig(); string projectName = textBox1.Text; string projectPath = comboBox1.Text; string developor = textBox2.Text; Project newProject = new Project(car, ccfg, projectName, projectPath, developor); bool overwrite = false; recreate: if (newProject.StartCreateProject(overwrite, out string error, out string errorDetails)) { this.Hide(); newProject.NextStatus(); newProject.SetStatusOpen(); updateGlobalProjectHandler(newProject); }
public static void Parse(TextAsset Text) { XmlDocument doc = new XmlDocument(); doc.LoadXml(Text.text); XmlNode Node = doc.SelectSingleNode("Config"); if (Node != null) { XmlNodeList NodeList = Node.ChildNodes; if (NodeList != null && NodeList.Count > 0) { foreach (XmlElement e in NodeList) { if (e == null || !e.GetType().Equals(typeof(XmlElement))) { continue; } CarConfig config = new CarConfig(); config.carname = e.GetAttribute("carname"); config.id = int.Parse(e.GetAttribute("id")); config.resname = e.GetAttribute("resname"); AllCarDic.Add(config.id, config); } } } }
public Car ProduceCar<T>(CarConfig config) where T : Car, new() { Car car = new T(); car.Size = config.Size; car.Engine = config.Engine; car.Producer = config.Producer; return car; }
public void Prepare(CarConfig carConfig, Dictionary <int, GameObject> streets, Mission mission) { Streets = streets; SpriteRenderer carRenderer = gameObject.AddComponent <SpriteRenderer>(); Texture2D carT = (Texture2D)carConfig.CarTexture; carRenderer.sprite = Sprite.Create(carT, new Rect(0, 0, carT.width, carT.height), new Vector2(0.5f, 0.5f)); carRenderer.sortingLayerName = "Layer3"; float scale = InGamePosition.tileH / carRenderer.bounds.size.y; gameObject.transform.localScale = new Vector3(scale, scale); if (carConfig.CarStatistics[CarStatisticType.SHIELD].Value > 0) { ShieldCompo sc = gameObject.AddComponent <ShieldCompo>(); sc.Prepare(carConfig.CarStatistics[CarStatisticType.SHIELD]); } Speeder speeder = gameObject.AddComponent <Speeder>(); speeder.Prepare(carConfig.CarStatistics[CarStatisticType.COMBUSTION], mission.Env.CarStartingSpeed); Fuel fuel = gameObject.AddComponent <Fuel>(); fuel.Prepare(carConfig.CarStatistics [CarStatisticType.FUEL_TANK], carConfig.CarStatistics [CarStatisticType.STARTING_OIL]); gameObject.AddComponent <InGamePosition>(); float shooterProbability = 0; float jumperProbability = 0; float ticket = Random.Range(0, shooterProbability + jumperProbability); if (ticket <= jumperProbability) { Jumper jumper = gameObject.AddComponent <Jumper>(); jumper.JumpDistance = 2; jumper.JumpCost = 4; } else if (ticket <= jumperProbability + shooterProbability) { gameObject.AddComponent <Shooter>(); } CarTurner carTurner = gameObject.AddComponent <CarTurner>(); carTurner.Prepare(carConfig.CarStatistics [CarStatisticType.WHEEL]); Accelerator accelerator = gameObject.AddComponent <Accelerator> (); accelerator.Prepare(mission.Env.CarMaxSpeed, mission.Env.MaxSpeedDistance); gameObject.AddComponent <HurtTaker> (); }
public Project(CarInfo car, CarConfig ccfg, string name, string path, string dev) { CarInfo = car; CarConfig = ccfg; ProjectName = name; LocalPath = path; Developer = dev; Status = ProjectStatus.StartCreateProject; Editer = new PropertyiesEditer <int, Property>(); }
public FileProject(string path) { this.BasePath = path; this.OutPath = Path.GetFullPath($"out", this.BasePath); this.ConfigPath = Path.GetFullPath("zdragon.json", this.BasePath); this.CarConfig = CarConfig.Load(this.ConfigPath); this.FileSystem = ProjectContext.FileSystem ?? throw new Exception("FileSystem does not exist"); this.FileSystem.CreateDirectory(OutPath); this.InitializeModules(); }
IEnumerator SetCarConfig(string body_style, int body_r, int body_g, int body_b, string car_name, int font_size) { CarConfig conf = carObj.GetComponent <CarConfig>(); if (conf) { conf.SetStyle(body_style, body_r, body_g, body_b, car_name, font_size); } yield return(null); }
void Awake() { car = carObj.GetComponent <ICar>(); conf = carObj.GetComponent <CarConfig>(); pm = GameObject.FindObjectOfType <PathManager>(); Canvas canvas = GameObject.FindObjectOfType <Canvas>(); GameObject go = CarSpawner.getChildGameObject(canvas.gameObject, "AISteering"); if (go != null) { ai_text = go.GetComponent <Text>(); } }
private void loadScene(TreeView treeview, CarConfig carConfig) { Form_Progress form_Progress = new Form_Progress(carConfig.GetTotalSceneNum(), false); form_Progress.Location = new Point((displayWidth - form_Progress.Width) / 2, (displayHeight - form_Progress.Height) / 2); form_Progress.Show(); GlobalConfig.Controller.HideCenterBoardPictureBox(); rightPanel.SuspendLayout(); treeview.BeginUpdate(); foreach (Scene scene in carConfig.Scenes) { TreeNode sceneNode = new TreeNode { Name = scene.Id.ToString(), Text = scene.Name }; GlobalConfig.Controller.InitScene(scene.Id, true); foreach (Scene childScene in scene.children) { sceneNode.Nodes.Add(new TreeNode { Name = childScene.Id.ToString(), Text = childScene.Name }); GlobalConfig.Controller.InitScene(childScene.Id, true); form_Progress.AddProgressValue(1, string.Format("场景 {0} 已加载", childScene.Name)); } form_Progress.AddProgressValue(1, string.Format("场景 {0} 已加载", scene.Name)); treeview.Nodes.Add(sceneNode); } treeview.EndUpdate(); rightPanel.ResumeLayout(); GlobalConfig.Controller.ShowCenterBoardPictureBox(); form_Progress.Close(); form_Progress.Dispose(); }
public static void InitCarConfig() { foreach (CarInfo carInfo in FileManager.carInfoList) { CarConfig car = new CarConfig(); car.CarId = carInfo.Id; if (car.CarId == mUserInfo.CurrentCar) { car.LeftWp = int.Parse(mUserInfo.BoughtWeapon.Split(new char[] { ',' })[0]); if (mUserInfo.BoughtWeapon.Split(',').Length > 1) { //car.RightWp = mUserInfo.BoughtWeapon.Split(new char[] { ',' })[RaceController.loadLevelIndex.Equals(RaceController.GuideLevel) ? 1 : 0]; car.RightWp = int.Parse(mUserInfo.BoughtWeapon.Split(new char[] { ',' })[0]); } else { car.RightWp = int.Parse(mUserInfo.BoughtWeapon.Split(new char[] { ',' })[0]); } car.CarSkin = int.Parse(mUserInfo.BoughtCarSkin.Split(new char[] { ',' })[0]); car.WheelSkin = int.Parse(mUserInfo.BoughtWheelSkin.Split(new char[] { ',' })[0]); } else { car.LeftWp = 101; car.RightWp = 101; car.CarSkin = carInfo.SkinId; car.WheelSkin = carInfo.WheelSkin; } if (mUserInfo.CarConfigDic == null) { mUserInfo.CarConfigDic = new Dictionary <int, CarConfig>(); // CarConfig defaultCar = GetDefaultCarConfig(_carId); mUserInfo.CarConfigDic.Add(carInfo.Id, car); //CarConfigDic.Add() } else { if (!mUserInfo.CarConfigDic.ContainsKey(carInfo.Id)) { mUserInfo.CarConfigDic.Add(carInfo.Id, car); } } } }
void Awake() { car = carObj.GetComponent <ICar>(); conf = carObj.GetComponent <CarConfig>(); pm = GameObject.FindObjectOfType <PathManager>(); carSpawner = GameObject.FindObjectOfType <CarSpawner>(); Canvas canvas = GameObject.FindObjectOfType <Canvas>(); GameObject go = CarSpawner.getChildGameObject(canvas.gameObject, "AISteering"); if (go != null) { ai_text = go.GetComponent <Text>(); } if (pm != null && carObj != null) { iActiveSpan = pm.carPath.GetClosestSpanIndex(carObj.transform.position); } }
public void PrepareRace(PlayerState player, AfterMinigameF afterMinigame, Mission mission, CarConfig chosenCar) { if (Me != null) { Me.UnloadResources(); Destroy(Me); } Me = this; AfterMinigame = afterMinigame; Mission = mission; Player = player; CarConfig = chosenCar; InGamePosition.tileH = SpriteManager.GetCar().height / 70f; InGamePosition.tileW = SpriteManager.GetCar().width / 70f; GameObject previousStreet = null; int carStartingStreet = 0; int clearStreets = 0; int streetCount = 10; for (int i = -1; i < streetCount; i++) { bool noObstacles = clearStreets - streetCount - carStartingStreet <= Mission.Env.FirstClearStreets; GameObject thisStreet = CreateStreet(i, previousStreet, noObstacles, Mission.Env); Streets.Add(i, thisStreet); previousStreet = thisStreet; clearStreets++; } Car = new GameObject(); Car.name = "car"; Car tmp = Car.AddComponent <Car>(); tmp.Prepare(chosenCar, Streets, mission); Destroy(Camera.main.GetComponent <Camera>().gameObject.GetComponent <FollowGM>()); FollowGM fgm = Camera.main.gameObject.AddComponent <FollowGM> (); fgm.FollowWhom = Car; fgm.Offset.y = -0.5f; }
static void LoadCarConfig() { foreach (string s in mUserInfo.CarConfigs.Values) { byte[] bt = SGTool.stringToBytes(s); CarConfig car = SGTool.protobufDecode <CarConfig>(bt); if (mUserInfo.CarConfigDic == null) { mUserInfo.CarConfigDic = new Dictionary <int, CarConfig>(); mUserInfo.CarConfigDic.Add(car.CarId, car); } else { if (mUserInfo.CarConfigDic.ContainsKey(car.CarId)) { mUserInfo.CarConfigDic[car.CarId] = car; } else { mUserInfo.CarConfigDic.Add(car.CarId, car); } } } }
public JsonTests() { this.CarConfig = new CarConfig(); }
public ParserTests_Recursive() { this.CarConfig = new CarConfig(); }
public ASTTypeToJSchema(CarConfig carConfig) { this.CarConfig = carConfig; }
public PlayerState(CarConfig carConfig, int coins) { Initialize(carConfig, coins); }
private void Initialize(CarConfig carConfig, int coins) { CarConfig = carConfig; _EverEarnedCoins = _Coins = coins; }
public ASTAliasToJSchema(CarConfig carConfig) { this.CarConfig = carConfig; }
public JsonMapper(ASTGenerator generator, CarConfig carConfig) { this.Generator = generator; this.CarConfig = carConfig; }