2024-04-09 13:22:52 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
2024-04-10 16:18:32 +08:00
|
|
|
|
using System.Globalization;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
using Game.Player;
|
|
|
|
|
using Sirenix.OdinInspector;
|
2024-04-10 16:18:32 +08:00
|
|
|
|
using TMPro;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
using UnityEngine;
|
2024-04-09 13:22:52 +08:00
|
|
|
|
using Random = UnityEngine.Random;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-07 17:20:48 +08:00
|
|
|
|
namespace Game.Room
|
2024-04-06 11:59:18 +08:00
|
|
|
|
{
|
2024-04-10 16:18:32 +08:00
|
|
|
|
[System.Serializable]
|
2024-04-07 17:20:48 +08:00
|
|
|
|
public class RoomInfo : MonoBehaviour
|
2024-04-06 11:59:18 +08:00
|
|
|
|
{
|
2024-04-10 16:18:32 +08:00
|
|
|
|
[ShowInInspector] [ReadOnly] private Room _room;
|
2024-04-07 17:20:48 +08:00
|
|
|
|
[SerializeField] [ReadOnly] private Vector2 room_LeftDown;
|
|
|
|
|
[SerializeField] [ReadOnly] private Vector2 room_RightUp;
|
2024-04-09 13:22:52 +08:00
|
|
|
|
[SerializeField] private SpriteRenderer _renderer;
|
2024-04-10 16:18:32 +08:00
|
|
|
|
private TMP_Text number;
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-12 17:32:37 +08:00
|
|
|
|
[ShowInInspector] private Transform left;
|
|
|
|
|
// {
|
|
|
|
|
// set => this.room_LeftDown = value.position;
|
|
|
|
|
// get => null;
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
[ShowInInspector] private Transform right;
|
|
|
|
|
// {
|
|
|
|
|
// set => this.room_RightUp = value.position;
|
|
|
|
|
// get => null;
|
|
|
|
|
// }
|
2024-04-06 11:59:18 +08:00
|
|
|
|
|
2024-04-12 17:32:37 +08:00
|
|
|
|
[Button("SetPos")]
|
|
|
|
|
private void Set()
|
2024-04-07 17:20:48 +08:00
|
|
|
|
{
|
2024-04-12 17:32:37 +08:00
|
|
|
|
this.room_LeftDown = left.position;
|
|
|
|
|
this.room_RightUp = right.position;
|
2024-04-07 17:20:48 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-08 18:20:55 +08:00
|
|
|
|
public RoomType roomType => this._room.roomType;
|
|
|
|
|
public Vector2 room_Center => transform.position;
|
|
|
|
|
|
2024-04-09 13:22:52 +08:00
|
|
|
|
private void Awake()
|
|
|
|
|
{
|
|
|
|
|
_renderer = this.GetComponent<SpriteRenderer>();
|
|
|
|
|
this._renderer.enabled = false;
|
2024-04-10 16:18:32 +08:00
|
|
|
|
number = transform.FindChildDeep<TMP_Text>("number");
|
|
|
|
|
this.number.text = "0";
|
2024-04-09 13:22:52 +08:00
|
|
|
|
}
|
|
|
|
|
|
2024-04-10 16:18:32 +08:00
|
|
|
|
public void SetRoom(Room room)
|
2024-04-08 18:20:55 +08:00
|
|
|
|
{
|
|
|
|
|
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-09 13:22:52 +08:00
|
|
|
|
|
|
|
|
|
public void SetSelect(bool isSelected)
|
|
|
|
|
{
|
|
|
|
|
_renderer.enabled = isSelected;
|
|
|
|
|
}
|
2024-04-10 16:18:32 +08:00
|
|
|
|
|
|
|
|
|
public void UpdateNumber(float f)
|
|
|
|
|
{
|
|
|
|
|
this.number.text = f.ToString("F");
|
|
|
|
|
}
|
2024-04-06 11:59:18 +08:00
|
|
|
|
}
|
|
|
|
|
}
|