Exemple #1
0
 void Awake()
 {
     UIScore = GameObject.Find ("UICanvas").gameObject.transform.Find ("ScoreText").gameObject.GetComponent<Text> ();
     UITime = GameObject.Find ("UICanvas").gameObject.transform.Find ("TimeText").gameObject.GetComponent<Text> ();
     shaker = GameObject.Find("CameraContainer").GetComponent<Shaker>();
     InvokeRepeating ("BlinkText", 0, 0.1f);
 }
Exemple #2
0
 private void Awake()
 {
     StartPosition = transform.position;
     instance      = this;
 }
Exemple #3
0
    void Start() {
        Collider = GetComponent<Collider2D>();
        particles = GetComponentInChildren<ParticleSystem>();
        sprite = transform.FindChild("Square").GetComponent<SpriteRenderer>();
        shaker = GetComponentInChildren<Shaker>();
	}
    public void OnPlayerHit()
    {
        Shaker cameraShaker = GetMainCamera().GetComponent <Shaker>();

        cameraShaker.Shake(playerHitShakePreset);
    }
Exemple #5
0
 private void Awake()
 {
     instance = this;
 }
        private IEnumerator Sequence()
        {
            Player player;

            do
            {
                yield return(null);

                player = Scene.Tracker.GetEntity <Player>();
            }while (!triggered && (manualTrigger || player == null || player.X < X + 30f || player.X > Right + 8f));

            SoundSource shakingSfx = baseData.Get <SoundSource>("shakingSfx");

            shakingSfx.Play(SFX.game_00_fallingblock_prologue_shake);
            float  time   = delay;
            Shaker shaker = new Shaker(time, removeOnFinish: true, v => baseData["shake"] = v);

            if (delay > 0f)
            {
                Add(shaker);
            }
            Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);

            while (time > 0f)
            {
                player = Scene.Tracker.GetEntity <Player>();
                if (!manualTrigger && player != null && (player.X >= X + Width - 8f || player.X < X + 28f))
                {
                    shaker.RemoveSelf();
                    break;
                }
                yield return(null);

                time -= Engine.DeltaTime;
            }

            for (int i = 2; i < Width; i += 4)
            {
                SceneAs <Level>().Particles.Emit(FallingBlock.P_FallDustA, 2, new Vector2(X + i, Y), Vector2.One * 4f, (float)Math.PI / 2f);
                SceneAs <Level>().Particles.Emit(FallingBlock.P_FallDustB, 2, new Vector2(X + i, Y), Vector2.One * 4f);
            }
            shakingSfx.Param("release", 1f);

            time = 0f;
            do
            {
                yield return(null);

                time = Calc.Approach(time, 1f, speed * Engine.DeltaTime);
                MoveTo(Vector2.Lerp(baseData.Get <Vector2>("start"), baseData.Get <Vector2>("end"), Ease.CubeIn(time)));
            }while (time < 1f);

            for (int j = 0; j <= Width; j += 4)
            {
                SceneAs <Level>().ParticlesFG.Emit(FallingBlock.P_FallDustA, 1, new Vector2(X + j, Bottom), Vector2.One * 4f, -(float)Math.PI / 2f);
                float direction = (j < Width / 2f) ? ((float)Math.PI) : 0f;
                SceneAs <Level>().ParticlesFG.Emit(FallingBlock.P_LandDust, 1, new Vector2(X + j, Bottom), Vector2.One * 4f, direction);
            }
            shakingSfx.Stop();
            Audio.Play(SFX.game_00_fallingblock_prologue_impact, Position);
            SceneAs <Level>().Shake();
            Input.Rumble(RumbleStrength.Strong, RumbleLength.Medium);
            Add(new Shaker(0.25f, removeOnFinish: true, v => baseData["shake"] = v));
        }
Exemple #7
0
    void Attack()//hits in front of the player; any other players in the colliders in the Hitbox gameobject will die
    {
        Collider2D currentPlayerPolygonCollider = gameObject.FindComponentInChildWithTag <PolygonCollider2D>("Hitbox");
        Collider2D currentPlayerCircleCollider  = gameObject.FindComponentInChildWithTag <CircleCollider2D>("Hitbox");

        //ATTACK ANIMATION/EFFECT
        hitParticles = Instantiate(hitPrefab, transform.position + (transform.right * hitPointDistance), transform.rotation) as GameObject;

        //ATTACK SOUND
        float randomPitch = UnityEngine.Random.Range(0.7f, 1.3f);

        AudioManager.instance.Play("GravityHammer1", 1f, randomPitch, false);

        //SHAKE CAMERA
        Shaker.ShakeAll(hitShakePreset);

        //DETECT ALL OTHER PLAYERS THAT ARE HIT
        //get player colliders hit by the polygon hit collider stored as a list
        List <Collider2D> hitPlayersFromPolygonCollider = new List <Collider2D>();
        LayerMask         playerLayerMask     = LayerMask.GetMask("Player");
        ContactFilter2D   playerContactFilter = new ContactFilter2D();

        playerContactFilter.SetLayerMask(playerLayerMask);//With this, the overlap collider will only detect colliders that have the "Player" layer on it, including the controlled player
        int polygonColliderCount = currentPlayerPolygonCollider.OverlapCollider(playerContactFilter, hitPlayersFromPolygonCollider);

        //get player colliders hit by the circle hit collider stored as a list
        List <Collider2D> hitPlayersFromCircleCollider = new List <Collider2D>();
        int circleColliderCount = currentPlayerCircleCollider.OverlapCollider(playerContactFilter, hitPlayersFromCircleCollider);

        //get union of the above lists
        IEnumerable <Collider2D> unionOfHitBoxLists = hitPlayersFromPolygonCollider.Union(hitPlayersFromCircleCollider);

        //KILL THE HIT PLAYERS (except the player that did the hit)
        foreach (Collider2D playerCollider in unionOfHitBoxLists)
        {
            //disattach balls from players who are about to die
            Collider2D ballsCollider = Helper.FindComponentInChildWithTag <Collider2D>(playerCollider.gameObject, "Ball");
            if (ballsCollider != null)
            {
                ballsCollider.attachedRigidbody.isKinematic = false;
                ballsCollider.enabled          = true;
                ballsCollider.transform.parent = null;
                Mover playerMover = (Mover)playerCollider.gameObject.GetComponent(typeof(Mover));
                playerMover.hasBall = false;
            }
            //kill the players
            if (playerCollider.gameObject.GetComponent <Mover>().playerIndex != this.playerIndex) //playerCollider.name != this.gameObject.name)
            {
                /*Vector2 direction = (playerCollider.transform.position - transform.position)*10000; //intended to shoot the player off the edge really fast like in advance wars so they could explode off the edge like in smash bros; couldnt get it to work
                 * playerCollider.attachedRigidbody.AddForceAtPosition(direction, transform.position);*/
                KillPlayer(playerCollider.gameObject);
            }
        }

        //GET ALL BALLS THAT WILL BE HIT
        //get ball colliders hit by the polygon hit collider stored as a list
        List <Collider2D> hitBallsFromPolygonCollider = new List <Collider2D>();
        LayerMask         ballLayerMask     = LayerMask.GetMask("Ball");
        ContactFilter2D   ballContactFilter = new ContactFilter2D();

        ballContactFilter.SetLayerMask(ballLayerMask);//With this, the overlap collider will only detect colliders that have the "Ball" layer on it
        int polygonBallColliderCount = currentPlayerPolygonCollider.OverlapCollider(ballContactFilter, hitBallsFromPolygonCollider);

        //get player colliders hit by the circle hit collider stored as a list
        List <Collider2D> hitBallsFromCircleCollider = new List <Collider2D>();
        int circleBallColliderCount = currentPlayerCircleCollider.OverlapCollider(ballContactFilter, hitBallsFromCircleCollider);

        //get union of the above lists
        IEnumerable <Collider2D> unionOfBallHitBoxLists = hitBallsFromPolygonCollider.Union(hitBallsFromCircleCollider);

        //SEND FORCES OUTWARDS TO AFFECT BALL
        foreach (Collider2D ballCollider in unionOfBallHitBoxLists)
        {
            Vector2 direction = (ballCollider.transform.position - currentPlayerCircleCollider.transform.position);
            ballCollider.attachedRigidbody.AddForce(direction.normalized * hitStrengthMultiplier);
        }

        //COMMENCE ATTACK FREEZE - PREVENTS PLAYER FROM DOING ANYTHING ELSE UNTIL FREEZETIME IS OVER
        hitFreezeTime = Time.time + hitFreezeTimeIncrement;
    }
Exemple #8
0
 private void Start()
 {
     _shaker = GetComponent <Shaker>();
 }
 protected virtual void Start()
 {
     SetLockedLabelVisible(false);
     shaker = GetComponent <Shaker>();
     spriteRenderer.color = RoomShell.Instance.attackableColor;
 }
 private void Ressurect()
 {
     died           = false;
     Time.timeScale = 1f;
     Shaker.SetShakeLengthSpeed(0.2f, 40f);
 }
Exemple #11
0
 void Awake()
 {
     MainCameraShaker = this;
 }
Exemple #12
0
 void Start()
 {
     animator = GetComponent <Animator>();
     shaker   = GetComponent <Shaker>();
     velocity = minVelocity;
 }
Exemple #13
0
 // Start is called before the first frame update
 private void Start()
 {
     progressbar   = gameObject.GetComponentInChildren <ProgressBar>();
     ingCount.text = "0";
     shaker        = gameObject.GetComponentInParent <Shaker>();
 }
 // Use this for initialization
 void Start()
 {
     audioSource = GetComponent <AudioSource>();
     shaker      = GameObject.Find("CameraRig").GetComponent <Shaker>();
 }
Exemple #15
0
 // Use this for initialization
 void Start()
 {
     myShake = gameObject.GetComponent <Shaker>();
 }
Exemple #16
0
    void Start()
    {
        _scoreKeeper = GameObject.FindObjectOfType<ScoreKeeper> ();
        _particles = GameObject.FindObjectOfType<ParticleSystem> ();
        _shaker = GameObject.FindObjectOfType<Shaker> ();
        _successAudio = GameObject.Find ("Success SFX").GetComponent<AudioSource> ();
        _shrinkCurve = new AnimationCurve (new Keyframe (0, 1), new Keyframe (10000, 1), new Keyframe (10000 + (shrinkDuration * 0.1F), 1.25F), new Keyframe (10000 + shrinkDuration, 0));
        _numberOfRings = transform.childCount;
        _startTime = Time.time;
        _lastTriggerTime = 0;
        _save = FindObjectOfType <Save> ();

        SetTargetScaleMultiplier();
    }
Exemple #17
0
        protected override void Draw(GameTime gameTime)
        {
            GraphicsDevice.Clear(Color.CornflowerBlue);
            spriteBatch.Begin();
            //spriteBatch.DrawString(debugFont, debugstring1, new Vector2(10, 10), Color.Black);
            //spriteBatch.DrawString(debugFont, debugstring2, new Vector2(10, 40), Color.Black);
            //spriteBatch.DrawString(debugFont, debugstring3, new Vector2(10, 70), Color.Black);
            switch (CurrentGameState)
            {
            case GameState.MainMenu:
                //spriteBatch.DrawString(debugFont, gameTimeSinceStart.ToString(), new Vector2(10, 10), Color.Black);
                //spriteBatch.DrawString(debugFont, gameTimeSincePlaying.ToString(), new Vector2(10, 40), Color.Black);
                playBeatmapsButton.Draw(spriteBatch);
                createBeatmapsButton.Draw(spriteBatch);
                gameTimeSinceStart = (int)gameTime.TotalGameTime.TotalMilliseconds;
                break;

            case GameState.Playing:
                //gameTimeSincePlaying = (int)gameTime.TotalGameTime.TotalMilliseconds - gameTimeSinceStart;

                spriteBatch.DrawString(debugFont, PointGenerator.TotalPoints.ToString(), new Vector2(10, 10), Color.Black);
                spriteBatch.DrawString(debugFont, PointGenerator.Multiplicator, new Vector2(10, 30), Color.Black);
                //this.countShakersAndBeats();
                //spriteBatch.DrawString(debugFont, debugstring1, new Vector2(10, 50), Color.Black);
                //spriteBatch.DrawString(debugFont, debugstring2, new Vector2(10, 70), Color.Black);
                //spriteBatch.DrawString(debugFont, endTime.ToString(), new Vector2(10, 90), Color.Black);


                PointGenerator.Draw(spriteBatch, (int)MediaPlayer.PlayPosition.TotalMilliseconds);

                foreach (var kv in BeatDictionary.ToDictionary(kv => kv.Key, kv => kv.Value))
                {
                    if (kv.Key <= MediaPlayer.PlayPosition.TotalMilliseconds)
                    {
                        if (kv.Value.Identifier() == PlayObjectIdentifier.Shaker)
                        {
                            Shaker tempShaker = kv.Value as Shaker;
                            if ((tempShaker.Length + kv.Key) <= (int)MediaPlayer.PlayPosition.TotalMilliseconds)
                            {
                                BeatDictionary.Remove(kv.Key);
                                if (tempShaker.isComplete())
                                {
                                    PointGenerator.generatePointEffect(new Vector2(400f, 240f), PointEffectState.FullPoints, (int)MediaPlayer.PlayPosition.TotalMilliseconds);
                                }
                                else
                                {
                                    PointGenerator.generatePointEffect(new Vector2(400f, 240f), PointEffectState.ReducedPoints, (int)MediaPlayer.PlayPosition.TotalMilliseconds);
                                }
                                checkForEndOfSong();
                            }
                        }
                        else
                        {
                            ClickablePlayObject tempBeat = kv.Value as ClickablePlayObject;
                            if (!tempBeat.thisDraw)
                            {
                                BeatDictionary.Remove(kv.Key);
                                PointGenerator.generatePointEffect(tempBeat.Center, 2f, (int)MediaPlayer.PlayPosition.TotalMilliseconds);
                            }
                        }
                        kv.Value.Draw(spriteBatch);
                    }
                    else
                    {
                        break;
                    }
                }
                spriteBatch.DrawString(debugFont, MediaPlayer.PlayPosition.TotalMilliseconds.ToString(), new Vector2(10, 430), Color.Yellow);

                break;

            case GameState.BeatmapCreator:
                gameTimeSinceCreating = (int)gameTime.TotalGameTime.TotalMilliseconds - gameTimeSinceStart;
                returnToMainMenuButton.Draw(spriteBatch);
                //spriteBatch.DrawString(debugFont, MediaPlayer.PlayPosition.TotalMilliseconds.ToString(), new Vector2(10, 10), Color.Black);
                //spriteBatch.DrawString(debugFont, debugstring1, new Vector2(10, 30), Color.Black);
                //spriteBatch.DrawString(debugFont, debugstring2, new Vector2(10, 50), Color.Black);
                //spriteBatch.DrawString(debugFont, debugstring3, new Vector2(10, 70), Color.Black);
                break;


            case GameState.SaveMenu:

                break;

            case GameState.XMLLoadMenu:
                loadMenu.Draw(spriteBatch);
                break;

            case GameState.SongLoadMenu:
                loadMenu.Draw(spriteBatch);
                break;

            case GameState.ScoreMenu:
                returnToMainMenuButton.Draw(spriteBatch);
                spriteBatch.DrawString(scoreFont, "Final Score:", new Vector2(150, 200), Color.Red);
                spriteBatch.DrawString(scoreFont, PointGenerator.TotalPoints.ToString(), new Vector2(150, 300), Color.Red);
                break;
            }


            spriteBatch.End();
            base.Draw(gameTime);
        }
	// Use this for initialization
	void Start () {
        InputManager.WordFired += InputManager_WordFired;
        shaker = GetComponent<Shaker>();
	}
Exemple #19
0
 private void Start()
 {
     shaker = new Shaker();
     paramController.PlayerDamaged += Shaking;
 }
 void Start()
 {
     shaker = GameObject.FindGameObjectWithTag("ScreenShake").GetComponent <Shaker>();
 }
Exemple #21
0
    private void shoot()
    {
        float a = Input.GetAxis(joy + 3);
        float b = Input.GetAxis(joy + 4) * -1;

        shoot_direction = new Vector3(a, 0, b);
        shoot_direction.Normalize();

        if ((gameObject.tag == "male" && a < 0) || (gameObject.tag == "female" && a > 0))
        {
            if (bar_timer > bar_reload)
            {
                AtakZBara(shoot_direction);
                bar_timer = 0;
            }
        }
        else
        if (Mathf.Abs(a) + Mathf.Abs(b) > 0.8f)
        {
            if (w.shoot_timer > w.reload_weapon_timer)
            {
                moveArm(shoot_direction);

                if (cool_timer > cool)
                {
                    audio.PlayOneShot(clip);
                    cool_timer = 0;
                }


                float range = w.recoil;

                bullet.GetComponent <BulletBehaviour>().changeDmg(w.dmg);
                Vector3    v3        = new Vector3(Random.Range(-range, range), 0, Random.Range(-range, range));
                Vector3    direction = v3; //losowy wektor
                GameObject tmp       = null;

                float oneAngle    = w.shootingRange * 2 / (w.number_bullets - 1);
                float actualAngle = -1 * w.shootingRange;

                if (w.number_bullets == 1)
                {
                    direction = shoot_direction + v3;
                    tmp       = (GameObject)Instantiate(bullet, missile.transform.position, Quaternion.identity);
                    tmp.GetComponent <Rigidbody>().velocity = direction * w.bulletSpeed;
                }
                else
                {
                    for (int i = 0; i < w.number_bullets; i++)
                    {
                        Vector3 where = missile.transform.position;
                        Quaternion matrix = Quaternion.AngleAxis(actualAngle, Vector3.up);

                        direction = shoot_direction + v3;
                        direction = matrix * direction;

                        v3 = new Vector3(Random.Range(-range, range), 0, Random.Range(-range, range));

                        tmp = (GameObject)Instantiate(bullet, missile.transform.position + direction.normalized * 0.01f, Quaternion.identity);


                        tmp.GetComponent <Rigidbody>().velocity = direction * w.bulletSpeed;
                        actualAngle += oneAngle;
                    }
                }
                //Time.timeScale = 0;

                /*
                 * if (w.number_bullets > 1)
                 * {
                 *  for (int i = 0; i < w.number_bullets; i++)
                 *  {
                 *      GameObject tmp = (GameObject)Instantiate(bullet, missile.transform.position, Quaternion.identity);
                 *      Vector3 v4 = new Vector3((i / w.number_bullets) * 0.1f - 0.05f, 0, ((i / w.number_bullets) * 0.1f - 0.05f) * w.bulletSpeed);
                 *      tmp.GetComponent<Rigidbody>().velocity = (shoot_direction + v3 +v4)* w.bulletSpeed;
                 *  }
                 * }
                 * else
                 * {*/



                ScreenshakeManager Shaker;
                if (Shaker = Camera.main.GetComponent <ScreenshakeManager>())
                {
                    Shaker.Shake(0.08f, 0.07f);
                }
                KnockBack(shoot_direction);

                w.shoot_timer = 0;
            }
        }
        //else
        //audio.Stop();
    }
Exemple #22
0
 void Awake()
 {
     rb     = GetComponent <Rigidbody2D>();
     anim   = GetComponent <Animator>();
     shaker = GameObject.Find("Main Camera").GetComponent <Shaker>();
 }
Exemple #23
0
 /// <summary>
 /// Locates the components.
 /// </summary>
 void LocateComponents()
 {
     _rectTransform = GetComponent<RectTransform> ();
     scoreKeeper = GameObject.FindObjectOfType<ScoreKeeper> ();
     _particles = GameObject.FindObjectOfType<ParticleSystem> ();
     shaker = GameObject.FindObjectOfType<Shaker> ();
     _successAudio = GameObject.Find ("Success SFX").GetComponent<AudioSource> ();
 }
Exemple #24
0
 void Start()
 {
     monstersInMotel = new List <MonsterScript>();
     shaker          = GetComponent <Shaker>();
     loveParticles.Stop();
 }
Exemple #25
0
 public void UIShakeOnce()
 {
     Shaker.ShakeAllSeparate(shakeData, null, seed);
 }
    public void OnEnemyHit()
    {
        Shaker cameraShaker = GetMainCamera().GetComponent <Shaker>();

        cameraShaker.Shake(enemyDeathShakePreset);
    }
Exemple #27
0
        public SeekerBoss(Vector2 position) : base(position)
        {
            Depth        = -200;
            Collider     = physicsHitbox = new Hitbox(6f, 6f, -3f, -3f);
            attackHitbox = new Hitbox(12f, 8f, -6f, -2f);
            bounceHitbox = new Hitbox(16f, 6f, -8f, -8f);
            pushRadius   = new Circle(40f);
            Add(new PlayerCollider(OnAttackPlayer, attackHitbox));
            Add(new PlayerCollider(OnBouncePlayer, bounceHitbox));
            Add(shaker = new Shaker(false));
            Add(state  = new StateMachine());
            state.SetCallbacks(StateIdle, IdleUpdate);
            state.SetCallbacks(StateRegenerate, RegenerateUpdate, RegenerateCoroutine, RegenerateBegin, RegenerateEnd);
            Add(idleSineX = new SineWave(0.5f, 0.0f));
            Add(idleSineY = new SineWave(0.7f, 0.0f));
            Add(light     = new VertexLight(Color.White, 1f, 32, 64));
            Add(new MirrorReflection());
            IgnoreJumpThrus    = true;
            Add(sprite         = GFX.SpriteBank.Create("seeker"));
            sprite.OnLastFrame = f => {
                if (!flipAnimations.Contains(f) || spriteFacing == facing)
                {
                    return;
                }

                spriteFacing = facing;
                if (nextSprite != null)
                {
                    sprite.Play(nextSprite);
                    nextSprite = null;
                }
            };
            sprite.OnChange = (last, next) => {
                nextSprite = null;
                sprite.OnLastFrame(last);
            };
            scaleWiggler = Wiggler.Create(0.8f, 2f);
            Add(scaleWiggler);
            Add(boopedSfx = new SoundSource());
            Add(reviveSfx = new SoundSource());
            //原码到此
            spinnerPosition1  = position + new Vector2(0, 16);
            spinnerPosition2  = position + new Vector2(0, -16);
            spinnerPosition3  = position + new Vector2(16, 8);
            spinnerPosition4  = position + new Vector2(16, -8);
            spinnerPosition5  = position + new Vector2(-16, 8);
            spinnerPosition6  = position + new Vector2(-16, -8);
            switchPosition1   = position + new Vector2(-128, -64);
            switchPosition2   = position + new Vector2(-88, 64);
            switchPosition3   = position + new Vector2(128, -64);
            switchPosition4   = position + new Vector2(88, 64);
            gliderPosition    = position + new Vector2(40, -32);
            Add(chargeSfx     = new SoundSource());
            Add(laserSfx      = new SoundSource());
            pattern           = 0;
            gliderRespawnTime = 1.0f;
            switchAppearTime  = 0.0f;
            attackCoroutine   = new Coroutine(false);
            Add(attackCoroutine);
            attackCoroutine.Replace(Attack0Sequence());
        }
 public void ShakeScene(float speed, int level, int attenuation, int vector, int loopcount, bool isblocking)
 {
     Shaker.ShakeObject(mainuiPanel.gameObject, speed, level, attenuation, vector, loopcount, isblocking);
 }
 public static void PlayShake(Shake shake)
 {
     //Debug.Log(shake);
     Shaker.ShakeAll(GetShakePreset(shake));
 }
Exemple #30
0
 void Awake()
 {
     Instance         = this;
     startingRotation = transform.rotation;
 }
Exemple #31
0
        public void ShakeSolution_ValidInput(string targetSolution, IEnumerable <string> expected)
        {
            IEnumerable <string> actual = Shaker.ShakeSolution(targetSolution);

            Assert.That(actual, Is.EquivalentTo(expected));
        }