/// <summary>
        /// Handle the raycastHits to check if one of them touch something
        /// </summary>
        /// <param name="hits">The list of RaycastHits to check</param>
        /// <param name="isOver">the BoolVariable to set if something got hit</param>
        /// <param name="hitPoint">The Hit Point where the raycast collide</param>
        /// <param name="objectOver">The GameEvent to raise with the transform of the hit</param>
        private void HandleOver(List <RaycastHit> hits, BoolVariable isOver, RaycastHitVariable hitPoint, GameEventTransform objectOver)
        {
            //If nothing is hit, we set the hasHit value to false
            if (hits.Count == 0)
            {
                isOver.SetValue(false);
            }
            else
            {
                foreach (var hit in hits)
                {
                    // If something is hit and is not from the Exclusion layer, we set everything and return
                    if (hit.collider.gameObject.layer != pointerRayCast.ExclusionLayer)
                    {
                        var hitTransform = hit.collider.transform;

                        isOver.SetValue(true);

                        hitPoint.SetValue(hit);
                        objectOver.Raise(hitTransform);
                        return;
                    }
                    //If the only hit was on the exclusion layer, we set the hasHit value to false
                    else
                    {
                        isOver.SetValue(false);
                    }
                }
            }
        }
Beispiel #2
0
 public void loseHealth(int health)
 {
     life -= health;
     if (life <= 0)
     {
         enemyDead.Raise(this.transform);
         GameObject.Destroy(this.gameObject);
     }
 }
Beispiel #3
0
        /// <summary>
        /// Handle the raycastHits to check if one object was clicked
        /// </summary>
        /// <param name="hits">The list of RaycastHits to check</param>
        /// <param name="hasClicked">the BoolVariable to set if something got clicked</param>
        /// <param name="objectClicked">The GameEvent to raise with the transform of the hit</param>
        private void HandleClick(List <RaycastHit> hits, BoolVariable hasClicked, GameEventTransform objectClicked)
        {
            foreach (var hit in hits)
            {
                if (hit.collider.gameObject.layer != pointerRayCast.ExclusionLayer)
                {
                    var hitTransform = hit.collider.transform;

                    hasClicked.SetValue(true);

                    objectClicked.Raise(hitTransform);
                    return;
                }
            }
        }
Beispiel #4
0
 /// <summary>
 /// Handle the raycastHits to check if one object was clicked
 /// </summary>
 /// <param name="hits">The list of RaycastHits to check</param>
 /// <param name="hasClicked">the BoolVariable to set if something got clicked</param>
 /// <param name="objectClicked">The GameEvent to raise with the transform of the hit</param>
 private void HandleClick(RaycastHitVariable hit, BoolVariable hasClicked, GameEventTransform objectClickedEvent)
 {
     //If nothing is hit, we set the isOver value to false
     if (hit.isNull)
     {
         hasClicked.SetValue(false);
     }
     else
     {
         if (hit.Value.collider != null)
         {
             hasClicked.SetValue(true);
             objectClickedEvent.Raise(hit.Value.collider.transform);
         }
     }
 }
        /// <summary>
        /// Handle the raycastHits to check if one of them touch something
        /// </summary>
        /// <param name="isOver">the BoolVariable to set if something got hit</param>
        /// <param name="hit">The Hit Point where the raycast collide</param>
        /// <param name="objectOver">The GameEvent to raise with the transform of the hit</param>
        private void HandleOver(BoolVariable isOver, RaycastHitVariable hit, GameEventTransform objectOver)
        {
            //If nothing is hit, we set the isOver value to false
            if (hit.isNull)
            {
                isOver.SetValue(false);
            }
            else
            {
                if (hit.Value.collider != null)
                {
                    var hitTransform = hit.Value.collider.transform;
                    objectOver.Raise(hitTransform);

                    isOver.SetValue(true);
                }
            }
        }