コード例 #1
0
 private void TakeTrashCall(TrashModel trashModel)
 {
     if (TakeTrashEvent != null)
     {
         TakeTrashEvent.Invoke(trashModel);
     }
 }
コード例 #2
0
        /// <summary>
        /// Accepts reports of the fact of drop garbage out of hand.
        /// </summary>
        /// <param name="trash"></param>
        public void DropTrash(TrashModel trash)
        {
            if (trash == CurrentTrash)
            {
                Destroy(_currentTrashJoint);
                CurrentTrash = null;

                //check if the tuoch position is on garbage can
                RaycastHit hitInfo;
                var        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
                if (Physics.Raycast(ray, out hitInfo, Mathf.Infinity, _garbageTankLayer))
                {
                    var garbageCanModel = hitInfo.transform.GetComponentInParent <GarbageTankModel>();
                    //is there a GarbageTankModel component in the object? If is, is the garbage equals the trash can.
                    if (garbageCanModel && garbageCanModel.GarbageTankColor == trash.GarbageTankColor)
                    {
                        //throw garbage in the tank
                        trash.Rigidbody.velocity = Helper.Physics.PassToPosition(trash.Rigidbody,
                                                                                 garbageCanModel.CenterCast.position);
                    }
                    else
                    {
                        DropTrashCall(trash);
                    }
                }
                else
                {
                    DropTrashCall(trash);
                }
            }
            else
            {
                Debug.LogError(Const.LogicError);
            }
        }
コード例 #3
0
 private void DropTrashCall(TrashModel trashModel)
 {
     if (DropTrashEvent != null)
     {
         DropTrashEvent.Invoke(trashModel);
     }
 }
コード例 #4
0
ファイル: TrashCtrl.cs プロジェクト: wivanw/BidOnTest
        private void Awake()
        {
            var view = GetComponent <TouchView>();

            view.IsTakeEvent    += IsTake;
            view.MouseDragEvent += MouseDrag;

            _model = GetComponent <TrashModel>();
        }
コード例 #5
0
ファイル: GarbageTankCtrl.cs プロジェクト: wivanw/BidOnTest
 /// <summary>
 /// It works when the garbage touches the garbage tank inside.
 /// Starts the closing animation garbage tank.
 /// Increases the amount of garbage count.
 /// </summary>
 /// <param name="trash">Garbage model</param>
 private void TrashTrigger(TrashModel trash)
 {
     if (!Controller.TouchManager.CurrentTrash)
     {
         _model.Animator.SetBool(Const.IsOpen, false);
         if (!trash.IsInGarbageCan)
         {
             _model.AddTrash();
             AddTrashEvent.Invoke(_model);
         }
         trash.IsInGarbageCan = true;
     }
 }
コード例 #6
0
        /// <summary>
        /// Accepts reports of the fact of taking garbage in hand.
        /// Attaches a physical joint to the garbage object to control the movement of garbage.
        /// </summary>
        /// <param name="trash"></param>
        public void TakeTrash(TrashModel trash)
        {
            Vector3 castPos;

            if (Helper.RayCast.ScreenMouseToRay(_trashLayer, out castPos))
            {
                CurrentTrash = trash;
                TakeTrashCall(CurrentTrash);
                _currentTrashJoint = Helper.Physics.InitTakeJoint(
                    CurrentTrash.gameObject.AddComponent <ConfigurableJoint>());
                _currentTrashJoint.anchor = CurrentTrash.Transform.InverseTransformPoint(castPos);
            }
        }
コード例 #7
0
ファイル: GarbageTankCtrl.cs プロジェクト: wivanw/BidOnTest
 /// <summary>
 /// It works when the trash take in hand.
 /// Starts the opening/closing animation garbage tank.
 /// </summary>
 /// <param name="trashModel">Garbage model</param>
 private void TakeTrash(TrashModel trashModel)
 {
     if (trashModel.GarbageTankColor == _model.GarbageTankColor)
     {
         if (!_model.IsTrashFull)
         {
             _model.Animator.SetBool(Const.IsOpen, true);
         }
     }
     else
     {
         _model.Animator.SetBool(Const.IsOpen, false);
     }
 }
コード例 #8
0
ファイル: AudioCtrl.cs プロジェクト: wivanw/BidOnTest
 /// <summary>
 /// Play take trash audio.
 /// </summary>
 /// <param name="trashModel"></param>
 private static void TakeTrash(TrashModel trashModel)
 {
     AudioSource.PlayClipAtPoint(Model.Audio.TakeTrashClip, trashModel.Transform.position);
 }
コード例 #9
0
ファイル: GarbageTankCtrl.cs プロジェクト: wivanw/BidOnTest
 /// <summary>
 /// It works when the garbage drop out of hand.
 /// Starts the closing animation garbage tank.
 /// </summary>
 /// <param name="trashModel">Garbage model</param>
 private void DropTrash(TrashModel trashModel)
 {
     _model.Animator.SetBool(Const.IsOpen, false);
 }