using UnityEngine; namespace ET { public class BattleSceneViewComponentAwakeSystem : AwakeSystem { 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(); 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; } } }