public void Test_1x1_Board() { /* * P = Pillar (some game element path's last position * * y * ^ * | * -1 0 -> x * -2 * -1 * 0 P | 0 | */ var map = new Map(new Pillar[1, 1] { { new Pillar(0, 0) } }); var nearesPillars = new NearestPillars(map); nearesPillars.SetPillars(new Pillar(0, -1)); Assert.That(nearesPillars.Pillars, Is.Not.Null, "Pillars"); Assert.That(nearesPillars.Pillars.Length, Is.EqualTo(1), "Pillars.Length"); Pillar onlyDirection = nearesPillars.Pillars[0]; Assert.That(onlyDirection.X, Is.EqualTo(0), "onlyDirection.X"); Assert.That(onlyDirection.Y, Is.EqualTo(0), "onlyDirection.Y"); }
private Pillar getTargetPillar(PillarInputModel inputData) { Pillar pillar; if (inputData.PillarId == 0) { pillar = new Pillar(); } else { pillar = context.Pillars.Where(b => b.PillarId == inputData.PillarId).FirstOrDefault(); } if (pillar != null) { var fileService = new FileService(); var processedFiles = fileService.processFiles(inputData.PillarImage, "~/UploadedFiles"); pillar.PillarName = inputData.PillarName; pillar.PillarDescription = inputData.PillarDescription; pillar.PillarLink = inputData.PillarLink; pillar.PillarActive = inputData.PillarActive; var fileName = inputData.PillarImage[0].FileName; pillar.PillarImage = (String.IsNullOrEmpty(fileName) == false && processedFiles.ContainsKey(fileName)) ? processedFiles[fileName] : ""; } return(pillar); }
public void GenerateMap() { string[] split = mapToGenerate.Split('.'); float yOffset = 0, xOffset = 0; // rows for (int y = 0; y < split.Length; y++) { yOffset += (y % 2 == 0 ? zOffsetEven : zOffsetOdd); if (y % 2 == 0) { xOffset = xOffsetOdd; } else { xOffset = 0; } // cols for (int x = 0; x < split[y].Length; x++) { xOffset += (xOffsetEven); Pillar newPillar = new Pillar(); GameObject newPillarObj = Instantiate(pillars[Random.Range(0, pillars.Length)], transform); newPillar.transform = newPillarObj.transform; newPillar.transform.position = new Vector3(xOffset, 0, yOffset); newPillar.transform.localPosition = new Vector3(newPillar.transform.localPosition.x, 0, newPillar.transform.localPosition.z); newPillar.x = x; newPillar.y = y; float rotation = 60 * (int)Random.Range(0, 5); newPillar.transform.eulerAngles = new Vector3(-90, rotation, 0); generatedMap.Add(newPillar); } } }
public void OnTrigger(Collider2D other) { Platform platform = other.GetComponent <Platform>(); if (platform != null) { Pillar pillar = platform.GetComponent <Pillar> (); if (pillar != null) { pillar.sword = m_sword; pillar.sword.pillar = pillar; } m_sword.EndLoopRotate(); m_sword.particleHit.Play(true); if (other.bounds.Intersects(m_sword.caboCollider.bounds)) { m_sword.transform.localEulerAngles = new Vector3(0.0f, 0.0f, m_sword.transform.localEulerAngles.z + 180.0f); } m_sword.transform.SetParent(other.transform); if (Joystick.Instance.JoysticksCount() > 1) { Joystick.Instance.Vibrate(0.5f, 0); Joystick.Instance.Vibrate(0.5f, 1); VictoryManager.Instance.InvokeStop(); } m_sword.SetState(new SIdle()); } }
public Pillar[] Steppable(Pillar[] positions, Pillar lastPosition) { Log.Debug("BuilderRules.Steppable()", 1); int index = 0; for (int i = 0; i < positions.Length; i++) { if (CanStep(lastPosition, positions[i])) { positions[index] = positions[i]; index++; } } Pillar[] available = new Pillar[index]; for (int i = 0; i < available.Length; i++) { available[i] = positions[i]; Log.Debug($"({available[i].X}; {available[i].Y})"); } Log.Debug(-1, "BuilderRules.Steppable() END"); return(available); }
public void Update() { //Update player this._running = this.player.Update() ? 0 : 1; for (var i = 0; i < this.pillars.Count; i++) { Pillar pillar = this.pillars[i]; //pillar.Update will return true if it needs rebuilding if (pillar.Update() && pillar.Type == "Upper") { RebuildPillar(pillar, this.pillars[i + 1]); } if (pillar.CheckHit(this.player)) { this.HitHandler(); break; } } if (this.score % 5 == 0 && this.score > this.latestScore) { this.IncreaseDifficulty(); } }
public void No_Steppable_Pillars_Should_Return_Empty_Array() { /* * X = lastPosition * * 0 1 2 X axis * 0 | | 0 | | * 1 | 0 | X | 0 | * 2 | | 0 | | * * Y * * a * x * i * s */ var nearestPillars = new Pillar[4] { new Pillar(1, 0), new Pillar(2, 1), new Pillar(1, 2), new Pillar(0, 1), }; var lastPosition = new Pillar(1, 1); lastPosition.Build(); var actual = _rules.Steppable(nearestPillars, lastPosition); Assert.That(actual, Is.Not.Null); Assert.That(actual.Length, Is.EqualTo(0)); }
public void Impact(GameObject hexagon) { this.intensity = intensityDef; Pillar pillar = generatedMap.Find(x => x.transform == hexagon.transform); StartCoroutine(ImpactCoroutine(new Vector2(pillar.x, pillar.y))); }
public override InstanceState SaveToState(bool integrate = true) { ushort node = id.NetNode; NodeState state = new NodeState { instance = this, Info = Info, position = nodeBuffer[node].m_position, flags = nodeBuffer[node].m_flags, isCustomContent = Info.Prefab.m_isCustomContent }; state.terrainHeight = TerrainManager.instance.SampleOriginalRawHeightSmooth(state.position); if (Pillar != null) { state.pillarState = Pillar.SaveToState() as BuildingState; } for (int i = 0; i < 8; i++) { ushort segment = nodeBuffer[node].GetSegment(i); if (segment != 0) { state.segmentsList.Add(segment); state.segmentsSave[i].startDirection = segmentBuffer[segment].m_startDirection; state.segmentsSave[i].endDirection = segmentBuffer[segment].m_endDirection; } } //state.SaveIntegrations(integrate); return(state); }
private void GeneratePillars() { if (pillars == null) { return; } int i = 0; foreach (BoardPillar pillar in pillars) { Vector3 pos = position + new Vector3(pillar.pos.x * posOffset, 0, pillar.pos.y * posOffset); GameObject pillarObj = null; if (pillar.type == BoardPillarType.Regular) { pillarObj = (GameObject)Instantiate(regularPillar, pos, Quaternion.identity); } else if (pillar.type == BoardPillarType.Key) { pillarObj = (GameObject)Instantiate(keyPillar, pos, Quaternion.identity); } Pillar pillarScript = pillarObj.GetComponent <Pillar>(); pillarScript.Init(this, i, pillar.pos); i++; } }
public string ProjectReleases(string project) { if (project.Contains(",")) { List <string> releases = new List <string>(); string[] projects = project.Split(','); Pillar pillar = new Pillar(); foreach (var proj in projects) { List <string> currentReleases = pillar.GetActiveReleases(proj); foreach (var rel in currentReleases) { if (!releases.Contains(rel)) { releases.Add(rel); } } } return(string.Join(",", releases)); } else { return(string.Join(",", new Pillar().GetActiveReleases(project))); } }
void OnTriggerEnter2D(Collider2D coll) { if (coll.tag == "PlayerGround") { isGoingBack = false; pushedByPlayer = true; pushedByPillar = false; pillarPushing = null; } if (coll.tag == "PillarElastic") { Pillar pillar = coll.GetComponent <Pillar>(); if ((pillar.pushedByPillar || pillar.pushedByPlayer) && !pushedByPlayer) { if (pillar.pillarPushing != this) { pushedByPillar = true; pillarPushing = pillar; } } } }
public void RegisterPillar(Pillar pillar) { pillars.Add(pillar); pillar.index = numberOfTotalPillar; numberOfTotalPillar++; }
public void Init(Vector3Int size) { this.Size = size; items = new List <ItemObject>(); space = new Dictionary <int, List <ItemObject> >(); floor = transform.Find("floor").GetComponent <Floor>(); floor.Init(new Vector2Int(size.x, size.z)); walls = new Wall[4]; pillarsV = new Pillar[4]; pillarsH = new Pillar[4]; for (int i = 0; i < 4; i++) { Wall wall = transform.Find("wall_" + wallNames[i]).GetComponent <Wall>(); Direction dir = wallDirections[i]; int x = (int)Mathf.Abs(Vector3.Dot(dir.Vector, size)); Vector2Int wallSize = new Vector2Int(x, size.y); wall.Init(wallSize, dir); walls[i] = wall; Pillar pillarV = transform.Find("v_" + wallNames[i]).GetComponent <Pillar>(); pillarV.Init(); pillarsV[i] = pillarV; Pillar pillarH = transform.Find("h_" + wallNames[i]).GetComponent <Pillar>(); pillarH.Init(); pillarsH[i] = pillarH; } // showWalls showWalls = new int[2]; }
private void OnTriggerEnter2D(Collider2D other) { Pillar pillar = other.GetComponent <Pillar>(); SoundManager.Instance.PlaySFX(11); if (pillar != null) { if (!pillar.isCharging) { pillar.currentCharacter = m_character; pillar.ActiveEffect(); } else { m_character.ActiveCuspe(); } } else { m_character.ActiveCuspe(); } m_particle.transform.position = transform.position; m_particle.Play(true); this.gameObject.SetActive(false); }
public override IEnumerable <object> Solve(TextReader inputStream) { var pillarCount = inputStream.ReadInt(); var pillars = new Pillar[pillarCount]; for (int i = 0; i < pillarCount; i++) { var xy = inputStream.ReadIntArray(); pillars[i] = new Pillar(xy[0], xy[1]); } Array.Sort(pillars); int max = 0; for (int i = 0; i < pillars.Length; i++) { for (int j = i + 1; j < pillars.Length; j++) { var dx = pillars[i].Y - pillars[j].Y; var dy = pillars[j].X - pillars[i].X; var p = new Pillar(pillars[j].X + dx, pillars[j].Y + dy); var q = new Pillar(pillars[i].X + dx, pillars[i].Y + dy); if (Array.BinarySearch(pillars, p) >= 0 && Array.BinarySearch(pillars, q) >= 0) { var square = dx * dx + dy * dy; max = Math.Max(max, square); } } } yield return(max); }
/// <summary> /// Get a valid starting point for the <see cref="Builder"/>. /// </summary> /// <param name="map">The board where the action is happening.</param> /// <returns>Reference object from the <see cref="Map"/>.</returns> public Pillar InitialPosition(Map map) { int x = PyramidGame.Random.Next(0, map.Width); int y = PyramidGame.Random.Next(0, map.Height); if ((x != 0 || x != map.Width - 1) && (y != 0 || y != map.Height - 1)) { var randInt = PyramidGame.Random.Next(0, 4); if (0 == randInt) { x = 0; } else if (1 == randInt) { x = map.Width - 1; } else if (2 == randInt) { y = 0; } else { y = map.Height - 1; } } Pillar position = map.GetField(x, y); Log.Debug($"InitialPosition({position.X}; {position.Y})"); return(position); }
private void DiscoverRoutes(Path path) { Pillar lastPosition = path.Last(); _nearestPillars.SetPillars(lastPosition); if (_nearestPillars.HasAny) { Pillar[] nearestPositions = _nearestPillars.Pillars; Pillar[] steppablePositions = _rules.Steppable(nearestPositions, lastPosition); if (steppablePositions.Length == 1) { path.Increase(steppablePositions[0]); DiscoverRoutes(path); } else if (1 < steppablePositions.Length) { foreach (var newBranch in steppablePositions) { int cloneIndex = Clone(path); DiscoverRoutes(_results[cloneIndex]); } } } }
public override InstanceState GetState() { ushort node = id.NetNode; NodeState state = new NodeState(); state.instance = this; state.Info = Info; state.position = nodeBuffer[node].m_position; state.terrainHeight = TerrainManager.instance.SampleOriginalRawHeightSmooth(state.position); state.flags = nodeBuffer[node].m_flags; MoveableBuilding pillarInstance = Pillar; if (Pillar != null) { state.pillarState = Pillar.GetState() as BuildingState; } for (int i = 0; i < 8; i++) { ushort segment = nodeBuffer[node].GetSegment(i); if (segment != 0) { state.segmentsSave[i].startDirection = segmentBuffer[segment].m_startDirection; state.segmentsSave[i].endDirection = segmentBuffer[segment].m_endDirection; } } return(state); }
private bool StepOrBuild(Pillar lastPosition, Pillar beforeLastPosition) { _nearestPillars.SetPillars(lastPosition, beforeLastPosition); Pillar[] steppablePositions = _rules.Steppable(_nearestPillars.Pillars, lastPosition); if (0 < steppablePositions.Length) { lastPosition = _map.GetField(steppablePositions[PyramidGame.Random.Next(0, steppablePositions.Length)]); Step(lastPosition); return(true); } else { Pillar[] buildablePos = _rules.Buildable(_nearestPillars.Pillars, lastPosition); if (buildablePos.Length != 0) { lastPosition = _map.GetField(buildablePos[PyramidGame.Random.Next(0, buildablePos.Length)]); } Build(lastPosition); return(false); } }
private Pillar[] GetNearestFields(Pillar centerField) { Log.Debug($"GetNearestFields({centerField.X}; {centerField.Y})", 1); Pillar[] fields = new Pillar[4]; int index = 0; if (HasRight(centerField)) { SetField(fields, ref index, centerField.X + 1, centerField.Y); } if (HasBottom(centerField)) { SetField(fields, ref index, centerField.X, centerField.Y + 1); } if (HasLeft(centerField)) { SetField(fields, ref index, centerField.X - 1, centerField.Y); } if (HasTop(centerField)) { SetField(fields, ref index, centerField.X, centerField.Y - 1); } Log.Debug(-1, $"GetNearestFields() END"); _count = index; return(fields); }
void SpawnPillar() //기둥을 일정 위치에 일정 속도로 움직이도록 스폰함 { float randomIndex = Random.Range(4f, 8.1f); Vector2 moveDir = new Vector2(-2.3f, 0); GameObject pillarUp = om.MakeObj("pillarUp"); //윗 기둥 GameObject pillarDown = om.MakeObj("pillarDown"); //아랫 기둥 GameObject scoreZone = om.MakeObj("scoreZone"); //점수 획득 존 //기둥 스폰 위치 pillarUp.transform.position = new Vector3(3.5f, randomIndex); pillarDown.transform.position = new Vector3(3.5f, randomIndex - 9.82f); scoreZone.transform.position = new Vector3(3.5f, randomIndex - 4.9f); Rigidbody2D rigidU = pillarUp.GetComponent <Rigidbody2D>(); Rigidbody2D rigidD = pillarDown.GetComponent <Rigidbody2D>(); Rigidbody2D rigidS = scoreZone.GetComponent <Rigidbody2D>(); Pillar pillarULogic = pillarUp.GetComponent <Pillar>(); Pillar pillarDLogic = pillarDown.GetComponent <Pillar>(); ScoreZone scoreLogic = scoreZone.GetComponent <ScoreZone>(); //기둥과 점수획득 존을 왼쪽으로 일정하게 움직이도록 함 rigidU.velocity = moveDir; rigidD.velocity = moveDir; rigidS.velocity = moveDir; }
public void Constructor_Can_Drop_Reference() { var map = new Pillar[4, 4] { { new Pillar(0, 0, 100), new Pillar(1, 0, 100), new Pillar(2, 0, 1), new Pillar(3, 0, 100) }, { new Pillar(0, 1, 100), new Pillar(1, 1, 100), new Pillar(2, 1, 2), new Pillar(3, 1, 100) }, { new Pillar(0, 2, 100), new Pillar(1, 2, 100), new Pillar(2, 2, 3), new Pillar(3, 2, 100) }, { new Pillar(0, 3, 100), new Pillar(1, 3, 100), new Pillar(2, 3, 4), new Pillar(3, 3, 100) }, }; var oldFrame = new BoardFrame(new Map(map)); var actual = new BoardFrame(oldFrame); int x = 1; int y = 2; var oldColoredPillar = new ColoredPillar(x, y, 4, ConsoleColor.Magenta, ConsoleColor.Black); oldFrame.SetInPosition(oldColoredPillar); Assert.IsFalse(ReferenceEquals( oldFrame.GetFrom(x, y), actual.GetFrom(x, y)), $"oldframe[{x}, {y}] should not reference actual[{x}, {y}]"); var oldFramePillar = oldFrame.GetFrom(x, y); Assert.That(oldFramePillar.X, Is.EqualTo(x), "oldFramePillar.X"); Assert.That(oldFramePillar.Y, Is.EqualTo(y), "oldFramePillar.Y"); Assert.That(oldFramePillar.Height, Is.EqualTo(4), "oldFramePillar.Height"); var actualFramePillar = actual.GetFrom(x, y); Assert.That(actualFramePillar.X, Is.EqualTo(x), "actualFramePillar.X"); Assert.That(actualFramePillar.Y, Is.EqualTo(y), "actualFramePillar.Y"); Assert.That(actualFramePillar.Height, Is.EqualTo(100), "actualFramePillar.Height"); }
public void Three_Steppable_Pillars_Should_Return_One_Item() { /* * X = lastPosition * * 0 1 2 X axis * 0 | | 0 | | * 1 | 2 | X | 2 | * 2 | | 2 | | * * Y * * a * x * i * s */ var right = new Pillar(2, 1); right.Build(); right.Build(); var bottom = new Pillar(1, 2); bottom.Build(); bottom.Build(); var left = new Pillar(0, 1); left.Build(); left.Build(); var nearestPillars = new Pillar[4] { new Pillar(1, 0), right, bottom, left, }; var lastPosition = new Pillar(1, 1); lastPosition.Build(); var actual = _rules.Steppable(nearestPillars, lastPosition); Assert.That(actual, Is.Not.Null); Assert.That(actual.Length, Is.EqualTo(3)); Assert.That(actual[0].X, Is.EqualTo(right.X), "right.X"); Assert.That(actual[0].Y, Is.EqualTo(right.Y), "right.X"); Assert.That(actual[1].X, Is.EqualTo(bottom.X), "bottom.X"); Assert.That(actual[1].Y, Is.EqualTo(bottom.Y), "bottom.X"); Assert.That(actual[2].X, Is.EqualTo(left.X), "left.X"); Assert.That(actual[2].Y, Is.EqualTo(left.Y), "left.X"); }
public void DoDamage(Pillar target) { if (pillars.Contains(target)) { --health; pillars.Remove(target); } }
private void DestroyWall(Pillar flom, Pillar to) { if (flom.IsActice == false) { Destroy(_newWall); IsGenerateWall = false; } }
private void Build(Pillar position) { Model.Step(position); position.Build(); Log.Debug($"BUILD ({position.X}; {position.Y}) Height : {position.Height - 1} -> {_map.GetField(position).Height}", 1); }
private void ParseLine(int lineIndex, string line, Pillar[,] map) { string[] pillarHeights = line.Split(_separator); for (int x = 0; x < map.GetLength(1); x++) { map[lineIndex, x] = new Pillar(x, lineIndex, int.Parse(pillarHeights[x])); } }
public async Task <ActionResult> DeleteConfirmed(int id) { Pillar pillar = await db.Pillars.FindAsync(id); db.Pillars.Remove(pillar); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public TestInput MediumMap() { /* * * y * ^ * | * | * * * 2 | 1 | 1 | 1 | 1 | * 1 | 1 | 4 | 5 | 1 | * 0 | 2 | 3 | 1 | 1 | * * 0 1 2 3 ---> x */ var map = new Pillar[3, 4] { { new Pillar(0, 0, 2), new Pillar(1, 0, 3), new Pillar(2, 0), new Pillar(3, 0) }, { new Pillar(0, 1), new Pillar(1, 1, 4), new Pillar(2, 1, 5), new Pillar(3, 1) }, { new Pillar(0, 2), new Pillar(1, 2), new Pillar(2, 2), new Pillar(3, 2) }, }; Map = new Map(map); Paths = new Path[] { new Path(new Pillar(0, 2)), new Path(new Pillar(1, 2)), new Path(new Pillar(2, 2)), new Path(new Pillar(3, 2)), new Path(new Pillar(3, 1)), new Path(new Pillar(3, 0)), new Path(new Pillar(2, 0)), new Path( Map.GetField(1, 0), Map.GetField(1, 1), Map.GetField(2, 1)), new Path( Map.GetField(0, 0), Map.GetField(1, 0), Map.GetField(1, 1), Map.GetField(2, 1)), new Path( Map.GetField(0, 1), Map.GetField(0, 0), Map.GetField(1, 0), Map.GetField(1, 1), Map.GetField(2, 1)), }; LongestPathIndex = 9; return(this); }
public void Clear() { for (int i = 0; i < run_pool.Count; i++) { recyle_pool.Enqueue(run_pool[i]); run_pool[i].Recyle(); } run_pool.Clear(); currPillar = null; }