Example #1
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.tag == "Player")
        {
            numSegmentsIn += 1;

            switch (roomData.roomType)
            {
            case RoomType.normal:
                if (numSegmentsIn > 0 && !didPlayerEnter)
                {
                    didPlayerEnter = true;
                    //Debug.Log("Player entered room type " + roomData.roomType);

                    isInCombat = true;
                }
                break;

            case RoomType.challenge:
            case RoomType.boss:

                if (numSegmentsIn == Player.body.Length && !didPlayerEnter)
                {
                    didPlayerEnter = true;
                    //Debug.Log("Player entered room type " + roomData.roomType);

                    isInCombat = true;
                    SetDoorIsClosed(true);
                }
                break;
            }

            if (!didFog)
            {
                didFog = true;
                if (Fog.isActive)
                {
                    Vector3    pPos  = Player.GetHead().transform.position;
                    Vector3Int start = new Vector3Int((int)pPos.x, (int)pPos.y, 0);
                    Vector3Int min   = new Vector3Int((int)transform.position.x, (int)transform.position.y, 0);
                    Vector3Int max   = min + new Vector3Int(roomData.width, roomData.height, 0);
                    Fog.Flood(start, min, max);
                }
            }
        }
    }