コード例 #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
ファイル: Clinga.cs プロジェクト: BATzerk/Unity-BounceMeister
 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));
 }