public void Move(int dir) { targetIndex = OPMath.FullLoop(0, targetList.values.Count, targetIndex + dir); target.value = targetList.values[targetIndex]; targetChangedEvent.Invoke(); cursorMovedEvent.Invoke(); }
/// <summary> /// Moves the highlight to the next active entry in the list. /// dir is the amount of steps back or forward in the list. /// </summary> /// <param name="dir"></param> public void Move(int dir) { if (!isSelected) { return; } if (entries.Count == 0) { position = 0; return; } position = OPMath.FullLoop(0, entries.Count, position + dir); if (position <= bot) { bot = Mathf.Max(0, position - 1); } else if (top - 1 <= position) { bot = Mathf.Max(0, Mathf.Min(entries.Count - visibleSize, position - visibleSize + 2)); } top = Mathf.Min(bot + visibleSize, entries.Count); UpdateEntries(); }
public void ChangeControllerP2(int dir) { do { p2Index.value = OPMath.FullLoop(0, schemePool.Length - 1, p2Index.value + dir); } while (p1Index.value == p2Index.value); SetupControllers(); }
public override bool MoveValue(int dir) { index = OPMath.FullLoop(0, selections.Length, index + dir); value.value = (selections[index] != null) ? selections[index].value : index; valueText.text = selectionNames[index]; updateEvent.Invoke(); return(true); }
public void OnDown() { if (!paused.value) { return; } pauseIndex = OPMath.FullLoop(0, pauseButtons.Length - 1, pauseIndex + 1); UpdateButtons(); }
public void UpdateAwardExp(int dir) { if (!awardMode) { return; } int cap = (totalScrap.value > 0) ? Mathf.Min(11, totalScrap.value + 1) : 1; awardAmount = OPMath.FullLoop(0, cap, awardAmount + dir); SetupBexpAwarding(); }
public void OnRight() { if (menuMode == 1) { levelIndex = OPMath.FullLoop(0, levelButtons.Count - 1, levelIndex + 1); UpdateButtons(); } else if (menuMode == 2) { ChangeControllerP1(1); } }
public override void OnDownArrow() { if (!selectMode) { inventoryIndex.value = OPMath.FullLoop(0, InventoryContainer.INVENTORY_SIZE, inventoryIndex.value + 1); inventoryChangedEvent.Invoke(); menuMoveEvent.Invoke(); } else { itemMenuPosition.value = inventoryButtons.Move(1); menuMoveEvent.Invoke(); } }
/// <summary> /// Moves the cursor on the prompt in dir direction. /// </summary> public void Move(int dir) { if (position == -1 || optionSize == 0) { return; } if (optionSize > 2) { dir *= -1; } position = OPMath.FullLoop(0, optionSize, position - dir); UpdateButtons(); }
public bool MoveHorizontal(int dir) { if (selectionY == -1) { return(false); } selectionX = OPMath.FullLoop(0, squadCount + 1, selectionX + dir); int listSize = Mathf.Max(squadLists[selectionX].values.Count - 1, 0); selectionY = Mathf.Min(selectionY, listSize); UpdateSelection(); return(true); }
public void OnUp() { if (menuMode == 0) { currentIndex--; if (currentIndex < 0) { currentIndex = mainButtons.Length - 1; } } else if (menuMode == 1) { levelIndex = OPMath.FullLoop(0, levelButtons.Count - 1, levelIndex - 10); } UpdateButtons(); }
public void OnDown() { if (menuMode == 0) { currentIndex++; if (currentIndex > mainButtons.Length - 1) { currentIndex = 0; } } else if (menuMode == 1) { levelIndex = OPMath.FullLoop(0, levelButtons.Count - 1, levelIndex + 10); } UpdateButtons(); }
/// <summary> /// Changes to the next available weapon without equipping it for the forecast. /// </summary> /// <param name="diff"></param> public void ChangeWeapon(int diff) { bool inRange = false; int startIndex = listIndex; do { listIndex = OPMath.FullLoop(0, attackerWeapons.Count, listIndex + diff); inRange = attackerWeapons[listIndex].InRange(BattleMap.DistanceTo(selectedCharacter.value, defendTile.value)); battleWeaponIndex.value = attackerWeapons[listIndex].index; } while (!inRange && startIndex != listIndex); if (startIndex != listIndex) { menuMoveEvent.Invoke(); } forecast.UpdateUI(true); }
/// <summary> /// Moves the highlight to the next button. /// dir defins which direction the selection should move in. /// </summary> /// <param name="dir"></param> public int Move(int dir) { if (buttonNames.Count == 0) { return(-1); } position = OPMath.FullLoop(0, buttonNames.Count, position + dir); if (position <= bot) { bot = Mathf.Max(0, position - 1); } else if (top - 1 <= position) { bot = Mathf.Max(0, Mathf.Min(buttonNames.Count - size, position - size + 2)); } top = Mathf.Min(bot + size, buttonNames.Count); UpdateButtons(); return(position); }
public List <LevelGain> LevelupOptions(int[] classLevels) { List <LevelGain> gains = new List <LevelGain>(); int nextLeft = 0, nextRight = 0; int adjacent = 0, current = 0; for (int i = 0; i < classLevels.Length; i++) { nextLeft = OPMath.FullLoop(0, CLASS_COUNT, i - 1); nextRight = OPMath.FullLoop(0, CLASS_COUNT, i + 1); adjacent = (classLevels[nextLeft] > 0 || classLevels[nextRight] > 0) ? 1 : 0; current = (classLevels[i] > 0) ? classLevels[i] + 1 : 0; int level = Mathf.Max(current, adjacent); if (level == 0) { continue; } LevelGain gain = new LevelGain() { className = classes[i].entryName, classIcon = classes[i].icon, level = level, weaponSkills = classes[i].weaponSkills, skill = classes[i].skills[level - 1], bonusHp = classes[i].bonusHp, bonusDmg = classes[i].bonusDmg, bonusMnd = classes[i].bonusMnd, bonusSkl = classes[i].bonusSkl, bonusSpd = classes[i].bonusSpd, bonusDef = classes[i].bonusDef }; gains.Add(gain); } return(gains); }
public void MoveHorizontal(int dir) { position = OPMath.FullLoop(0, houseCount.value * roomCount.value, position + dir); UpdateSelection(); }
private void ChangeSchema(int dir) { currentSchema = OPMath.FullLoop(0, schemes.Length, currentSchema += dir); UpdateScheme(); }
/// <summary> /// Makes the cursor jump to the next character in line. /// </summary> public void JumpCursor() { if (selectCharacter.value == null) { // No selected character - move to next character to move for (int i = 0; i < playerCharacters.values.Count; i++) { if (!playerCharacters.values[i].hasMoved && !playerCharacters.values[i].hasEscaped) { cursorX.value = playerCharacters.values[i].posx; cursorY.value = playerCharacters.values[i].posy; cursorMovedEvent.Invoke(); break; } } } else if (selectCharacter.value.faction == Faction.PLAYER) { // Player selected - Jump to next player that hasn't moved int pos = 0; for (int i = 0; i < playerCharacters.values.Count; i++) { pos = i; TacticsMove tactics = playerCharacters.values[i]; if (tactics.posx == cursorX.value && tactics.posy == cursorY.value) { break; } } int startPos = pos; do { pos = OPMath.FullLoop(0, playerCharacters.values.Count, pos + 1); } while (startPos != pos && playerCharacters.values[pos].hasMoved && playerCharacters.values[pos].hasEscaped); cursorX.value = playerCharacters.values[pos].posx; cursorY.value = playerCharacters.values[pos].posy; cursorMovedEvent.Invoke(); } else if (selectCharacter.value.faction == Faction.ENEMY) { // Enemy selected - Jump to next enemy int pos = 0; for (int i = 0; i < enemyCharacters.values.Count; i++) { pos = i; TacticsMove tactics = enemyCharacters.values[i]; if (tactics.posx == cursorX.value && tactics.posy == cursorY.value) { break; } } pos = OPMath.FullLoop(0, enemyCharacters.values.Count, pos + 1); cursorX.value = enemyCharacters.values[pos].posx; cursorY.value = enemyCharacters.values[pos].posy; cursorMovedEvent.Invoke(); } UpdateCursor(); CursorHover(); }
/// <summary> /// Searches for the best tile to move to with the currently equipped weapon. /// If no tile can be reached within 1 turn, a good tile is picked instead and the /// AI will be able to move towards that tile instead. /// </summary> /// <param name="weapons"></param> /// <param name="tileBest"></param> /// <param name="tileGood"></param> private void FindBestTile(List <InventoryTuple> weapons, out MapTile tileBest, out MapTile tileGood) { // Generate map links GenerateHitTiles(weapons); if (aggroType == AggroType.HUNT && huntTile.interacted) { aggroType = AggroType.CHARGE; Debug.Log("CHARGE!"); } // Skip move if guarding type of enemy if (aggroType == AggroType.GUARD || aggroType == AggroType.BOSS) { if (currentTile.attackable) { currentMode.value = (weapons[0].itemCategory == ItemCategory.WEAPON) ? ActionMode.ATTACK : ActionMode.HEAL; //currentMode.value = ActionMode.MOVE; tileBest = currentTile; //tileBest = null; tileGood = null; } else { tileBest = null; tileGood = null; //tileGood = currentTile; currentMode.value = ActionMode.NONE; } return; } BFS(); int moveSpeed = GetMoveSpeed(); MapTile bestTile = null; // Reachable this turn MapTile goodTile = null; // Reachable in multiple turns //Hunting or Escaping AI if (aggroType == AggroType.HUNT || aggroType == AggroType.ESCAPE) { tileBest = huntTile; tileGood = null; while (tileBest != null && (tileBest.distance > moveSpeed || !tileBest.selectable)) { tileBest = tileBest.parent; } if (tileBest != null) { tileBest.PrintPos(); currentMode.value = ActionMode.MOVE; return; } } // Go through all tiles and find the best one to move to or towards for (int i = 0; i < battleMap.tiles.Length; i++) { MapTile tempTile = battleMap.tiles[i]; if ((!tempTile.attackable && !tempTile.supportable) || !tempTile.selectable) { continue; } tempTile.target = true; if (tempTile.distance <= moveSpeed) { if (IsBetterTile(bestTile, tempTile)) { bestTile = tempTile; } } else { if (IsBetterTile(goodTile, tempTile)) { goodTile = tempTile; } } } if (bestTile) { // Found a best tile to move to bestTile.current = true; currentMode.value = (weapons[0].itemCategory == ItemCategory.WEAPON) ? ActionMode.ATTACK : ActionMode.HEAL; tileBest = bestTile; tileGood = null; if (aggroType == AggroType.WAIT) { aggroType = AggroType.CHARGE; } } else if (goodTile && aggroType != AggroType.CHARGE && aggroType != AggroType.PATROL) { //Have no weapons that can be used currentMode.value = ActionMode.NONE; tileBest = null; tileGood = null; } else if (aggroType == AggroType.PATROL) { tileBest = null; tileGood = patrolTiles[patrolIndex]; while (tileGood != null && (tileGood.distance > moveSpeed || !tileGood.selectable)) { tileGood = tileGood.parent; } if (tileGood != null) { tileGood.PrintPos(); currentMode.value = ActionMode.MOVE; if (tileGood == patrolTiles[patrolIndex]) { patrolIndex = OPMath.FullLoop(0, patrolTiles.Count, patrolIndex + 1); } return; } else { currentMode.value = ActionMode.NONE; tileGood = null; return; } } else { //The finds the tile which takes the character towards the good tile if (goodTile != null) { while (goodTile.distance > moveSpeed || !goodTile.IsEmpty(this)) { goodTile = goodTile.parent; } goodTile.current = true; } currentMode.value = ActionMode.MOVE; tileBest = null; tileGood = goodTile; } }
/// <summary> /// Changes the current tab in the direction of dir. /// </summary> /// <param name="dir"></param> public void Move(int dir) { position = OPMath.FullLoop(0, tabs.Length, position + dir); UpdateTabs(); }
public void MoveVertical(int dir) { position = OPMath.FullLoop(0, houseCount.value * roomCount.value, position + dir * roomCount.value * rowSize); UpdateSelection(); }