void Start() { parabolaController = GetComponent <ParabolaController>(); rb2D = GetComponent <Rigidbody2D>(); turningMask = 1 << 8; // only includes colliders in the 8th layer mask (Turning Point) currentSpeed = maxSpeed; }
public ParabolaFly(Transform ParabolaRoot, ParabolaController parent) { this.parent = parent; List <Component> components = new List <Component>(ParabolaRoot.GetComponentsInChildren(typeof(Transform))); List <Transform> transforms = components.ConvertAll(c => (Transform)c); transforms.Remove(ParabolaRoot.transform); transforms.Sort(delegate(Transform a, Transform b) { return(a.name.CompareTo(b.name)); }); Points = transforms.ToArray(); //check if odd if ((Points.Length - 1) % 2 != 0) { throw new UnityException("ParabolaRoot needs odd number of points"); } //check if larger is needed if (parabolas == null || parabolas.Length < (Points.Length - 1) / 2) { parabolas = new Parabola3D[(Points.Length - 1) / 2]; partDuration = new float[parabolas.Length]; } }
// Start is called before the first frame update void Start() { timerMovePlatform = 1.0f; timerCountMovePlatform = 0.0f; haveToLaunch = false; _pb = parabola.GetComponent <ParabolaController>(); }
private new void Start() { base.Start(); startPos = transform.position; controller = GetComponent <ParabolaController>(); particle = effect.GetComponent <ParticleSystem>(); renderers = GetComponentsInChildren <Renderer>(); }
// Start is called before the first frame update void Start() { controller = GetComponent <CharacterController>(); parabolaController = GetComponent <ParabolaController>(); startPos = transform.position; parabolaController.Speed *= playerSpeed; transform.position = startPos; }
private float startLife; // Used in calculations for aiming the bomb in mid air (for particles) void Start() { paraC = GetComponent <ParabolaController> (); ringParts = ringParticle.GetComponent <ParticleSystem> (); towerParts = towerParticle.GetComponent <ParticleSystem> (); adjustStats(); startLife = Time.timeSinceLevelLoad; }
// Start is called before the first frame update void Start() { audioManager = AudioManager.instance; slimeAnim = GetComponent <Animator>(); renderer = GetComponent <SpriteRenderer>(); coll = GetComponent <BoxCollider2D>(); slimeRB = GetComponent <Rigidbody2D>(); trapParabola = GetComponent <ParabolaController>(); }
void Fire(float power) { Debug.Log("This much power: " + power); ThrowScythe(); ParabolaController controller = scythe.GetComponent <ParabolaController>(); controller.RefreshTransforms(1); controller.FollowParabola(); canThrow = false; }
public void Start() { _rb = GetComponent <Rigidbody>(); _target = GameObject.Find("JumpTarget").gameObject; _trb = _target.GetComponent <Rigidbody>(); _target.SetActive(false); _shockwave = transform.Find("Shockwave").gameObject; _sRenderer = _shockwave.GetComponent <MeshRenderer>(); _shockwave.SetActive(false); pController = GetComponent <ParabolaController>(); Transform _jumpParabola = GameObject.Find("JumpParabola").transform; _pStart = _jumpParabola.GetChild(2); _pMid = _jumpParabola.GetChild(1); _pEnd = _jumpParabola.GetChild(0); _collider = GetComponent <BoxCollider>(); }
private void FixedUpdate() { Move(player.stats.moveSpeed * 1f); Vector3 pos; if (((startTravelTime + travelTime) <= Time.time) && switchSides) //check to see if the side switching has ended { switchSides = false; } if (leftSide != (transform.position.z >= transform.position.x)) //if this is true a side has been switched { leftSide = !leftSide; switchSides = true; startTravelTime = Time.time; latestPosition = GhostBody.transform.position; } ParabolaController Ghost = leftSide ? GhostParabola1 : GhostParabola2; Vector3 offset = leftSide ? GameManager.instance.GhostOffset : -GameManager.instance.GhostOffset; Quaternion rotation = (transform.position.z >= transform.position.x) ? Quaternion.Euler(0f, 135, 0f) : Quaternion.Euler(0f, 315f, 0f); Vector3 currentPosition = Ghost.UpdatePosition((transform.position.z + transform.position.x) / 2) + offset; pos = currentPosition; if (!switchSides) //this is the default case, business as usual no switching { pos = currentPosition; GhostBody.transform.rotation = rotation; latestPosition = GhostBody.transform.position; } else //if sides have switches then continue the lerp { float lerpPosition = (Time.time - startTravelTime) / travelTime; //how far along the lerp should it be //pos = Vector3.Lerp(latestPosition, currentPosition, lerpPosition); //pos = Vector3.SmoothDamp(latestPosition, currentPosition, ref smoothVel, 10f); } if (pos != Vector3.zero) { targetPosition = pos; } //GhostBody.transform.position = pos; }
private float lastGroundDistance = 4f; //the previously height of the crosshair // public GameObject ShootPoint; private void Start() { smoothVel = Vector3.zero; //stuff for movement forward = Camera.main.transform.forward; forward.Scale(new Vector3(1, 0, 1)); forward.Normalize(); right = Camera.main.transform.right; right.Scale(new Vector3(1, 0, 1)); right.Normalize(); Target.color = playerColor; AOE.GetComponent <Renderer>().material.SetColor("Color_52FADAA", playerColor * 2f); lr = GetComponent <LineRenderer>(); lr.positionCount = 1; lr.SetPosition(0, transform.position); Renderer rend = GetComponent <Renderer>(); lr.startColor = playerColor; lr.endColor = playerColor; leftSide = transform.position.z >= transform.position.x; //true for left, false for right (could work for up & down as well) Quaternion rotation = (transform.position.z >= transform.position.x) ? Quaternion.Euler(0f, 135, 0f) : Quaternion.Euler(0f, 315f, 0f); GhostBodyInstantiate(); transform.position = new Vector3(transform.position.x, 10f, transform.position.z); GameObject Curves = GameObject.Find("GhostCurves"); GhostParabola1 = Curves.transform.Find("Curve 1").gameObject.GetComponent <ParabolaController>(); GhostParabola2 = Curves.transform.Find("Curve 2").gameObject.GetComponent <ParabolaController>(); input.controllers[player.inputControllerNumber].attack.OnDown.AddListener(Activate); StartCoroutine("SpawnCursor"); startTravelTime = Time.time; //this is included so when the ghost spawns, it spawns where thep player died and then floats to its proper spot real quick latestPosition = GhostBody.transform.position; travelTime = travelTime * 2f; }
private void Initialize() { enemyHM = GetComponent <EnemyHealthManager>(); enemyRend = GetComponent <SpriteRenderer>(); enemyAnim = GetComponent <Animator>(); enemyRB = GetComponent <Rigidbody2D>(); parabolaController = GetComponent <ParabolaController>(); thePlayer = FindObjectOfType <Player>(); groundPosition = transform.position; if (thePlayer != null) { theTarget = thePlayer.transform.position; } defaultColor = enemyRend.color; timerToTransition = minTime; audioManager = AudioManager.instance; if (audioManager == null) { Debug.LogError("No Audio Manager in Scene"); } }
// Update is called once per frame void Update() { if (_GAME.playerActive == false) { return; } if (!isThrown) { scythe.transform.position = target.position; } if (_GAME.Energy >= _GAME.throwEngery) { canThrow = true; } if (Input.GetMouseButton(0) && _GAME.scytheEquiped && !_GAME.onCD) { ParabolaController controller = scythe.GetComponent <ParabolaController>(); controller.parabolaScale = 1 + normalThrowTimer * 7f; normalThrowTimer += Time.deltaTime; normalThrowTimer = Mathf.Clamp(normalThrowTimer, min, max); //if (chargeValue < max) { /* * chargeValue += chargeSpeed * Time.deltaTime; * if (chargeValue > max) * { * chargeValue = max; * } */ float percentage = normalThrowTimer / max; chargeBar.alphaCutoff = 1 - percentage; Debug.Log(percentage); } } if (Input.GetMouseButtonUp(0) && canThrow && _GAME.scytheEquiped && !_GAME.onCD) { if (transform.position.x < Camera.main.ScreenToWorldPoint(Input.mousePosition).x) { throwLeft = true; } else { throwLeft = false; } canThrow = false; //if (normalThrowTimer < normalThrowThreshold) //{ // ThrowScythe(); // ParabolaController controller = scythe.GetComponent<ParabolaController>(); // controller.FollowParabola(); // Debug.Log(normalThrowTimer); //} //if (normalThrowTimer > 0.2f) //{ // Fire(normalThrowTimer * throwPower); //} ThrowScythe(); Fire(normalThrowTimer * throwPower); normalThrowTimer = min; _GAME.Energy -= _GAME.throwEngery; } if (Input.GetKeyDown(KeyCode.E)) { ReturnScythe(); } // If the scythe is returning if (isReturning) { Debug.Log("Is Returning"); // Returning calcs if (time < 1.0f) { // Update its position by using the Bezier formula based on the current time scythe.position = getBQCPoint(time, old_pos, curve_point.position, target.position); // Reset its rotation (from current to the targets rotation) with 50 units/s scythe.rotation = Quaternion.Slerp(scythe.transform.rotation, target.rotation, 50 * Time.deltaTime); // Increase our timer, if you want the scythe to return faster, then increase "time" more // With something like: // time += Timde.deltaTime * 2; // It will return as twice as fast time += Time.deltaTime; } else { // Otherwise, if it is 1 or more, we reached the target so reset ResetScythe(); } } if (Vector3.Distance(scythe.velocity, Vector3.zero) < 0.5f && !isReturning) { //if coming to a stop do this scythe.velocity = Vector3.zero; scythe.angularVelocity = Vector3.zero; StartCoroutine(ResetRotation()); } }
// Use this for initialization void Start() { msEvent.isFly = true; pc = GetComponent <ParabolaController>(); }
void Start() { mRigidbody = gameObject.GetComponent <Rigidbody> (); mParabolaController = GetComponent <ParabolaController> (); legScript = GetComponent <LegActionScript>(); }
// Start is called before the first frame update void Start() { pc = GetComponent <ParabolaController>(); Fired(); }
public void Pattern() { ParabolaController.Parabola(projectile.transform.position, destination, parabolaHeight, projectile.lifeTime); }
private void Awake() { level = 1; base.Initialize(NPCType.DRAGON); agent = GetComponent <NavMeshAgent>(); agent.Warp(transform.position); anim = GetComponentInChildren <DragonAnimController>(); parabolaController = GetComponent <ParabolaController>(); state = State.PATROL; SwitchState(state); inverseKinematics.Add(DragonNPCAbility.BITE, new InverseKinematics() { speed = 3f, endTime = 0.8f, returning = false, originalPosition = biteTarget.transform.localPosition, target = biteTarget, npc = this }); Ability fire = new Ability(this, DragonNPCAbility.FIRE) { endTime = fireEndTime, multiplier = 0 }; fire.fxs.Add(new FX() { name = "FireFX", start = 2.5f, end = 6 }); abilities.Add(DragonNPCAbility.FIRE, fire); Ability stomp = new Ability(this, DragonNPCAbility.STOMP) { endTime = stompEndTime, multiplier = 0 }; stomp.fxs.Add(new FX() { name = "StompFX", start = 1.5f, end = anim.stompFX.main.duration }); abilities.Add(DragonNPCAbility.STOMP, stomp); Ability flyFire = new Ability(this, DragonNPCAbility.FLY_FIRE) { endTime = flyFireEndTime, multiplier = 0 }; flyFire.fxs.Add(new FX() { name = "FireFX", start = 3f, end = 6f }); abilities.Add(DragonNPCAbility.FLY_FIRE, flyFire); abilities.Add(DragonNPCAbility.TAIL_ATTACK, new Ability(this, DragonNPCAbility.TAIL_ATTACK) { endTime = tailAttackEndTime, multiplier = 1.2f }); abilities.Add(DragonNPCAbility.JUMP, new Ability(this, DragonNPCAbility.JUMP) { endTime = jumpEndTime, multiplier = 0 }); abilities.Add(DragonNPCAbility.BITE, new Ability(this, DragonNPCAbility.BITE) { multiplier = 1.5f, useUpdate = false }); disableMultipleCollisition.Add(DragonNPCAbility.TAIL_ATTACK, new List <PlayerCharacter>()); biteCollider.enabled = false; EnableDisableTailColliders(false); }
/** * Update is called once per frame. */ void Update() { OVRInput.Update(); // Display the number of cycles left in the therapy. ScoreText.GetComponent <Text>().text = "Cycles Left: " + (numOfCycles - cycleCounter).ToString(); // Set game over to true once the therapy rounds are completed. if (cycleCounter == numOfCycles) { gameOver = true; } if (!gameOver) { leader.SetActive(false); // If there are stones left, bring towards the player on inhale. if (canSummon && Input.GetKey(KeyCode.Space) || OVRInput.Get(OVRInput.RawButton.RIndexTrigger) || flag == 1) { if (count == stones.Count) { Debug.Log("No more stones left"); } else { cont = stones[count].GetComponent <ParabolaController>(); isMovingTowardsPlayer = true; //vfx[count].transform.GetChild(0).gameObject.SetActive(false); if (stoneHandUpdate) { CanvasText.GetComponent <Text>().text = "Inhale Target Time: " + inhaleTime.ToString(); coroutineInhale = StartCoroutine(countDownInhale(inhaleTime)); stoneHandDistance = Vector3.Distance(stones[count].transform.position, transform.position); stoneHandDistance -= 0.4f; stoneHandUpdate = false; } if (Vector3.Distance(stones[count].transform.position, transform.position) > 0.45f) { stones[count].transform.position = Vector3.MoveTowards(stones[count].transform.position, transform.position + transform.forward * 0.4f - transform.up * 0.1f, Time.deltaTime * (stoneHandDistance / inhaleTime)); } } } // called if player stops inhaling before stone reaches the player //else if (move && flag!=1 && Vector3.Distance(stones[count].transform.position, transform.position) > 0.2f) else if (isMovingTowardsPlayer && !Input.GetKey(KeyCode.Space) && Vector3.Distance(stones[count].transform.position, transform.position) > 0.45f) { stones[count].GetComponent <Rigidbody>().useGravity = true; StopCoroutine(coroutineInhale); //vfx[count].SetActive(false); count++; isMovingTowardsPlayer = false; stoneHandUpdate = true; cycleCounter++; } // for the stone to always be in front of the camera if (Vector3.Distance(stones[count].transform.position, this.transform.position) <= 0.45f) { stones[count].transform.position = transform.position + transform.forward * 0.4f - transform.up * 0.1f; //stones[count].transform.rotation = new Quaternion(0.0f, transform.rotation.y, 0.0f, transform.rotation.w); } // When stone has arrived if ((Input.GetKey(KeyCode.D) || OVRInput.Get(OVRInput.RawButton.A) || flag == 3) && Vector3.Distance(stones[count].transform.position, this.transform.position) <= 0.45f && fruitCount < fru.Count && s.stay) { vfx[count].SetActive(true); //vfx[count].transform.GetChild(0).gameObject.SetActive(true); isMovingTowardsPlayer = false; canShoot = true; canSummon = false; GameObject.Find("Trails").GetComponent <ParticleSystem>().Play(); GameObject point1 = new GameObject(); GameObject point2 = new GameObject(); GameObject point3 = new GameObject(); GameObject root = new GameObject(); point1.name = "child1"; point2.name = "child2"; point3.name = "child3"; root.name = "parent"; point1.transform.parent = root.transform; point2.transform.parent = root.transform; point3.transform.parent = root.transform; point1.transform.position = stones[count].transform.position; point3.transform.position = s.go.transform.position; point2.transform.position = new Vector3((point1.transform.position.x + point3.transform.position.x) / 2, point3.transform.position.y + 0.3f, (point1.transform.position.z + point3.transform.position.z) / 2); if (!cont.enabled) { cont.enabled = true; } if (stoneFruitUpdate) { CanvasText.GetComponent <Text>().text = "Exhale Target Time: " + exhaleTime.ToString(); coroutineExhale = StartCoroutine(countDownExhale(exhaleTime)); stoneFruitDistance = Vector3.Distance(stones[count].transform.position, s.go.transform.position); stoneFruitDistance -= 1f; cont.Speed = stoneFruitDistance / exhaleTime; stoneFruitUpdate = false; } cont.ParabolaRoot = root; cont.Autostart = true; cont.Animation = true; cont.Speed = stoneFruitDistance / exhaleTime; } // when player stops exhaling before stone hits the fruit //else if (canShoot && flag!=3 && Vector3.Distance(stones[count].transform.position, transform.position) >= 1f) // For keyboard playability, uncomment else if below and comment out the else if on line 221. //else if (canShoot && !Input.GetKey(KeyCode.D) && Vector3.Distance(stones[count].transform.position, transform.position) >= 1f) else if (canShoot && flag != 3 && Vector3.Distance(stones[count].transform.position, transform.position) >= 1f) { stones[count].GetComponent <Rigidbody>().useGravity = true; vfx[count].SetActive(false); count++; StopCoroutine(coroutineExhale); cont.enabled = false; canSummon = true; canShoot = false; stoneHandUpdate = true; stoneFruitUpdate = true; cycleCounter++; } //When stone has hit the fruit if (s.go && count < stones.Count && stones[count] && Vector3.Distance(stones[count].transform.position, s.go.transform.position) < 1f && fruitCount < fru.Count) { var particleEffect = stones[count].transform.GetChild(0); stones[count].transform.GetChild(0).transform.parent = null; stones[count].GetComponent <Rigidbody>().useGravity = true; playPluck = true; CanvasText.GetComponent <Text>().text = "Inhale Target Time: " + inhaleTime.ToString(); Destroy(stones[count]); //toDestory.Add(vfx[count]); for (int i = 0; i < 3; i++) { GameObject.Find("stoneVFX").transform.GetChild(i).gameObject.GetComponent <ParticleSystem>().Stop(); } StartCoroutine(destory(vfx[count])); count++; s.go.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.None; s.go.GetComponent <Rigidbody>().isKinematic = false; s.go.GetComponent <Rigidbody>().constraints = RigidbodyConstraints.FreezeRotationY | RigidbodyConstraints.FreezeRotationX | RigidbodyConstraints.FreezeRotationZ; s.go.GetComponent <Rigidbody>().useGravity = true; ParticleSystem points = s.go.transform.GetChild(1).gameObject.GetComponent <ParticleSystem>(); points.Play(); score += 5; fruitCount++; canShoot = false; canSummon = true; stoneHandUpdate = true; stoneFruitUpdate = true; cycleCounter++; } } else { ScoreText.GetComponent <Text>().text = ""; CanvasText.GetComponent <Text>().text = ""; FinalScoreText.GetComponent <Text>().text = "Final Score: " + score + "/" + (numOfCycles * 5); leader.SetActive(true); if (fwLeaderBoard.publicCode == "") { Debug.LogError("You forgot to set the publicCode variable"); } if (fwLeaderBoard.privateCode == "") { Debug.LogError("You forgot to set the privateCode variable"); } fwLeaderBoard.AddScore(userName, (int)(100 * score / (numOfCycles * 5))); //fwLeaderBoard.GetScores(); List <dreamloLeaderBoard.Score> scoreList = fwLeaderBoard.ToListHighToLow(); if (scoreList == null) { Debug.Log("(loading...)"); } else { int maxToDisplay = 6; int countScr = 0; foreach (dreamloLeaderBoard.Score currentScore in scoreList) { countScr++; //Debug.Log(currentScore.score.ToString()); topRankList.text += countScr + "\n"; topScoreList.text += currentScore.score.ToString() + "%\n"; topNameList.text += currentScore.playerName.Replace("+", " ") + "\n"; if (countScr >= maxToDisplay) { break; } } } } }