// Use this for initialization void Start() { explosion = GetComponentInChildren <ExplosionAnimation>(); startPosition = transform.position; game = Camera.mainCamera.GetComponent <GameController>(); foreach (Transform child in transform) { if (child.name == "UpThruster") { upThruster = child.GetComponent <Thruster>(); } else if (child.name == "DownThruster") { downThruster = child.GetComponent <Thruster>(); } else if (child.name == "RightThruster") { rightThruster = child.GetComponent <Thruster>(); } } movementOnScreenToCFactor = (transform.position.x / Gamma.GetGamma(game.GetCSpeed())); }
protected virtual void OnSceneGUI() { Thruster t = target as Thruster; float size = HandleUtility.GetHandleSize(t.transform.position) * 5.0f; Handles.ScaleValueHandle(1.0f, t.transform.position, Quaternion.LookRotation(t.transform.TransformDirection(t.thrustDir), t.transform.up), size, Handles.ArrowHandleCap, 0.0f); }
void _initThusters() { atmThs.Clear(); hyThs.Clear(); ionThs.Clear(); pg.GridTerminalSystem.GetBlocksOfType <IMyThrust> ( l, x => x.CubeGrid == pg.Me.CubeGrid); MatrixD m = pg.Me.CubeGrid.WorldMatrix; Thruster t; for (int i = 0; i < l.Count; i++) { t = new Thruster((IMyThrust)l[i], m, pg); if (t.get_type() == Thruster.ATM) { atmThs.Add(t); } else if (t.get_type() == Thruster.HY) { hyThs.Add(t); } else if (t.get_type() == Thruster.ION) { ionThs.Add(t); } else { } } forceMapDict.Clear(); _addOrDictList(atmThs); _addOrDictList(ionThs); _addOrDictList(hyThs); }
public void RegisterThruster(Thruster thruster) { foreach (var thrusterList in allThrusters) { if (thrusterList.Contains(thruster)) { Debug.LogError($"Already has thruster {thruster} in a list of thrusters when it gets registered!", thruster); return; } } switch (thruster.direction) { case Direction.N: upThrusters.Add(thruster); break; case Direction.S: downThrusters.Add(thruster); break; case Direction.E: rightThrusters.Add(thruster); break; case Direction.W: leftThrusters.Add(thruster); break; default: break; } }
protected virtual void OnSceneGUI() { Thruster t = target as Thruster; float size = HandleUtility.GetHandleSize(t.transform.position); Handles.ScaleValueHandle(1.0f, t.transform.position, Quaternion.AngleAxis(0.0f, t.thrustDir), size, Handles.ArrowHandleCap, 0.0f); }
private void ThrusterSelector_SelectedIndexChanged(object sender, EventArgs e) { bool enabled = false; object obj = ThrusterSelector.SelectedItem; if ((obj != null) && (obj is ThrusterWrapper wrapper)) { Thruster thruster = wrapper.Thruster; enabled = true; ThrusterMinPulse.ValueChanged -= ThrusterMinPulse_ValueChanged; ThrusterZeroPulse.ValueChanged -= ThrusterZeroPulse_ValueChanged; ThrusterMaxPulse.ValueChanged -= ThrusterMaxPulse_ValueChanged; { ThrusterMinPulse.Value = thruster.MinimumPulse; ThrusterZeroPulse.Value = thruster.ZeroPulse; ThrusterMaxPulse.Value = thruster.MaximumPulse; } ThrusterMinPulse.ValueChanged += ThrusterMinPulse_ValueChanged; ThrusterZeroPulse.ValueChanged += ThrusterZeroPulse_ValueChanged; ThrusterMaxPulse.ValueChanged += ThrusterMaxPulse_ValueChanged; settings.ThrusterRanges[wrapper.Name] = thruster.PulseRange; } EnableThrustBtn.Enabled = enabled; DisableThrustBtn.Enabled = enabled; StopThrustBtn.Enabled = enabled; ThrusterMinPulse.Enabled = enabled; ThrusterZeroPulse.Enabled = enabled; ThrusterMaxPulse.Enabled = enabled; }
public void LoadShip() { //Generate players ship GameObject hullObj = Instantiate(GameManager.current.allParts[MiscData.currentHull].gameObject, new Vector3(), Quaternion.identity); hull = hullObj.GetComponent <Hull>(); if (!hull) { Destroy(hullObj); } GameObject thrusterObj = Instantiate(GameManager.current.allParts[MiscData.currentThruster].gameObject, hull.thrusterLocation.position, hull.thrusterLocation.rotation); thruster = thrusterObj.GetComponent <Thruster>(); if (!thruster) { Destroy(thrusterObj); } weapons = new Weapon[hull.weaponPorts.Length]; for (int i = 0; i < MiscData.currentWeapons.Length; i += 1) { if (MiscData.currentWeapons[i] >= 0) { Weapon weapon = Instantiate(GameManager.current.allParts[MiscData.currentWeapons[i]].gameObject, hull.weaponPorts[i].position, hull.weaponPorts[i].rotation).GetComponent <Weapon>(); weapon.barrel = hull.weaponPorts[i]; weapons[i] = weapon; } } }
public override void OnInspectorGUI() { Thruster t = target as Thruster; serializedObject.Update(); EditorGUILayout.PropertyField(direction); EditorGUILayout.LabelField(t.transform.TransformDirection(t.thrustDir).ToString()); EditorGUILayout.PropertyField(speed); EditorGUILayout.PropertyField(affectedBody); EditorGUILayout.PropertyField(active); serializedObject.ApplyModifiedProperties(); Rect r = EditorGUILayout.BeginHorizontal("Button"); if (GUI.Button(r, GUIContent.none)) { t.active = true; } else { t.active = false; } GUILayout.Label("THRUST"); EditorGUILayout.EndHorizontal(); }
// Start is called before the first frame update void Start() { gameObject.layer = 8; // Ignore layer thruster = GetComponent <Thruster>(); thruster.SetThrustV(1f); // Go forward levelController = GameObject.Find("LevelControl").GetComponent <LevelController>(); }
public bool Release() { Thruster closestThruster = FindClosestThruster(); Debug.Log("Trying to load " + closestThruster); if (closestThruster != null && closestThruster.FuelInRange && !closestThruster.IsLoaded) { Debug.Log("Loading " + closestThruster); closestThruster.Load(); GameManager.instance.DestroyObject(this.GetComponent <ObjectController>()); GlobalSoundManager.instance.PlayClip(GlobalSounds.PlaceFuelTank, SourcePosition.Center, 1); foreach (Thruster t in _thrusters) { t.FuelHighlightEnabled = false; } return(true); } else { if (!closestThruster.IsLoaded) { Debug.Log("Thruster too far away!"); } else { Debug.Log("Thruster already loaded!"); } } return(false); }
public void DeregisterThruster(Thruster thruster) { upThrusters.Remove(thruster); downThrusters.Remove(thruster); leftThrusters.Remove(thruster); rightThrusters.Remove(thruster); }
void Update() { if (rotating && !dead) { if (PlayerHealth.dead) { return; } FireWait += Time.deltaTime; Quaternion q = Quaternion.LookRotation(Target.position - Barrel.transform.position); barrelRotationHor = q.eulerAngles.y; barrelRotationVert = q.eulerAngles.x; if (FireWait >= FireRate) { Vector3 rot = ProjectileSpawner.position - Barrel.position; GameObject ob = Instantiate(o, ProjectileSpawner.position, Quaternion.LookRotation(rot)); ob.layer = Constants.LAYER_PROJECTILE_ENEMY; Thruster t = ob.GetComponent <Thruster>(); t.target = Target; t.Eff = Instantiate(EffectPrefab, ProjectileSpawner.position, Quaternion.Euler(0, 15, 0) * Quaternion.LookRotation(rot)); t.damage = Damage; FireWait = 0; } } }
//todo -- we are using this information for anything yet //todo -- create a ThursterGlow component and use normal/radius from glows for effects private GameObject CreateThrusters() { if (!model.HasThrusters) { return(null); } GameObject retn = new GameObject("Thrusters"); List <Thruster> thrusters = model.thrusters; for (int i = 0; i < thrusters.Count; i++) { Thruster thruster = thrusters[i]; GameObject thrusterGo = new GameObject("Thruster " + i); thrusterGo.transform.parent = retn.transform; for (int j = 0; j < thruster.glows.Length; j++) { ThrusterGlow glow = thruster.glows[j]; GameObject glowGo = new GameObject("Thruster Glow " + j); glowGo.transform.parent = thrusterGo.transform; glowGo.transform.position = glow.position; glowGo.transform.rotation = Quaternion.LookRotation(glow.normal, Vector3.up); //glowGo.AddComponent<ThrusterGlowPulse>(); } } return(retn); }
public PlayerControlledState(IPlayerContext context, BasicInput input, Thruster thruster, Cannon cannon, Transform transform) : base(context) { Input = input; Thruster = thruster; Cannon = cannon; Transform = transform; }
private static void ParseCfg(GameObject go, string path) { string jsonString = File.ReadAllText(path + ".cfg"); JsonData data = JsonMapper.ToObject(jsonString); IDictionary tdictionary = data; if (tdictionary.Contains("Part")) { Part part = go.transform.parent.gameObject.AddComponent <Part>(); part.mass = floatParse(data["Part"]["Mass"]); go.transform.localPosition = VectorParse(data["Part"]["Position"]); go.transform.localRotation = Quaternion.Euler(VectorParse(data["Part"]["Rotation"])); go.transform.localScale = VectorParse(data["Part"]["Scale"]); } if (tdictionary.Contains("Thruster")) { Thruster thruster = go.transform.parent.gameObject.AddComponent <Thruster>(); thruster.enabled = false; thruster.ISP = floatParse(data["Thruster"]["ISP"]); thruster.Thrust = floatParse(data["Thruster"]["Thrust"]); GameObject flame = (GameObject)Object.Instantiate( Resources.Load("Flame"), VectorParse(data["Thruster"]["Flame"]["Position"]), Quaternion.identity, go.transform.parent ); flame.SetActive(false); go.transform.parent.gameObject.AddComponent <Staged>(); } if (tdictionary.Contains("ResourceContainer")) { ResourceContainer resourceContainer = go.transform.parent.gameObject.AddComponent <ResourceContainer>(); resourceContainer.DryMass = floatParse(data["Part"]["Mass"]); resourceContainer.LiquidFuel = floatParse(data["ResourceContainer"]["LiquidFuel"]); resourceContainer.Oxidizer = floatParse(data["ResourceContainer"]["Oxidizer"]); } if (tdictionary.Contains("Nodes")) { foreach (JsonData node in data["Nodes"]) { Object.Instantiate( Resources.Load("Snappoint"), VectorParse(node["Position"]), Quaternion.Euler(VectorParse(node["Rotation"])), go.transform.parent ); } } if (tdictionary.Contains("Decoupler")) { go.transform.parent.gameObject.AddComponent <Decoupler>(); go.transform.parent.gameObject.AddComponent <Staged>(); } }
private void SetThruster(Thruster active, Thruster inactive) { active.thruster.Play(true); inactive.thruster.Stop(true); active.trail.SetActive(true); inactive.trail.SetActive(false); }
protected virtual void OnSceneGUI() { i += 0.01f; Thruster t = target as Thruster; Handles.color = Color.Lerp(Color.magenta,Color.cyan,i); float size = HandleUtility.GetHandleSize(t.transform.position) * 5.0f; Handles.ScaleValueHandle(1.0f, t.transform.position, Quaternion.LookRotation(t.transform.TransformDirection(t.thrustDir), t.transform.up), size, Handles.ArrowHandleCap, 0.0f); }
public Corvette(MainHull hull, FtlDrive ftlDrive, CombatComputer combatComputer, Thruster thruster, Radar radar) { this.hull = hull; this.ftlDrive = ftlDrive; this.combatComputer = combatComputer; this.thruster = thruster; this.radar = radar; }
void Awake() { thr = GameObject.FindWithTag("Thruster"); ts = thr.GetComponent <Thruster>(); GameObject fg = GameObject.FindWithTag("MainCamera"); fadr = fg.GetComponent <TextFader>(); }
void Movement() { //Debug.Log(TheRigidbody.centerOfMass); CenterOfMassObj.transform.localPosition = TheRigidbody.centerOfMass; transform.position = new Vector3(transform.position.x, transform.position.y, 0); /*Determine which thrusters activate when executing a movement*/ for (int i = 0; i < ShipThrusters.Count; ++i) { Thruster aTruster = ShipThrusters[i].GetComponent <Thruster>(); aTruster.Activated = false; //Left turn if (Input.GetKey(KeyCode.A)) { if (ShipThrusters[i].transform.localPosition.y > TheRigidbody.centerOfMass.y && aTruster.IsLeft || ShipThrusters[i].transform.localPosition.y <TheRigidbody.centerOfMass.y && aTruster.IsRight || ShipThrusters[i].transform.localPosition.y> TheRigidbody.centerOfMass.y && ShipThrusters[i].transform.localPosition.x < TheRigidbody.centerOfMass.x && aTruster.IsDown || ShipThrusters[i].transform.localPosition.y <TheRigidbody.centerOfMass.y && ShipThrusters[i].transform.localPosition.x> TheRigidbody.centerOfMass.x && aTruster.IsUp) { aTruster.Activated = true; TheRigidbody.AddForceAtPosition(ShipThrusters[i].transform.right * aTruster.TrusterSpeed, ShipThrusters[i].transform.position); } } //Right turn if (Input.GetKey(KeyCode.D)) { if (ShipThrusters[i].transform.localPosition.y > TheRigidbody.centerOfMass.y && aTruster.IsRight || ShipThrusters[i].transform.localPosition.y <TheRigidbody.centerOfMass.y && aTruster.IsLeft || ShipThrusters[i].transform.localPosition.y> TheRigidbody.centerOfMass.y && ShipThrusters[i].transform.localPosition.x > TheRigidbody.centerOfMass.x && aTruster.IsDown || ShipThrusters[i].transform.localPosition.y < TheRigidbody.centerOfMass.y && ShipThrusters[i].transform.localPosition.x < TheRigidbody.centerOfMass.x && aTruster.IsUp) { aTruster.Activated = true; TheRigidbody.AddForceAtPosition(ShipThrusters[i].transform.right * aTruster.TrusterSpeed, ShipThrusters[i].transform.position); } } if (Input.GetKey(KeyCode.W)) { if (aTruster.IsUp) { aTruster.Activated = true; TheRigidbody.AddForceAtPosition(ShipThrusters[i].transform.right * aTruster.TrusterSpeed, ShipThrusters[i].transform.position); } } if (Input.GetKey(KeyCode.S)) { if (aTruster.IsDown) { aTruster.Activated = true; TheRigidbody.AddForceAtPosition(ShipThrusters[i].transform.right * aTruster.TrusterSpeed, ShipThrusters[i].transform.position); } } } }
void OnDrawGizmos() { Thruster t = this; Handles.color = Color.cyan; float size = HandleUtility.GetHandleSize(t.transform.position) * 5.0f; Handles.ScaleValueHandle(1.0f, t.transform.position, Quaternion.LookRotation(t.transform.TransformDirection(t.thrustDir), t.transform.up), size, Handles.ArrowHandleCap, 0.0f); }
public PlayerStateFactory(IPlayerContext context, BasicInput input, Thruster thruster, Cannon cannon, Transform transform, Rigidbody rigidbody) { _context = context; _input = input; _thruster = thruster; _cannon = cannon; _transform = transform; _rigidbody = rigidbody; }
public void testThrusterSetIDS() { Thruster thruster = new Thruster("2851612992", di); Assert.AreEqual("Deluxe Thruster", thruster.Name); thruster = thruster.setIDS("2314747200"); Assert.AreEqual("Heavy Thruster", thruster.Name); }
public Program() { StepScheduler = new Scheduler(this); MyThruster = new Thruster(this); IMyTextSurfaceProvider debugoutputblock = GridTerminalSystem.GetBlockWithName("LCD Panel debug") as IMyTextSurfaceProvider; debugoutput = debugoutputblock.GetSurface(0); }
void Awake() { if (instance == null) { instance = this; } _originalSize = transform.localScale; }
Vector2 sumOfForces() { Vector2 forceSum = new Vector2(0, 0); foreach (GameObject obj in circuitBoardScript.componentArray) { if (obj != null) { if (obj.name.Contains("thruster")) { Thruster circuitComponent = obj.GetComponent("Thruster") as Thruster; GameObject shipObj = componentArray[circuitComponent.index_Row, circuitComponent.index_Column]; if (circuitComponent._powerLevel > 0) { float thrusterAngle = shipObj.transform.localEulerAngles.z - shipAngle; while (thrusterAngle < 0) { thrusterAngle += 360; } while (thrusterAngle > 360) { thrusterAngle -= 360; } thrusterAngle = thrusterAngle * Mathf.Deg2Rad + Mathf.PI / 2; Vector2 forceVector = new Vector2(circuitComponent.speed * Mathf.Cos(thrusterAngle), circuitComponent.speed * Mathf.Sin(thrusterAngle)); forceSum.x += forceVector.x; forceSum.y += forceVector.y; //massTotal += shipComponent._mass; //weightedMass.x+=(obj.transform.position.x * shipComponent._mass); //weightedMass.y+=(obj.transform.position.y * shipComponent._mass); } } } } //Friction Vector2 frictionForce = new Vector2(-1 * coeffKineticFriction * shipVelocity.x, -1 * coeffKineticFriction * shipVelocity.y); forceSum.x += frictionForce.x; forceSum.y += frictionForce.y; forceSum.x /= totalMass; forceSum.y /= totalMass; //Debug.Log (forceSum); return(forceSum); }
void Awake() { mangr = transform.parent.gameObject.GetComponent <CheckpointManager>(); GameObject fg = GameObject.FindWithTag("MainCamera"); fadr = fg.GetComponent <TextFader>(); GameObject thrOb = GameObject.FindWithTag("Thruster"); thrst = thrOb.GetComponent <Thruster>(); }
public ThrusterControls(Thruster mainThruster, Thruster portForeThruster, Thruster portAftThruster, Thruster starboardForeThruster, Thruster starboardAftThruster, Thruster portRetroThruster, Thruster starboardRetroThruster) { this.mainThruster = mainThruster; this.portForeThruster = portForeThruster; this.portAftThruster = portAftThruster; this.starboardForeThruster = starboardForeThruster; this.starboardAftThruster = starboardAftThruster; this.portRetroThruster = portRetroThruster; this.starboardRetroThruster = starboardRetroThruster; }
private void StopThrustBtn_Click(object sender, EventArgs e) { object obj = ThrusterSelector.SelectedItem; if ((obj != null) && (obj is ThrusterWrapper wrapper)) { Thruster thruster = wrapper.Thruster; thruster.Stop(); } }
private void DisableThrustBtn_Click(object sender, EventArgs e) { object obj = ThrusterSelector.SelectedItem; if ((obj != null) && (obj is ThrusterWrapper wrapper)) { Thruster thruster = wrapper.Thruster; thruster.Enabled = false; } }
// Use this for initialization void Start() { shipbody = this.gameObject.GetComponent<Rigidbody>(); var thrusters = this.gameObject.GetComponentsInChildren<Thruster>(); foreach (var thruster in thrusters) { if (thruster.name == "EngineBurn") engineBurn = thruster; else if (thruster.name == "ForwardLeftThruster") forwardLeftThruster = thruster; else if (thruster.name == "ForwardRightThruster") forwardRightThruster = thruster; else if (thruster.name == "BackLeftThruster") backLeftThruster = thruster; else if (thruster.name == "BackRightThruster") backRightThruster = thruster; else if (thruster.name == "ReverseThruster") reverseThruster = thruster; thruster.SetFiring(false); } }
public void TurnOnThrusterGroup (Thruster[] whichGroup) { /*if(whichGroup == toStrafeLeft || whichGroup == toStrafeRight || whichGroup == toReverse) return;*/ if(whichGroup.Length == 0) return; for(int i = 0; i < whichGroup.Length; i++) { whichGroup[i].myRenderer.enabled = true; whichGroup[i].lastTurnedOnTime = Time.time; } }
private void Awake() { taskMove = GetComponent<TaskMove> (); particles = transform.FindChild ("Afterburner").gameObject; thruster = GetComponent<Thruster> (); }
private void Awake() { m_transform = transform; m_rigidbody2D = GetComponent<Rigidbody2D>(); m_thruster = GetComponent<Thruster>(); m_boxCollider2D = GetComponent<BoxCollider2D>(); m_rayShooter2D = new RayShooter2D(); m_startAltitude = Altitude(); m_shieldObj.SetActive(false); grader = GameObject.Find("Grading"); grade = grader.GetComponent<Grade>(); // Make sure that these are set to false thrusterFlame.SetActive(false); thrusterSmoke.SetActive(false); dieExplosion.SetActive(false); shieldShatterParticle.SetActive(false); // E-man - End // Set up raycast collision check Vector2 size = m_boxCollider2D.size; Vector3 scale = transform.localScale; float width = size.x * Mathf.Abs(scale.x) - (2.0f * m_skinWidth); m_verticalRayInterval = width / (m_totalVerticalRays - 1); audioSources = GetComponents<AudioSource>(); m_objectState = GetComponent<ObjectState>(); m_meshTransform = m_transform.FindChild("Ship"); StartPosition = transform.position; /* meshRenderer = GameObject.Find("default").GetComponent<MeshRenderer>(); if (meshRenderer) { Debug.Log("Yo dude meshrenderer has been created"); }*/ allAudioSources = FindObjectsOfType(typeof(AudioSource)) as AudioSource[]; isPaused = false; }