예제 #1
0
        protected override void Awake()
        {
            base.Awake();

            _animator     = InstanseObject.GetComponent <Animator>();
            _playingSound = InstanseObject.GetComponent <PlayingSound>();
        }
예제 #2
0
        /// <summary>
        /// Отключение стрелы после использования
        /// </summary>
        private IEnumerator TurnOffObject()
        {
            yield return(new WaitForSeconds(1.5f));

            Transform.localEulerAngles = Vector3.zero;
            InstanseObject.SetActive(false);
        }
예제 #3
0
        /// <summary>
        /// Действия при касании персонажа с коллайдером
        /// </summary>
        /// <param name="character">персонаж</param>
        public override void ActionsOnEnter(Character character)
        {
            character.SetSound(Character.Sounds.Coin);
            character.PlayingSound.PlaySound();

            Main.Instance.Coins++;

            InstanseObject.SetActive(false);
        }
예제 #4
0
        protected override void Awake()
        {
            base.Awake();

            _boxcollider = InstanseObject.GetComponent <BoxCollider2D>();
            _rigidbody   = InstanseObject.GetComponent <Rigidbody2D>();
            _joint       = InstanseObject.GetComponent <FixedJoint2D>();

            _sortingOrder = SpriteRenderer.sortingOrder;
        }
예제 #5
0
        public override void ActionsOnEnter(Character character)
        {
            character.SetSound(Character.Sounds.Brain);
            character.PlayingSound.PlaySound();

            GameManager.Instance.Brains--;
            UpdateQuantityBrains();

            InstanseObject.SetActive(false);
        }
예제 #6
0
        /// <summary>
        /// Действия при касании персонажа с коллайдером
        /// </summary>
        /// <param name="character">персонаж</param>
        public override void ActionsOnEnter(Character character)
        {
            character.SetSound(Character.Sounds.Brain);
            character.PlayingSound.PlaySound();

            // Уменьшаем количество мозгов
            Main.Instance.Brains--;
            UpdateQuantityBrains();

            InstanseObject.SetActive(false);
        }
예제 #7
0
        /// <summary>
        /// Уничтожение бочки
        /// </summary>
        public void DestroyBarrel()
        {
            _destruction.transform.position = Transform.position;

            if (_destruction.enabled == false)
            {
                _destruction.enabled = true;
            }
            _destruction.Rebind();

            PlayerPrefs.SetInt("barrel", PlayerPrefs.GetInt("barrel") + 1);
            InstanseObject.SetActive(false);
        }
        /// <summary>
        /// Уничтожение бочки
        /// </summary>
        public void DestroyBarrel()
        {
            _destruction.transform.position = Transform.position;

            // Перезапускаем анимацию взрыва
            if (_destruction.enabled == false)
            {
                _destruction.enabled = true;
            }
            _destruction.Rebind();

            // Увеличиваем число уничтоженных бочек
            PlayerPrefs.SetInt("barrel", PlayerPrefs.GetInt("barrel") + 1);

            InstanseObject.SetActive(false);
        }
예제 #9
0
        protected override void OnTriggerEnter2D(Collider2D collision)
        {
            base.OnTriggerEnter2D(collision);

            // Если стрела касается поверхности
            if (collision.gameObject.layer == (LayerMask.GetMask("Surface") >> 5))
            {
                _boxcollider.enabled = false;
                SpriteRenderer.sortingOrder--;

                // Пробуем получить физический компонент у поверхности
                var physics = collision.gameObject.GetComponent <Rigidbody2D>();

                if (physics)
                {
                    _rigidbody.mass      = 0;
                    _joint.connectedBody = physics;
                }

                // Если стрела активна
                if (InstanseObject.activeInHierarchy)
                {
                    // Запускаем ее остановку
                    _ = StartCoroutine(StopFlight(0.03f, physics));
                }

                return;
            }

            // Если стрела попадает в другое препятствие
            if (collision.gameObject.GetComponent <SharpObstacles>())
            {
                InstanseObject.SetActive(false);
                return;
            }

            // Если стрела попала в реку
            if (collision.gameObject.GetComponent <River>())
            {
                _speed /= 2;
            }
        }
예제 #10
0
        protected override void OnTriggerEnter2D(Collider2D collision)
        {
            base.OnTriggerEnter2D(collision);

            if (collision.gameObject.layer == (LayerMask.GetMask("Surface") >> 5))
            {
                _boxcollider.enabled = false;
                SpriteRenderer.sortingOrder--;

                var physics = collision.gameObject.GetComponent <Rigidbody2D>();

                if (physics)
                {
                    _rigidbody.mass      = 0;
                    _joint.connectedBody = physics;
                }

                if (InstanseObject.activeInHierarchy)
                {
                    _ = StartCoroutine(StopFlight(0.03f, physics));
                }

                return;
            }

            if (collision.gameObject.GetComponent <SharpObstacles>())
            {
                InstanseObject.SetActive(false);
                return;
            }

            if (collision.gameObject.GetComponent <River>())
            {
                _speed /= 2;
            }
        }
 protected virtual void Awake()
 {
     InstanseObject = gameObject;
     Transform      = InstanseObject.transform;
     SpriteRenderer = InstanseObject.GetComponent <SpriteRenderer>();
 }
 protected override void Awake()
 {
     base.Awake();
     Rigidbody = InstanseObject.GetComponent <Rigidbody2D>();
 }