// Use this for initialization void Start() { scriptGameMaster = GameObject.Find("ControllerGame").GetComponent <ScriptGameMaster>(); layerMask = 1 << activeLayer; //lineRenderer = GetComponent<LineRenderer>(); if (Random.value >= 0.5) { oscillationMode = OscillationMode.Ascending; } else { oscillationMode = OscillationMode.Descending; } currentAngle = (int)Mathf.Floor(Random.value * (finishAngle - startAngle) - finishAngle); if (scriptCharacterSheet == scriptGameMaster.selectedSheet) { playerKeyCode = KeyCode.Q; } else if (scriptCharacterSheet == scriptGameMaster.opposingSheet) { playerKeyCode = KeyCode.P; } else { Debug.Log("Invalid Player"); } }
// Update is called once per frame void Update() { //if(oscillationIsEnabled) //{ if (shotFired) { cooldownTimer += Time.deltaTime; if (cooldownTimer >= cooldown) { shotFired = false; shotInputReady = true; lineRenderer.SetColors(Color.green, Color.green); } } if (scriptCharacterSheet.activeItem != null) { //Set currentAngle if (!oscillationIsPaused) { if (oscillationMode == OscillationMode.Ascending) { if (currentAngle <= finishAngle) { currentAngle += speedConstant; } else { oscillationMode = OscillationMode.Descending; currentAngle -= speedConstant; } } else if (oscillationMode == OscillationMode.Descending) { if (currentAngle >= startAngle) { currentAngle -= speedConstant; } else { oscillationMode = OscillationMode.Ascending; currentAngle += speedConstant; } } else { Debug.Log("Invalid oscillation mode"); } } else { //Oscillation paused, do not change angle } //Update ray currentRay = GetSelectionRay(currentAngle); //Debug.DrawRay(hotRay.origin, hotRay.direction // * scriptCharacterSheet.activeItem.itemStatProfile.maxRangeAspect // , Color.green); //Draw line lineRenderer.SetPosition(0, currentRay.origin); lineRenderer.SetPosition(1, currentRay.direction * scriptCharacterSheet.activeItem.itemStatProfile.maxRangeAspect + currentRay.origin); //Debug.Log (hotRay.origin.ToString () + "<>" + hotRay.direction.ToString()); } //Input if (Input.GetKeyDown(playerKeyCode)) { if (shotInputReady) { shotLoaded = true; } } if (Input.GetKey(playerKeyCode) && shotLoaded) { //shotInputReady = false; oscillationIsPaused = true; } else { oscillationIsPaused = false; } if (Input.GetKeyUp(playerKeyCode) && shotLoaded) { Debug.Log("Button release ray: " + currentRay.ToString()); //Fire shot RaycastHit hit; if (Physics.Raycast(currentRay, out hit, scriptCharacterSheet.activeItem.itemStatProfile.maxRangeAspect, layerMask)) { PlayerShotInfo playerShotInfo = new PlayerShotInfo(scriptCharacterSheet); playerShotInfo.shotLocation = hit.collider.gameObject; playerShotInfo.target = playerShotInfo.shotLocation.transform.parent.parent.GetComponent <CharacterSheet>(); playerShotInfo.shotRay = currentRay; scriptGameMaster.SendMessage("ExecuteAction", playerShotInfo); } else { PlayerShotInfo playerShotInfo = new PlayerShotInfo(scriptCharacterSheet); playerShotInfo.shotLocation = null; playerShotInfo.shotRay = currentRay; Debug.Log("shotray Assigned: " + playerShotInfo.shotRay.ToString()); scriptGameMaster.SendMessage("ExecuteAction", playerShotInfo); //Debug.Log ("Miss "); } //Set as not ready shotInputReady = false; shotLoaded = false; shotFired = true; lineRenderer.SetColors(Color.red, Color.red); cooldownTimer = 0; } //} }
public OscillationCurve(OscillationMode mode, int frequency, float strength) { Mode = mode; Frequency = frequency; Strength = strength; }