private void DoTriggerPressed(object sender, ControllerInteractionEventArgs e) { DebugLogger(e.controllerIndex, "TRIGGER", "pressed", e); ; if (false)//leftController == null) { PorkChopPlot.triggerPork = true; double time = 30d; var thisodata = UXStateManager.GetSource().GetComponent <OrbitData>(); Vector3d r1 = thisodata.getR(); var oe2 = UXStateManager.GetTarget().GetComponent <OrbitData>().GetOE(); var tra2 = OrbitalTools.Program.anomalyAfterTime(OrbitData.parentGM, oe2, time); oe2.tra = tra2; Vector3d r2 = OrbitalTools.Util.oe2rd(OrbitData.parentGM, oe2); Vector3d initVel, finalVel; LambertSolver.Solve(r1, r2, time, OrbitData.parentGM, true, out initVel, out finalVel); thisodata.rv[3] = initVel.x; thisodata.rv[4] = initVel.y; thisodata.rv[5] = initVel.z; } }
public GameObject FireMissile() { Debug.Log("Fire missile"); var newMissile = Instantiate(_missile); //set rot and pos to gun newMissile.SetActive(true); newMissile.transform.position = _gun.transform.position; newMissile.transform.rotation = _gun.transform.rotation; //give speed var upGain = Random.Range(-1.0f, 1f); var rightGain = Random.Range(-1f, 1f); var forwardGain = Random.Range(1f, 3f); var velocity = _gun.transform.forward * forwardGain + _gun.transform.up * upGain + _gun.transform.right * rightGain; newMissile.GetComponent <Rigidbody>().velocity = velocity.normalized * 3; //sound! //set die time var missileLogic = newMissile.GetComponent <MissileLogic>(); missileLogic.BornTime = Time.time; missileLogic.DieAfterTime = 30; missileLogic.enabled = true; missileLogic.target = UXStateManager.GetTarget(); CameraFollow(newMissile); return(newMissile); }
bool GetOEs() //returns true valid src/tgt { var src = UXStateManager.GetSource(); var tgt = UXStateManager.GetTarget(); if (src == null || tgt == null) { Debug.Log("Something's not right, can't run prokchop: src: " + src + " tgt: " + tgt); return(false); } oe1 = src.GetComponent <OrbitData>().GetOE(); oe2 = tgt.GetComponent <OrbitData>().GetOE(); return(true); }
void UnselectedState() { if (target == UXStateManager.GetTarget()) { NextState = SelectedState; selectedIconSR.enabled = true; Debug.Log("state: selected"); } else { //steady state for unselected lockedIconSR.enabled = false; selectedIconSR.enabled = false; } }
void TargetLockFSM() { if (NextState == EndState) { return; } if (target == null) { NextState = GoneState; } else if (target != UXStateManager.GetTarget()) { NextState = UnselectedState; } NextState(); }
public void prepFindIntercept() { var src = UXStateManager.GetSource(); var tgt = UXStateManager.GetTarget(); if (src == null || tgt == null) { Debug.Log("src and tgt must be set!"); return; } //show markers on closest approach var od1 = src.GetComponent <OrbitData>(); var oe1 = Util.rv2oe(OrbitData.parentGM, od1.rv); var od2 = tgt.GetComponent <OrbitData>(); var oe2 = Util.rv2oe(OrbitData.parentGM, od2.rv); findInterceptPoints(oe1, oe2); }
public void TriggerIntercept() { if (mStartTime + mComputeTime <= eventManager.GetSimTime()) { Debug.Log("Error: Intercept injection in the past"); return; } Debug.Log("Trigger intercept event"); var src = UXStateManager.GetSource(); var tgt = UXStateManager.GetTarget(); Debug.Log("InjVec: " + mInjectionVector.ToString()); var e = new ManeuverEvent(src, tgt, (float)(mStartTime + mComputeTime), (float)mTravelTime, "intercepts", mInjectionVector); //Events.instance.Queue(e); //deprecated, should be made illegal eventManager.Queue(e); }
void InitialState() //assumes prev target was destroyed and is coming from EndState { //squareIconSR.enabled = true; this is determined by squareIcon function sphericalIconSR.enabled = true; sphericalIconBaseSR.enabled = true; sphericalIconLR.enabled = true; var isSelected = (target == UXStateManager.GetTarget()); if (isSelected) { NextState = SelectedState; } else { NextState = UnselectedState; } selectedIconSR.enabled = isSelected; lockedIconSR.enabled = isSelected; }
public void SelectNextTarget() { //sort targets by distance //get currently selected target var target = UXStateManager.GetTarget(); GameObject nextTarget = target; if (target != null) { nextTarget = FindClosestTarget(target, target.transform.position.magnitude); } if (target == null || target == nextTarget) { //pick closest target var unit = FindClosestTarget(); UXStateManager.SelectTarget(unit); } else { //pick next closest target UXStateManager.SelectTarget(nextTarget); } }