2024-04-06 11:59:18 +08:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using Game.Player;
|
|
|
|
|
using Sirenix.OdinInspector;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
namespace Game.Room
|
2024-04-06 11:59:18 +08:00
|
|
|
|
{
|
2024-04-07 17:20:48 +08:00
|
|
|
|
public class RoomInfo : MonoBehaviour
|
2024-04-06 11:59:18 +08:00
|
|
|
|
{
|
2024-04-07 17:20:48 +08:00
|
|
|
|
[SerializeField] [ReadOnly] private IRoom _room;
|
|
|
|
|
[SerializeField] [ReadOnly] private Vector2 room_LeftDown;
|
|
|
|
|
[SerializeField] [ReadOnly] private Vector2 room_RightUp;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
[ShowInInspector]
|
|
|
|
|
private Transform left
|
|
|
|
|
{
|
|
|
|
|
set => this.room_LeftDown = value.position;
|
|
|
|
|
get => null;
|
|
|
|
|
}
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
[ShowInInspector]
|
|
|
|
|
private Transform right
|
|
|
|
|
{
|
|
|
|
|
set => this.room_RightUp = value.position;
|
|
|
|
|
get => null;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-08 18:20:55 +08:00
|
|
|
|
public RoomType roomType => this._room.roomType;
|
|
|
|
|
public Vector2 room_Center => transform.position;
|
|
|
|
|
|
|
|
|
|
public void SetRoom(IRoom room)
|
|
|
|
|
{
|
|
|
|
|
this._room = room;
|
|
|
|
|
}
|
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
public Vector2 GetJoinPosition()
|
|
|
|
|
{
|
|
|
|
|
var vector2 = this.room_RightUp - this.room_LeftDown;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
Vector2 vec = new Vector2(Random.Range(0, vector2.x), Random.Range(0, vector2.y));
|
|
|
|
|
vec += this.room_LeftDown;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
return vec;
|
|
|
|
|
}
|
2024-04-06 11:59:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|