예제 #1
0
 /// <summary>
 /// Freeze object in space for a limited time.
 /// </summary>
 /// <param name="binding">Object that will be bound.</param>
 private void Bind(GameObject binding)
 {
     base.Hit();
     _boundObj = binding;
     if (_brambledDict.ContainsKey(binding.GetInstanceID()))
     {
         _brambledDict[binding.GetInstanceID()].ResetTime(bindTime);
     }
     else
     {
         //add to dict
         var newNode = new BrambledNode(binding, _bindTime);
         _myNode = newNode;
         _brambledDict.Add(binding.GetInstanceID(), newNode);
         //extract interface
         var inter = (IBrambleable)binding.GetComponents(typeof(Component)).First(c => c is IBrambleable);
         if (inter != null)
         {
             inter.Bramble(true);
         }
         else if (TryGetComponent <Rigidbody>(out var rb))
         {
             rb.isKinematic = true;
         }
     }
 }
예제 #2
0
 /// <summary>
 /// Handle memory of Node in case it still exists.
 /// </summary>
 private void OnDestroy()
 {
     if (_myNode != null)
     {
         _brambledDict.Remove(_myNode.instanceID);
         _myNode = null;
     }
 }
예제 #3
0
    private void Update()
    {
        if (_myNode == null)
        {
            return;
        }

        if (!_myNode.isTimeUp)
        {
            _myNode.DecrementTimer();
        }
        else
        {
            _myNode = null;
        }
    }
예제 #4
0
    } // end BrambledNode

    protected override void Awake()
    {
        _myNode = null;
        base.Awake();
    }