/// <summary> /// Inicializa el escuadron especificado /// </summary> /// <param name="squadron">Escuadrón de vehículos</param> private void InitializeSquadron(Vehicle[] squadron) { // Punto de posición del escuadrón Vector3 where = new Vector3(RandomComponent.Next(5000) + 5000, 600, RandomComponent.Next(5000) + 5000); float?h = this.m_Scenery.Scenery.GetHeigthAtPoint(where.X, where.Z); if (h.HasValue) { where.Y = h.Value + 1f; } squadron[0].SetInitialState(where, Quaternion.Identity); this.Physics.RegisterObject(squadron[0]); for (int i = 1; i < squadron.Length; i++) { // Posición de cada vehículo relativa al anterior Vector3 rWhere = squadron[i - 1].Position - Vector3.Multiply(Vector3.One, 10f); float?rh = this.m_Scenery.Scenery.GetHeigthAtPoint(rWhere.X, rWhere.Z); if (rh.HasValue) { rWhere.Y = rh.Value + 1f; } squadron[i].SetInitialState(rWhere, Quaternion.Identity); // Indicar a cada vehículo que siga al anterior //squadron[i].AutoPilot.Follow(squadron[i - 1], 150f); this.Physics.RegisterObject(squadron[i]); } }
// Start is called before the first frame update void Start() { // UIComponent ui = new UIComponent(); // ui.SyncOpenView<StartView>(); //var path = @"C:\Users\Xqh\Desktop\test.db"; //var connect = new SQLiteConnection(path, "123"); //connect.CreateTable<AAAAA>(); //connect.InsertAll(new[] //{ // new AAAAA() // { // Id = 1, // abc = Guid.NewGuid().ToString(), // x_y = 6 // }, //}); //new SqlCipherComponent(); RandomComponent aa = new RandomComponent(); aa.RandomChinese(20, 1, 6).ContinueWith(t => { foreach (var temp in t.Result) { Debug.Log(temp); } }); }
private void PlayRandomomponent(ComponentInstance zComponentInstance) { if (_playMode == RandomComponentPlayMode.Random) { int index = _shuffleBag.get(); _selectedComponent = _components[index]; } else { int num = -1; if (!_shareRandomNoRepeatHistory) { num = GetNextRandomNoRepeatIndex(); } else { RandomComponent randomComponent = base.ComponentHolder as RandomComponent; if ((bool)randomComponent) { num = randomComponent.GetNextRandomNoRepeatIndex(); } } if (num < 0) { return; } _selectedComponent = _components[num]; } if (_selectedComponent != null) { _selectedComponent.PlayInternal(zComponentInstance, 0f, 0.5f); } }
/// <summary> /// Añade una nueva partícula al sistema /// </summary> /// <param name="position">Posición</param> /// <param name="velocity">Velocidad</param> public void AddParticle(Vector3 position, Vector3 velocity) { //Obtener el siguiente índice disponible int nextFreeParticle = this.m_FirstFreeParticle + 1; //Si se ha llegado al final, se empieza desde el principio if (nextFreeParticle >= this.m_Particles.Length) { nextFreeParticle = 0; } //Si no ha partículas libres, se terminar el proceso if (nextFreeParticle == this.m_FirstRetiredParticle) { return; } //Ajustar la velocidad velocity *= this.Settings.EmitterVelocitySensitivity; //Añadir algo de velocidad horizontal float horizontalVelocity = MathHelper.Lerp( this.Settings.MinHorizontalVelocity, this.Settings.MaxHorizontalVelocity, RandomComponent.NextFloat()); double horizontalAngle = RandomComponent.NextDouble() * MathHelper.TwoPi; velocity.X += horizontalVelocity * (float)Math.Cos(horizontalAngle); velocity.Z += horizontalVelocity * (float)Math.Sin(horizontalAngle); //Añadir algo de velocidad vertical velocity.Y += MathHelper.Lerp( this.Settings.MinVerticalVelocity, this.Settings.MaxVerticalVelocity, RandomComponent.NextFloat()); //Colores Color randomValues = new Color( (byte)RandomComponent.Next(255), (byte)RandomComponent.Next(255), (byte)RandomComponent.Next(255), (byte)RandomComponent.Next(255)); //Añadir la partícula this.m_Particles[this.m_FirstFreeParticle].Position = position; this.m_Particles[this.m_FirstFreeParticle].Velocity = velocity; this.m_Particles[this.m_FirstFreeParticle].Random = randomValues; this.m_Particles[this.m_FirstFreeParticle].Time = this.m_CurrentTime; this.m_FirstFreeParticle = nextFreeParticle; }
protected override void OnPreInitialise(bool inPreviewMode = false) { if ((bool)_component) { RandomComponent componentInChildren = base.gameObject.GetComponentInChildren <RandomComponent>(); if (componentInChildren != null) { randomComponent = componentInChildren.gameObject; } if (randomComponent == null) { randomComponent = UnityEngine.Object.Instantiate(_component.gameObject, _component.gameObject.transform.position, _component.gameObject.transform.rotation); randomComponent.transform.parent = base.transform; } SetLoop(_loop, forceUpdate: true); } }
/// <summary> /// 点击确认注册按钮 /// </summary> private void OnRegisterConfirmBtnClick() { if (string.IsNullOrEmpty(_accountInput.text) || string.IsNullOrEmpty(_passwordInput.text)) { _registerErrorText.text = "账号或密码不能为空!"; return; } //是否存在该用户 AVUser.Query.WhereEqualTo(_netComponent.GetProperty <AVUser>(t => t.Username), _accountInput.text) .CountAsync().ContinueWith(t => { if (t.Result != 0) { _registerErrorText.text = "该账号已注册!"; return; } //不存在该用户,可以注册 var user = new AVUser() { Username = _accountInput.text, Password = _passwordInput.text, [_showPasswordKey] = _passwordInput.text }; user.SignUpAsync().ContinueToForeground(p => { string petName = new RandomComponent().RandomChinese(UnityEngine.Random.Range(2, 5)); var player = new Player { PetName = petName, UserId = AVUser.CurrentUser }; player.SaveAsync().ContinueWith(n => { Login(_accountInput.text, _passwordInput.text).ContinueToForeground(a => { _uiComponent.SyncOpenView <MainView>(); _uiComponent.DestroyView <LoginView>(); }); } ); }); }); }
/// <summary> /// Inicializa el estado de los edificios /// </summary> /// <param name="buildings">Lista de edificios</param> private void InitializeBuildings(Building[] buildings) { // Punto de posición del edificio foreach (Building building in buildings) { Vector3 where = new Vector3(RandomComponent.Next(5000) + 5000, 600, RandomComponent.Next(5000) + 5000); float?h = this.m_Scenery.Scenery.GetHeigthAtPoint(where.X, where.Z); if (h.HasValue) { where.Y = h.Value + 1f; } building.SetInitialState(where, Quaternion.Identity); this.Physics.RegisterObject(building); } }