public void SpawnPortal() { m_PortalObjects.Clear(); //Spawn Portal Vector3 randomPosition1 = new Vector3(portalPosition1.position.x + Random.Range(-0f, 2f), portalPosition1.position.y, 0f); BulletObject portalObject1 = m_PortalPool.Pop(randomPosition1); m_PortalObjects.Add(portalObject1); Vector3 randomPosition2 = new Vector3(portalPosition2.position.x + Random.Range(-0f, -2f), portalPosition1.position.y, 0f); BulletObject portalObject2 = m_PortalPool.Pop(randomPosition2); m_PortalObjects.Add(portalObject2); //Link portals Portal portal1 = m_PortalObjects[0].transform.GetComponent <Portal>(); Portal portal2 = m_PortalObjects[1].transform.GetComponent <Portal>(); portal1.RemoveListener(Portalling); portal1.linkedPortal = portal2; portal1.AddListener(Portalling); portal1.CanPortal(false); portal2.RemoveListener(Portalling); portal2.linkedPortal = portal1; portal2.AddListener(Portalling); portal2.CanPortal(false); m_PortalLiveTimer = 12f; m_PortalDelayTimer = 1f; }
public void StartJumpAttack() { jumpDamager.EnableDamage(); //Fire magic spells for (int i = 0; i < 4; i++) { Vector3 rightOffset = new Vector3(1.5f - i * 0.2f, (i - 1) * 0.35f + 0.1f, 0); Vector3 leftOffset = rightOffset; leftOffset.x *= -1; if (m_SpriteRenderer.flipX) { BulletObject bulletObject = m_JumpAttackSpellPool.Pop(transform.position + leftOffset); bulletObject.rigidbody2D.velocity = Vector2.left * 7; bulletObject.rigidbody2D.transform.RotateToDirection(Vector2.right); } else { BulletObject bulletObject = m_JumpAttackSpellPool.Pop(transform.position + rightOffset); bulletObject.rigidbody2D.velocity = Vector2.right * 7; bulletObject.rigidbody2D.transform.RotateToDirection(Vector2.left); } } }
public void Spread() { BulletObject darkMatter1 = m_DarkMatterPool.Pop(transform.position); BulletObject darkMatter2 = m_DarkMatterPool.Pop(transform.position); darkMatter1.rigidbody2D.velocity = 5f * Vector2.left; darkMatter2.rigidbody2D.velocity = 5f * Vector2.right; }
private void LaserFollowAttack() { Vector2 startingShootPosition1 = new Vector3(-0.45f, 0.45f, 0) + transform.position; Vector2 startingShootPosition2 = new Vector3(0.45f, 0.45f, 0) + transform.position; //get bullet object BulletObject laserAttackBulletObject = m_LaserAttackPool.Pop(Random.Range(0, 2) == 1 ? startingShootPosition1 : startingShootPosition2); Vector2 direction = (laserFollower.position - laserAttackBulletObject.transform.position).normalized; //rotate laserAttackBulletObject.transform.RotateToDirection(direction); laserAttackBulletObject.rigidbody2D.velocity = direction * 15f; }
public void SpawnChaserAttack() { BulletObject chaserObject = m_ChaserPool.Pop(m_CurrentDarkVoidPosition); chaserObject.transform.GetComponent <ChaseTarget>().StartChasing(); chaserObject.transform.RotateTo(targetToTrack.position); }
public void Shoot() { BulletObject bulletObject = m_BulletPool.Pop(transform.position); bulletObject.transform.RotateToDirection(transform.up); bulletObject.rigidbody2D.velocity = bulletSpeed * transform.up; }
private bool Attack1() { if (timeToCoolDown <= 0) { //throw new NotImplementedException(); for (int i = 0; i < shootPoints.Length; i++) { bulletObjects[i] = bulletPool.Pop(shootPoints[i].position); bulletObjects[i].instance.GetComponent <StartShooting>().speed = 0; } StartCoroutine(WaitToShoot()); timeToCoolDown = attack1CoolDown; if (++currentAmount == amount) { currentAmount = 0; return(true); } } else { timeToCoolDown -= Time.deltaTime; } return(false); }
public void InstantiateSlashPrefab() { BulletObject slash = m_SlashPool.Pop(transform.position + (m_SpriteRenderer.flipX ? Vector3.left * 0.5f : Vector3.right * 0.5f)); PlayerSlash playerSlash = slash.transform.GetComponent <PlayerSlash>(); playerSlash.speed = Mathf.Abs(playerSlash.speed) * (m_SpriteRenderer.flipX ? -1 : 1); }
private void PopLoadThorn() { Debug.Log("Pop Thorn"); foreach (var item in loadThornPos) { thornLoadBulletPool.Pop(item.position); } }
private IEnumerator PopBullet(Vector3 pos) { for (int i = 0; i < bulletObjects.Length; ++i) { bulletObjects[i] = bulletPool.Pop(pos); bulletObjects[i].instance.GetComponent <StartShooting>().direction = (Quaternion.Euler(0, 0, angleToTarget) * Vector2.left).normalized; yield return(new WaitForSeconds(0.1f)); } }
public void Shoot() { BulletObject bulletObject = bulletPool.Pop(transform.position + transform.up * 0.8f); bulletObject.transform.SetParent(this.transform); bulletObject.transform.RotateToDirection(-transform.up); bulletObject.rigidbody2D.velocity = bulletSpeed * transform.up; shootAudio.Play(); }
private void PopSphere() { sphereBulletObjects = new BulletObject[spherePos.Length]; for (int i = 0; i < spherePos.Length; ++i) { sphereBulletObjects[i] = sphereBulletPool.Pop(spherePos[i].position); sphereBulletObjects[i].instance.GetComponent <FallTowardTarget>().target = targetToTrack; } }
private void PopVortex() { vortexGrounds = new BulletObject[numberOfSoldier]; for (int i = 0; i < numberOfSoldier; ++i) { float x = Random.Range(startRandomBombPos.position.x, endRandomBombPos.position.x); vortexGrounds[i] = vortexGroundEffect.Pop(new Vector2(x, startRandomBombPos.position.y)); } }
private void SpawnConcentratingAttack() { Vector3 spawnPosition = new Vector3(targetToTrack.transform.position.x, targetToTrack.transform.position.y + 0.5f, 0); BulletObject concentratingAttack = m_ConcentratingAttackPool.Pop(spawnPosition); m_CurrentConcentratingAttack = concentratingAttack.bullet.GetComponent <Damager>(); m_CurrentConcentratingAttack.DisableDamage(); }
public void Shoot() { BulletObject bulletObject = m_BulletPool.Pop(transform.position + transform.up * 0.8f); bulletObject.transform.RotateToDirection(transform.up); bulletObject.rigidbody2D.velocity = bulletSpeed * transform.up; if (shootAudioPlayer != null) { shootAudioPlayer.PlayRandomSound(); } }
public void StartSlashAttacking() { for (int i = 0; i < 2; i++) { if (transform.localScale.x < 0) { Vector3 position = transform.position + new Vector3(-1f - 0.6f * i, 0.9f, 0); BulletObject slashObject = m_SlashPool.Pop(position); slashObject.transform.GetComponent <SpriteRenderer>().flipX = true; slashObject.rigidbody2D.velocity = Vector2.left * 6f; } else { Vector3 position = transform.position + new Vector3(1f + 0.6f * i, 0.9f, 0); BulletObject slashObject = m_SlashPool.Pop(position); slashObject.transform.GetComponent <SpriteRenderer>().flipX = false; slashObject.rigidbody2D.velocity = Vector2.right * 6f; } } }
private void SpawnSoldier() { attack3BulletObject = new BulletObject[numberOfSoldier]; for (int i = 0; i < numberOfSoldier; ++i) { float x = Random.Range(startRandomBombPos.position.x, endRandomBombPos.position.x); attack3BulletObject[i] = bulletPool3.Pop(new Vector2(vortexGrounds[i].instance.transform.position.x, startRandomBombPos.position.y - 1.9f)); attack3BulletObject[i].instance.GetComponent <Rigidbody2D>().velocity = Vector2.up; //attack3BulletObject[i].instance.GetComponent<MiniSoldier>().Active(); } }
private void Attack1() { if (spriteRenderer.flipX) { foreach (var item in shootRight) { BulletObject bullet = bulletPool1.Pop(item.position); bullet.instance.GetComponent <StartShooting>().direction = Vector2.right; } } else { foreach (var item in shootLeft) { BulletObject bullet = bulletPool1.Pop(item.position); bullet.instance.GetComponent <StartShooting>().direction = Vector2.left; } } Shooting.Play(); }
public void StartTopToBottomAttack() { shortDamager.EnableDamage(); BulletObject m_DarkMatter1 = m_DarkMatterPool.Pop(transform.position + (m_SpriteRenderer.flipX ? new Vector3(-0.5f, 0, 0) : new Vector3(0.5f, 0, 0))); m_DarkMatter1.rigidbody2D.velocity = (m_SpriteRenderer.flipX ? Vector2.left : Vector2.right) * 2; BulletObject m_DarkMatter2 = m_DarkMatterPool.Pop(transform.position + (m_SpriteRenderer.flipX ? new Vector3(-0.5f, 0, 0) : new Vector3(0.5f, 0, 0))); m_DarkMatter2.rigidbody2D.velocity = (m_SpriteRenderer.flipX ? Vector2.left : Vector2.right) * 2; m_PrincessFuryPosition = transform.position; m_DarkMatters.Add(m_DarkMatter1); m_DarkMatters.Add(m_DarkMatter2); m_DarkMatterTimer = 0; }
private void ShootThorns() { int angle = 0; //Debug.Log("load thorn position: " + loadThornPos.Length); for (int i = 0; i < loadThornPos.Length; ++i) { for (int j = 0; j < 6; ++j) { BulletObject bulletObject = thornBulletPool.Pop(loadThornPos[i].position); bulletObject.instance.GetComponent <StartShooting>().direction = (Quaternion.Euler(0, 0, angle) * Vector2.right).normalized; bulletObject.instance.GetComponent <Transform>().rotation = Quaternion.Euler(0, 0, angle); angle = angle - 60 == -360 ? 0 : angle - 60; //Debug.Log("thorn " + i + " :" + bulletObject.instance.GetComponent<Transform>().rotation.z); } } }
// Update is called once per frame void Update() { if (GameController.Instance.gameMode == Mode.fight) { if (type == ItemType.playerWeapons) { timer -= Time.deltaTime; if (timer < 0) { timer = time; if (bulletPool != null) { BulletObject bullet = bulletPool.Pop(transform.position); bullet.rigidbody2D.velocity = Vector2.up; } } } } }
public void AttackHit(Damager damager, Damageable damageable) { OnAttackHit(damager); if (damageable.CurrentHealth - damager.damage <= 0 && LayerMask.LayerToName(damageable.gameObject.layer) == "Enemy") { int count = Random.Range(4, 8); for (int i = 0; i < count; i++) { //VFXController.Instance.Trigger("MiniCollectableHealth", damageable.transform.position + (Vector3)Random.insideUnitCircle * 1f, 0, false, null); BulletObject miniCollectableHealth = m_MiniCollectableHealthPool.Pop(damageable.transform.position + (Vector3)Random.insideUnitCircle * 1f); } } //VFXController.Instance.Trigger(m_HashSlashHitEffect, damageable.transform.position, 0, false, null); //if (slashHitAudioPlayer) //{ // slashHitAudioPlayer.PlayRandomSound(); //} ////Slowdown time a little bit //TimeManager.SlowdownTime(0.2f, 0.2f); ////Push damageable object back just a tiny bit //Rigidbody2D damageableBody = damageable.GetComponent<Rigidbody2D>(); //if (damageableBody == null) return; //Vector2 damagerToDamageable = damager.transform.position - damageableBody.transform.position; //if (damagerToDamageable.x > 0) //{ // damageableBody.MovePosition(damageableBody.position + new Vector2(-0.2f, 0)); //} //else //{ // damageableBody.MovePosition(damageableBody.position + new Vector2(0.2f, 0)); //} }
public void SummonMiniSoldier() { m_Soldiers.Clear(); m_SoldierAppearingTimer = 0; for (int i = 0; i < m_SoldierCount; i++) { float xPosition = Random.Range(summonPosition1.position.x, summonPosition2.position.x); VFXController.Instance.Trigger(m_VortexGroundEffectHash, new Vector3(xPosition, summonPosition1.position.y, 0), 0, false, null); BulletObject soldier = m_SoldierPool.Pop(new Vector3(xPosition, summonPosition1.position.y - 1.5f)); soldier.bullet.GetComponent <MiniSoldier>().DeActive(); m_Soldiers.Add(soldier); soldier.rigidbody2D.velocity = Vector2.up * 0.5f; } m_SoldierAppearingTimer = 3.7f; m_SoldierCount++; }
public void Shooting() { Vector2 force = spriteForward.x > 0 ? Vector2.right.Rotate(shootAngle) : Vector2.left.Rotate(-shootAngle); force *= shootForce; Vector2 shootPosition = shootingOrigin.transform.localPosition; if ((spriteFaceLeft && spriteForward.x > 0) || (!spriteFaceLeft && spriteForward.x > 0)) { shootPosition.x *= -1; } BulletObject obj = bulletPool.Pop(shootingOrigin.TransformPoint(shootPosition)); shootingAudio.PlayRandomSound(); obj.rigidbody2D.velocity = (GetProjectileVelocity(targetShootPosition, shootingOrigin.transform.position)); }
public void Shooting() { Vector2 force = m_SpriteForward.x > 0 ? Vector2.right.Rotate(shootAngle) : Vector2.left.Rotate(-shootAngle); force *= shootForce; Vector2 shootPosition = shootingOrigin.transform.localPosition; //if we are flipped compared to normal, we need to localy flip the shootposition too if ((spriteFaceLeft && m_SpriteForward.x > 0) || (!spriteFaceLeft && m_SpriteForward.x < 0)) { shootPosition.x *= -1; } BulletObject obj = m_BulletPool.Pop(shootingOrigin.TransformPoint(shootPosition)); if (shootingAudio != null) { shootingAudio.PlayRandomSound(); } obj.rigidbody2D.velocity = GetProjectilVelocity(m_TargetShootPosition, shootingOrigin.transform.position); }
protected void SpawnBullet() // Tests location of bullet spawn to make sure it isn't on the other side of a wall. If ok, spawns bullet by popping from bullet pool. Adds velocity in proper direction. { Vector2 testPosition = transform.position; testPosition.y = currentBulletSpawnPoint.position.y; Vector2 direction = (Vector2)currentBulletSpawnPoint.position - testPosition; float distance = direction.magnitude; direction.Normalize(); RaycastHit2D[] results = new RaycastHit2D[12]; if (Physics2D.Raycast(testPosition, direction, characterController2D.GroundContactFilter, results, distance) > 0) { return; } BulletObject bullet = bulletPool.Pop(currentBulletSpawnPoint.position); bool facingLeft = currentBulletSpawnPoint == facingLeftBulletSpawnPoint; bullet.rigidbody2D.velocity = new Vector2(facingLeft ? -bulletSpeed : bulletSpeed, 0f); bullet.spriteRenderer.flipX = facingLeft ^ bullet.bullet.spriteOriginallyFacesLeft; rangedAttackAudioPlayer.PlayRandomSound(); }
private void PopBlackKnightBullet() { skill3NumberOfButllet++; skill3PollIndex = 0; if (skill3NumberOfButllet == 1) { skill3BulletObjects[(skill3PollIndex) % 4] = skill3BulletPool.Pop(skill3Pos[0].position); } if (skill3NumberOfButllet == 2) { skill3BulletObjects[(skill3PollIndex++) % 4] = skill3BulletPool.Pop(skill3Pos[1].position); skill3BulletObjects[(skill3PollIndex) % 4] = skill3BulletPool.Pop(skill3Pos[2].position); } if (skill3NumberOfButllet >= 3) { skill3BulletObjects[(skill3PollIndex++) % 4] = skill3BulletPool.Pop(skill3Pos[0].position); skill3BulletObjects[(skill3PollIndex++) % 4] = skill3BulletPool.Pop(skill3Pos[1].position); skill3BulletObjects[(skill3PollIndex) % 4] = skill3BulletPool.Pop(skill3Pos[2].position); } }
private void Shoot() { m_CurrentBulletPool.Pop(bulletSpawnPoint.position, transform.position, m_CurrentBulletPattern); }
public void StartDarkVoidAttacking() { BulletObject darkVoidObject = m_DarkVoidPool.Pop(new Vector3(Random.Range(darkVoidPosition1.position.x, darkVoidPosition2.position.x), darkVoidPosition1.position.y, 0f)); darkVoidObject.rigidbody2D.velocity = Vector2.down * 2f; }