public void Update() { if (!_started) { if ( ScoreTracker.Instance.Scores.Select(score => score.playerId) .All(id => Input.GetKey("joystick " + id + " button 3")) && ScoreTracker.Instance.Scores.Count > 0) { _time += Time.deltaTime; Screenshaker.Shake((_time / PartyTime) * Shake, new Vector2(Random.value, Random.value).normalized); if (_time >= PartyTime) { _started = true; } } else { _time = 0; } } else { var laser = (LaserProjectile)Instantiate(Laser, transform.position + new Vector3((Random.value - 0.5f) * Camera.main.orthographicSize, (Random.value - 0.5f) * Camera.main.orthographicSize), Quaternion.identity); laser.SetDirection(new Vector2(Random.value - 0.5f, Random.value - 0.5f)); Destroy(laser, laser.survivalTime); } }
protected virtual void FireProjectile(int index) { var insProj = Instantiate(projectile, transform.position + transform.parent.localScale.x * Vector3.right * 0.7f, Quaternion.identity) as Projectile; if (index > 0) { insProj.SetDirection(transform.parent.localScale.x * Vector2.right + new Vector2(Random.Range(-0.1f, 0.1f), Random.Range(-0.1f, 0.1f)), Random.Range(angularVelocityMin, angularVelocityMax)); } else { insProj.SetDirection(transform.parent.localScale.x * Vector2.right, Random.Range(angularVelocityMin, angularVelocityMax)); } Screenshaker.Shake(0.4f, Vector2.right * transform.parent.localScale.x); insProj.SetOwner(ref weaponOwner); }
private void Spawn(int index, int slot, PlayerController controller) { var player = controller.GetComponent <PlayerMovement>(); controller.transform.position = (_spawnPoints.SingleOrDefault( spawner => Vector3.Distance(spawner.transform.position, averageplayer) == maxDist) ?? _spawnPoints[Random.Range(0, _spawnPoints.Count)]).transform.position; controller.Player = player; controller.Index = slot; _players[index] = player; Screenshaker.Shake(1, Vector2.up); ScoreTracker.Instance.RegisterPlayer(slot, index, player.GetComponent <PlayerCore>()); GetComponent <AudioSource>().clip = SpawnClips[Random.Range(0, SpawnClips.Length)]; GetComponent <AudioSource>().Play(); if (SpawnEffect.Length >= slot) { Destroy(Instantiate(SpawnEffect[Mathf.Clamp(slot - 1, 0, SpawnEffect.Length)], player.transform.position, Quaternion.identity), 4); } }
protected override void FireProjectile(int index) { var insProj = Instantiate(projectile, transform.position + transform.parent.localScale.x * Vector3.right * 1.2f + Vector3.up * 1.2f, Quaternion.identity) as Projectile; Physics2D.IgnoreCollision(insProj.GetComponent <Collider2D>(), gameObject.GetComponent <Collider2D>()); float angle = (thorwAngle + Random.Range(-randomRange, randomRange)) * Mathf.Deg2Rad; Vector2 shotDirection = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle)); shotDirection.x *= transform.parent.localScale.x; insProj.SetDirection(shotDirection); insProj.SetOwner(ref weaponOwner); Screenshaker.Shake(0.4f, Vector2.right * transform.parent.localScale.x); }