Пример #1
0
        public void Push(T gameObject)
        {
            if (_active.Count == 0)
            {
                // or throw exception?
                return;
            }

            var index = _active.IndexOf(gameObject);

            if (index < 0)
            {
                return;           // or throw exception?
            }
            var item = _active[index];

            item.gameObject.SetActive(false);
            _active.RemoveAt(index);
            _inactive.Add(item);
            OnPushed?.Invoke(item);
        }
Пример #2
0
        private void Update()
        {
            if (Input.GetMouseButtonDown(0))
            {
                RaycastHit hit;
                Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);

                if (Physics.Raycast(ray, out hit, 100f, _hitMask))
                {
                    if (hit.collider != null &&
                        hit.collider == _collider)
                    {
                        _isPushed = true;
                        if (OnPushed != null)
                        {
                            OnPushed.Invoke();
                        }
                    }
                }
            }
        }
Пример #3
0
 public void Pushed(Vector3 direction)
 {
     OnPushed?.Invoke(direction);
 }