コード例 #1
0
 public void Move(int dir)
 {
     targetIndex  = OPMath.FullLoop(0, targetList.values.Count, targetIndex + dir);
     target.value = targetList.values[targetIndex];
     targetChangedEvent.Invoke();
     cursorMovedEvent.Invoke();
 }
コード例 #2
0
    /// <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();
    }
コード例 #3
0
 public void ChangeControllerP2(int dir)
 {
     do
     {
         p2Index.value = OPMath.FullLoop(0, schemePool.Length - 1, p2Index.value + dir);
     } while (p1Index.value == p2Index.value);
     SetupControllers();
 }
コード例 #4
0
    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);
    }
コード例 #5
0
    public void OnDown()
    {
        if (!paused.value)
        {
            return;
        }
        pauseIndex = OPMath.FullLoop(0, pauseButtons.Length - 1, pauseIndex + 1);

        UpdateButtons();
    }
コード例 #6
0
    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();
    }
コード例 #7
0
 public void OnRight()
 {
     if (menuMode == 1)
     {
         levelIndex = OPMath.FullLoop(0, levelButtons.Count - 1, levelIndex + 1);
         UpdateButtons();
     }
     else if (menuMode == 2)
     {
         ChangeControllerP1(1);
     }
 }
コード例 #8
0
 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();
     }
 }
コード例 #9
0
    /// <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();
    }
コード例 #10
0
    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);
    }
コード例 #11
0
    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();
    }
コード例 #12
0
    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();
    }
コード例 #13
0
    /// <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);
    }
コード例 #14
0
    /// <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);
    }
コード例 #15
0
ファイル: ClassWheel.cs プロジェクト: parrexion/Fried-Embrum
    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);
    }
コード例 #16
0
 public void MoveHorizontal(int dir)
 {
     position = OPMath.FullLoop(0, houseCount.value * roomCount.value, position + dir);
     UpdateSelection();
 }
コード例 #17
0
 private void ChangeSchema(int dir)
 {
     currentSchema = OPMath.FullLoop(0, schemes.Length, currentSchema += dir);
     UpdateScheme();
 }
コード例 #18
0
ファイル: MapCursor.cs プロジェクト: parrexion/Fried-Embrum
    /// <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();
    }
コード例 #19
0
    /// <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;
        }
    }
コード例 #20
0
ファイル: MyTabber.cs プロジェクト: parrexion/Fried-Embrum
 /// <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();
 }
コード例 #21
0
 public void MoveVertical(int dir)
 {
     position = OPMath.FullLoop(0, houseCount.value * roomCount.value, position + dir * roomCount.value * rowSize);
     UpdateSelection();
 }