public void PhysicsRefresh(InputManager.InputPkg playerInput) { rb.AddRelativeForce((Vector2.up * playerInput.dirPressed) * moveSpeed); rb.AddTorque(-playerInput.dirPressed.x * turnSpeed * Time.deltaTime); ShipOutOfBorder(); }
public void Refresh(InputManager.InputPkg inputPck) { if (live > 0) { if (canShoot) { if (canFire) { if (inputPck.fire) { GameObject ball = GameObject.Instantiate(bullet, transform.position + transform.up * 1, Quaternion.identity, transform.parent); ball.transform.eulerAngles = transform.eulerAngles; canFire = false; } } else { if (counterBetweenFire <= 0) { canFire = true; counterBetweenFire = timeBetweenFire; } else { counterBetweenFire -= Time.deltaTime; } } } } else { PlayerManager.Instance.playerDeath(); } }
public void Refresh(InputManager.InputPkg inputPkg) { abilityManager.Refresh(inputPkg); stats.currentEnegy = Mathf.Clamp(stats.currentEnegy + stats.energyRegenPerSec * Time.deltaTime,0,stats.maxEnergy); if (stats.hp <= 0) ShipDestroyed(); //Debug.Log("Energy: " + stats.currentEnegy); }
public void PhysicsRefresh(InputManager.InputPkg inputPck) { transform.localEulerAngles += ((-Vector3.forward) * inputPck.dirPressed.x) * rotationSpeed * Time.fixedDeltaTime; rbPlayer.AddRelativeForce(Vector2.up * inputPck.dirPressed * speed); Vector2 velo = new Vector2(Mathf.Clamp(rbPlayer.velocity.x, -maxSpeed, maxSpeed), Mathf.Clamp(rbPlayer.velocity.y, -maxSpeed, maxSpeed)); rbPlayer.velocity = velo; }
public void PhysicsRefresh(InputManager.InputPkg inputPkg) { abilityManager.PhysicsRefresh(inputPkg); Throttle(inputPkg.throttleAmount); //increase or decrease speed based on holding down the throttle amount (-1 to 1) rb.AddForce(-Vector3.up * Mathf.Lerp(0, 9.81f, Mathf.Clamp01( 1 - ((stats.relativeLocalVelo .z)/stats.forwardSpeedAtWhichGravityIsCanceled)))); //add the force of custom gravity, relative to our speed (faster speed @ 50%, less gravity due to "air-lift") //This could be done way better, using dot product to determine the speed relative to my facing direction/perpendicular to the ground rb.angularVelocity = transform.TransformDirection( new Vector3(stats.pitchSpeed * inputPkg.dirPressed.y, 0, stats.rollSpeed * inputPkg.dirPressed.x)); }
//Update each ability whose ability type happens during an Fixed-update phase public void PhysicsRefresh(InputManager.InputPkg playerInputPkg) { for (int i = 0; i < abilities.Length; i++) { if (abilities[i] != null && abilities[i].stats.updateType == UpdateType.FixedUpdate) { UpdateAbility(abilities[i], playerInputPkg.abilityKeyPress[i]); } } }
//Update the right player public void Update() { if (players != null && players.Count > 0) { InputManager.InputPkg pkg = inputMan.GetInputs(); players[playerTurn - 1].UpdatePlayer(pkg); UIManager.Instance.Update(); moveCam.UpdateCamera(pkg); } }
public void UpdateCamera(InputManager.InputPkg pkg) { if (transform.rotation.eulerAngles.y == 180) { transform.position -= pkg.cameraDirectionPressed * speed; } else { transform.position += pkg.cameraDirectionPressed * speed; } }
private void Move() { Vector2 dir = new Vector2(0, 0); if (InputManager.GetKeysInput().W) { transform.localEulerAngles = new Vector3(0, 0, 0); dir += new Vector2(0, 1); isMoving = true; } if (InputManager.GetKeysInput().S) { transform.localEulerAngles = new Vector3(0, 0, 180); dir += new Vector2(0, -1); isMoving = true; } if (InputManager.GetKeysInput().A) { transform.localEulerAngles = new Vector3(0, 0, 90); dir += new Vector2(-1, 0); isMoving = true; } if (InputManager.GetKeysInput().D) { transform.localEulerAngles = new Vector3(0, 0, -90); dir += new Vector2(1, 0); isMoving = true; } if (isMoving && !soundStarted) { soundStarted = true; SoundManager.PlaySound(SoundManager.EnumSound.PlayerMove); } if (Input.GetKeyDown(KeyCode.O)) { GameObject go = GameObject.Instantiate(Resources.Load("Prefabs/Spark_Particle"), transform.position, Quaternion.identity) as GameObject; GameObject.Destroy(go, 10); } InputManager.InputPkg pkg = InputManager.GetKeysInput(); if (!pkg.A && !pkg.D && !pkg.S && !pkg.W) { isMoving = false; soundStarted = false; SoundManager.StopSound(); } rb.velocity = dir * speed; }
public void PlayerFixedUpdate(InputManager.InputPkg input, float dt) { if (input.jumpPressed && dashAvailable) { UseDash(); } //Debug.Log("dir: " + input.dirPressed); UpdateMovement(input.dirPressed); //Debug.Log(transform.GetComponent<Rigidbody2D>().velocity); base.UnitFixedUpdate(); }
public void Refresh(InputManager.InputPkg playerInput) { if (currentAmmo > 0) { if (amountBeforeCooldown > 0) { if (playerInput.shootPressed) { currentAmmo--; amountBeforeCooldown--; ShootBullet(); } } else { cooldownTime -= Time.deltaTime; if (cooldownTime <= 0) { amountBeforeCooldown = 10; cooldownTime = 2; } } } if (bulletList != null) { foreach (Rigidbody2D bullet in bulletList.ToArray()) { MoveBullet(bullet); BulletOutOfBorder(bullet, bulletList); } } List <Asteroid> asteroidList = AsteroidManager.Instance.asteroidList; List <Rigidbody2D> itemList = ItemManager.Instance.spawnedItems; foreach (Asteroid asteroid in asteroidList.ToArray()) { if (HitObject(rb, asteroid.GetRigidbody2D())) { OnAsteroidHit(asteroid); HitShip(asteroid.GetRigidbody2D()); } } foreach (Rigidbody2D item in itemList.ToArray()) { if (HitObject(rb, item)) { HitShip(item); } } }
//Update each ability whose ability type happens during an update phase public void Refresh(InputManager.InputPkg playerInputPkg) { for (int i = 0; i < abilities.Length; i++) { if (abilities[i] != null && abilities[i].stats.updateType == UpdateType.Update) { UpdateAbility(abilities[i], playerInputPkg.abilityKeyPress[i]); } } for (int i = 0; i < abilities.Length; i++) { if (abilities[i] != null && !abilities[i].stats.canUseAbility)//Time.time - abilities[i].stats.timeAbilityLastUsed <= abilities[i].stats.cooldown) { playerSounds.PlayShots(i); } } }
public void PlayerUpdate(InputManager.InputPkg input, float dt) { isHolding = input.leftMouseButtonHeld; if (input.interactPressed) { Interact(); } if (input.switchWeaponPressed) { SwitchWeapon(); } base.UnitUpdate(dt, input.aimingDirection); MovementAnimations(); }
public void Refresh(InputManager.InputPkg inputPkg) { //Player Rewinder ///////////////////////////////////////// //PlayerRecorder(3); ///////////////////////////////////////// if (!stats.engineStalled) { abilityManager.Refresh(inputPkg); } ModEnergy(stats.energyRegenPerSec * Time.deltaTime); //stats.currentEnegy = Mathf.Clamp(stats.currentEnegy + stats.energyRegenPerSec * Time.deltaTime,0,stats.maxEnergy); if (stats.hp <= 0) { ShipDestroyed(); } //Debug.Log("Energy: " + stats.currentEnegy); }
public void PhysicsRefresh(InputManager.InputPkg inputPkg) { if (!stats.engineStalled) { abilityManager.PhysicsRefresh(inputPkg); Throttle(inputPkg.throttleAmount); //increase or decrease speed based on holding down the throttle amount (-1 to 1) rb.angularVelocity = transform.TransformDirection(new Vector3(stats.pitchSpeed * inputPkg.dirPressed.y, stats.yawSpeed * inputPkg.yawPressed, stats.rollSpeed * inputPkg.dirPressed.x)); //Rotate velocity towards aim? //Vector3 relativeVelocity = rb.velocity; rb.velocity = Vector3.RotateTowards(rb.velocity, transform.forward, 5, 0); // rb.velocity = transform.TransformDirection(relativeLocalVelocity); } else { transform.localEulerAngles = Vector3.RotateTowards(transform.localEulerAngles, new Vector3(90, 0, transform.localEulerAngles.z), .4f * Time.fixedDeltaTime, 0); rb.angularVelocity += transform.TransformDirection(new Vector3(0, 0, .2f) * Time.fixedDeltaTime); rb.velocity = Vector3.RotateTowards(rb.velocity, transform.forward, 5, 0); } }
public void Refresh(InputManager.InputPkg inputPkg) { if (!stats.engineStalled) { abilityManager.Refresh(inputPkg); } ModEnergy(stats.energyRegenPerSec * Time.deltaTime); //stats.currentEnegy = Mathf.Clamp(stats.currentEnegy + stats.energyRegenPerSec * Time.deltaTime,0,stats.maxEnergy); if (stats.hp <= 0) { ShipDestroyed(); } //Debug.Log("Energy: " + stats.currentEnegy); if (stats.hp < 50 && activateSmoke) { activateSmoke = false; GameObject smokeGO = Instantiate(Smoke, transform.position, Quaternion.identity); smokeGO.transform.SetParent(this.transform); } }
void UpdatePhase3(InputManager.InputPkg pkg) { co.CmdCheckTerritory(id); NextPhase(); }
public void UpdatePlayer(InputManager.InputPkg pkg) { //If the player is initialize if (initialize == true) { //If the player is local if (!isLocalPlayer) { return; } //get the package from the inputManager if (pkg.objectSelected != null) { co.CmdDebug(id, name); if (currentMode == CurrentMode.STANDBY && Movements.CanSelectUnit(pkg.objectSelected, phase)) { } else if (currentMode == CurrentMode.CREATE) { if (pkg.objectSelected.tag == "IntersectionCollider") { co.CmdspawnUnit(pkg.objectSelected.GetComponentInParent <Intersection>().arrayPos, id, UnitType.Bit); GridManager.Instance.DeactivateLight(Movements.posActiver); currentMode = CurrentMode.STANDBY; NextPhase(); } } else if (currentMode == CurrentMode.MOVE) { if (pkg.objectSelected.tag == "IntersectionCollider") { Vector2 pos = Movements.LastObjetSelectionne.GetComponent <BasePawnsClass>().positionInGridArray; Vector2 des = pkg.objectSelected.transform.parent.gameObject.GetComponent <Intersection>().arrayPos; co.CmdMoveUnit(id, pos, des); GridManager.Instance.DeactivateLight(Movements.posActiver); currentMode = CurrentMode.STANDBY; NextPhase(); } } } //Update each phase if (phase == KERNELPHASE) { } else if (phase == MOVEPHASE) { } else if (phase == TERRITORYPHASE) { UpdatePhase3(pkg); } } }
public void PlayerFixedUpdate(InputManager.InputPkg input, float dt) { }
public void UpdatePlayer(float dt) { InputManager.InputPkg inputPkg = inputManager.GetKeysPressed(); MovePlayer(inputPkg.directionPressed, dt); }