Ejemplo n.º 1
0
 void Awake()
 {
     duration_  = duration.Value;
     magnitude_ = magnitude.Value;
     instance   = this;
     ShakeBehaviour.isShaking = false;
 }
Ejemplo n.º 2
0
 private void OnTriggerStay2D(Collider2D other)
 {
     if (other.gameObject.name == "Enemy")
     {
         //ShakeBehaviour.shakeDuration = 1;
         shakeData = GameObject.Find("Main Camera").GetComponent <ShakeBehaviour>();
         shakeData.shakeDuration = 1;
     }
 }
Ejemplo n.º 3
0
    private void Awake()
    {
        instance = this;

        if (transform == null)
        {
            transform = GetComponent(typeof(Transform)) as Transform;
        }
    }
Ejemplo n.º 4
0
 // Update is called once per frame
 void Update()
 {
     if (AbilitiesInput.EarthQuakeDestroy == true)
     {
         //AbilitiesInput.EarthQuakeDestroy = false;
         Destroy(gameObject);
         ShakeBehaviour.StopShake();
     }
     QuakeCollider.radius += GrowthRate * Time.deltaTime;                                                                                                            //öka storleken på jordbävning lite varje frame
 }
Ejemplo n.º 5
0
    private CircleCollider2D QuakeCollider;                                                                                                             //variabel för att kunna komma åt collidern på objektet
    // Start is called before the first frame update
    void Start()
    {
        QuakeCollider = GetComponent <CircleCollider2D>();                                                                                              //tar den collidern vi vill göra saker med

        if (ShakeBehaviour.isShaking == false)                                                                                                          //ser till så att kameran inte redan skakar
        {
            ShakeBehaviour.Shake(ShakeDuration, ShakeMagnitude);                                                                                        //startar skaka skärmen med längden och styrkan som sätts i unity
        }
        EventManager.TriggerEvent("Earthquake");
        Instantiate(Cracks, new Vector3(transform.position.x, transform.position.y), Quaternion.identity);
    }
Ejemplo n.º 6
0
    public static bool isShaking;                                                                                                          //variabel som säger iffal skärmen redan skakar


    void Awake()
    {
        instance = this;                                                                                                                   //instance är just det här scriptet
        ShakeBehaviour.isShaking = false;                                                                                                  //skärmen skaks inte till att börja med
        cameras = new List <Camera>();                                                                                                     //ger en tom lista
        for (int i = 0; i < Camera.allCameras.Length - 1; i++)
        {
            instance.cameras.Add(Camera.allCameras[i]);
            if (instance.cameras[i].tag != "MainCamera")
            {
                instance.cameras.RemoveAt(i);
            }
        }
    }
Ejemplo n.º 7
0
    void Update()
    {
        if (SecondScore < Time.time && AssistantBehaviour.Tutorial == false)
        {
            ScoreManaging.AddScore(1);
            SecondScore = Time.time + 1;
        }
        if (ProgressBar.fillAmount < 0.60f)
        {
            Bar.color = Stage01;
        }
        if (ProgressBar.fillAmount > 0.60f && ProgressBar.fillAmount < 0.75f)
        {
            Bar.color = Stage02;
        }
        if (ProgressBar.fillAmount > 0.75f)
        {
            Bar.color = Stage03;
        }

        if (DEVSWITCH == false)
        {
            ProgressBar.fillAmount = ProgressPool;
            if (ProgressPool >= 1)
            {
                DestoryDisasters();
                ShakeBehaviour.StopShake();
                PlayerWin      = false;
                GameEnd        = true;
                Time.timeScale = 0;
                StartCoroutine(switchScene());
            }
            if (ProgressPool < 0)
            {
                DestoryDisasters();
                ShakeBehaviour.StopShake();
                if (added == false)
                {
                    ScoreManaging.AddScore(5000);
                    added = true;
                }
                PlayerWin      = true;
                GameEnd        = true;
                Time.timeScale = 0;
                StartCoroutine(switchScene());
            }
        }
    }
Ejemplo n.º 8
0
    void OnTriggerEnter2D(Collider2D col)
    {
        DamageDealer damageDealer = col.gameObject.GetComponent <DamageDealer>();

        if (damageDealer != null)
        {
            //Debug.Log(damageType.name + " hit: " + damageDealer.damageType.name);
            if (col.CompareTag("Shield") && gameObject.CompareTag("Bullet"))
            {
                var particle = col.GetComponentInChildren <ParticleSystem>();
                if (particle != null)
                {
                    particle.transform.position = gameObject.transform.position;
                    particle.Play();
                }

                Destroy(gameObject);
                return;
            }

            if (damageDealer.damageType.TakesDamageFrom.Contains(damageType))
            {
                col.gameObject.GetComponent <Stats>().DealDamage(DamageAmount.Value);

                if (!gameObject.CompareTag("Alien"))
                {
                    if (damageType.name == "Enemy")
                    {
                        ShakeBehaviour.Shake();
                    }

                    if (!gameObject.CompareTag("Fireball"))
                    {
                        Destroy(gameObject);
                    }
                }
            }
        }
    }
Ejemplo n.º 9
0
        // Update is called once per frame

        void Awake()
        {
            //singleton pattern
            if (_instance != null && _instance != this)
            {
                Destroy(this.gameObject);
            }
            else
            {
                _instance = this;
            }

            minPosition = transform.position.x;
            //maxPosition = -35f;                         //hard-coded values, oof, but (camera.transform.position.x + Screen.Width/2) should NOT exceed wall1.transform.position.x;
            maxPosition = 40f; //Currently Fidel's last position

            minMaxDistance = Mathf.Abs(minPosition - maxPosition);

            vertExtent = Camera.main.orthographicSize;
            horzExtent = vertExtent * Screen.width / Screen.height;

            shakeScript = this.gameObject.GetComponent <ShakeBehaviour>();
        }
Ejemplo n.º 10
0
    // Start is called before the first frame update
    void Start()
    {
        //set starting position
        transform.position = new Vector3(0, _minPosY, 0);

        _currAmmo = _maxAmmo;

        _isTripleLaserActive = false;
        _isShieldActive      = false;

        //find gameobject then get component
        _spawnManager = GameObject.Find("Spawn_Manager").GetComponent <SpawnManager>();
        _uIManager    = GameObject.FindObjectOfType <Canvas>().GetComponent <UIManager>();
        _camera       = GameObject.FindObjectOfType <Camera>().GetComponent <ShakeBehaviour>();
        _animator     = GetComponent <Animator>();
        _audioSource  = GetComponent <AudioSource>();
        _thruster     = GameObject.Find("Player/Thruster");
        _shield       = GameObject.Find("Player/Shield");
        _shieldSprite = _shield.GetComponent <SpriteRenderer>();
        _shield.SetActive(false);

        _leftEngine  = GameObject.Find("Left_Engine");
        _rightEngine = GameObject.Find("Right_Engine");
        _leftEngine.SetActive(false);
        _rightEngine.SetActive(false);

        //UI
        _uIManager.UpdateUIAmmo(_currAmmo, _maxAmmo);

        //null checks
        if (_animator == null)
        {
            Debug.LogError("Player.animator is NULL");
        }
        if (_thruster == null)
        {
            Debug.LogError("Player.thruster is NULL");
        }
        if (_camera == null)
        {
            Debug.LogError("Player.camera is NULL");
        }
        if (_uIManager == null)
        {
            Debug.LogError("Player.uimanager is NULL");
        }
        if (_spawnManager == null)
        {
            Debug.LogError("Player.spawn manager is NULL");
        }
        if (_shield == null)
        {
            Debug.LogError("Player.shield is NULL");
        }
        if (_shieldSprite == null)
        {
            Debug.LogError("Player.shieldSprite is NULL");
        }
        if (LaserPrefab == null)
        {
            Debug.LogError("Player.Laserprefab is NULL");
        }
        if (LaserTriplePrefab == null)
        {
            Debug.LogError("Player.LaserTriplePrefab is NULL");
        }

        if (_audioSource == null)
        {
            Debug.LogError("Player.audiosource is NULL");
        }
        else
        {
            _audioSource.clip = _laserAudioClip;
        }
    }
Ejemplo n.º 11
0
 // Start is called before the first frame update
 void Start()
 {
     ShakeBehaviour.Shake();
 }
Ejemplo n.º 12
0
 void Start()
 {
     AI_Script     = FindObjectOfType <AITest>();
     Player_Script = FindObjectOfType <PlayerController>();
     ScreenShake   = FindObjectOfType <ShakeBehaviour>();
 }
 private void Awake()
 {
     _shaker = FindObjectOfType <ShakeBehaviour>();
     _music  = FindObjectOfType <MusicManager>();
     NoiseManager.AddAudioSource(this.gameObject);
 }
Ejemplo n.º 14
0
 private void Awake()
 {
     _shakeBehaviour = Camera.main.GetComponent <ShakeBehaviour>();
 }