using UnityEngine;
using System.Collections;
using System.Collections.Generic;
namespace YLBattle
{
///
/// 占位管理
///
public class FightingSeatManager : MonoBehaviour
{
///
/// 元素
///
private List mElements = new List();
///
/// 当前战斗占位模式
/// 0=普通占位 1=PVP
///
private int seatMode = -1;
///
///
///
private int mMaxCount = 99;
///
/// 当前占位根节点
///
private Transform mSeatRoot = null;
///
/// 当前占位根节点初始位置
///
private Vector3 mOrgPosition = Vector3.zero;
///
/// 实例
///
public static FightingSeatManager mInstance;
///
/// 获取单键
///
/// 单键实例
public static FightingSeatManager Instance
{
get
{
if (mInstance == null)
{
GameObject obj = GameObject.Find("FightingManager");
if (obj != null)
{
mInstance = obj.AddComponent();
}
}
return mInstance;
}
}
///
/// 初始化
/// 卡槽管理+旋转工具+整形工具
///
public void InitComponents(int mode)
{
this.mElements.Clear();
this.mSeatRoot = BattleStaticFunc.FindTransform(transform, mode == 2 ? "PvPSeat" : "RoleSeat");
this.mOrgPosition = mSeatRoot.position;
for (int ei = 0; ei < mMaxCount; ei++)
{
Transform obj = BattleStaticFunc.FindTransform(mSeatRoot, "Seat_" + ei.ToString());
if (obj != null)
{
mElements.Add(obj);
}
else
{
break;
}
}
}
///
/// 通过占位获得占位的Trans
///
/// 占位
/// 当前战斗模式 0=普通 1=PVP
///
public Transform GetFightingMapSeat(int _seat, int _mode = 0)
{
if (_mode != this.seatMode)
{
this.seatMode = _mode;
InitComponents(this.seatMode);
}
if (_seat >= 0 && _seat < this.mElements.Count)
{
return this.mElements[_seat];
}
return null;
}
///
///
///
void Update()
{
if (mSeatRoot != null)
{
///同步地图和占位的位置,以达到地图动画和角色共振的效果
mSeatRoot.position = this.mOrgPosition + FightingMap.Instance.MapPos;
}
}
}
}