forked from zxl/Frame
1
0
Fork 0
Frame/Assets/Scripts/Room/RoomInfo.cs

60 lines
1.5 KiB
C#
Raw Normal View History

2024-04-09 13:22:52 +08:00
using System;
using System.Collections.Generic;
2024-04-06 11:59:18 +08:00
using Game.Player;
using Sirenix.OdinInspector;
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-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-09 13:22:52 +08:00
[SerializeField] private SpriteRenderer _renderer;
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;
2024-04-09 13:22:52 +08:00
private void Awake()
{
_renderer = this.GetComponent<SpriteRenderer>();
this._renderer.enabled = false;
}
2024-04-08 18:20:55 +08:00
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-09 13:22:52 +08:00
public void SetSelect(bool isSelected)
{
_renderer.enabled = isSelected;
}
2024-04-06 11:59:18 +08:00
}
}