You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

58 lines
1.9 KiB

using UnityEngine;
namespace ET
{
public class BattleSceneViewComponentAwakeSystem : AwakeSystem<BattleSceneViewComponent>
{
public override void Awake(BattleSceneViewComponent self)
{
self.Awake();
}
}
[FriendClass(typeof(BattleSceneViewComponent))]
public static class BattleSceneViewComponentSystem
{
public static void Awake(this BattleSceneViewComponent self)
{
var gameSceneMgr = self.ZoneScene().CurrentScene().GetComponent<GameSceneManagerComponent>();
Transform battleSceneRoot = gameSceneMgr.GetRoot(GameSceneType.Battle).transform;
self.PeopleRoot = battleSceneRoot.Find("PeopleRoot");
self.LeftStartPoint = battleSceneRoot.Find("LeftStartPoint");
self.RightStartPoint = battleSceneRoot.Find("RightStartPoint");
}
public static Vector3 GetUnitPosByIndex(this BattleSceneViewComponent self, int index, bool left)
{
Vector3 pos;
if (left)
{
// 左边
// --------
// |7|4|1|
// --------
// |8|5|2|
// --------
// |9|6|3|
// --------
pos = new Vector3(-(index / 3) * self.PeopleStandTileSize, -index % 3 * self.PeopleStandTileSize, 0) + self.LeftStartPoint.position;
}
else
{
// 右边
// --------
// |1|4|7|
// --------
// |2|5|8|
// --------
// |3|6|9|
// --------
pos = new Vector3(index / 3 * self.PeopleStandTileSize, -index % 3 * self.PeopleStandTileSize, 0) + self.RightStartPoint.position;
}
return pos;
}
}
}