private void FillDataTransferEquipment() { foreach (Equipment equipment in equipmentManager.GetCurrentEquipment()) { dataTransferManager.AddEquipmentItem(equipment); } }
private void Update() { //if (Time.timeScale > 0f) { if (!animator.GetBool("isAttacking") && !animator.GetBool("isPushing") && !animator.GetBool("isThrowing")) // && !isDashing) { walkInput = new Vector2(Input.GetAxisRaw(walkHorizontalInput + inputExtensionString), Input.GetAxisRaw(walkVerticalInput + inputExtensionString)); /* * if (GameManager.singleGame) * { * if(walkInput.x == 0f) * walkInput.x = Input.GetAxisRaw(walkHorizontalInput + "2"); * if(walkInput.y == 0f) * walkInput.y = Input.GetAxisRaw(walkVerticalInput + "2"); * } */ if (walkInput.x != 0 && walkInput.y != 0) { walkInput /= 1.5f; } if (walkInput != Vector2.zero) { if (!isDashing) { speed = walkSpeed * (1 + (4 * timeSlowMoEffectValue)); } animator.SetBool("isWalking", true); if (walkInput.y < 0) { animator.SetInteger("direction", 2); if (prevWalkState == 0) { comboKeys += "D"; } } else if (walkInput.y > 0) { animator.SetInteger("direction", 0); if (prevWalkState == 0) { comboKeys += "U"; } } else if (walkInput.x > 0) { animator.SetInteger("direction", 1); if (prevWalkState == 0) { comboKeys += "R"; } } else if (walkInput.x < 0) { animator.SetInteger("direction", 3); if (prevWalkState == 0) { comboKeys += "L"; } } if (walkInput.x > 0) { sprRenderer.flipX = true; } else { sprRenderer.flipX = false; } } else { speed = 0f; animator.SetBool("isWalking", false); } } //Potion if (Input.GetButtonDown(attackInput + inputExtensionString)) { potionTimer = potionAttackButtonPressMinTime; } if (Input.GetButtonUp(attackInput + inputExtensionString)) { potionTimer = -1000f; } if (potionTimer <= 0 && potionTimer > -900f) { EquipmentManager eqMan = GetComponent <EquipmentManager>(); if (eqMan != null && eqMan.GetCurrentEquipment() != null && eqMan.GetCurrentEquipment().Length > 1 && eqMan.GetCurrentEquipment()[1] != null) { eqMan.UsePotion(GetComponent <EquipmentManager>().GetCurrentEquipment()[1]); if (playerNo == 1) { Subtitles.AddPlayer1Subtitle("Potion Used"); } else if (playerNo == 2) { Subtitles.AddPlayer2Subtitle("Potion Used"); } } else { if (playerNo == 1) { Subtitles.AddPlayer1Subtitle("Potion not equipped"); } else if (playerNo == 2) { Subtitles.AddPlayer2Subtitle("Potion not equipped"); } } potionTimer = -1000f; potionUsed = true; } else if (potionTimer > 0f && potionTimer > -900f) { potionTimer -= Time.deltaTime; } //Attack if (actionPoints >= attackActionDeplete && !animator.GetBool("isAttacking") && !animator.GetBool("isPushing") && !animator.GetBool("isThrowing") && !isDashing && (Input.GetButtonUp(attackInput + inputExtensionString) /*|| GameManager.singleGame && Input.GetButtonDown(attackInput + "2")*/)) { if (!potionUsed) { comboKeys += "A"; if (comboKeys != "UA" && comboKeys != "RA" && comboKeys != "DA" && comboKeys != "LA") { animator.SetBool("isAttacking", true); speed = attackSpeed * (1 + (4 * timeSlowMoEffectValue)); /* * if (playerNo == 1) * Subtitles.AddPlayer1Subtitle("TEST_Player 1 Attacking"); * else if (playerNo == 2) * Subtitles.AddPlayer2Subtitle("TEST_Player 2 Attacking"); */ if (animator.GetBool("isWalking")) { attackSpeedTimer = attackSpeedTime; } else { int dir = animator.GetInteger("direction"); if (dir == 0) { walkInput.x = 0; walkInput.y = 1; } else if (dir == 1) { walkInput.x = 1; walkInput.y = 0; } else if (dir == 2) { walkInput.x = 0; walkInput.y = -1; } else if (dir == 3) { walkInput.x = -1; walkInput.y = 0; } attackSpeedTimer = attackSpeedTime / 2f; } actionPoints -= attackActionDeplete; if (aud != null && TogglesValues.sound) { aud.PlayOneShot(weaponSounds[weaponPossession.weaponID + 1], weaponSoundVolumes[weaponPossession.weaponID + 1]); } } } potionUsed = false; } //Push if (pushPossible != null && !animator.GetBool("isPushing") && !animator.GetBool("isAttacking") && !animator.GetBool("isThrowing") && !isDashing && (comboKeys == "UU" || comboKeys == "RR" || comboKeys == "DD" || comboKeys == "LL")) { animator.SetBool("isPushing", true); speed = 0f; if (playerNo == 1) { Subtitles.AddPlayer1Subtitle("TEST_Player 1 Pushing"); } else if (playerNo == 2) { Subtitles.AddPlayer2Subtitle("TEST_Player 2 Pushing"); } actionPoints -= pushActionDeplete; pushPossible = null; comboKeys = ""; } //Dash if (actionPoints >= dashActionDeplete && !isDashing && !animator.GetBool("isAttacking") && !animator.GetBool("isPushing") && !animator.GetBool("isThrowing") && (comboKeys == "UU" || comboKeys == "RR" || comboKeys == "DD" || comboKeys == "LL" || comboKeys == "UR" || comboKeys == "UL" || comboKeys == "DR" || comboKeys == "DL" || comboKeys == "RU" || comboKeys == "RD" || comboKeys == "LU" || comboKeys == "LD") && hitCheck.knockback == Vector2.zero) { isDashing = true; dashTimer = dashTime / (1 + (4 * timeSlowMoEffectValue)); speed = dashSpeed * (1 + (4 * timeSlowMoEffectValue)); gameObject.layer = 10; actionPoints -= dashActionDeplete; if (aud != null && TogglesValues.sound) { aud.PlayOneShot(dashSound); } comboKeys = ""; } //Throw if (!animator.GetBool("isThrowing") && !animator.GetBool("isAttacking") && !animator.GetBool("isPushing") && !isDashing && (((keyComboTimer <= keyComboMaxTimeGap / 3.8f) && (comboKeys == "UA" || comboKeys == "RA" || comboKeys == "DA" || comboKeys == "LA")) || ((Input.GetButtonDown(attackInput + inputExtensionString)) && (Input.GetButtonDown(walkHorizontalInput + inputExtensionString) || Input.GetButtonDown(walkVerticalInput + inputExtensionString)))) ) { animator.SetBool("isThrowing", true); speed = attackSpeed * (1 + (4 * timeSlowMoEffectValue)); attackSpeedTimer = attackSpeedTime / 2f; actionPoints -= throwActionDeplete; if (throwFXObject && nextFXdelay < 0f) { GameObject FX = Instantiate(throwFXObject, transform.position, Quaternion.Euler(0f, 0f, 0f)); nextFXdelay = MINIMUM_TIME_BETWEEN_FX; } comboKeys = ""; } if (actionPoints < 1f) { actionPoints += regenerateActionPointsPerSec * Time.deltaTime * (1 + (4 * timeSlowMoEffectValue)); } if (isDashing && dashTimer <= 0f) { isDashing = false; speed = walkSpeed * (1 + (4 * timeSlowMoEffectValue)); gameObject.layer = 8; } else if (dashTimer > 0f || (attackSpeedTimer > 0f && attackSpeedTimer < attackSpeedTime / 3f)) { GameObject ghostSpriteFX = Instantiate(dashFXObject, transform.position, Quaternion.Euler(0f, 0f, 0f)); SpriteRenderer GSFX_sprRend = ghostSpriteFX.GetComponent <SpriteRenderer>(); if (dashFXObject && nextFXdelay < 0f) { GameObject FX = Instantiate(dashFXObject, transform.position, Quaternion.Euler(0f, 0f, 0f)); FX.GetComponent <SpriteRenderer>().sprite = sprRenderer.sprite; nextFXdelay = MINIMUM_TIME_BETWEEN_FX; } GSFX_sprRend.sprite = sprRenderer.sprite; if (name == "Player1") { GSFX_sprRend.color = Color.red; GSFX_sprRend.material.color = Color.red; } else { GSFX_sprRend.color = Color.green; GSFX_sprRend.material.color = Color.green; } } if ((animator.GetBool("isAttacking") || animator.GetBool("isThrowing")) && attackSpeedTimer <= 0f) { speed = 0f; } if (keyComboTimer >= keyComboMaxTimeGap) { comboKeys = ""; } if (comboKeys != "") { keyComboTimer += Time.deltaTime; } else { keyComboTimer = 0f; } if (hitComboTimer <= 0f) { hitComboCount = 0; } else { hitComboTimer -= Time.deltaTime; } if (criticalHitTimePauseTimer <= 0f) { if (Time.timeScale >= 0.05f && Time.timeScale <= 0.1f) { Time.timeScale = 1f; } else if (timeSlowMoTimer > 0f) { timeSlowMoTimer -= Time.unscaledDeltaTime; Time.timeScale = Mathf.Lerp(Time.timeScale, 0.5f, 0.025f); ImageEffect.SetImageEffectMaterialIndex(2); timeSlowMoEffectValue = Mathf.Lerp(timeSlowMoEffectValue, 0.25f, 0.025f); ImageEffect.SetImageEffectValue(timeSlowMoEffectValue); } else if (timeSlowMoTimer <= 0f) { if (Time.timeScale >= 0.5f && Time.timeScale != 1f) { if (Time.timeScale <= 0.505f && aud != null && TogglesValues.sound) { aud.PlayOneShot(slowMoToNormalSound); } Time.timeScale = Mathf.Lerp(Time.timeScale, 1f, 0.05f); if (Time.timeScale >= 0.98f) { Time.timeScale = 1f; } } if (timeSlowMoEffectValue <= 0f) { ImageEffect.SetImageEffectMaterialIndex(0); ImageEffect.SetImageEffectValue(0.04f); timeSlowMoEffectValue = 0f; } else { timeSlowMoEffectValue -= Time.unscaledDeltaTime / 5f; ImageEffect.SetImageEffectValue(timeSlowMoEffectValue); } } } else { Time.timeScale = 0.06f; criticalHitTimePauseTimer -= Time.unscaledDeltaTime; } animator.speed = 1f * (1 + (4 * timeSlowMoEffectValue)); attackSpeedTimer -= Time.deltaTime; dashTimer -= Time.deltaTime; nextFXdelay -= Time.deltaTime; // don't spam FX every frame prevWalkState = walkInput == Vector2.zero ? 0 : 1; } }