Exemple #1
0
    public override void HandleStart()
    {
        mDurationTime = 3f;
        nameState     = "Surprise!";
        mStateID      = 3;
        mBulletType   = BulletSpawner.eBulletType.Normal;

        CameraAnimation.Shake();

        mExtraEnemy.SetActive(true);
        float   minDistance         = float.PositiveInfinity;
        Vector3 spawnPosition       = Vector3.zero;
        float   minDistanceToPlayer = Mathf.Max(mPlayer.GetComponent <SpriteRenderer>().bounds.size.x, mPlayer.GetComponent <SpriteRenderer>().bounds.size.y) +
                                      Mathf.Max(mExtraEnemy.GetComponent <SpriteRenderer>().bounds.size.x, mExtraEnemy.GetComponent <SpriteRenderer>().bounds.size.y);

        foreach (Vector3 position in mSpawnPoints)
        {
            float currentPositionDistance = Vector3.Distance(mPlayer.transform.position, position);
            if (currentPositionDistance < minDistance && currentPositionDistance > minDistanceToPlayer)
            {
                minDistance   = currentPositionDistance;
                spawnPosition = position;
            }
        }
        mExtraEnemy.transform.position = spawnPosition;

        mLastTimeShootedExtraEnemy = Time.time;

        mAppearAudio.Play();

        base.BasicStart();
    }
 void OnCollisionEnter2D(Collision2D aCollision)
 {
     if (aCollision.gameObject.tag == BulletTag || aCollision.gameObject.tag == EnemyTag)
     {
         CameraAnimation.Shake();
         if (mCanDie)
         {
             GameManagerSC.GoToGameState(GameManagerSC.GameState.NotPlaying);
         }
     }
 }
Exemple #3
0
    public override void StateFixedUpdate()
    {
        base.Move();
        base.ShootingManager();

        if (Time.time - mLastTimeShootedExtraEnemy > mTimeBetweenShootingExtraEnemy)
        {
            mLastTimeShootedExtraEnemy = Time.time;
            mShootCoroutines.Add(StartCoroutine(ShootBurst()));
            CameraAnimation.Shake(0.03f, mBulletsPerShootingExtraEnemy * mTimeBetweenBulletExtraEnemy);
        }
    }
 void OnTriggerEnter2D(Collider2D aCollision)
 {
     if (aCollision.gameObject.CompareTag(BulletTag))
     {
         Destroy(aCollision.gameObject);
         Destroy(this.gameObject);
     }
     else if (aCollision.gameObject.CompareTag(ObstacleTag) || aCollision.gameObject.CompareTag(EnemyTag))
     {
         Destroy(this.gameObject);
     }
     mCristalAudio.pitch = Random.Range(0.9f, 1.1f);
     mCristalAudio.Play();
     CameraAnimation.Shake(0.03f, 0.1f);
 }
    // Update is called once per frame
    public void OnInputEventShield(InputAction.CallbackContext context)
    {
        if (CanGenerateShield())
        {
            ResetShield();

            mEquipShieldAudio.Play();
            CameraAnimation.Shake(0.08f, 0.09f);

            float shielRadius    = Mathf.Max(gameObject.GetComponent <SpriteRenderer>().bounds.size.x, gameObject.GetComponent <SpriteRenderer>().bounds.size.y) + mRadiusFromGameObject;
            float angleIncrement = (2.0f * Mathf.PI) / mPartsNum;
            for (int part = 0; part < mPartsNum; ++part)
            {
                Vector3    offset     = shielRadius * new Vector3(Mathf.Cos(angleIncrement * part), Mathf.Sin(angleIncrement * part), 0.0f);
                GameObject shieldPart = Instantiate(mPrefab, gameObject.transform.position + offset, Quaternion.identity);
                shieldPart.transform.parent = gameObject.transform;
                mParts.Add(shieldPart);
            }

            StartShieldCooldown();
        }
    }