Example #1
0
 ///Generalize method for distribution of a reward table
 ///
 private void DistributeReward(BoardManager bm, RewardTable table)
 {
     if (table != null)
     {
         table.DistributeReward(bm);
     }
 }
Example #2
0
    public bool TryGetReward(ref int rewardCoin)
    {
        if (!isCompleted)
        {
            return(false);
        }

        RewardTable data = GetRewardTable(nowLevel);

        if (data == null)
        {
            return(false);
        }

        rewardCoin = data.reward;
        if (nowLevel < GetMaxLevel())
        {
            nowLevel++;
        }

        isCompleted = false;
        nowValue    = 0;

        RewardManager.GetInstance().CheckReward(type);
        return(true);
    }
Example #3
0
    /*
     * Inicializamos la tabla de recompensas a -1 las casillas atravesables
     * -5 las celdas con muros
     * 100 la meta
     */
    private void initRewardTable(BoardInfo board)
    {
        //Obtenemos toda la informaciĆ³n de todas las celdas del tablero
        CellInfo[,] info = board.CellInfos;
        //Celda con objeto Goal
        CellInfo goal = board.CellWithItem("Goal");

        for (int i = 0; i < RewardTable.GetLength(0); i++)
        {
            for (int j = 0; j < RewardTable.GetLength(1); j++)
            {
                if (info[i, j].GetPosition == goal.GetPosition)
                {
                    RewardTable[i, j] = 100;
                }
                else if (!info[i, j].Walkable)
                {
                    RewardTable[i, j] = -5;
                }
                else
                {
                    RewardTable[i, j] = -1;
                }
            }
        }
    }
Example #4
0
    public override void CheckState()
    {
        RewardTable table = GetRewardTable(nowLevel);

        if (table != null)
        {
            nowValue = DataManager.GetInstance().useCoin;
        }
    }
Example #5
0
    public override void CheckState()
    {
        RewardTable table = GetRewardTable(nowLevel);

        if (table != null)
        {
            nowValue = DataManager.GetInstance().GetHasPetListCount();
        }
    }
Example #6
0
    public override string GetInfoText()
    {
        RewardTable table = GetRewardTable(nowLevel);

        if (table == null)
        {
            return("");
        }
        return(string.Format(DataManager.GetText(table.infoIdx), table.maxValue));
    }
Example #7
0
    public int GetRewardCoin()
    {
        RewardTable table = GetRewardTable(nowLevel);

        if (table == null)
        {
            return(0);
        }
        return(table.reward);
    }
Example #8
0
    public RewardTable Copy()
    {
        RewardTable rt = new RewardTable();

        foreach (Reward r in rewards)
        {
            rt.AddReward((Reward)r.Copy());
        }

        return(rt);
    }
Example #9
0
    public bool IsComplete(RewardBase reward)
    {
        RewardTable data = DataManager.GetInstance().GetRewardTable(reward.GetRewardType(), reward.nowLevel);

        if (data != null)
        {
            return(reward.nowValue >= data.maxValue);
        }
        Debug.Log("something is wrong");
        return(false);
    }
Example #10
0
    public string GetRewardStateText(RewardBase reward)
    {
        RewardTable data = DataManager.GetInstance().GetRewardTable(reward.GetRewardType(), reward.nowLevel);

        if (data != null)
        {
            return(reward.nowValue.ToString() + "/" + data.maxValue.ToString());
        }
        Debug.Log("something is wrong");
        return(null);
    }
Example #11
0
    public bool IsCompleted()
    {
        if (isCompleted)
        {
            return(true);
        }

        CheckState();
        RewardTable table = GetRewardTable(nowLevel);

        return(nowValue >= table.maxValue);
    }
Example #12
0
 public RewardTable GetRewardTable(int id)
 {
     for (int i = 0; i < rewardTables.Length; ++i)
     {
         if (rewardTables[i].id == id)
         {
             RewardTable rewardTable = new RewardTable();
             rewardTable = rewardTables[i];
             return(rewardTable);
         }
     }
     Debug.Log("table with id: " + id + " not found!");
     return(null);
 }
Example #13
0
    public override void CheckState()
    {
        RewardTable table = GetRewardTable(nowLevel);

        if (table != null)
        {
            int petLevel = 0;
            for (int i = 0, max = DataManager.GetInstance().GetHasPetListCount(); i < max; i++)
            {
                PetData data = DataManager.GetInstance().GetHasPetDataWithNumber(i);
                petLevel += data.level;
            }
            nowValue = petLevel;
        }
    }
Example #14
0
    public List <Reward> GetAdditionalRewards(int baseDifficultyValue)
    {
        RewardTable   table             = DataBase.instance.GetRewardTable(rewardTableID);
        List <Reward> additionalRewards = new List <Reward> ();
        float         random            = Random.Range(0, 1f);

        if (random < chancesForAdditionalReward)
        {
            additionalRewards.Add(table.GetReward(baseDifficultyValue));
            if (random * 3 < chancesForAdditionalReward)
            {
                additionalRewards.Add(table.GetReward(baseDifficultyValue));
            }
        }
        return(additionalRewards);
    }
Example #15
0
    public override void CheckState()
    {
        RewardTable table = GetRewardTable(nowLevel);

        if (table != null)
        {
            if ((double)int.MaxValue < DataManager.GetInstance().bestScore)
            {
                nowValue = int.MaxValue;
            }
            else
            {
                nowValue = (int)DataManager.GetInstance().bestScore;
            }
        }
    }
Example #16
0
 void client_getRewardCompleted(object sender, GetRewardCompletedEventArgs e)
 {
     foreach (Panda.Phone.Publisher.PublisherServiceReference.Reward item in e.Result)
     {
         RewardTable reward = new RewardTable()
         {
             Address   = item.Address,
             City      = item.City,
             Describe  = item.Describe,
             Latitude  = item.Latitude,
             Longitude = item.Longitude,
             Phone     = item.Phone,
             StoreName = item.StoreName
         };
         db.Rewards.InsertOnSubmit(reward);
     }
     db.SubmitChanges();
     getList_RewardModel();
 }
Example #17
0
    public Mission(string key) : base(key)
    {
        MissionEvents    = new List <Event>();
        npcs             = new List <ActorData>();
        missionsToUnlock = new List <string>();
        started          = false;
        completed        = false;
        reoccuring       = false;

        interactionMap  = new Dictionary <string, Interaction>();
        worlmapID       = "";
        descript        = "";
        int_cutsceneKey = "";
        end_cutscenekey = "";

        typeChangeDict = new Dictionary <MapCoords, string>();

        mainReward    = new RewardTable();
        sideRewards   = new RewardTable();
        secretRewards = new RewardTable();


        mainObjectives   = new List <ObjectiveComponent>();
        sideObjectives   = new List <ObjectiveComponent>();
        secretObjectives = new List <ObjectiveComponent>();
        failstate        = new List <ObjectiveComponent>()
        {
            new AllAlliesDeadFailState()
        };


        MapEnchantments = new List <MapEnchantment>();

        currentTurn = 0;

        initTileEffects = new List <Tuple <MapCoords, List <string> > >();
    }
Example #18
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (Battle.GetWinner() == Team.A)
            {
                var RewardTables = Rewards;
                // Get the appropiate chest rewards table
                var chests = chestTable[Difficulty];
                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);

                // If there was *no* mimic, add a counter weight
                var lurCapBonus = new[] { 16, 12, 10, 9, 8 };
                if (!Battle.TeamB.Any(f => f.Name.Contains("Mimic")))
                {
                    chests.Add(new DefaultReward()
                    {
                        Weight = chests.Weight * lurCapBonus[LureCaps]
                    });
                }
                RewardTables.Add(chests);

                if (Battle.TeamB.Any(f => f.Name.Contains("Djinn")))
                {
                    var djinnTable  = new RewardTable();
                    var djinnWeight = (int)Difficulty;
                    if (Battle.TeamB.Any(f => f.Name.Contains("enus Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Venus", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("ars Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mars", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("upiter Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Jupiter", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("ercury Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mercury", Weight = 1
                        });
                    }
                    djinnTable.Add(new DefaultReward()
                    {
                        Weight = djinnTable.Weight * (10 - (int)Difficulty) * 3 - djinnTable.Weight
                    });
                    RewardTables.Add(djinnTable);
                }

                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(UserAccountProvider.GetById(p.Id), RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonSingleBattle(UserAccountProvider.GetById(p.Id), lobbyChannel, Difficulty));

                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);
                _ = WriteGameOver();
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ForEach(p => p.Moves.OfType <Djinn>().ToList().ForEach(d => { d.Summon(p); d.CoolDown = 0; }));
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(UserAccountProvider.GetById(p.Id), lobbyChannel));
                _ = WriteGameOver();
            }

            await Task.CompletedTask;
        }
Example #19
0
        protected override async Task GameOver()
        {
            var winners = Battle.GetTeam(Battle.GetWinner());

            if (Battle.SizeTeamB == 0)
            {
                Console.WriteLine("Game Over with no enemies existing.");
            }
            if (Battle.GetWinner() == Team.A)
            {
                winsInARow++;
                var RewardTables = Rewards;
                var chests       = chestTable[Difficulty];
                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);
                var lurCapBonus = new[] { 16, 12, 10, 9, 8 };
                if (!Battle.TeamB.Any(f => f.Name.Contains("Mimic")))
                {
                    chests.Add(new DefaultReward {
                        Weight = chests.Weight * lurCapBonus[LureCaps]
                    });
                }
                RewardTables.Add(chests);

                if (Battle.TeamB.Any(f => f.Name.Contains("Djinn")))
                {
                    var djinnTable  = new RewardTable();
                    var djinnWeight = (int)Difficulty;
                    if (Battle.TeamB.Any(f => f.Name.Contains("Venus Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Venus", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("Mars Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mars", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("Jupiter Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Jupiter", Weight = 1
                        });
                    }
                    if (Battle.TeamB.Any(f => f.Name.Contains("Mercury Djinn")))
                    {
                        djinnTable.Add(new DefaultReward()
                        {
                            Djinn = "Mercury", Weight = 1
                        });
                    }
                    djinnTable.Add(new DefaultReward()
                    {
                        Weight = djinnTable.Weight * (10 - (int)Difficulty) * 2 - djinnTable.Weight
                    });
                    RewardTables.Add(djinnTable);
                }

                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonBattle(p.avatar, RewardTables.GetRewards(), p.battleStats, lobbyChannel, BattleChannel));
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserWonEndless(p.avatar, lobbyChannel, winsInARow, mode, p.battleStats.TotalTeamMates + 1, string.Join(", ", Battle.TeamA.Select(pl => pl.Name))));

                chests.RemoveAll(s => s is DefaultReward d && !d.HasChest);

                Battle.TeamA.ForEach(p =>
                {
                    p.PPrecovery += (winsInARow <= 8 * 4 && winsInARow % 4 == 0) ? 1 : 0;
                    p.RemoveNearlyAllConditions();
                    p.Buffs = new List <Buff>();
                    p.Heal((uint)(p.Stats.HP * 5 / 100));
                });

                var text = $"{winners.First().Name}'s Party wins Battle {winsInARow}! Battle will reset shortly.";
                await Task.Delay(3000);

                await StatusMessage.ModifyAsync(m => { m.Content = text; m.Embed = null; });

                await Task.Delay(3000);

                SetNextEnemy();
                Battle.turn = 0;
                _           = StartBattle();
            }
            else
            {
                var losers = winners.First().battle.GetTeam(winners.First().enemies);
                losers.ConvertAll(s => (PlayerFighter)s).ForEach(async p => await ServerGames.UserLostBattle(p.avatar, lobbyChannel));
                winners.OfType <PlayerFighter>().ToList().ForEach(async p => await ServerGames.UserFinishedEndless(p.avatar, lobbyChannel, winsInARow, mode));
                _ = WriteGameOver();
            }
        }