public void Melee() { if (characterType == EntityType.Enemy3) { if (photonView.isMine) { AudioFW.Play("AlienAttack"); } } else if (characterType == EntityType.Enemy2) { if (photonView.isMine) { AudioFW.Play("SpiderAttack"); } } rotator.transform.right = target - rotator.transform.position; // Turn rotator Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, attackRange, layerMaskPlayer); foreach (var hit in hits) { IDamageable <int> iDamageable = hit.gameObject.GetComponent(typeof(IDamageable <int>)) as IDamageable <int>; if (iDamageable != null) { Vector3 recoilVector = new Vector3(hit.gameObject.transform.position.x - transform.position.x, hit.gameObject.transform.position.y - transform.position.y, 0f).normalized; iDamageable.TakeDamage(damage, recoilVector); } } // Play animation //meleeIndicator.SetActive(true); //StartCoroutine(RotateMe(Vector3.forward * 85, attackInterval * .3f)); }
/// <summary> /// /// </summary> /// <param name="d">Damage</param> /// <param name="r">Range</param> /// <param name="s">Speed</param> /// <param name="dir">Direction</param> /// <param name="shotByNPC">True if shot by npc</param> public void LaunchProjectile(int d, float r, float s, Vector2 dir, bool shotByNPC) { // Set original position origPos = transform.position; // Set damage of the projectile damage = d; // Set range range = r; // Set speed speed = s; // Set direction direction = dir; // Set npc npc = shotByNPC; // Set Launchtime launchTime = Time.time; if (impulse) { rb2D.AddForce(dir * s, ForceMode2D.Impulse); } if (npc) { var random = Random.Range(0, 4); AudioFW.Play("EnemyShoot" + random); } else { var random = Random.Range(0, 4); AudioFW.Play("PlayerShoot" + random); } launched = true; //Debug.Log("launched"); }
public void Attack() { //No need to check the closest target, since we should lock our attention to one troop at least as long as it's in the reachRadius if (Vector2.Distance(transform.position, currentTarget.position) < reachRad && currentTarget != gameObject.transform) { //Attack the target attackTimer -= Time.deltaTime; if (attackTimer <= 0) { currentTarget.GetComponent <IDamageable>().ApplyDamage(attackPower); attackTimer += attackPerSecond; AudioFW.Play("Unit_Knight_Attack"); } } else if (Vector2.Distance(transform.position, currentTarget.position) < aggroRadius) { currentState = AIstate.Aggro; } else { currentState = AIstate.Navigate; //DeListen target death notification } }
public void Show(int hero) { if (!movingOut) { if (!selected) { frameImage.color = heroColors[hero]; heroImage = heroImages[hero]; Image SetheroImageCard = heroImageCard.GetComponent(typeof(Image)) as Image; SetheroImageCard.sprite = heroImage; for (int i = 0; i < textFields.Length; i++) { textFields[i].text = character.GetCharacterData(i, hero); } AudioFW.Play("Whip"); ShowCard(); queue = -1; } } else { queue = hero; } HideTitle(); }
void ShootMLAW() { int random = Random.Range(0, 3); AudioFW.Play("MLAWFire" + random); PoolManager.Instance.mlawPool.SpawnProjectile(projSpawn.transform.position, projSpawn.transform.rotation, 100, 1); }
void ShootWizBall() { int random = Random.Range(0, 3); AudioFW.Play("WizSpawn" + random); PoolManager.Instance.wizballPool.SpawnProjectile(projSpawn.transform.position, projSpawn.transform.rotation, 30, 5); }
void InRoom() { var rb = roomInteractables.GetComponentsInChildren <Button>(); foreach (var b in rb) { b.interactable = true; } var lb = lobbyInteractables.GetComponentsInChildren <Button>(); foreach (var b in lb) { b.interactable = false; } MenuCanvasManager.Instance.currentRoomCanvas.transform.SetAsLastSibling(); AudioFW.Play("Whip"); LeanTween.move(roomInteractables, Vector3.zero, .5f).setEaseOutQuart(); if (PhotonNetwork.isMasterClient) { startGame.interactable = true; startGame.Select(); } else { startGame.interactable = false; leaveGame.Select(); } }
public void AddKey(int num) { inputs.Add(num); int rng = Random.Range(1, 4); AudioFW.Play("button" + rng); }
public void TakeDamage(int damage, Vector3 recoilOffset) { if (Time.time > timeDamageTaken + damageCooldownLength) { timeDamageTaken = Time.time; // If the player took more than 10 damage start recoil if (damage > 10) { // Scale recoil based on damage float recoilMultiplier = damage / 40f; //float timeMult = (float)damage / 100; LeanTween.move(playerCam, playerCam.transform.position + recoilOffset * recoilMultiplier, .25f).setEaseOutExpo(); Stun(.25f); //StartCoroutine(recoil(recoilOffset * recoilMultiplier, 0.05f)); } SetHealth(-damage, this); if (photonView.isMine) { var random = Random.Range(0, 4); AudioFW.Play("PlayerTakesDamage" + random); if (!intense) { Intense(); } } } }
public IEnumerator LoseGame() { print("You Lose!"); gameLost = true; yield return(new WaitForSeconds(2)); camAnim.SetTrigger("Lose"); gameAnim.SetTrigger("Lose"); AudioFW.Play("LoseGame"); yield return(new WaitForSeconds(1.5f)); GameObject expl = Instantiate(explosion, transform.GetChild(0).transform.position, explosion.transform.rotation); transform.GetChild(0).gameObject.SetActive(false); Destroy(expl, 0.25f); yield return(new WaitForSeconds(0.07f)); fader.SetActive(true); faderAnim.SetTrigger("Fade"); AudioFW.StopLoop("Ambience"); GameObject[] enemies = GameObject.FindGameObjectsWithTag("Enemy"); foreach (GameObject enemy in enemies) { Destroy(enemy); } }
private void FixedUpdate() { RotateWheels(350); if (lives < 15 && !damaged) { damaged = true; agent.speed = damagedSpeed; AudioFW.Play("TruckDamaged"); } if (lives < 1) { EnemyManager.enemiesLeft--; GunShoot gun = GameObject.Find("BulletSpawn").GetComponent <GunShoot>(); gun.kills++; Clipboard.instance.ChangeKills(gun.kills.ToString()); Destroy(gameObject); GameObject deadTruck = Instantiate(truckDeath, transform.position, transform.rotation); Destroy(deadTruck, 5f); CameraShaker.GetInstance("Main Camera").ShakeOnce(6f, 5f, 0.0f, 2.5f); AudioFW.Play("TruckDie"); } if (damaged) { flames.SetActive(true); } }
IEnumerator MeleeAttackRotator(float time, float rotation, int dmg, GameObject rotator, float warningTime) { rotator.LeanScale(new Vector3(1f, 1f, 1f), warningTime); //transform.GetComponent<SpriteRenderer>().color = Color.yellow; if (photonView.isMine) { AudioFW.Play("BossMeleeSwing"); } yield return(new WaitForSeconds(warningTime)); rotator.gameObject.transform.GetChild(0).GetComponent <PolygonCollider2D>().enabled = true; float rotDelta = 0; float elapsedTime = 0; Quaternion startRot = new Quaternion(); startRot.eulerAngles = rotator.transform.rotation.eulerAngles; Quaternion rot = new Quaternion(); MeleeHand hand = rotator.transform.GetChild(0).gameObject.GetComponent <MeleeHand>(); hand.damage = dmg; while (elapsedTime < time) { rotDelta = (rotation * (elapsedTime / time)); rot.eulerAngles = startRot.eulerAngles + new Vector3(0, 0, rotDelta); rotator.transform.rotation = rot; elapsedTime += Time.deltaTime; yield return(null); } Destroy(rotator); //transform.GetComponent<SpriteRenderer>().color = Color.white; meleeAttackFin = true; }
public void Melee() { int random = Random.Range(0, 4); AudioFW.Play("PlrMelee" + random); if (!photonView.isMine) { damage = 0; } Collider2D[] hits = Physics2D.OverlapCircleAll(transform.position, attackRange, layerMaskEnemy); foreach (var hit in hits) { IDamageable <int> iDamageable = hit.gameObject.GetComponent(typeof(IDamageable <int>)) as IDamageable <int>; if (iDamageable != null) { iDamageable.TakeDamage(damage, new Vector3(0, 0, 0)); } } if (photonView.isMine) { Vector2 mouseVector = new Vector2(Input.mousePosition.x - camPos.x, Input.mousePosition.y - camPos.y).normalized; if (characterType == EntityType.Hero1) { animator.SetTrigger("LightOniAttack"); } else if (characterType == EntityType.Hero3) { animator.SetTrigger("DarkOniAttack"); } animator.SetFloat("Horizontal", mouseVector.x); animator.SetFloat("Vertical", mouseVector.y); } }
void RPC_Dash() { AudioFW.Play("Dash"); dashing = true; print("dash particles on others!"); dashEffectParticles.GetComponent <ParticleSystem>().Play(); }
public void Attack() { //No need to check the closest target, since we should lock our attention to one troop at least as long as it's in the reachRadius if (Vector2.Distance(transform.position, currentTarget.position) < reachRad && currentTarget != gameObject.transform) { //Attack the target attackTimer -= Time.deltaTime; if (attackTimer <= 0) { List <Transform> enemyUnits = targetManager.FindAllTargetsWithinRadius(gameObject.transform, thisPlayer, attackRad + 0.1f); foreach (Transform unit in enemyUnits) { IDamageable healthScript = unit.GetComponent <IDamageable>(); if (healthScript != null) { healthScript.ApplyDamage(attackPower); } } attackTimer += attackPerSecond; AudioFW.Play("Unit_DarkK_Attack"); } } else if (Vector2.Distance(transform.position, currentTarget.position) < aggroRadius) { currentState = AIstate.Aggro; } else { currentState = AIstate.Navigate; //DeListen target death notification } }
void Dash() { AudioFW.Play("Dash"); dashing = true; dashEffectParticles.GetComponent <ParticleSystem>().Play(); dashVector = lastDir; photonView.RPC("RPC_Dash", PhotonTargets.Others); }
private void OnCollisionEnter(Collision collision) { if (!hasPlayed) { int rng = Random.Range(1, 3); AudioFW.Play("impact" + rng); } }
public void setBossDefeated() { GameManager.Instance.bossDefeated = true; if (photonView.isMine) { AudioFW.Play("BossDeath"); } }
public void AfterSelection() { AudioFW.StopAllSounds(); InfoManager.Instance.HideCard(); InfoManager.Instance.HideTitle(); AudioFW.Play("Whip"); LeanTween.move(controlInfo, Vector2.zero, .5f).setEaseInQuart().setOnComplete(select); }
void Select() { AudioFW.Play("CharacterSelected"); LeanTween.cancel(chooseText); LeanTween.scale(chooseText, Vector3.one, 0f); chooseText.GetComponent <TextMeshProUGUI>().text = "Get Ready!"; LeanTween.scale(chooseText, Vector3.one * 1.2f, .2f).setLoopPingPong().setEaseInExpo(); }
IEnumerator StartShootSounds() { AudioFW.StopSfx("BurstTail"); AudioFW.Play("BurstStart"); yield return(new WaitForSeconds(0.030f)); AudioFW.PlayLoop("BurstLoop"); }
void RPC_GameLost() { print("RPC_GameLost " + name); switchingScene = true; rb2D.velocity = Vector2.zero; AudioFW.StopAllSounds(); AudioFW.Play("AllDead"); }
public void OnChangeSelection(int dir, string playerID) //I still couldn't read the if-statements below in clear english. Good luck! { if (playerID.Equals(_playerID)) { if (clickedCard) { UndoClickOperations(); } selected = lastSelected; if (selected != null && selected.IsSelected) //This is the normal situation: we have a selection active (non-null) and said selection IsSelected. { HashSet <Selectable> visited = new HashSet <Selectable>(); if (dir > 0) { visited.Add(selected); selected = selected.next; while (selected != null && selected.isSelectable == false && (!visited.Contains(selected))) { /*We basically make sure that the "selected.next" is actually selectable (isSelectable == true), * or else we skip to the next one. The Hashset shouldn't also contain the selected itself, meaning that it will choose itself if it's the only one available: * The loop ends when the selected itself is in-fact in the Hashset, and thus keep the selection as itself. Meaning that selected is the same as selected.next*/ visited.Add(selected); selected = selected.next; } } if (dir < 0) { visited.Add(selected); selected = selected.previous; while (selected != null && selected.isSelectable == false && (!visited.Contains(selected))) { visited.Add(selected); selected = selected.previous; } } } if (selected == null || (selected.isSelectable == false)) { // if we don't have a valid next selectable, select first item in array of all selectables RefreshSelectables(); selected = Array.Find <Selectable>(selectables, selectable => selectable.isSelectable); } if (selected != null) { if (lastSelected != null) { lastSelected.IsSelected = false; } selected.IsSelected = true; lastSelected = selected; } } AudioFW.Play("Card_Use"); }
public void OnButtonHoverExit() { LeanTween.scale(rectTransform, Vector3.one, onHoverExitLength); if (shadow != null) { shadow.effectDistance = shadowDistance; } AudioFW.Play("ButtonSwitch"); }
public void GetPotion() { potion = true; if (photonView.isMine) { uim.UpdatePotion(); AudioFW.Play("PotionPickup"); } }
public void OnButtonHoverEnter() { LeanTween.scale(rectTransform, Vector3.one * onHoverSizeMultiplier, onHoverEnterLength); if (shadow != null) { shadow.effectDistance = shadowDistance * onHoverSizeMultiplier * 1.5f; } AudioFW.Play("ButtonSwitch"); }
void Spit() { LeanTween.scale(gameObject, Vector3.one, spawnInterval * 0.35f).setEaseOutElastic(); AudioFW.Play("Spit"); if (PhotonNetwork.isMasterClient) { SpawnNow(); } }
void Update() { if (!outOfAmmo && !overheating && !GameManager.instance.gameLost && !Menus.paused) { if (Input.GetKey(KeyCode.Mouse0)) { if (!shooting) { shooting = true; StartCoroutine("StartShootSounds"); } if (Time.time > nextFireTime) { Shoot(); --currentAmmo; flashParticle.SetActive(true); nextFireTime = Time.time + fireRate; //spawn belt links GameObject newLink = Instantiate(link, linkSpawn.transform.position, Quaternion.identity); newLink.GetComponent <Rigidbody>().AddForce(new Vector3(Random.Range(0.5f, 1.5f), 0, 0), ForceMode.Impulse); Destroy(newLink, 0.5f); } } if (Input.GetKeyUp(KeyCode.Mouse0)) { if (shooting) { shooting = false; StopShootSounds(); flashParticle.SetActive(false); } } } else if (outOfAmmo) { if (Input.GetKeyDown(KeyCode.Mouse0)) { AudioFW.Play("ClickEmpty"); } } if (Input.GetKeyDown(KeyCode.Mouse1)) { pistol.GetComponent <Animator>().SetTrigger("Shoot"); } if (Input.GetKeyDown(KeyCode.R) && !overheating && currentAmmo < maxAmmo && !reloading) { StartCoroutine(Reload()); } if (Input.GetKeyDown(KeyCode.F) && !overheating && !shooting && !reloading) { overheating = true; StartCoroutine(BarrelChange()); } }
public void SlideBossDoor() { //bc.enabled = false; AudioFW.Play("DoorOpen"); //opened = true; //uim.SetInfoText(openerName + " opened " + gameObject.name, 2); //GameObject particles = Instantiate(doorOpenParticles, transform.GetChild(1).transform.position, transform.rotation, transform.GetChild(1)); //Destroy(particles, 5); StartCoroutine(Slide(-3.3f, 1)); }
public void UndoClickOperations() { Selectable currentSelection = Array.Find(selectables, selectable => selectable.IsSelected); cursor.DeleteCursorObjects(); cursor.ResetCursor(); currentSelection.IsClicked = false; clickedCard = false; AudioFW.Play("Card_Reset"); }