public void SetOrb(Orb orb) { LoadOrbImage(orb); OrbType = orb.type; OrbName = orb.asset_name; }
public void Deserialize(NetworkReader reader, Orb target) => throw new InvalidOperationException("Cannot deserialize using the default orb deserializer");
internal static extern int cv_features2d_ORB_descriptorType(Orb extractor);
void Update() { //select an orb if (Input.GetMouseButtonDown(0)) { if (!GameManager.ActiveGameManager.EventSystem.IsPointerOverGameObject()) { if (GameManager.ActiveGameManager.CameraManager.CURRENT_CAM_MODE == CameraManager.CAM_MODE.ALL_LAYERS || GameManager.ActiveGameManager.CameraManager.CURRENT_CAM_MODE == CameraManager.CAM_MODE.SINGLE_LAYER) { if (!GameManager.ActiveGameManager.RenderViewPanel.RenderViewOn) { Camera cam = GameManager.ActiveGameManager.CameraManager.MainCamera; Vector2 click = cam.ScreenToWorldPoint(Input.mousePosition); bool orbFound = false; foreach (Orb o in orbs) { if (!o.gameObject.activeSelf) { continue; } float dist = Vector2.Distance(click, o.transform.position); if (dist < o.Radius) { selectedOrb = o; orbWasDragged = false; orbFound = true; mouseClickPos = click; heldSinceSelected = true; initialPanelOpened = false; mouseToOrbOffset = click - new Vector2(o.transform.position.x, o.transform.position.y); break; } } if (!orbFound) { selectedOrb = null; } } } } } //after clicking and releasing an orb, open the panel if (!Input.GetMouseButton(0) && selectedOrb != null && !heldSinceSelected && !orbWasDragged && !initialPanelOpened) { GameManager.ActiveGameManager.BrushEditor.gameObject.SetActive(true); GameManager.ActiveGameManager.BrushEditor.SetSelectedOrb(selectedOrb); //find the preset name for this orb in the dropdown list and set the dropdown list to that value List <UnityEngine.UI.Dropdown.OptionData> presets = GameManager.ActiveGameManager.BrushEditor.presetDropdownList.options; int currentPresetValue = 0; foreach (UnityEngine.UI.Dropdown.OptionData option in presets) { if (option.text == selectedOrb.presetName) { break; } else { currentPresetValue++; } } if (currentPresetValue >= presets.Count) { Debug.Log("Preset Name attatched to Orb not found in preset list"); } else { GameManager.ActiveGameManager.BrushEditor.presetDropdownList.value = currentPresetValue; } initialPanelOpened = true; } if (!Input.GetMouseButton(0)) { heldSinceSelected = false; if (selectedOrb == null) { orbWasDragged = false; } } //drag the orb if (Input.GetMouseButton(0) && selectedOrb != null && heldSinceSelected) { Camera cam = GameManager.ActiveGameManager.CameraManager.MainCamera; Vector2 click = cam.ScreenToWorldPoint(Input.mousePosition); if (Vector3.Distance(mouseClickPos, click) > minOrbDragDistance) { selectedOrb.transform.position = new Vector3(click.x, click.y, selectedOrb.transform.position.z) - mouseToOrbOffset; orbWasDragged = true; } } //glowing outline on selected orb if (selectedOrb != null && !GameManager.ActiveGameManager.RenderViewPanel.RenderViewOn && GameManager.ActiveGameManager.LayerManager.Layers[selectedOrb.layer].Active) { selectedOrbOutline.gameObject.SetActive(true); selectedOrbOutline.gameObject.transform.position = selectedOrb.transform.position + Vector3.forward; } else { selectedOrbOutline.gameObject.SetActive(false); } activeOrbs = 0; //activate only orbs in current layer if (GameManager.ActiveGameManager.CameraManager.CURRENT_CAM_MODE == CameraManager.CAM_MODE.SINGLE_LAYER) { int currentLayer = GameManager.ActiveGameManager.CameraManager.CurrentLayer; for (int i = 0; i < orbs.Count; i++) { if (orbs[i].layer == currentLayer) { orbs[i].gameObject.SetActive(true); activeOrbs++; } else { orbs[i].gameObject.SetActive(false); } } return; } //activate orbs in all active layers bool[] activeLayers = GameManager.ActiveGameManager.LayerToggle.LayersActive; foreach (Orb o in orbs) { o.gameObject.SetActive(activeLayers[o.layer]); if (activeLayers[o.layer]) { activeOrbs++; } } }
public void PlaceOrb(Orb orb, int floorId) { orb.linkedChunk = this; this.PlaceGameobject(orb.gameObject, floorId); }
internal static extern void cv_features2d_ORB_detect(Orb detector, Arr image, KeyPointCollection keypoints, Arr mask);
// Update is called once per frame void Update() { if (Time.timeScale < 0.0001f || storyManager.storyBeat == StoryManager.Beat.TUTORIAL_GHOSTIGHOST_EMERGE) { return; } // Drop items if commanded. if (Input.GetAxis("Fire2") > 0f) { this.DropItem(); } // Look for any items being targeted by the left click. if (Input.GetMouseButtonDown(0)) { this.targetItem = null; this.isTargettingMachine = false; this.isTargettingVoid = false; Ray ray = this.camera.ScreenPointToRay(Input.mousePosition); RaycastHit2D[] hits = Physics2D.GetRayIntersectionAll(ray); foreach (RaycastHit2D hit in hits) { Item hitItem = hit.transform.gameObject.GetComponent <Item>(); if (hitItem != null) { this.targetItem = hitItem; this.targetOrb = hit.transform.gameObject.GetComponent <Orb>(); this.targetMonster = hit.transform.gameObject.GetComponent <Monster>(); break; } } } // Otherwise, just set the target to the position clicked... Or, go to the machine. Or void if (Input.GetMouseButton(0)) { // Check if player should go to machine OR Void this.isTargettingVoid = false; this.isTargettingMachine = false; Ray ray = this.camera.ScreenPointToRay(Input.mousePosition); RaycastHit2D[] hits = Physics2D.GetRayIntersectionAll(ray); foreach (RaycastHit2D hit in hits) { Machine machine = hit.transform.gameObject.GetComponentInParent <Machine>(); if (machine != null) { this.isTargettingMachine = true; this.targetItem = null; break; } Void voido = hit.transform.gameObject.GetComponentInParent <Void>(); if (voido != null) { this.isTargettingVoid = true; this.targetItem = null; break; } } if (this.isTargettingMachine) { // Go to machine this.waypoint = this.machine.GetWaypoint(); } else if (this.isTargettingVoid) { // Go to void this.waypoint = this.voido.GetFrontalWaypoint(); } else if (this.targetItem == null) { // Go to mouse this.waypoint = this.camera.ScreenToWorldPoint(Input.mousePosition); } } // Walk towards the target item (or point). Vector2 displacement = this.waypoint - (Vector2)this.transform.position; if (this.targetItem != null) { displacement = this.targetItem.transform.position - this.transform.position; } if (displacement.magnitude > this.walkRange) { float x1 = this.gate.transform.position.x; float x2 = x1 + this.gate.width; float y1 = this.gate.transform.position.y; float y2 = y1 + this.gate.height; float cx = 0.5f * (x1 + x2); Vector2 position = this.transform.position; Vector2 deltaPos = displacement.normalized * this.speed * Time.deltaTime; bool inGateY = (position.y > y1 && position.y < y2); if (!inGateY) { if (position.x + deltaPos.x > x1 && position.x < cx && deltaPos.x > 0f) { deltaPos.x = x1 - position.x; } if (position.x + deltaPos.x < x2 && position.x > cx && deltaPos.x < 0f) { deltaPos.x = x2 - position.x; } } this.transform.position += (Vector3)deltaPos; this.footstepDistance -= deltaPos.magnitude; if (this.footstepDistance < 0f) { this.footstepDistance = 0.65f; this.audioSource.PlayOneShot(this.footstepSound, 0.01f); } if (Mathf.Abs(deltaPos.x) < Mathf.Abs(deltaPos.y)) { if (deltaPos.y < 0) { this.animator.Play("Main_Down"); } else { this.animator.Play("Main_Up"); } } else { if (deltaPos.x < 0) { this.animator.Play("Main_Left"); } else { this.animator.Play("Main_Right"); } } } else { this.animator.Play("Main_Idle"); // If character has made it to the machine, then interact with the machine if (this.storyManager.storyBeat != StoryManager.Beat.TUTORIAL_DROP_ORB_INSTRUCTIONS && this.storyManager.storyBeat != StoryManager.Beat.TUTORIAL_RELEASE_MONSTER_INSTRUCTIONS) { if (this.isTargettingMachine) { this.machine.Interact(); this.item = null; this.isTargettingMachine = false; } } // If character made it to void if (this.isTargettingVoid) { this.voido.Interact(); this.item = null; this.isTargettingVoid = false; } } // If you don't already have an item, then pick it up. if (this.item == null && this.targetItem != null && displacement.magnitude < this.pickupRange) { if (this.storyManager.storyBeat == StoryManager.Beat.TUTORIAL_PICKUP_ORB_INSTRUCTIONS) { Orb orb = this.targetItem.GetComponent <Orb>(); if (orb != null && orb.orbColor != Orb.OrbColor.BLUE) { this.storyManager.state = StoryManager.State.PROMPT; this.targetItem = null; this.waypoint = this.transform.position; goto skipOrb; } } if (this.targetItem.Pickup()) { this.item = this.targetItem; this.item.audioSource.PlayOneShot(this.item.pickupSound, 0.5f); } this.waypoint = this.targetItem.transform.position; this.targetItem = null; } skipOrb: // Maintain z ordering. Vector2 pos = this.transform.position; this.transform.position = new Vector3(pos.x, pos.y, pos.y / 300f); }
// this function changes the board! make a copy before calling it private List <Combo> GetCombosWithoutGravity() { List <Combo> combos = new List <Combo>(); Board comboBoard = new Board(Height, Width); for (int i = 0; i < Height; i++) { for (int j = 1; j < Width - 1; j++) { if (Orbs[i, j] == Orb.None) { continue; } if (Orbs[i, j - 1] == Orbs[i, j] && Orbs[i, j] == Orbs[i, j + 1]) { comboBoard.Orbs[i, j - 1] = Orbs[i, j]; comboBoard.Orbs[i, j] = Orbs[i, j]; comboBoard.Orbs[i, j + 1] = Orbs[i, j]; } } } for (int i = 1; i < Height - 1; i++) { for (int j = 0; j < Width; j++) { if (Orbs[i, j] == Orb.None) { continue; } if (Orbs[i - 1, j] == Orbs[i, j] && Orbs[i, j] == Orbs[i + 1, j]) { comboBoard.Orbs[i - 1, j] = Orbs[i, j]; comboBoard.Orbs[i, j] = Orbs[i, j]; comboBoard.Orbs[i + 1, j] = Orbs[i, j]; } } } // row check bool[] isRows = new bool[Height]; for (int i = 0; i < isRows.Length; i++) { isRows[i] = true; } for (int i = 0; i < Height; i++) { for (int j = 1; j < Width; j++) { isRows[i] = isRows[i] ? Orbs[i, j] == Orbs[i, 0] : false; } } Stack <Tuple <int, int> > orbStack = new Stack <Tuple <int, int> >(); HashSet <Tuple <int, int> > visited = new HashSet <Tuple <int, int> >(); for (int i = 0; i < Height; i++) { for (int j = 0; j < Width; j++) { int comboNumOrbs = 0; int comboNumEnhances = 0; bool isRow = true; Orb orbType = Orbs[i, j]; if (comboBoard.Orbs[i, j] == Orb.None) { continue; } orbStack.Clear(); orbStack.Push(new Tuple <int, int>(i, j)); while (orbStack.Any()) { var curLoc = orbStack.Pop(); if (visited.Contains(new Tuple <int, int>(curLoc.Item1, curLoc.Item2))) { continue; } comboBoard.Orbs[curLoc.Item1, curLoc.Item2] = Orb.None; Orbs[curLoc.Item1, curLoc.Item2] = Orb.None; comboNumOrbs++; if (Enhancements[curLoc.Item1, curLoc.Item2]) { comboNumEnhances++; } isRow = isRow ? isRows[curLoc.Item1] : false; visited.Add(curLoc); foreach (var direction in MatchDirections) { var newY = curLoc.Item1 + direction[0]; var newX = curLoc.Item2 + direction[1]; if (newY < 0 || newY >= Height || newX < 0 || newX >= Width || visited.Contains(new Tuple <int, int>(newY, newX)) || orbType != comboBoard.Orbs[newY, newX]) { continue; } orbStack.Push(new Tuple <int, int>(newY, newX)); } } combos.Add(new Combo { OrbType = orbType, NumOrbs = comboNumOrbs, NumEnahcements = comboNumEnhances, IsRow = isRow }); } } return(combos); }
void Awake() { orbPrefab = orbPref; orbManager = this; }
/* ============================================================================================================= * Do the orb swap with lerp and play the orb swapping sound effect * ============================================================================================================= */ private IEnumerator SwapOrbs(int newOrbX, int newOrbY) { Vector3 targetAngle; GameObject orbSwapper = new GameObject(); WaitForSeconds swapLoopTimer = new WaitForSeconds(0.01f); // TO-DO: USE AUDIO MANAGER AudioSource audio = GetComponent <AudioSource>(); audio.Play(0); float swapLerpPercent = 0f; int oldOrbX = heldOrbX, oldOrbY = heldOrbY; heldOrbX = newOrbX; heldOrbY = newOrbY; Orb tempOrb = orbArr[newOrbX, newOrbY]; orbArr[newOrbX, newOrbY] = orbArr[oldOrbX, oldOrbY]; orbArr[oldOrbX, oldOrbY] = tempOrb; if (orbClone.orbObject.transform.parent != null) { orbClone.orbObject.transform.parent = null; orbClone.orbObject.transform.position = new Vector2(oldOrbX, oldOrbY); } if (orbArr[oldOrbX, oldOrbY].orbObject.transform.parent != null) { orbArr[oldOrbX, oldOrbY].orbObject.transform.parent = null; orbArr[oldOrbX, oldOrbY].orbObject.transform.position = new Vector2(newOrbX, newOrbY); } targetAngle = new Vector3(0, 0, 180f); orbSwapper.transform.position = new Vector2(oldOrbX - ((oldOrbX - newOrbX) / 2f), oldOrbY - ((oldOrbY - newOrbY) / 2f)); orbClone.orbObject.transform.parent = orbArr[oldOrbX, oldOrbY].orbObject.transform.parent = orbSwapper.transform; while (swapLerpPercent <= 1f) { orbSwapper.transform.eulerAngles = Vector3.Lerp(Vector3.zero, targetAngle, swapLerpPercent); swapLerpPercent += 0.1f; yield return(swapLoopTimer); } orbSwapper.transform.eulerAngles = targetAngle; if (orbArr[oldOrbX, oldOrbY].orbObject.transform.parent == orbSwapper.transform) { orbArr[oldOrbX, oldOrbY].orbObject.transform.parent = null; } if (orbClone.orbObject != null) { if (orbClone.orbObject.transform.parent == orbSwapper.transform) { orbClone.orbObject.transform.parent = null; } } if (orbSwapper != null) { Destroy(orbSwapper); } }
private void QueueOrb(Orb orb) { _orbQueue.Enqueue(orb); }
private void addHardSkill(int index) { System.Random rand = new System.Random(getRandomSeedByFloor()); Func <bool> wtu = () => true; Func <ORB_VALUE, OrbSpawnRate> newSpawnRates; bool markZeroAndFives = currState.number % 5 == 0; bool isAnti = RNG.Next(2) == 0; switch (index) { case 0: int numNullify = rand.Next(1, 3); wtu = () => GameController.Instance.isTurnMod(2 * numNullify, RNG.Next(numNullify)); Func <Orb, bool> randZeros = (Orb o) => { List <Orb> currZeros = new List <Orb>(); for (int i = 0; i < Board.COLUMNS; i++) { for (int j = 0; j < Board.ROWS; j++) { Orb z = Board.Instance.getOrb(i, j); if (z.getOrbValue() == ORB_VALUE.ZERO) { currZeros.Add(z); } } } for (int i = 0; i < numNullify && currZeros.Count > 0; i++) { int orb = rand.Next(currZeros.Count); if (currZeros[orb] == o) { return(true); } currZeros.RemoveAt(orb); } return(false); }; EnemyBoardSkill zerosToNullify = EnemyBoardSkill.MarkIfSkill(wtu, randZeros, 0.1f, skillTrans); zerosToNullify.addSetSkill(0.1f, (Orb o) => ORB_VALUE.NULLIFY); skillList.Add(zerosToNullify); break; case 1: int numOrbReduce = rand.Next(1, 4); newSpawnRates = (ORB_VALUE orbVal) => { if (markZeroAndFives) { return(orbVal == ORB_VALUE.ZERO || orbVal == ORB_VALUE.FIVE ? OrbSpawnRate.DECREASED : Board.getDefaultOrbSpawnRates()[(int)orbVal]); } return(orbVal <= ORB_VALUE.NINE && (int)orbVal % 2 == 0 ? OrbSpawnRate.DECREASED : Board.getDefaultOrbSpawnRates()[(int)orbVal]); }; wtu = () => GameController.Instance.isTurnMod(2 * numOrbReduce, RNG.Next(numOrbReduce)); skillList.Add(EnemyOrbSkill.Create(wtu, newSpawnRates, numOrbReduce, skillTrans)); break; case 2: wtu = () => GameController.Instance.isTurnMod(3, RNG.Next(3)); Func <Orb, bool> evensOrFives = (Orb o) => o.isDigit() && o.getIntValue() % (markZeroAndFives ? 5 : 2) == 0; EnemyBoardSkill clearEvensOrFives = EnemyBoardSkill.MarkIfSkill(wtu, evensOrFives, 0.1f, skillTrans); clearEvensOrFives.addRmvSkill(0); skillList.Add(clearEvensOrFives); break; case 3: wtu = () => GameController.Instance.isTurnMod(3, RNG.Next(3)); EnemyBoardSkill replaceWithAntiOrStop = null; replaceWithAntiOrStop = EnemyBoardSkill.MarkOrderSkill(wtu, () => getRandomPattern(replaceWithAntiOrStop), 0.1f, skillTrans, 1); replaceWithAntiOrStop.addSetSkill(0.1f, (Orb o) => isAnti ? ORB_VALUE.POISON : ORB_VALUE.STOP); skillList.Add(replaceWithAntiOrStop); break; case 4: wtu = () => GameController.Instance.isTurnMod(4, RNG.Next(4)); EnemyBoardSkill emptyFourLines = null; emptyFourLines = EnemyBoardSkill.MarkOrderSkill(wtu, () => getFourLines(emptyFourLines), 0.1f, skillTrans, 1); emptyFourLines.addSetSkill(0.1f, (Orb o) => ORB_VALUE.EMPTY); skillList.Add(emptyFourLines); break; case 5: wtu = () => GameController.Instance.isTurnMod(3, RNG.Next(3)); EnemyBoardSkill allHealsToAntiOrStop = EnemyBoardSkill.MarkIfSkill(wtu, (Orb o) => o.getOrbValue() == ORB_VALUE.ZERO, 0.1f, skillTrans, 1); allHealsToAntiOrStop.addSetSkill(0.1f, (Orb o) => isAnti ? ORB_VALUE.POISON : ORB_VALUE.STOP); skillList.Add(allHealsToAntiOrStop); break; case 6: int numNoneZeroTurns = rand.Next(1, 3); newSpawnRates = (ORB_VALUE orbVal) => orbVal == ORB_VALUE.ZERO ? OrbSpawnRate.NONE : Board.getDefaultOrbSpawnRates()[(int)orbVal]; wtu = () => GameController.Instance.isTurnMod(2 * numNoneZeroTurns, RNG.Next(numNoneZeroTurns)); skillList.Add(EnemyOrbSkill.Create(wtu, newSpawnRates, numNoneZeroTurns, skillTrans)); break; case 7: int antiOrStop = rand.Next(2, 4); newSpawnRates = (ORB_VALUE orbVal) => orbVal == (antiOrStop == 2 ? ORB_VALUE.POISON : ORB_VALUE.STOP) ? OrbSpawnRate.INCREASED : Board.getDefaultOrbSpawnRates()[(int)orbVal]; wtu = () => GameController.Instance.isTurnMod(antiOrStop, RNG.Next(antiOrStop - 1)); skillList.Add(EnemyOrbSkill.Create(wtu, newSpawnRates, 1, skillTrans)); break; case 8: int numTimerTurns = rand.Next(1, 3); wtu = () => GameController.Instance.isTurnMod(2 * numTimerTurns, RNG.Next(numTimerTurns)); EnemyTimer numDOT = EnemyTimer.Create(wtu, Mathf.Clamp(currState.number / 10f, 0f, 10f), numTimerTurns, skillTrans); numDOT.addDOTSkill(() => - currState.number); skillList.Add(numDOT); break; case 9: int numDecrement = rand.Next(1, 4); wtu = () => GameController.Instance.isTurnMod(numDecrement + 2, RNG.Next(numDecrement)); EnemyBoardSkill decrementPattern = null; decrementPattern = EnemyBoardSkill.MarkOrderSkill(wtu, () => getRandomPattern(decrementPattern), 0.1f, skillTrans, numDecrement); decrementPattern.addIncSkill(0.1f, (Orb o) => - numDecrement); skillList.Add(decrementPattern); break; } }
public Orb RemoveOrb() { Colour = new Color(); Orb toReturn = orb; orb = null; return toReturn; }
internal OrbMessage(Orb orb, IOrbSerializer serializer) { this.orb = orb; this.serializer = serializer; }
private static Path GetBestPathFrom(Board b, Options o, int y, int x, BoardScorer.Options bso) { Path bestPath = new Path(); PriorityQueue <Tuple <Board, Path>, double> paths = new PriorityQueue <Tuple <Board, Path>, double>(); paths.Enqueue(new Tuple <Board, Path>(b, new Path { Start = new Tuple <int, int>(y, x), Current = new Tuple <int, int>(y, x), Depth = 1, Score = b.Score(bso) })); int depth = 0; while (depth++ < o.MaxDepth) { // Console.WriteLine("currently at depth {0}...", depth); PriorityQueue <Tuple <Board, Path>, double> newPaths = new PriorityQueue <Tuple <Board, Path>, double>(); while (paths.Count != 0) { var cur = paths.Dequeue(); var curPath = cur.Item2; var curBoard = cur.Item1; if (curPath.Score > bestPath.Score) { bestPath = curPath; } //if (paths.Count() > o.WhenToPrune) //{ // var newPaths = new Stack<Tuple<Board, Path>>(); // foreach (var path in paths.OrderByDescending(p => p.Item2.Score).Take(o.NumToKeep).Reverse()) // newPaths.Push(path); // paths = newPaths; //} foreach (var direction in Board.MoveDirections) { if (curPath.Length != 0 && curPath.Actions.Last()[0] == -direction[0] && curPath.Actions.Last()[1] == -direction[1]) { continue; } var newY = curPath.Current.Item1 + direction[0]; var newX = curPath.Current.Item2 + direction[1]; if (newY < 0 || newY >= b.Height || newX < 0 || newX >= b.Width) { continue; } Board newBoard = new Board(curBoard); Orb tempOrb = newBoard.Orbs[newY, newX]; newBoard.Orbs[newY, newX] = newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2]; newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2] = tempOrb; var newPath = new List <int[]>(curPath.Actions); newPath.Add(direction); double score = newBoard.Score(bso) - curPath.Depth / 100; newPaths.Enqueue(new Tuple <Board, Path>(newBoard, new Path { Start = curPath.Start, Current = new Tuple <int, int>(newY, newX), Depth = curPath.Depth + 1, Score = score, Actions = newPath }), score); } } paths = newPaths.TrimToSize(o.BeamWidth); } return(bestPath); }
public Board(int height, int width) { Orbs = new Orb[height, width]; Enhancements = new bool[height, width]; }
private void TurnOptionsOff() { Options.SetActive(false); OrbCounter.SetActive(false); Orb.SetActive(false); }
public Sequence OnTurn(int x, int y, bool blink = false) { Sequence sequence = DOTween.Sequence(); // Store the previous location prevPos = pos.GetVector2i(); if (tileManager.GetTileData(x, y).color == TileColor.None || tileManager.GetTileData(x, y).type == TileType.Wall) { return(sequence); } Monster foundMonster = GameStateManager.Instance.CheckMonsterPosition(x, y); if (foundMonster != null) { ApplyDamage(foundMonster.DamageToPlayer); foundMonster.moveCancelled = true; sequence.Append(pos.AnimatedMove(x, y, 0.2f).OnPlay(() => { animator.SetTrigger("Hit"); StartCoroutine(PlayDamageEffect()); })); sequence.Append(pos.AnimatedMove(prevPos.x, prevPos.y, 0.2f)); return(sequence); } if (blink) { sequence.Append(pos.AnimatedMove(x, y, 0.2f).OnPlay(() => { // Debug.Log("Set blink trigger"); animator.SetTrigger("Blink"); FindObjectOfType <InputHandler>().inputManager.CanBlink = false; })); } else { sequence.Append(pos.AnimatedMove(x, y, 0.2f).OnPlay(() => { animator.SetTrigger("Move"); })); } // Consume the orb after the player paints the current color Orb foundOrb = GameStateManager.Instance.CheckOrbPosition(x, y); if (foundOrb != null) { if (playerTileColor != foundOrb.Color) { if (foundOrb.Color == TileColor.Red) { soundManager.PlayBackground(SoundManager.Sounds.Red); } else if (foundOrb.Color == TileColor.Blue) { soundManager.PlayBackground(SoundManager.Sounds.Blue); } else if (foundOrb.Color == TileColor.Yellow) { soundManager.PlayBackground(SoundManager.Sounds.Yellow); } } playerTileColor = foundOrb.Color; UpdateAuraColor(); } GameItem foundItem = GameStateManager.Instance.CheckItemPosition(x, y); if (foundItem != null) { Inventory.Add(foundItem); GameStateManager.Instance.items.Remove(foundItem); Destroy(foundItem.gameObject); } if ((playerTileColor != TileColor.None) && (foundOrb == null)) { bool fillingExecuted = tileManager.SetTileColorAndFill(x, y, playerTileColor); if (fillingExecuted) { soundManager.Play(SoundManager.Sounds.TileActivate); } tileManager.GetTile(x, y).PlaySubEffect(); } return(sequence); } // end of OnTurn
public void AddOrb(Orb orb) { orbs.Add(orb); }
//public static Path GetBestPath(Board b, Options o, BoardScorer.Options bso) //{ // Board targetBoard = new Board(b.Height, b.Width); // Board goalBoard = GetOptimalBoards(b, o, bso).First(); // Path path = new Path(); // for (int j = 0; j < targetBoard.Width; j++) // for (int i = 0; i < targetBoard.Height; i++) // { // targetBoard.Orbs[i, j] = goalBoard.Orbs[i, j]; // path = GetBestPathFrom(b, targetBoard, bso, path); // b = b.GetBoardsAfterPath(path.Start.Item1, path.Start.Item2, path.Actions).Item1; // } // return path; //} //private static Path GetBestPathFrom(Board b, Board target, BoardScorer.Options bso, Path p) //{ // HashSet<Board> explored = new HashSet<Board>(); // explored.Add(b); // Queue<Tuple<Board, Path>> paths = new Queue<Tuple<Board, Path>>(); // paths.Enqueue(new Tuple<Board, Path>(b, p)); // while (paths.Any()) // { // var cur = paths.Dequeue(); // var curPath = cur.Item2; // var curBoard = cur.Item1; // if (curBoard.EqualsBoard(target, ignoreNone: true)) // return curPath; // foreach (var direction in Board.MoveDirections) // { // if (curPath.Length != 0 && // curPath.Actions.Last()[0] == -direction[0] && // curPath.Actions.Last()[1] == -direction[1]) // continue; // var newY = curPath.Current.Item1 + direction[0]; // var newX = curPath.Current.Item2 + direction[1]; // if (newY < 0 || newY >= b.Height || // newX < 0 || newX >= b.Width) // continue; // Board newBoard = new Board(curBoard); // Orb tempOrb = newBoard.Orbs[newY, newX]; // newBoard.Orbs[newY, newX] = newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2]; // newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2] = tempOrb; // var newPath = new List<int[]>(curPath.Actions); // newPath.Add(direction); // if (explored.Contains(newBoard)) // continue; // explored.Add(newBoard); // paths.Enqueue(new Tuple<Board, Path>(newBoard, new Path // { // Start = curPath.Start, // Current = new Tuple<int, int>(newY, newX), // Depth = curPath.Depth + 1, // Score = 0, // Actions = newPath // })); // } // } // return null; //} // a-star is silly if all edges are length 1...? public static Path GetBestPath(Board b, Options o, BoardScorer.Options bso) { Board goalBoard = GetOptimalBoards(b, o, bso).First(); Heuristic h = o.HeuristicGen(goalBoard); PriorityQueue <Tuple <Board, Path>, double> queue = new PriorityQueue <Tuple <Board, Path>, double>(); HashSet <Board> visited = new HashSet <Board>(); Dictionary <Board, double> toExplore = new Dictionary <Board, double>(); toExplore.Add(b, 0); queue.Enqueue(new Tuple <Board, Path>(b, new Path { Start = new Tuple <int, int>(2, 2) }), -h(b)); while (!queue.Empty) { var cur = queue.Dequeue(); var curBoard = cur.Item1; var curPath = cur.Item2; var curCost = curPath.Depth; if (curBoard.EqualsBoard(goalBoard)) { return(curPath); } visited.Add(curBoard); foreach (var direction in Board.MoveDirections) { if (curPath.Length != 0 && curPath.Actions.Last()[0] == -direction[0] && curPath.Actions.Last()[1] == -direction[1]) { continue; } var newY = curPath.Current.Item1 + direction[0]; var newX = curPath.Current.Item2 + direction[1]; if (newY < 0 || newY >= b.Height || newX < 0 || newX >= b.Width) { continue; } Board newBoard = new Board(curBoard); Orb tempOrb = newBoard.Orbs[newY, newX]; newBoard.Orbs[newY, newX] = newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2]; newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2] = tempOrb; if (visited.Contains(newBoard) || toExplore.ContainsKey(newBoard) && toExplore[newBoard] <= curCost + 1) { continue; } var newPath = new List <int[]>(curPath.Actions); newPath.Add(direction); queue.Enqueue(new Tuple <Board, Path>(newBoard, new Path { Start = curPath.Start, Current = new Tuple <int, int>(newY, newX), Depth = curCost + 1, Score = 0, //newBoard.Score(BoardScorer.Options.Horus) - curPath.Depth / 100, Actions = newPath }), -h(newBoard) - curCost - 1); toExplore[newBoard] = curCost + 1; } } return(new Path()); }
public void RemoveOrb(Orb orb) { orbs.Remove(orb); }
internal static extern void cv_features2d_ORB_compute(Orb extractor, Arr image, KeyPointCollection keypoints, Arr descriptors);
public bool RemoveOrbPermanently(Orb orb, int quantity = 1) { int orbTypeIndex = ( int )orb.type; int countToRemove = quantity; // make sure quantity is less than or equal to number of that orb in hand and bag int numInBag = 0; int numInHand = 0; if (QuantityTable.ContainsKey(orb.asset_name)) { numInBag = QuantityTable[orb.asset_name]; } if (DrawnQuantityTable.ContainsKey(orb.asset_name)) { numInHand = DrawnQuantityTable[orb.asset_name]; } if (countToRemove <= (numInBag + numInHand)) { // removing from Orb list that will be saved to JSON RemoveOrbFromOrbList(orb, quantity); // remove from hand first then bag // num in hand is greater than count to remove so remove that much // no need to readjust weight table since this has already been taken out of the bag if (numInHand >= countToRemove) { DrawnQuantityTable[orb.asset_name] -= countToRemove; TypeTableDrawn[orbTypeIndex] -= countToRemove * orb.power; countToRemove = 0; NumberOfOrbsDrawn -= countToRemove; } else if (numInHand > 0) { countToRemove -= DrawnQuantityTable[orb.asset_name]; NumberOfOrbsDrawn -= DrawnQuantityTable[orb.asset_name]; DrawnQuantityTable[orb.asset_name] = 0; TypeTableDrawn[orbTypeIndex] = 0; } // if we've removed all the orbs we need to then return true and leave function. // else, try to remove from bag if (countToRemove == 0) { return(true); } if (numInBag >= countToRemove) { QuantityTable[orb.asset_name] -= countToRemove; TypeTableInBag[orbTypeIndex] -= countToRemove * orb.power; ReadjustWeightTableAfterRemove(orb, countToRemove); NumberOfOrbsInBag -= countToRemove; countToRemove = 0; } else if (numInBag > 0) { NumberOfOrbsInBag -= QuantityTable[orb.asset_name]; ReadjustWeightTableAfterRemove(orb, QuantityTable[orb.asset_name]); countToRemove -= QuantityTable[orb.asset_name]; QuantityTable[orb.asset_name] = 0; TypeTableInBag[orbTypeIndex] = 0; } return(countToRemove == 0); } else { Debug.LogError(string.Format("ERROR in Bag.cs RemoveOrbPermanently: Cannot remove {0} orb from bag / hand. " + "Currently have {1} in bag / hand and requesting {2} to be removed", orb.asset_name, numInHand + numInBag, quantity)); } return(false); }
public void SetSelectedToNull() { selectedOrb = null; }
private static Path GetBestPathFrom(Board b, Options o, int y, int x) { Path bestPath = new Path(); Stack <Tuple <Board, Path> > paths = new Stack <Tuple <Board, Path> >(); paths.Push(new Tuple <Board, Path>(b, new Path { Start = new Tuple <int, int>(y, x), Current = new Tuple <int, int>(y, x), Depth = 1, Score = b.Score(BoardScorer.Options.Horus) })); while (paths.Any()) { var cur = paths.Pop(); var curPath = cur.Item2; var curBoard = cur.Item1; if (curPath.Score > bestPath.Score) { bestPath = curPath; } if (curPath.Depth == o.MaxDepth) { continue; } //if (paths.Count() > o.WhenToPrune) //{ // var newPaths = new Stack<Tuple<Board, Path>>(); // foreach (var path in paths.OrderByDescending(p => p.Item2.Score).Take(o.NumToKeep).Reverse()) // newPaths.Push(path); // paths = newPaths; //} foreach (var direction in Board.MoveDirections) { if (curPath.Length != 0 && curPath.Actions.Last()[0] == -direction[0] && curPath.Actions.Last()[1] == -direction[1]) { continue; } var newY = curPath.Current.Item1 + direction[0]; var newX = curPath.Current.Item2 + direction[1]; if (newY < 0 || newY >= b.Height || newX < 0 || newX >= b.Width) { continue; } Board newBoard = new Board(curBoard); Orb tempOrb = newBoard.Orbs[newY, newX]; newBoard.Orbs[newY, newX] = newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2]; newBoard.Orbs[curPath.Current.Item1, curPath.Current.Item2] = tempOrb; var newPath = new List <int[]>(curPath.Actions); newPath.Add(direction); paths.Push(new Tuple <Board, Path>(newBoard, new Path { Start = curPath.Start, Current = new Tuple <int, int>(newY, newX), Depth = curPath.Depth + 1, Score = newBoard.Score(BoardScorer.Options.Horus) - curPath.Depth / 100, Actions = newPath })); } } return(bestPath); }
public void ProcessOrb(Orb orb) { bool skullLimitPassed = _player.ProcessOrb(orb); OrbProcessedEvent?.Invoke(skullLimitPassed); }
public State(DTenemy enemy, Orb o, Goal pGoal, Goal eGoal) { this.enemy = enemy; this.pGoal = pGoal; this.eGoal = eGoal; }
public void Serialize(NetworkWriter writer, Orb target) => throw new InvalidOperationException("Cannot serialize using the default orb serializer");
// Update is called once per frame void Update() { int mod = -1; float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); float rotationX = transform.localEulerAngles.y + Input.GetAxis("Mouse X") * sensitivityX; Vector3 vel = (transform.forward * v + transform.right * h) * speed; rotationY += Input.GetAxis("Mouse Y") * sensitivityY; rotationY = Mathf.Clamp(rotationY, minimumY, maximumY); transform.localEulerAngles = new Vector3(-rotationY, rotationX, 0); if (cc.isGrounded) { vSpeed = 0; // We are grounded, so recalculate // move direction directly from axes if (Input.GetButton("Jump")) { vSpeed = jumpSpeed; } } if (absorbed) { switch (grabbedOrb.type) { case Orb.Type.Speed: vel *= 2f; break; case Orb.Type.Flip: mod = 1; break; } } vSpeed = vSpeed + (gravity * Time.deltaTime) * mod; vel.y = vSpeed; cc.Move(vel * Time.deltaTime); if (grabbedOrb == null) { Ray ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width / 2, Screen.height / 2, 0)); if (Physics.Raycast(ray, out hit, 1.5f)) { GameObject go = hit.collider.gameObject; if (go.GetComponent <Orb> () != null) { go.GetComponent <Orb> ().Hover(); if (Input.GetMouseButtonDown(0)) { grabbedOrb = go.GetComponent <Orb> (); grabbedOrb.grabbed = true; foreach (Collider c in go.GetComponents <Collider>()) { c.enabled = false; } grabbedOrb.GetComponent <Rigidbody>().useGravity = false; grabbedOrb.GetComponent <Rigidbody>().Sleep(); } } } } else { grabbedOrb.transform.position = Camera.main.transform.position + (Camera.main.transform.forward * .6f); grabbedOrb.transform.rotation = Quaternion.Euler(0, transform.rotation.eulerAngles.y - 90, transform.rotation.eulerAngles.z); // Dropping orb if (Input.GetMouseButtonDown(0)) { Vector3 pos = Camera.main.transform.position + (Camera.main.transform.forward * .35f); Orb b = grabbedOrb.GetComponent <Orb>(); b.grabbed = false; grabbedOrb.transform.position = pos; b.GetComponent <Rigidbody>().WakeUp(); b.GetComponent <Rigidbody>().useGravity = true; b.GetComponent <Rigidbody>().isKinematic = false; b.GetComponent <Rigidbody>().velocity = cc.velocity; foreach (Collider c in grabbedOrb.GetComponents <Collider>()) { c.enabled = true; } grabbedOrb = null; absorbed = false; } // Throwing orb else if (Input.GetButtonDown("Throw")) { Vector3 pos = Camera.main.transform.position + (Camera.main.transform.forward * .35f); Orb b = grabbedOrb.GetComponent <Orb>(); grabbedOrb.transform.position = pos; b.GetComponent <Rigidbody>().WakeUp(); b.GetComponent <Rigidbody>().useGravity = true; b.GetComponent <Rigidbody>().isKinematic = false; foreach (Collider c in grabbedOrb.GetComponents <Collider>()) { c.enabled = true; } b.GetComponent <Rigidbody> ().AddForce(transform.forward * 500); grabbedOrb = null; absorbed = false; } // Absorb orb else if (Input.GetButtonDown("Absorb")) { absorbed = !absorbed; } } }
public void Deserialize(NetworkReader reader, Orb target) => _ = target is TOrb orb?reader.Read(ref orb) : throw new InvalidOperationException($"Invalid orb type, must be {this.guid}");
public void Deserialize(NetworkReader reader) { this.serializer = OrbSerializerCatalog.GetDef(reader.ReadBits <OrbSerializerCatalog.Index>()) !; this.orb = this.serializer.CreateInstance(); reader.Read(ref this.orb, this.serializer); }
private static void Orbwalking_BeforeAttack(Orb.Orbwalking.BeforeAttackEventArgs args) { ChampionClass.Orbwalking_BeforeAttack(args); }