using System.Runtime.CompilerServices;
using UnityEngine;
using UnityEngine.UI;
namespace Game
{
public class Common
{
static public bool CheckTagIsRole(string tag,out E_NODE_TYPE nodetype)
{
switch (tag)
{
case Tags.MainPlayer:
nodetype = E_NODE_TYPE.N_MAINPLAYER;
return true;
case Tags.NPC:
nodetype = E_NODE_TYPE.N_NPC;
return true;
case Tags.Monster:
nodetype = E_NODE_TYPE.N_MONSTER;
return true;
}
nodetype = E_NODE_TYPE.N_FREE;
return false;
}
#region 弹幕
static public string GetBulletProfabPath(string Name)
{
return $"Assets/GameAssets/Prefabs/Bullet/{Name}.prefab"; ;
}
static public string GetBulletCfgPath(string Name)
{
return "Assets/GameAssets/ScriptableObjectCfg/BulletCfg/" + Name + ".asset"; ;
}
#endregion
///
/// 根据角度算向量
///
///
static public Vector3 GetVecForAngleXZ(float angle)
{
return new Vector3(100 * Mathf.Cos(angle * Mathf.PI / 180), 0,100 * Mathf.Sin(angle * Mathf.PI / 180)).normalized;
}
///
/// 根据角度算向量
///
///
static public Vector3 GetVecForAngleXY(float angle)
{
return new Vector3(100 * Mathf.Cos(angle * Mathf.PI / 180),100 * Mathf.Sin(angle * Mathf.PI / 180),0).normalized;
}
static public Vector2Int GetCellXYforV3(Vector3 worldPos)
{
Vector2Int cell = new Vector2Int();
cell.x = (int)(worldPos.x / ConstClass.CellSize);
cell.y = (int)(worldPos.y / ConstClass.CellSize);
return cell;
}
static public Vector3 GetCellCenterPos(Vector2Int CellXY)
{
Vector3 pos= new Vector3();
pos.x = (CellXY.x * ConstClass.CellSize) + (ConstClass.CellSize * 0.5f);
pos.y = (CellXY.y * ConstClass.CellSize) + (ConstClass.CellSize * 0.5f);
return pos;
}
}
}