예제 #1
0
    public void InstantiateEnemyByNetwork(string enemyId, int tileKey, Enemy.EnemyType type)
    {
        Tile startTile = TileManager.GetExistTile(tileKey);

        Camera.main.transform.position = new Vector3(
            startTile.transform.position.x,
            startTile.transform.position.y,
            Camera.main.transform.position.z);

        var summonEffect = EffectManager.Get().ShowEnemySpawnEffect(startTile.transform.position);

        var summon = Run.WaitSeconds(0.3f)
                     .ExecuteWhenDone(() => {
            EnemyManager enemyManager = EnemyManager.Create(enemyPrefab, startTile, type, enemyId);
            enemyManager.Init();
            enemies.Add(enemyId, enemyManager);
        });

        Run.Join(new List <Run> {
            summonEffect, summon
        })
        .ExecuteWhenDone(() => {
            if (Network.isServer)
            {
                Slinqable.Slinq(enemies.Values)
                .FirstOrNone((enemyManager) => enemyManager.GetMoveState() == EnemyManager.MoveState.MakingEnemy)
                .ForEach((enemyManager) => enemyManager.OnEnemyMakingEffectEnd());
            }
        });
    }
예제 #2
0
    public LeftUIComps.Player GetPlayerUI(NetworkViewID playerId)
    {
        Option <LeftUIComps.Player> optionalPlayer = Slinqable.Slinq(players).FirstOrNone((player) => player.GetId() == playerId);

        return(optionalPlayer.ValueOr(() => {
            throw new Exception("CannotGetUI");
        }));
    }
예제 #3
0
    public static string GetEnemyIdOnTile(int tileKey)
    {
        var enemies = GameManager.gameManagerInstance.GetEnemiesList();

        return(Slinqable.Slinq(enemies).Where(
                   (enemyManager) => enemyManager.GetCurrentTileKey() == tileKey
                   ).First().enemyId);
    }
예제 #4
0
    public static int GetPlayerCountAt(int tileKey)
    {
        var players = GameManager.GetAllPlayersEnumerator();

        return(Slinqable.Slinq(players).Where(
                   (characterManager) => characterManager.GetCurrentTileKey() == tileKey
                   ).Count());
    }
예제 #5
0
    public static bool IsPlayerEncounter(int tileKey)
    {
        var players = GameManager.GetAllPlayersEnumerator();

        return(Slinqable.Slinq(players).Where(
                   (characterManager) => characterManager.GetCurrentTileKey() == tileKey
                   ).FirstOrNone().isSome);
    }
예제 #6
0
    public static int GetEnemyCountAt(int tileKey)
    {
        var enemies = GameManager.gameManagerInstance.GetEnemiesList();

        return(Slinqable.Slinq(enemies).Where(
                   (enemyManager) => enemyManager.GetCurrentTileKey() == tileKey
                   ).Count());
    }
예제 #7
0
    public static bool IsEnemyEncounter(int tileKey)
    {
        var enemies = GameManager.gameManagerInstance.GetEnemiesList();

        return(Slinqable.Slinq(enemies).Where(
                   (enemyManager) => enemyManager.GetCurrentTileKey() == tileKey
                   ).FirstOrNone().isSome);
    }
예제 #8
0
 void RemoveItem(Character.Item item)
 {
     Slinqable.Slinq(inventoryUI.itemCardComps)
     .FirstOrNone((itemCard) => itemCard.GetItem() == item)
     .ForEachOr(
         (itemCard) => itemCard.SetItem(Character.Item.None, null),
         () => { throw new Exception("Cannot get item"); }
         );
 }
예제 #9
0
    public static NetworkViewID GetPlayerIdOnTile(int tileKey)
    {
        var players = GameManager.GetAllPlayersEnumerator();

        var player = Slinqable.Slinq(players).Where(
            (characterManager) => characterManager.GetCurrentTileKey() == tileKey
            ).First();

        return(GameManager.GetNetworkViewID(player));
    }
예제 #10
0
 void SetDestination(Dictionary <TileManager.TileDirection, Tile> movableDictionaryWithoutSaveTiles)
 {
     Slinqable.Slinq(movableDictionaryWithoutSaveTiles.Values).
     OrderBy((tile) => Random.Range(0, 100))
     .FirstOrNone()
     .ForEachOr(
         (tile) => toMoveTile = tile,
         () => Debug.LogError("Cannot find next tile")
         );
 }
예제 #11
0
파일: LeftUI.cs 프로젝트: SNUGDC/BeerWorld
        public void SetPortrait()
        {
            Option <Sprite> portraitSprite = Slinqable.Slinq(BattleUIManager.Get().leftUI.classSprite)
                                             .FirstOrNone((classSprite) => classSprite.charClass == this.charClass)
                                             .Select((classSprite) => classSprite.sprite);

            portraitSprite.ForEachOr(
                (sprite) => this.portrait.sprite = sprite,
                () => Debug.LogError("Cannot find sprite for left ui.")
                );
        }
예제 #12
0
 public void AddItemCard(Character.Item item)
 {
     Slinqable.Slinq(inventoryUI.itemCardComps).FirstOrNone(
         (itemCard) => itemCard.GetItem() == Character.Item.None
         ).ForEachOr(
         (itemCard) => {
         var sprite = GetSpriteOfItem(item);
         itemCard.SetItem(item, sprite);
     },
         () => Debug.Log("There is no empty imte.")
         );
 }
예제 #13
0
    public void CreateCharacters()
    {
        myCharacterManager = CharacterManager.CreateInStart(characterPrefab, arrowPrefab, playerClasses[NetworkManager.networkInstance.Id]);
        myCharacterManager.Init();

        Slinqable.Slinq(otherPlayers).ForEach(
            (otherPlayerId) => {
            otherCharacterManagers.Add(otherPlayerId,
                                       CharacterManager.CreateInStart(characterPrefab, arrowPrefab, playerClasses[otherPlayerId]));
            otherCharacterManagers[otherPlayerId].Init();
        }
            );
    }
예제 #14
0
    public Sprite GetSpriteOfItem(Character.Item item)
    {
        var sprite = Slinqable.Slinq(itemSprites).FirstOrNone(
            (itemSprite) => itemSprite.item == item
            )
                     .Select(
            (itemSprite) => itemSprite.sprite
            )
                     .ValueOr(
            () => { throw new System.Exception("cannot get item sprite"); }
            );

        return(sprite);
    }
예제 #15
0
    void RearrangeInventory()
    {
        var items = Slinqable.Slinq(inventoryUI.itemCardComps)
                    .Select((itemCard) => itemCard.GetItem())
                    .Where((item) => item != Character.Item.None)
                    .ToList();

        Slinqable.Slinq(inventoryUI.itemCardComps)
        .ForEach((itemCard) => itemCard.SetItem(Character.Item.None, null));

        items.ForEach(
            (item) => { AddItemCard(item); }
            );
    }
예제 #16
0
 public static NetworkViewID GetNetworkViewID(CharacterManager player)
 {
     if (gameManagerInstance.isMyCharacterManager(player))
     {
         return(NetworkManager.networkInstance.Id);
     }
     else
     {
         return(Slinqable.Slinq(gameManagerInstance.otherPlayers).Where(
                    (playerId) => {
             var otherPlayer = gameManagerInstance.otherCharacterManagers[playerId];
             return otherPlayer == player;
         }).First());
     }
 }
예제 #17
0
    public void SetPlayers(List <NetworkViewID> playerIds, Dictionary <NetworkViewID, Character.CharClass> playerClasses)
    {
        if (playerIds.Count > leftUI.playerUIs.Count)
        {
            Debug.LogError("Not enough UI slot for character");
        }

        Queue <GameObject> playerUIs = new Queue <GameObject>(leftUI.playerUIs);
        var players = Slinqable.Slinq(playerIds).Select((playerId) => {
            var playerUI = playerUIs.Dequeue();
            return(new LeftUIComps.Player(playerUI, playerId, playerClasses[playerId]));
        });

        this.players = players.ToList();
    }
예제 #18
0
    void InitializeDice()
    {
        Slinqable.Slinq(ui.attackDices)
        .ForEach((attackDice) => {
            attackDice.SetActive(false);
        });

        Queue <BDice.Species> attackDiceSpecies = new Queue <BDice.Species>(attackDices);

        Slinqable.Slinq(ui.attackDices)
        .Reverse()
        .Take(attackDices.Count)
        .ForEach((attackDice) => {
            attackDice.SetActive(true);
            if (attackDiceSpecies.Dequeue() == BDice.Species.Four)
            {
                attackDice.SendMessage("roll4ByNumber", 1);
            }
            else
            {
                attackDice.SendMessage("rollByNumber", 1);
            }
        });

        Slinqable.Slinq(ui.defenseDices)
        .ForEach((defenseDice) => {
            defenseDice.SetActive(false);
        });

        Queue <BDice.Species> defenseDiceSpecies = new Queue <BDice.Species>(defenseDices);

        Slinqable.Slinq(ui.defenseDices)
        .Reverse()
        .Take(defenseDices.Count)
        .ForEach((defenseDice) => {
            defenseDice.SetActive(true);
            if (defenseDiceSpecies.Dequeue() == BDice.Species.Four)
            {
                defenseDice.SendMessage("roll4ByNumber", 1);
            }
            else
            {
                defenseDice.SendMessage("rollByNumber", 1);
            }
        });
    }
예제 #19
0
    Run DiceReroll()
    {
        //Add effect.

        int minDiceValue = Slinqable.Slinq(playerCalcResult.diceResults)
                           .Select((diceResult) => diceResult.diceValue).Min();
        int indexOfLowestDice = playerCalcResult.diceResults.FindIndex(
            (diceResult) => diceResult.diceValue == minDiceValue);

        //FIXME ui is reversed.
        int indexOfLowestDiceUI = player.ui.attackDices.Length - 1 - indexOfLowestDice;

        if (attackOrDefense == AttackOrDefense.Attack)
        {
            //Add re-roll effect playerDice @player.ui.attackDices[i]

            int diceResult = Dice.Roll(player.attackDices[indexOfLowestDice]);
            Debug.Log("Attack dicke to reroll is " + indexOfLowestDice);
            player.ui.attackDices [indexOfLowestDiceUI].SendMessage("rollByNumber", diceResult);

            var animationGameObject = player.ui.attackDices[indexOfLowestDiceUI];
            var diceAnimation       = animationGameObject.GetComponent <DiceAnimation>();

            totalPlayerDice += (diceResult - minDiceValue);
            playerCalcResult.totalDiceResult = totalPlayerDice;

            return(Run.WaitSeconds(0.1f).Then(() => Run.WaitWhile(diceAnimation.IsRollAnimating)));
        }
        else
        {
            int diceResult = Dice.Roll(player.defenseDices[indexOfLowestDice]);
            Debug.Log("Defense dicke to reroll is " + indexOfLowestDice);
            player.ui.defenseDices [indexOfLowestDiceUI].SendMessage("rollByNumber", diceResult);

            var animationGameObject = player.ui.attackDices[indexOfLowestDiceUI];
            var diceAnimation       = animationGameObject.GetComponent <DiceAnimation>();

            totalPlayerDice += (diceResult - minDiceValue);
            playerCalcResult.totalDiceResult = totalPlayerDice;

            return(Run.WaitSeconds(0.1f).Then(() => Run.WaitWhile(diceAnimation.IsRollAnimating)));
        }
    }
예제 #20
0
    public void GameStart()
    {
        gameOverObj = gameOverImg;

        var enemyInfos = enemyInfoList.GetEnemyInfoList();

        Slinqable.Slinq(enemyInfos).ForEach(
            (enemyInfo) => {
            NetworkManager.MakeEnemy(enemyInfo);
        }
            );

        NetworkManager.SetTurnOrder(
            NetworkManager.networkInstance.Id, otherPlayers);

        CreateCharacters();

        NetworkManager.SendGameStartMessage();
        NetworkManager.SendTurnStartMessage(NetworkManager.networkInstance.Id);
    }
예제 #21
0
    public Run ScaleBuffUI(Character.Item item)
    {
        float scale      = 1.5f;
        float effectTime = 0.5f;

        Vector3 scaleVector = new Vector3(scale, scale, 1);

        Option <Run> effect = Slinqable.Slinq(ui.battleBuffUIs)
                              .Where((buffUI) => buffUI.item == item)
                              .FirstOrNone()
                              .Select((buffUI) => {
            var buffGO = buffUI.spriteRenderer.gameObject;
            iTween.ScaleTo(buffGO, iTween.Hash("scale", scaleVector, "time", effectTime));
            return(Run.WaitSeconds(effectTime)
                   .ExecuteWhenDone(() => {
                iTween.ScaleTo(buffGO, iTween.Hash("scale", Vector3.one, "time", effectTime));
            })
                   .Then(() => Run.WaitSeconds(effectTime)));
        });

        return(effect.ValueOr(Run.WaitSeconds(0)));
    }
예제 #22
0
 public Option <string> GetFirstEnemyId()
 {
     return(Slinqable.Slinq(enemies.Keys).FirstOrNone());
 }
예제 #23
0
    void AnimateDice()
    {
        int playerDiceNum = playerCalcResult.diceResults.Count;
        int enemyDiceNum  = enemyCalcResult.diceResults.Count;

        GameObject animationGameObject = null;

        Action <List <BDiceResult>, GameObject[]> render = (diceResults, uiDices) => {
            Queue <BDiceResult> diceResultQueue = new Queue <BDiceResult>(diceResults);
            Slinqable.Slinq(uiDices)
            .Reverse()
            .Take(diceResults.Count)
            .ForEach((attackDice) => {
                var diceResult = diceResultQueue.Dequeue();
                if (diceResult.species == BDice.Species.Four)
                {
                    attackDice.SendMessage("roll4ByNumber", diceResult.diceValue);
                }
                else
                {
                    attackDice.SendMessage("rollByNumber", diceResult.diceValue);
                }
                animationGameObject = attackDice;
            });
        };

        if (attackOrDefense == AttackOrDefense.Attack)
        {
            render(playerCalcResult.diceResults, player.ui.attackDices);
            render(enemyCalcResult.diceResults, enemy.ui.defenseDices);
        }
        else
        {
            render(playerCalcResult.diceResults, player.ui.defenseDices);
            render(enemyCalcResult.diceResults, enemy.ui.attackDices);
        }

        //Wait for animation end.
        var diceAnimation = animationGameObject.GetComponent <DiceAnimation>();

        Run.WaitSeconds(0.1f)
        .Then(() => Run.WaitWhile(diceAnimation.IsRollAnimating))
        .Then(() => Run.WaitSeconds(0.1f))
        .ExecuteWhenDone(() => {
            totalPlayerDice = playerCalcResult.totalDiceResult;
            totalEnemyDice  = enemyCalcResult.totalDiceResult;

            player.SetTotalDiceResult(totalPlayerDice);
            enemy.SetTotalDiceResult(totalEnemyDice);

            Run useItem = Run.WaitSeconds(0);
//------------------DiceChange
            if (useItemsInBattle.Contains(Character.Item.DiceChange) == true)
            {
                Debug.Log("DiceChangeSkill used.");
                useItem = useItem.Then(() => ShowItemScaleEffect(Character.Item.DiceChange))
                          .ExecuteWhenDone(() => {
                    ChangeDiceWithEnemy();
                    useItemsInBattle.Remove(Character.Item.DiceChange);
                    UpdateBuffUI();
                    UpdateTotalDiceResult();
                });
            }

//------------------DiceResultChange
            if (useItemsInBattle.Contains(Character.Item.DiceResultChange) == true)
            {
                useItem = useItem.Then(() => {
                    var diceRollWait  = DiceReroll();
                    var diceRollScale = ShowItemScaleEffect(Character.Item.DiceResultChange);

                    return(Run.Join(new List <Run> {
                        diceRollWait, diceRollScale
                    })
                           .ExecuteWhenDone(() => {
                        useItemsInBattle.Remove(Character.Item.DiceResultChange);
                        UpdateBuffUI();
                    }));
                });
            }

            useItem.ExecuteWhenDone(() => {
                //show animation with calculation result.
                totalPlayerDice = playerCalcResult.totalDiceResult;
                totalEnemyDice  = enemyCalcResult.totalDiceResult;

                player.SetTotalDiceResult(totalPlayerDice);
                enemy.SetTotalDiceResult(totalEnemyDice);

                state = State.ShowDamage;
                Run.Coroutine(AnimateDamage(totalPlayerDice, totalEnemyDice));
            });
        });
    }
예제 #24
0
    private void TestCorrectness()
    {
        var testTuple = tuples2.Slinq().FirstOrDefault();
        var testInt   = testTuple._1;
        var testInt2  = testInt * (maxValue - minValue + 1) / 25;
        var midSkip   = UnityEngine.Random.value < 0.5f ? testInt : 0;

        if (tuples1.Slinq().Aggregate(0, (acc, next) => acc + next._1) != tuples1.Aggregate(0, (acc, next) => acc + next._1))
        {
            Debug.LogError("Aggregate failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().Aggregate(0, (acc, next) => acc + next._1, acc => - acc) != tuples1.Aggregate(0, (acc, next) => acc + next._1, acc => - acc))
        {
            Debug.LogError("Aggregate failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().AggregateWhile(0, (acc, next) => acc < testInt2 ? new Option <int>(acc + next._1) : new Option <int>()) != tuples1.Slinq().AggregateRunning(0, (acc, next) => acc + next._1).Where(acc => acc >= testInt2).FirstOrDefault())
        {
            Debug.LogError("AggregateWhile / AggregateRunning failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().All(x => x._1 < testInt2) ^ tuples1.All(x => x._1 < testInt2))
        {
            Debug.LogError("All failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().All((x, c) => x._1 < c, testInt2) ^ tuples1.All(x => x._1 < testInt2))
        {
            Debug.LogError("All failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().Any(x => x._1 > testInt2) ^ tuples1.Any(x => x._1 > testInt2))
        {
            Debug.LogError("All failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().Any((x, c) => x._1 > c, testInt2) ^ tuples1.Any(x => x._1 > testInt2))
        {
            Debug.LogError("All failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Select(to_1).AverageOrNone().Cata(avg => avg == tuples1.Select(to_1f).Average(), tuples1.Count == 0))
        {
            Debug.LogError("AverageOrNone failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Concat(tuples2.Slinq()).SequenceEqual(tuples1.Concat(tuples2).Slinq(), eq))
        {
            Debug.LogError("Concat failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().Contains(testTuple, eq_1) ^ tuples1.Contains(testTuple, eq_1))
        {
            Debug.LogError("Contains failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().Where(x => x._1 < testInt).Count() != tuples1.Where(x => x._1 < testInt).Count())
        {
            Debug.LogError("Count failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Distinct(eq_1).SequenceEqual(tuples1.Distinct(eq_1).Slinq(), eq))
        {
            Debug.LogError("Distinct failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Except(tuples2.Slinq(), eq_1).SequenceEqual(tuples1.Except(tuples2, eq_1).Slinq(), eq))
        {
            Debug.LogError("Except failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().FirstOrNone().Cata(x => x == tuples1.First(), !tuples1.Any()))
        {
            Debug.LogError("FirstOrNone failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().FirstOrNone(x => x._1 < testInt).Cata(x => x == tuples1.First(z => z._1 < testInt), !tuples1.Where(z => z._1 < testInt).Any()))
        {
            Debug.LogError("FirstOrNone(predicate) failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().FirstOrNone((x, t) => x._1 < t, testInt).Cata(x => x == tuples1.First(z => z._1 < testInt), !tuples1.Where(z => z._1 < testInt).Any()))
        {
            Debug.LogError("FirstOrNone(predicate, parameter) failed.");
            testCorrectness = false;
        }

        if (!new List <Tuple <int, int> >[] { tuples1, tuples2 }.Slinq().Select(x => x.Slinq()).Flatten().SequenceEqual(tuples1.Concat(tuples2).Slinq(), eq))
        {
            Debug.LogError("Flatten failed.");
            testCorrectness = false;
        }

        {
            var feAcc = 0;
            tuples1.Slinq().ForEach(x => feAcc += x._1);
            if (feAcc != tuples1.Slinq().Select(to_1).Sum())
            {
                Debug.LogError("ForEach failed.");
                testCorrectness = false;
            }
        }

        if (!tuples1.Slinq().Intersect(tuples2.Slinq(), eq_1).SequenceEqual(tuples1.Intersect(tuples2, eq_1).Slinq(), eq))
        {
            Debug.LogError("Intersect failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().GroupBy(to_1).SequenceEqual(
                tuples1.GroupBy(to_1f).Slinq(),
                (s, l) => s.key == l.Key && s.values.SequenceEqual(l.Slinq(), eq)))
        {
            Debug.LogError("GroupBy failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().GroupJoin(tuples2.Slinq(), to_1, to_1, (a, bs) => Tuple.Create(a._1, a._2, bs.Count()))
            .SequenceEqual(tuples1.GroupJoin(tuples2, to_1f, to_1f, (a, bs) => Tuple.Create(a._1, a._2, bs.Count())).Slinq(), eq_t3))
        {
            Debug.LogError("GroupJoin failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Join(tuples2.Slinq(), to_1, to_1, (a, b) => Tuple.Create(a._1, a._2, b._2))
            .SequenceEqual(tuples1.Join(tuples2, to_1f, to_1f, (a, b) => Tuple.Create(a._1, a._2, b._2)).Slinq(), eq_t3))
        {
            Debug.LogError("Join failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().LastOrNone().Cata(x => x == tuples1.Last(), !tuples1.Any()))
        {
            Debug.LogError("LastOrNone failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().LastOrNone(x => x._1 < testInt).Cata(x => x == tuples1.Last(z => z._1 < testInt), !tuples1.Where(z => z._1 < testInt).Any()))
        {
            Debug.LogError("LastOrNone(predicate) failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().LastOrNone((x, t) => x._1 < t, testInt).Cata(x => x == tuples1.Last(z => z._1 < testInt), !tuples1.Where(z => z._1 < testInt).Any()))
        {
            Debug.LogError("LastOrNone(predicate, parameter) failed.");
            testCorrectness = false;
        }

        if (tuples1.Count > 0 && tuples1.Slinq().Max() != tuples1.Max())
        {
            Debug.LogError("Max failed.");
            testCorrectness = false;
        }

        if (tuples1.Count > 0 && tuples1.Slinq().Min() != tuples1.Min())
        {
            Debug.LogError("Min failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().MaxOrNone().Cata(x => x == tuples1.Max(), tuples1.Count == 0))
        {
            Debug.LogError("MaxOrNone failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().MinOrNone().Cata(x => x == tuples1.Min(), tuples1.Count == 0))
        {
            Debug.LogError("MinOrNone failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().OrderBy(to_1).SequenceEqual(tuples1.OrderBy(to_1f).Slinq(), eq))
        {
            Debug.LogError("OrderBy failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().OrderByDescending(to_1).SequenceEqual(tuples1.OrderByDescending(to_1f).Slinq(), eq))
        {
            Debug.LogError("OrderByDescending failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().OrderBy().SequenceEqual(tuples1.OrderBy(x => x).Slinq(), eq))
        {
            Debug.LogError("OrderBy keyless failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().OrderByDescending().SequenceEqual(tuples1.OrderByDescending(x => x).Slinq(), eq))
        {
            Debug.LogError("OrderByDescending keyless failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().OrderByGroup(to_1).SequenceEqual(tuples1.OrderBy(to_1f).Slinq(), eq))
        {
            Debug.LogError("OrderByGroup failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().OrderByGroupDescending(to_1).SequenceEqual(tuples1.OrderByDescending(to_1f).Slinq(), eq))
        {
            Debug.LogError("OrderByGroupDescending failed.");
            testCorrectness = false;
        }

        {
            var list  = RemovableList();
            var slinq = list.Slinq().Skip(midSkip);
            for (int i = 0; i < testInt; ++i)
            {
                slinq.Remove();
            }
            if (!list.Slinq().Skip(midSkip).SequenceEqual(tuples1.Slinq().Skip(midSkip).Skip(testInt), eq))
            {
                Debug.LogError("Remove failed.");
                testCorrectness = false;
            }
        }

        {
            var list  = RemovableList();
            var slinq = list.SlinqDescending().Skip(midSkip);
            for (int i = 0; i < testInt; ++i)
            {
                slinq.Remove();
            }
            if (!list.SlinqDescending().Skip(midSkip).SequenceEqual(tuples1.SlinqDescending().Skip(midSkip).Skip(testInt), eq))
            {
                Debug.LogError("Remove descending failed.");
                testCorrectness = false;
            }
        }

        {
            var list = RemovableList();
            list.Slinq().Skip(midSkip).Remove(testInt);
            if (!list.Slinq().Skip(midSkip).SequenceEqual(tuples1.Slinq().Skip(midSkip).Skip(testInt), eq))
            {
                Debug.LogError("Remove(int) failed.");
                testCorrectness = false;
            }
        }

        {
            var list = RemovableList();
            list.Slinq().Skip(midSkip).RemoveWhile(x => x._1 < testInt2);
            if (!list.Slinq().Skip(midSkip).SequenceEqual(tuples1.Slinq().Skip(midSkip).SkipWhile(x => x._1 < testInt2), eq))
            {
                Debug.LogError("RemoveWhile failed.");
                testCorrectness = false;
            }
        }

        {
            var list   = RemovableList();
            var sSlinq = tuples1.Slinq().Skip(midSkip);
            var rAcc   = list.Slinq().Skip(midSkip).RemoveWhile(0, (acc, next) => acc < testInt2 ? new Option <int>(acc + next._1) : new Option <int>());
            var sAcc   = sSlinq.SkipWhile(0, (acc, next) => acc < testInt2 ? new Option <int>(acc + next._1) : new Option <int>());

            if (rAcc != sAcc || !list.Slinq().Skip(midSkip).SequenceEqual(sSlinq, eq))
            {
                Debug.LogError("RemoveWhile aggregating failed.");
                testCorrectness = false;
            }
        }


        {
            var list  = RemovableLinkedList();
            var slinq = list.Slinq().Skip(midSkip);
            for (int i = 0; i < testInt; ++i)
            {
                slinq.Remove();
            }
            if (!list.Slinq().Skip(midSkip).SequenceEqual(tuples1.Slinq().Skip(midSkip).Skip(testInt), eq))
            {
                Debug.LogError("Remove LL failed.");
                testCorrectness = false;
            }
        }


        {
            var list  = RemovableLinkedList();
            var slinq = list.SlinqDescending().Skip(midSkip);
            for (int i = 0; i < testInt; ++i)
            {
                slinq.Remove();
            }
            if (!list.SlinqDescending().Skip(midSkip).SequenceEqual(tuples1.SlinqDescending().Skip(midSkip).Skip(testInt), eq))
            {
                Debug.LogError("Remove descending LL failed.");
                testCorrectness = false;
            }
        }

        {
            var list = RemovableLinkedList();
            list.Slinq().Skip(midSkip).Remove(testInt);
            if (!list.Slinq().Skip(midSkip).SequenceEqual(tuples1.Slinq().Skip(midSkip).Skip(testInt), eq))
            {
                Debug.LogError("Remove(int) LL failed.");
                testCorrectness = false;
            }
        }

        {
            var list = RemovableLinkedList();
            list.Slinq().Skip(midSkip).RemoveWhile(x => x._1 < testInt2);
            if (!list.Slinq().Skip(midSkip).SequenceEqual(tuples1.Slinq().Skip(midSkip).SkipWhile(x => x._1 < testInt2), eq))
            {
                Debug.LogError("RemoveWhile LL failed.");
                testCorrectness = false;
            }
        }

        {
            var list   = RemovableLinkedList();
            var sSlinq = tuples1.Slinq().Skip(midSkip);
            var rAcc   = list.Slinq().Skip(midSkip).RemoveWhile(0, (acc, next) => acc < testInt2 ? new Option <int>(acc + next._1) : new Option <int>());
            var sAcc   = sSlinq.SkipWhile(0, (acc, next) => acc < testInt2 ? new Option <int>(acc + next._1) : new Option <int>());

            if (rAcc != sAcc || !list.Slinq().Skip(midSkip).SequenceEqual(sSlinq, eq))
            {
                Debug.LogError("RemoveWhile aggregating LL failed.");
                testCorrectness = false;
            }
        }

        if (!tuples1.Slinq().Reverse().SequenceEqual(Enumerable.Reverse(tuples1).Slinq(), eq))
        {
            Debug.LogError("Reverse failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Select(to_1).SequenceEqual(tuples1.Select(to_1f).Slinq()))
        {
            Debug.LogError("Select failed.");
            testCorrectness = false;
        }

        if (!new List <Tuple <int, int> >[] { tuples1, tuples2 }.Slinq().SelectMany(x => x.Slinq()).SequenceEqual(tuples1.Concat(tuples2).Slinq(), eq))
        {
            Debug.LogError("SelectMany failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().SelectMany(x => x._1 < testInt ? new Option <int>(x._1) : new Option <int>()).SequenceEqual(tuples1.Where(x => x._1 < testInt).Select(x => x._1).Slinq()))
        {
            Debug.LogError("SelectMany option failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().SequenceEqual(tuples1.Slinq(), eq))
        {
            Debug.LogError("SequenceEqual failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().SequenceEqual(tuples2.Slinq(), eq) ^ tuples1.SequenceEqual(tuples2))
        {
            Debug.LogError("SequenceEqual failed.");
            testCorrectness = false;
        }

        {
            var a = new int[3];
            a[2] = testInt;
            if (a.Slinq().SingleOrNone().isSome ||
                a.Slinq().Skip(1).SingleOrNone().isSome ||
                !a.Slinq().Skip(2).SingleOrNone().Contains(testInt) ||
                a.Slinq().Skip(3).SingleOrNone().isSome)
            {
                Debug.LogError("SingleOrNone failed.");
                testCorrectness = false;
            }
        }

        {
            var slinq = tuples1.Slinq();
            for (int i = 0; i < testInt; ++i)
            {
                slinq.Skip();
            }
            if (!tuples1.Slinq().Skip(testInt).SequenceEqual(slinq, eq))
            {
                Debug.LogError("Skip failed.");
                testCorrectness = false;
            }
        }

        if (!tuples1.Slinq().SkipWhile(x => x._1 < testInt2).SequenceEqual(tuples1.SkipWhile(x => x._1 < testInt2).Slinq(), eq))
        {
            Debug.LogError("SkipWhile failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Reverse().SequenceEqual(tuples1.SlinqDescending(), eq))
        {
            Debug.LogError("SlinqDescending failed.");
            testCorrectness = false;
        }

        if (!tuples1.SlinqDescending().SequenceEqual(RemovableLinkedList().SlinqDescending(), eq))
        {
            Debug.LogError("SlinqDescending LL failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().SequenceEqual(RemovableLinkedList().SlinqNodes().Select(x => x.Value), eq))
        {
            Debug.LogError("SlinqNodes LL failed.");
            testCorrectness = false;
        }

        if (!tuples1.SlinqDescending().SequenceEqual(RemovableLinkedList().SlinqNodesDescending().Select(x => x.Value), eq))
        {
            Debug.LogError("SlinqNodesDescending LL failed.");
            testCorrectness = false;
        }

        if (!tuples1.SlinqWithIndex().All(x => x._1._2 == x._2) ||
            !tuples1.SlinqWithIndex().Select(x => x._1).SequenceEqual(tuples1.Slinq(), eq))
        {
            Debug.LogError("SlinqWithIndex failed.");
            testCorrectness = false;
        }

        if (!tuples1.SlinqWithIndexDescending().All(x => x._1._2 == x._2) ||
            !tuples1.SlinqWithIndexDescending().Select(x => x._1).SequenceEqual(tuples1.SlinqDescending(), eq))
        {
            Debug.LogError("SlinqWithIndexDescending failed.");
            testCorrectness = false;
        }

        if (tuples1.Slinq().Select(to_1).Sum() != tuples1.Select(to_1f).Sum())
        {
            Debug.LogError("Sum failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Take(testInt).SequenceEqual(tuples1.Take(testInt).Slinq(), eq))
        {
            Debug.LogError("Take failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().TakeRight(testInt).SequenceEqual(tuples1.Slinq().Skip(tuples1.Count - testInt), eq))
        {
            Debug.LogError("TakeRight failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().TakeWhile(x => x._1 < testInt2).SequenceEqual(tuples1.TakeWhile(x => x._1 < testInt2).Slinq(), eq))
        {
            Debug.LogError("TakeWhile failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().TakeWhile((x, c) => x._1 < c, testInt2).SequenceEqual(tuples1.TakeWhile(x => x._1 < testInt2).Slinq(), eq))
        {
            Debug.LogError("TakeWhile failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Union(tuples2.Slinq(), eq_1).SequenceEqual(tuples1.Union(tuples2, eq_1).Slinq(), eq))
        {
            Debug.LogError("Union failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Where(x => x._1 < testInt).SequenceEqual(tuples1.Where(x => x._1 < testInt).Slinq(), eq))
        {
            Debug.LogError("Where failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Where((x, c) => x._1 < c, testInt).SequenceEqual(tuples1.Where(x => x._1 < testInt).Slinq(), eq))
        {
            Debug.LogError("Where failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Zip(tuples2.Slinq()).SequenceEqual(
                Slinqable.Sequence(0, 1)
                .TakeWhile(x => x < tuples1.Count && x < tuples2.Count)
                .Select(x => Tuple.Create(tuples1[x], tuples2[x]))))
        {
            Debug.LogError("Zip tuples failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Zip(tuples2.Slinq(), (a, b) => Tuple.Create(a._1, b._1)).SequenceEqual(
                Slinqable.Sequence(0, 1)
                .TakeWhile(x => x < tuples1.Count && x < tuples2.Count)
                .Select(x => Tuple.Create(tuples1[x]._1, tuples2[x]._1)), eq))
        {
            Debug.LogError("Zip failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq()
            .ZipAll(tuples2.Slinq())
            .SequenceEqual(Slinqable.Sequence(0, 1)
                           .TakeWhile(x => x < tuples1.Count || x < tuples2.Count)
                           .Select(x => Tuple.Create(
                                       x < tuples1.Count ?     new Option <Tuple <int, int> >(tuples1[x]) : new Option <Tuple <int, int> >(),
                                       x < tuples2.Count ?     new Option <Tuple <int, int> >(tuples2[x]) : new Option <Tuple <int, int> >()))))
        {
            Debug.LogError("ZipAll tuples failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Skip(midSkip)
            .ZipAll(tuples2.Slinq())
            .SequenceEqual(Slinqable.Sequence(0, 1)
                           .TakeWhile(x => x + midSkip < tuples1.Count || x < tuples2.Count)
                           .Select(x => Tuple.Create(
                                       x + midSkip < tuples1.Count ? new Option <Tuple <int, int> >(tuples1[x + midSkip]) : new Option <Tuple <int, int> >(),
                                       x < tuples2.Count ? new Option <Tuple <int, int> >(tuples2[x]) : new Option <Tuple <int, int> >()))))
        {
            Debug.LogError("ZipAll tuples failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq()
            .ZipAll(tuples2.Slinq().Skip(midSkip))
            .SequenceEqual(Slinqable.Sequence(0, 1)
                           .TakeWhile(x => x < tuples1.Count || x + midSkip < tuples2.Count)
                           .Select(x => Tuple.Create(
                                       x < tuples1.Count ? new Option <Tuple <int, int> >(tuples1[x]) : new Option <Tuple <int, int> >(),
                                       x + midSkip < tuples2.Count ? new Option <Tuple <int, int> >(tuples2[x + midSkip]) : new Option <Tuple <int, int> >()))))
        {
            Debug.LogError("ZipAll tuples failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq()
            .ZipAll(tuples2.Slinq(), (a, b) => Tuple.Create(a, b))
            .SequenceEqual(Slinqable.Sequence(0, 1)
                           .TakeWhile(x => x < tuples1.Count || x < tuples2.Count)
                           .Select(x => Tuple.Create(
                                       x < tuples1.Count ?     new Option <Tuple <int, int> >(tuples1[x]) : new Option <Tuple <int, int> >(),
                                       x < tuples2.Count ?     new Option <Tuple <int, int> >(tuples2[x]) : new Option <Tuple <int, int> >()))))
        {
            Debug.LogError("ZipAll failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().Skip(midSkip)
            .ZipAll(tuples2.Slinq(), (a, b) => Tuple.Create(a, b))
            .SequenceEqual(Slinqable.Sequence(0, 1)
                           .TakeWhile(x => x + midSkip < tuples1.Count || x < tuples2.Count)
                           .Select(x => Tuple.Create(
                                       x + midSkip < tuples1.Count ? new Option <Tuple <int, int> >(tuples1[x + midSkip]) : new Option <Tuple <int, int> >(),
                                       x < tuples2.Count ? new Option <Tuple <int, int> >(tuples2[x]) : new Option <Tuple <int, int> >()))))
        {
            Debug.LogError("ZipAll failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq()
            .ZipAll(tuples2.Slinq().Skip(midSkip), (a, b) => Tuple.Create(a, b))
            .SequenceEqual(Slinqable.Sequence(0, 1)
                           .TakeWhile(x => x < tuples1.Count || x + midSkip < tuples2.Count)
                           .Select(x => Tuple.Create(
                                       x < tuples1.Count ? new Option <Tuple <int, int> >(tuples1[x]) : new Option <Tuple <int, int> >(),
                                       x + midSkip < tuples2.Count ? new Option <Tuple <int, int> >(tuples2[x + midSkip]) : new Option <Tuple <int, int> >()))))
        {
            Debug.LogError("ZipAll failed.");
            testCorrectness = false;
        }

        if (!tuples1.Slinq().ZipWithIndex().All(x => x._1._2 == x._2) ||
            !tuples1.Slinq().ZipWithIndex().Select(x => x._1).SequenceEqual(tuples1.Slinq(), eq))
        {
            Debug.LogError("ZipWithIndex failed.");
            testCorrectness = false;
        }
    }
예제 #25
0
 public void EnableBuffUI(Character.Item item)
 {
     Slinqable.Slinq(ui.battleBuffUIs)
     .Where((buffUI) => buffUI.item == item)
     .ForEach((buffUI) => buffUI.spriteRenderer.enabled = true);
 }