// Update is called once per frame void Update() { pos = transform.position.x; NumbericSpring.spring(ref pos, ref vel, oripos, dampening, freq, Time.deltaTime); transform.position = new Vector3(pos, transform.position.y, 0); if (Input.GetKeyDown(KeyCode.E)) { vel = 20; } }
public void Execute() { currtimer += Time.deltaTime; if (!isShooting && currtimer > delayBeforeShooting) { // starts shooting process //isShooting = true; moveTrolleytoFirePos(); } else if (isShooting && currtimer > shotDelay) { if (shotCount < 3) { // shoots a bullet owner.myTrolley.GetComponent <Trolleybehaviour>().ShootPri(); GameObject.Instantiate(owner.bullet4Prefab); // TODO :: add recoil spriVel = 20.0f; shotCount++; currtimer = 0; } else { moveTrolleytoDefultPos(); owner.mAnimator.SetBool("isManualShout", false); } } if (isShooting && shotCount < 3 && currtimer < 1.0f) { // update numeric spring Vector3 currpos = owner.myTrolley.transform.position; spriPos = currpos.x; NumbericSpring.spring(ref spriPos, ref spriVel, recoilTargetpos, 0.20f, 12, Time.deltaTime); owner.myTrolley.transform.position = new Vector3(spriPos, currpos.y, currpos.z); } // move closer to player moveTimer += Time.deltaTime; if (moveTimer > 1.2f && moving == false) { moving = true; float ypos = 0; for (var i = 0; i < playercollectionpos.Count; i++) { ypos += playercollectionpos[i]; } ypos /= playercollectionpos.Count; Vector3 p = camera.ViewportToWorldPoint(new Vector3(Random.Range(0.65f, 0.95f), 0, 0));// + new Vector3(0,ypos/2,0); newpos = new Vector3(p.x, ypos, 0); } if (moving) { owner.transform.position += (newpos - owner.transform.position) * Time.deltaTime; if (moveTimer > 2.2f) { moveTimer = 0.0f; moving = false; } } trackingTimer += Time.deltaTime; if (trackingTimer > 1.0f) { if (playercollectionpos.Count > 10) { playercollectionpos.RemoveAt(0); } playercollectionpos.Add(owner.player.transform.position.y); trackingTimer = 0; } phaseTimer += Time.deltaTime; if (owner.currentHealth < 0 || phaseTimer > 150.0f) { moveTrolleytoDefultPos(); if (!isShooting && currtimer == 0) { owner.mStateMachine.ChangeState((int)BoomerAunty.BOSSATTACKS.P1DASHFRONT); } } }