예제 #1
0
        private void OnCollisionEnter(Collision other)
        {
            bool interaction = LayerUtils.IsLayer(other.gameObject.layer, interactionMask);

            if (!interaction)
            {
                return;
            }

            OnCollision?.Invoke(other.gameObject);
        }
예제 #2
0
        public virtual bool IsValidMove(MovementInstruction instruction, int?entityLayer = null)
        {
            Vector2Int   target = GetCartesianPosition() + instruction.Direction;
            AbstractTile tile   = grid.GetTile(target);

            int layer = entityLayer ?? gameObject.layer;

            if (tile == null)
            {
                return(false);
            }

            Debug.Log(tile.transform.position);

            return(LayerUtils.IsLayer(layer, tile.entityWhiteList));
        }
예제 #3
0
 // ----------------------------------------------------------------
 //  Physics Events
 // ----------------------------------------------------------------
 private void OnTriggerEnter2D(Collider2D coll)
 {
     // IGNORE all collsions for first moment after birth.
     if (timeUntilDie > MaxLifetime - 0.1f)
     {
         return;
     }
     if (coll.isTrigger)
     {
         return;
     }                               // Ignore if THEY're a trigger too (i.e. DispGround and ToggleGround).
     // Ground?? Die!
     if (LayerUtils.IsLayer(coll.gameObject, Layers.Ground))
     {
         Die();
     }
 }
예제 #4
0
 private bool MayCling(Collider2D col)
 {
     // We may only cling to Ground or Platforms.
     return(LayerUtils.IsLayer(col.gameObject, Layers.Ground) ||
            LayerUtils.IsLayer(col.gameObject, Layers.Platform));
 }