Frame/Assets/Scripts/Room/RoomInfo.cs

60 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using Game.Player;
using Sirenix.OdinInspector;
using UnityEngine;
using Random = UnityEngine.Random;
namespace Game.Room
{
public class RoomInfo : MonoBehaviour
{
[SerializeField] [ReadOnly] private IRoom _room;
[SerializeField] [ReadOnly] private Vector2 room_LeftDown;
[SerializeField] [ReadOnly] private Vector2 room_RightUp;
[SerializeField] private SpriteRenderer _renderer;
[ShowInInspector]
private Transform left
{
set => this.room_LeftDown = value.position;
get => null;
}
[ShowInInspector]
private Transform right
{
set => this.room_RightUp = value.position;
get => null;
}
public RoomType roomType => this._room.roomType;
public Vector2 room_Center => transform.position;
private void Awake()
{
_renderer = this.GetComponent<SpriteRenderer>();
this._renderer.enabled = false;
}
public void SetRoom(IRoom room)
{
this._room = room;
}
public Vector2 GetJoinPosition()
{
var vector2 = this.room_RightUp - this.room_LeftDown;
Vector2 vec = new Vector2(Random.Range(0, vector2.x), Random.Range(0, vector2.y));
vec += this.room_LeftDown;
return vec;
}
public void SetSelect(bool isSelected)
{
_renderer.enabled = isSelected;
}
}
}