public void Initialize(GameObject StarshipPrefab) { Health health = StarshipPrefab.GetComponent <Health>(); Starship_Engine starship_Engine = StarshipPrefab.GetComponent <Starship_Engine>(); Starship_RotationEngine starship_RotationEngine = StarshipPrefab.GetComponent <Starship_RotationEngine>(); Guns guns = StarshipPrefab.GetComponent <Guns>(); StarshipData starshipData = StarshipsModificatonsData.GetStarshipData(StarshipPrefab.GetComponent <PlayerStarshipModifications>().Starship); InitializeModificationMenu(ModificationMenus[0], health.maxHp, starshipData, ModificationName.Health); InitializeModificationMenu(ModificationMenus[1], starship_Engine.force, starshipData, ModificationName.EnginePower); InitializeModificationMenu(ModificationMenus[2], starship_RotationEngine.force, starshipData, ModificationName.GyroPower); InitializeModificationMenu(ModificationMenus[3], 1 / guns.ShootTime, starshipData, ModificationName.ShootTime); }
public IEnumerator IStarshipMove(Starship starship) { Starship_Engine starship_Engine = starship.GetComponent <Starship_Engine>(); Starship_RotationEngine starship_RotationEngine = starship.GetComponent <Starship_RotationEngine>(); Rigidbody rigidbody = starship.GetComponent <Rigidbody>(); ToStartPosition(starship); OnStartMove?.Invoke(); starship_Engine.SetLockMove(false); while (Vector3.Distance(starship.transform.position, endTr.position) > 1f) { starship_RotationEngine.RotateToTargetWithPlaneLimiter(endTr.position + endTr.forward); starship_Engine.Move(MoveDirectionConsideringAngle(1, Vector3.Angle((endTr.position - rigidbody.velocity - starship.transform.position).normalized, starship.RotationPoint.forward))); // Двигаемся yield return(new WaitForFixedUpdate()); } starship_Engine.SetLockMove(true); OnEndMove?.Invoke(); }