public void Create(FightCtllerView ctl, FightGrid grid) { m_ctller = ctl; m_fight_grid = grid; Vector2 min = new Vector2(float.MaxValue, float.MaxValue); Vector2 max = new Vector2(float.MinValue, float.MinValue); m_units = new Unit[FightGrid.UnitCount.Y, FightGrid.UnitCount.X]; for (int y = 0; y < FightGrid.UnitCount.Y; ++y) { for (int x = 0; x < FightGrid.UnitCount.X; ++x) { GameObject obj_unit = ResMgr.Instance.CreateGameObject("Fight/GridUnit", gameObject); obj_unit.transform.localPosition = grid.Units[y, x].Position * Launcher.SpriteScale; FightGridUnitView uv = obj_unit.GetComponent<FightGridUnitView>(); uv.Create(this, grid.Units[y, x]); m_units[y, x] = new Unit(new Int2D(x, y), uv); min.x = Mathf.Min(min.x, grid.Units[y, x].Position.x - FightGrid.UnitSize / 2); min.y = Mathf.Min(min.y, grid.Units[y, x].Position.y - FightGrid.UnitSize / 2); max.x = Mathf.Max(max.x, grid.Units[y, x].Position.x + FightGrid.UnitSize / 2); max.y = Mathf.Max(max.y, grid.Units[y, x].Position.y + FightGrid.UnitSize / 2); } } min *= Launcher.SpriteScale; max *= Launcher.SpriteScale; BoxCollider cld = gameObject.AddComponent<BoxCollider>(); cld.center = min + (max - min) / 2; cld.size = (max - min); m_fight_grid.OnAddCreature += OnAddCreature; }
public void Create() { for (int i = 0; i < m_fg.Length; ++i) { m_fg[i] = new FightGrid(); m_fg[i].Create(this, (FightGrid.DirType)i); } }
public List <Creature> FetchTargetsFront() { List <Creature> targets = new List <Creature>(); FightGrid grid = m_proto.TargetGridFace ? OwnerSkill.OwnerCreature.FGrid.Face : OwnerSkill.OwnerCreature.FGrid; int c = OwnerSkill.OwnerCreature.Index.X + (OwnerSkill.OwnerCreature.Proto.Dim.X - 1) / 2; for (int y = 0; y < FightGrid.UnitCount.Y; ++y) { for (int i = 0; i < s_fetch_offset.Length; ++i) { int curt_x = s_fetch_offset[i] + c; if (curt_x < OwnerSkill.OwnerCreature.Index.X || curt_x >= OwnerSkill.OwnerCreature.Index.X + OwnerSkill.OwnerCreature.Proto.Dim.X) { break; } FightGrid.Unit u = grid.Units[y, curt_x]; if (u.Creature == null || u.Creature.State == Creature.StateType.Death) { continue; } else { targets.Add(u.Creature); return(targets); } } } for (int i = 0; i < s_fetch_offset.Length; ++i) { int curt_x = s_fetch_offset[i] + c; if (curt_x < 0 || curt_x >= FightGrid.UnitCount.X) { continue; } for (int y = 0; y < FightGrid.UnitCount.Y; ++y) { FightGrid.Unit u = grid.Units[y, curt_x]; if (u.Creature == null || u.Creature.State == Creature.StateType.Death) { continue; } else { targets.Add(u.Creature); return(targets); } } } return(null); }
public void Create(FightGridView grid, FightGrid.Unit unit) { m_grid = grid; m_unit = unit; m_rc_world = new Rect(m_unit.Position * Launcher.SpriteScale, Vector2.one * FightGrid.UnitSize * Launcher.SpriteScale); m_rc_world.position -= m_rc_world.size / 2; BodyColor = new Color(1, 1, 1, 0); }
public IEnumerator MoveToNewGrid(int gridIndex, float duration, bool moveChars = true) { FightGrid destinationGrid = fightGrids[gridIndex != -1 ? gridIndex : currentGridIndex]; GridManagerScript.Instance.MoveGrid_ToWorldPosition(destinationGrid.pivot); if (duration == 1234.56789f) { duration = destinationGrid.hasBaseTransitionTime ? destinationGrid.baseTransitionDuration : defaultTransitionTime; } Vector3 translation = -(fightGrids[currentGridIndex].transform.position - destinationGrid.transform.position); if (GridLeapSequencer != null) { StopCoroutine(GridLeapSequencer); } currentGridIndex = gridIndex != -1 ? gridIndex : currentGridIndex; GridLeapSequencer = GridLeapSequence(duration, translation, moveChars); yield return(GridLeapSequencer); }
public void Create(FightCtllerView ctl, FightGrid grid) { m_ctller = ctl; m_fight_grid = grid; gameObject.layer = (int)UnityLayer.UI; Vector2 min = new Vector2(float.MaxValue, float.MaxValue); Vector2 max = new Vector2(float.MinValue, float.MinValue); m_units = new Unit[FightGrid.UnitCount.Y, FightGrid.UnitCount.X]; for (int y = 0; y < FightGrid.UnitCount.Y; ++y) { for (int x = 0; x < FightGrid.UnitCount.X; ++x) { GameObject obj_unit = ResMgr.Instance.CreateGameObject("Fight/GridUnit", gameObject); obj_unit.transform.localPosition = grid.Units[y, x].Position; FightGridUnitView uv = obj_unit.GetComponent <FightGridUnitView>(); uv.Create(this, grid.Units[y, x]); m_units[y, x] = new Unit(new Int2D(x, y), uv); min.x = Mathf.Min(min.x, grid.Units[y, x].Position.x - FightGrid.UnitSize / 2); min.y = Mathf.Min(min.y, grid.Units[y, x].Position.y - FightGrid.UnitSize / 2); max.x = Mathf.Max(max.x, grid.Units[y, x].Position.x + FightGrid.UnitSize / 2); max.y = Mathf.Max(max.y, grid.Units[y, x].Position.y + FightGrid.UnitSize / 2); } } /* * BoxCollider cld = gameObject.AddComponent<BoxCollider>(); * cld.center = min + (max - min) / 2; * cld.size = (max - min); */ SetVisible(false); m_fight_grid.OnAddCreature += OnAddCreature; m_fight_grid.OnRemoveCreature += OnRemoveCreature; }