public Entity AddMap(PositionIndex newMap) { var component = CreateComponent <MapComponent>(CoreComponentIds.Map); component.Map = newMap; return(AddComponent(CoreComponentIds.Map, component)); }
public Entity ReplaceMap(PositionIndex newMap) { var component = CreateComponent <MapComponent>(CoreComponentIds.Map); component.Map = newMap; ReplaceComponent(CoreComponentIds.Map, component); return(this); }
public Entity AddCharacters(IdIndex newCharactersByID, PositionIndex newCharactersByPosition) { var component = CreateComponent <CharactersComponent>(CoreComponentIds.Characters); component.CharactersByID = newCharactersByID; component.CharactersByPosition = newCharactersByPosition; return(AddComponent(CoreComponentIds.Characters, component)); }
public Entity SetCharacters(IdIndex newCharactersByID, PositionIndex newCharactersByPosition) { if (hasCharacters) { throw new EntitasException("Could not set characters!\n" + this + " already has an entity with CharactersComponent!", "You should check if the pool already has a charactersEntity before setting it or use pool.ReplaceCharacters()."); } var entity = CreateEntity(); entity.AddCharacters(newCharactersByID, newCharactersByPosition); return(entity); }
private static string GetValue(string line, PositionIndex pos) { if (line.Length <= pos.Start || pos.Start < 0 || pos.Length <= 0) { return(string.Empty); } else if (line.Length <= pos.Start + (pos.Length ?? DefaultLength)) { return(line.Substring(pos.Start)); } return(line.Substring(pos.Start, pos.Length ?? DefaultLength)); }
public Entity SetMap(PositionIndex newMap) { if (hasMap) { throw new EntitasException("Could not set map!\n" + this + " already has an entity with MapComponent!", "You should check if the pool already has a mapEntity before setting it or use pool.ReplaceMap()."); } var entity = CreateEntity(); entity.AddMap(newMap); return(entity); }
public MazeSaveData(Labyrinth maze) { Height = maze.Height; Width = maze.Width; CellCount = maze.CellCount; Cells = new CellSaveData[CellCount]; for (int i = 0; i < CellCount; i++) { Cells[i] = new CellSaveData(maze._cells[i]); } ExitIndex = new PositionIndex(maze.ExitIndex); }
public override int GetHashCode() { unchecked { int hashCode = PositionIndex.GetHashCode(); hashCode = (hashCode * 1201) ^ NumRefPositionsBefore; hashCode = (hashCode * 1201) ^ NumRefPositionsAfter; foreach (int alleleIndex in AlleleIndexes) { hashCode = (hashCode * 1201) ^ alleleIndex.GetHashCode(); } return(hashCode); } }
public Entity ReplaceMap(PositionIndex newMap) { var entity = mapEntity; if (entity == null) { entity = SetMap(newMap); } else { entity.ReplaceMap(newMap); } return(entity); }
public Entity ReplaceCharacters(IdIndex newCharactersByID, PositionIndex newCharactersByPosition) { var entity = charactersEntity; if (entity == null) { entity = SetCharacters(newCharactersByID, newCharactersByPosition); } else { entity.ReplaceCharacters(newCharactersByID, newCharactersByPosition); } return(entity); }
public int CompareTo(AlleleBlock other) { // first sort ascending by start point of the blocks int positionCompare = PositionIndex.CompareTo(other.PositionIndex); if (positionCompare != 0) { return(positionCompare); } // then sort descending by end point of the blocks int sizeCompare = AlleleIndexes.Length.CompareTo(other.AlleleIndexes.Length); if (sizeCompare != 0) { return(-sizeCompare); } // then sort ascending by start point of the blocks w/ trimmed ref position considered int numRefPosBeforeCompare = NumRefPositionsBefore.CompareTo(other.NumRefPositionsBefore); if (numRefPosBeforeCompare != 0) { return(numRefPosBeforeCompare); } // then sort descending by end point of the blocks w/ trimmed ref position considered int numRefPosAfterCompare = NumRefPositionsAfter.CompareTo(other.NumRefPositionsAfter); if (numRefPosAfterCompare != 0) { return(-numRefPosAfterCompare); } // then sort ascending by each allele index for (int i = 0; i < AlleleIndexes.Length; i++) { int alleleCompare = AlleleIndexes[i].CompareTo(other.AlleleIndexes[i]); if (alleleCompare != 0) { return(alleleCompare); } } return(0); }
private void AddSkeleton(PositionIndex s, PositionIndex e) { var sk = new Skeleton() { LineObject = new GameObject(this.name + "_Skeleton" + (Skeletons.Count + 1).ToString("00")), start = jointPoints[s.Int()], end = jointPoints[e.Int()], }; sk.Line = sk.LineObject.AddComponent <LineRenderer>(); sk.Line.startWidth = 0.04f; sk.Line.endWidth = 0.01f; //頂点の数を決める sk.Line.positionCount = 2; sk.Line.material = SkeletonMaterial; Skeletons.Add(sk); }
public CellSaveData(Cell cell) { Position = new PositionIndex(cell.position); CellNeighbourIndicies neighborIndicies = new CellNeighbourIndicies(); CellNeighbourIndicies linkIndicies = new CellNeighbourIndicies(); if (cell.Neighbours.East != null) { neighborIndicies.East = new PositionIndex(cell.Neighbours.East.position); } if (cell.Neighbours.West != null) { neighborIndicies.West = new PositionIndex(cell.Neighbours.West.position); } if (cell.Neighbours.North != null) { neighborIndicies.North = new PositionIndex(cell.Neighbours.North.position); } if (cell.Neighbours.South != null) { neighborIndicies.South = new PositionIndex(cell.Neighbours.South.position); } if (cell.linkNeigbours.East != null) { linkIndicies.East = new PositionIndex(cell.linkNeigbours.East.position); } if (cell.linkNeigbours.West != null) { linkIndicies.West = new PositionIndex(cell.linkNeigbours.West.position); } if (cell.linkNeigbours.North != null) { linkIndicies.North = new PositionIndex(cell.linkNeigbours.North.position); } if (cell.linkNeigbours.South != null) { linkIndicies.South = new PositionIndex(cell.linkNeigbours.South.position); } Neigbours = neighborIndicies; Links = linkIndicies; }
/// <summary> /// Add skelton from joint points /// </summary> /// <param name="s">position index</param> /// <param name="e">position index</param> private void AddSkeleton(PositionIndex s, PositionIndex e) { var sk = new Skeleton() { LineObject = new GameObject("Line"), start = jointPoints[s.Int()], end = jointPoints[e.Int()], }; sk.Line = sk.LineObject.AddComponent <LineRenderer>(); sk.Line.startWidth = 0.04f; sk.Line.endWidth = 0.01f; // define the number of vertex sk.Line.positionCount = 2; sk.Line.material = SkeletonMaterial; Skeletons.Add(sk); }
public void GenerateObjects(GameObject[] houses) { for (int i = 0; i < 5;) { if (neighbours.Count == 0) { break; } int rand = Random.Range(0, neighbours.Count); PositionIndex posIndex = neighbours[rand]; neighbours.RemoveAt(rand); Collider[] hits = Physics.OverlapSphere(posIndex.pos, 0.5f); if (hits.Length > 0) { continue; } if (i == 0) { transform.position = posIndex.pos; } else { Quaternion rot = Quaternion.Euler(0, Random.Range(0, 360), 0); Instantiate(houses[houseIndex], posIndex.pos, rot, transform); } ++i; } houseIndex = (houseIndex + 1) % houses.Length; }
public StatementItemsPositions() { Datum = new PositionIndex(0, 6); }
public static int Int(this PositionIndex i) { return((int)i); }