Example #1
0
 public void AchieveAction_PlayerHasScoreButNotTopCard()
 {
     testGame.AgeAchievementDeck.Cards.Add(new Card {
         Age = 3
     });
     Assert.IsFalse(Achieve.Action(testPlayer, testGame));
 }
Example #2
0
 public void AchieveAction_Base()
 {
     testGame.AgeAchievementDeck.Cards.Add(new Card {
         Age = 1
     });
     Assert.IsTrue(Achieve.Action(testPlayer, testGame));
 }
Example #3
0
        public static Packet WriteUpdate(Achieve achieve)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.ACHIEVE);

            pWriter.WriteEnum(AchievePacketMode.Update);
            pWriter.WriteInt(achieve.Id);
            pWriter.Write(WriteIndividualAchieve(achieve).Buffer);

            return(pWriter);
        }
Example #4
0
        public void AchieveAction_PlayerHasTopCardButNotScore()
        {
            testPlayer.Tableau.ScorePile = new List <ICard>
            {
                new Card {
                    Age = 1
                },
            };

            testGame.AgeAchievementDeck.Cards.Add(new Card {
                Age = 2
            });
            Assert.IsFalse(Achieve.Action(testPlayer, testGame));
        }
Example #5
0
 private void LoadStats()
 {
     foreach (var itr in AchieveManager.Instance.achieves)
     {
         Achieve achieve = itr.Value;
         if (0 < achieve.complete_step)
         {
             stats.AddStat(achieve.reward_stat);
             Debug.Log("achievement bonus:" + achieve.reward_stat.type.ToString() + " " + achieve.reward_stat.value);
         }
     }
     foreach (var itr in meta.base_stats)
     {
         stats.SetStat(itr.CreateInstance());
     }
 }
Example #6
0
    private void LoadAchieveDatas()
    {
        Util.Sqlite.DataReader reader = Database.Execute(Database.Type.UserData,
                                                         "SELECT achieve_name, achieve_type, achieve_step, achieve_count, achieve_goal FROM user_achieve"
                                                         );
        while (true == reader.Read())
        {
            Achieve achieve = new Achieve(
                reader.GetString("achieve_name"),
                reader.GetString("achieve_type"),
                reader.GetInt32("achieve_step"),
                reader.GetInt32("achieve_count"),
                reader.GetInt32("achieve_goal")
                );

            achieves.Add(achieve.type, achieve);
            ProgressManager.Instance.Add(achieve);
        }
    }
Example #7
0
        private static Packet WriteIndividualAchieve(Achieve achieve)
        {
            int          tCount  = achieve.Timestamps.Count;
            PacketWriter pWriter = new PacketWriter();

            pWriter.WriteEnum(achieve.GetGradeStatus());            // grade status (refer to GradeStatus enum)
            pWriter.WriteInt(1);                                    // starting grade
            pWriter.WriteInt(achieve.CurrentGrade);                 // current grade to achieve
            pWriter.WriteInt(achieve.MaxGrade);                     // maximum grade
            pWriter.WriteByte(0);                                   // unknown
            pWriter.WriteLong(achieve.Counter);                     // progress counter
            pWriter.WriteInt(tCount);                               // number of timestamps
            for (int t = 0; t < tCount; t++)
            {
                pWriter.WriteInt(t + 1);                            // grade corresponding to timestamp
                pWriter.WriteLong(achieve.Timestamps.ElementAt(t)); // timestamp in unix time (seconds)
            }

            return(pWriter);
        }
Example #8
0
        public void Init(Achieve achieve)
        {
            if (0 == achieve.complete_step)
            {
                description.text = "<color=#6b6b6b>???</color>";
                background.color = new Color(0.6f, 0.6f, 0.6f, 0.6f);
            }
            else
            {
                description.text  = "";
                description.text += "<color=#cea652>" + achieve.name + "</color>\n";

                description.text   += "<color=#6b6b6b>" + achieve.meta.description + "</color>";
                description.text   += " <color=#4eb105>" + achieve.reward_stat.ToString() + "</color>\n";
                achieve_mark.sprite = ResourceManager.Instance.Load <Sprite>(achieve.meta.sprite_path);
            }
            //if (1 == achieve.step && achieve.count < achieve.goal)
            //{
            //	description.text += "<color=#6b6b6b>???</color>";
            //}
            //description.text += "<color=#CEA652>" + achieve.name + "</color>";
        }
Example #9
0
    /// <summary> Will be called at a time when an achievement may occur </summary>
    public void UpdateAchievement(Achieve chievo)
    {
        if (!GameManager.Instance.isReplay())
        {
            if (!Achievements[(int)chievo].Achieved)
            {
                bool t_Notify = false;
                int  count    = 0;
                int  count2   = 0;
                switch (chievo)
                {
                case Achieve.Friends:
                    foreach (bool save in GameManager.saveData.FriendSaves)
                    {
                        if (save)
                        {
                            count++;
                        }
                        if (count == 4)
                        {
                            t_Notify = true;
                        }
                    }
                    break;

                case Achieve.Powerups:
                    foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
                    {
                        if (item.PowerUpType == ShopItem.PowerType.Perma && item.Owned)
                        {
                            count++;
                        }
                    }

                    foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
                    {
                        if (item.PowerUpType == ShopItem.PowerType.Perma)
                        {
                            count2++;
                        }
                    }

                    if (count == count2)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Level2:
                    if (LevelManager.Instance.LevelsUnlocked >= 2)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Level3:
                    if (LevelManager.Instance.LevelsUnlocked >= 3)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Level4:
                    if (LevelManager.Instance.LevelsUnlocked >= 4)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Height1:
                    if (GameManager.Instance.heightAttained > 500)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Height2:
                    if (GameManager.Instance.heightAttained > 1500)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Height3:
                    if (GameManager.Instance.heightAttained > 4500)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Height4:
                    if (GameManager.Instance.heightAttained > 9000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Cosmetics:
                    foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
                    {
                        if (item.PowerUpType == ShopItem.PowerType.Vanity && item.Owned)
                        {
                            count++;
                        }
                    }

                    foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
                    {
                        if (item.PowerUpType == ShopItem.PowerType.Vanity)
                        {
                            count2++;
                        }
                    }

                    if (count == count2)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.TheFall:
                    if (HUDManager.Instance.FallDistance > 5000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.OverPowered:
                    if (AParams.PowersThisRun >= 5)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.JustSayNo:
                    if (GameManager.Instance.BestHieghtAttained > AParams.HeightWithoutPower)
                    {
                        AParams.HeightWithoutPower = GameManager.Instance.BestHieghtAttained;
                    }
                    if (AParams.PowersThisRun == 0 && AParams.HeightWithoutPower > 1000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.BugCollector1:
                    if (AParams.TotalBugs >= 100)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.BugCollector2:
                    if (AParams.TotalBugs >= 1000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.BugCollector3:
                    if (AParams.TotalBugs >= 10000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Infected1:
                    if (AParams.TotalInfection >= 30)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Infected2:
                    if (AParams.TotalInfection >= 120)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Infected3:
                    if (AParams.TotalInfection >= 240)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Dodger1:
                    if (GameManager.Instance.heightAttained >= 500 && GameManager.Instance.bugsCollected <= 5)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Dodger2:
                    if (GameManager.Instance.heightAttained >= 1500 && GameManager.Instance.bugsCollected <= 15)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Dodger3:
                    if (GameManager.Instance.heightAttained >= 5000 && GameManager.Instance.bugsCollected <= 50)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.TotalHeight:
                    if (AParams.TotalHeight >= 50000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.TotalFall:
                    if (AParams.TotalFall >= 10000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.TotalBugs:
                    if (AParams.TotalBugs >= 50000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.Challenge:
                    if (AParams.LevelCompletions[0] >= 15000 &&
                        AParams.LevelCompletions[1] >= 15000 &&
                        AParams.LevelCompletions[2] >= 15000 &&
                        AParams.LevelCompletions[3] >= 15000)
                    {
                        t_Notify = true;
                    }
                    break;

                case Achieve.GetBonked:
                    t_Notify = true;
                    break;

                case Achieve.Repellant:
                    t_Notify = true;
                    break;

                case Achieve.CloseCall:
                    t_Notify = true;
                    break;

                case Achieve.Share:
                    t_Notify = true;
                    break;

                case Achieve.Magnolia:
                    t_Notify = true;
                    break;

                case Achieve.Tookie:
                    t_Notify = true;
                    break;

                case Achieve.Shep:
                    t_Notify = true;
                    break;

                case Achieve.Ape:
                    t_Notify = true;
                    break;

                case Achieve.You:
                    t_Notify = true;
                    break;
                }

                if (t_Notify)
                {
                    GameManager.Instance.googleAnalytics.LogEvent("Game", "Achievement Unlocked", Achievements[(int)chievo].Title, 1);
                    int    n = (int)GameManager.Instance.TotalBugs;
                    string s = "";
                    if (n == 0)
                    {
                        s = "0";
                    }
                    else if (n <= 100)
                    {
                        s = "1-100";
                    }
                    else if (n <= 500)
                    {
                        s = "101-500";
                    }
                    else if (n <= 2000)
                    {
                        s = "501-2000";
                    }
                    else if (n <= 5000)
                    {
                        s = "2001-5000";
                    }
                    else if (n <= 10000)
                    {
                        s = "5001-10000";
                    }
                    else
                    {
                        s = "10000+";
                    }
                    GameManager.Instance.googleAnalytics.LogEvent(new EventHitBuilder().SetEventCategory("Game").SetEventAction("Bugs Collected").SetEventLabel("Achievement").SetEventValue((int)(Achievements[(int)chievo].Reward)).SetCustomDimension(6, GameManager.Instance.TotalBugs.ToString()).SetCustomDimension(7, s));
                    //GameManager.Instance.googleAnalytics.DispatchHits();
                    Achievements[(int)chievo].Achieved = true;
                    if (Application.loadedLevelName == "Game")
                    {
                        GameManager.Instance._playerState.GetComponent <PlayerData>().Smile();
                    }
                    if (GameManager.Instance.GetState() == GameManager.GameState.Menu)
                    {
                        StatusBarHandler.Instance.TopIndicatorUpdates();
                    }
                    SaveChievos();
                    GameManager.Instance.EarnBugs((int)(Achievements[(int)chievo].Reward));
                    NotificationManager.Instance.AddNotification(true, false, true, false, NotificationManager.Instance.AchievementImege, false, Achievements[(int)chievo].Title, Achievements[(int)chievo].Description, Achievements[(int)chievo].Reward.ToString());
                }

                if (chievo != Achieve.You)
                {
                    int totalAchieved = 0;
                    foreach (Achievement achieve in Achievements)
                    {
                        if (achieve.Achieved)
                        {
                            totalAchieved++;
                        }
                    }

                    if (totalAchieved == ((GameManager.Instance.WebVersion) ? (Achievements.Count - 2) : (Achievements.Count - 1)))
                    {
                        Achievements[(int)Achieve.You].Achieved = true;
                        UpdateAchievement(Achieve.You);
                    }
                }
            }
        }
    }
Example #10
0
    /// <summary> Will be called at a time when an achievement may occur </summary>
    public float CheckProgress(Achieve chievo)
    {
        float progress = 0;
        int   count    = 0;
        int   count2   = 0;
        float amount   = 0;

        switch (chievo)
        {
        case Achieve.Friends:
            foreach (bool save in GameManager.saveData.FriendSaves)
            {
                if (save)
                {
                    count++;
                }
                progress = 0.25f * count;
            }
            break;

        case Achieve.Powerups:
            foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
            {
                if (item.PowerUpType == ShopItem.PowerType.Perma && item.Owned)
                {
                    count++;
                }
            }

            foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
            {
                if (item.PowerUpType == ShopItem.PowerType.Perma)
                {
                    count2++;
                }
            }

            progress = ((float)count / (float)count2);
            break;

        case Achieve.Level2:
            if (LevelManager.Instance.LevelsUnlocked > 1)
            {
                progress = 1f;
            }
            break;

        case Achieve.Level3:
            if (LevelManager.Instance.LevelsUnlocked > 2)
            {
                progress = 1f;
            }
            break;

        case Achieve.Level4:
            if (LevelManager.Instance.LevelsUnlocked > 3)
            {
                progress = 1f;
            }
            break;

        case Achieve.Cosmetics:
            foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
            {
                if (item.PowerUpType == ShopItem.PowerType.Vanity && item.Owned)
                {
                    count++;
                }
            }

            foreach (ShopItem item in PowerUpManager.Instance.ShopListings)
            {
                if (item.PowerUpType == ShopItem.PowerType.Vanity)
                {
                    count2++;
                }
            }

            progress = ((float)count / (float)count2);
            break;

        case Achieve.BugCollector1:
            progress = AParams.TotalBugs / 100;
            break;

        case Achieve.BugCollector2:
            progress = AParams.TotalBugs / 1000;
            break;

        case Achieve.BugCollector3:
            progress = AParams.TotalBugs / 10000;
            break;

        case Achieve.TotalHeight:
            progress = AParams.TotalHeight / 50000;
            break;

        case Achieve.TotalFall:
            progress = AParams.TotalFall / 10000;
            break;

        case Achieve.TotalBugs:
            progress = AParams.TotalBugs / 50000;
            break;

        case Achieve.Height1:
            foreach (LevelSaveData level in GameManager.saveData.LevelData)
            {
                if (level.dHeight > amount)
                {
                    amount = level.dHeight;
                }

                if (level.nHeight > amount)
                {
                    amount = level.nHeight;
                }
            }

            progress = amount / 500f;
            break;

        case Achieve.Height2:
            foreach (LevelSaveData level in GameManager.saveData.LevelData)
            {
                if (level.dHeight > amount)
                {
                    amount = level.dHeight;
                }

                if (level.nHeight > amount)
                {
                    amount = level.nHeight;
                }
            }

            progress = amount / 1500f;
            break;

        case Achieve.Height3:
            foreach (LevelSaveData level in GameManager.saveData.LevelData)
            {
                if (level.dHeight > amount)
                {
                    amount = level.dHeight;
                }

                if (level.nHeight > amount)
                {
                    amount = level.nHeight;
                }
            }

            progress = amount / 4500f;
            break;

        case Achieve.Height4:
            foreach (LevelSaveData level in GameManager.saveData.LevelData)
            {
                if (level.dHeight > amount)
                {
                    amount = level.dHeight;
                }

                if (level.nHeight > amount)
                {
                    amount = level.nHeight;
                }
            }

            progress = amount / 9000f;
            break;

        case Achieve.TheFall:
            progress = AParams.HighestFall / 5000f;
            break;

        case Achieve.OverPowered:
            if (AParams.PowersThisRun > AParams.BestPowersPerRun)
            {
                AParams.BestPowersPerRun = AParams.PowersThisRun;
            }
            progress = AParams.BestPowersPerRun / 5f;
            break;

        case Achieve.JustSayNo:
            progress = AParams.HeightWithoutPower / 1000;
            break;

        case Achieve.GetBonked:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Repellant:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Infected1:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            else
            {
                progress = (AParams.TotalInfection / 30f);
                if (progress > 1f)
                {
                    progress = 1f;
                }
            }
            break;

        case Achieve.Infected2:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            else
            {
                progress = (AParams.TotalInfection / 120f);
                if (progress > 1f)
                {
                    progress = 1f;
                }
            }
            break;

        case Achieve.Infected3:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            else
            {
                progress = (AParams.TotalInfection / 240f);
                if (progress > 1f)
                {
                    progress = 1f;
                }
            }
            break;

        case Achieve.Challenge:
            foreach (float height in AParams.LevelCompletions)
            {
                if (height >= 15000)
                {
                    amount++;
                }
                progress = 0.25f * amount;
            }
            break;

        case Achieve.Dodger1:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Dodger2:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Dodger3:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.CloseCall:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Share:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Magnolia:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Tookie:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Shep:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.Ape:
            if (Achievements[(int)chievo].Achieved)
            {
                progress = 1f;
            }
            break;

        case Achieve.You:
            foreach (Achievement achievement in Achievements)
            {
                if (achievement.Achieved)
                {
                    count++;
                }
            }

            progress = ((float)count / (float)Achievements.Count);
            break;
        }
        return(progress);
    }
Example #11
0
    private void LoadAchieveMetas()
    {
        Dictionary <string, List <Achieve.Meta> > achieve_metas = new Dictionary <string, List <Achieve.Meta> >();

        Util.Sqlite.DataReader reader = Database.Execute(Database.Type.MetaData,
                                                         "SELECT achieve_type, achieve_step, achieve_name, achieve_goal, sprite_path, reward_stat_type, reward_stat_value, description FROM meta_achieve order by achieve_type, achieve_step"
                                                         );
        while (true == reader.Read())
        {
            Achieve.Meta meta = new Achieve.Meta()
            {
                type        = reader.GetString("achieve_type"),
                step        = reader.GetInt32("achieve_step"),
                name        = reader.GetString("achieve_name"),
                goal        = reader.GetInt32("achieve_goal"),
                sprite_path = reader.GetString("sprite_path"),
                description = reader.GetString("description")
            };
            meta.reward_stat = new Stat.Data()
            {
                type = (StatType)reader.GetInt32("reward_stat_type"), value = reader.GetFloat("reward_stat_value")
            };

            if (false == achieve_metas.ContainsKey(meta.type))
            {
                achieve_metas[meta.type] = new List <Achieve.Meta>();
            }

            achieve_metas[meta.type].Add(meta);
        }

        foreach (var itr in achieve_metas)
        {
            if (false == achieves.ContainsKey(itr.Key))
            {
                Achieve achieve = new Achieve(
                    itr.Value[0].name,
                    itr.Key,
                    1,
                    0,
                    itr.Value[0].goal
                    );

                Database.Execute(Database.Type.UserData,
                                 "INSERT INTO user_achieve(achieve_name, achieve_type, achieve_step, achieve_count, achieve_goal) VALUES('" + achieve.name + "','" + achieve.type + "',1,0," + achieve.goal + ")"
                                 );

                achieve.metas = itr.Value;
                achieves.Add(achieve.type, achieve);
                ProgressManager.Instance.Add(achieve);
            }
            else
            {
                if (false == achieves.ContainsKey(itr.Key))
                {
                    Debug.LogError("invalid achievemt type(type:" + itr.Key + ")");
                    continue;
                }

                Achieve achieveData = achieves[itr.Key];
                achieveData.metas = itr.Value;

                if (Achieve.State.Complete == achieveData.state)
                {
                    ProgressManager.Instance.Remove(achieveData);
                }
            }
        }
    }
Example #12
0
 public static void set_show(Achieve index)
 {
     string s = "scrollinglist/ScrollableArea/获得成就/Cup"+(int)index+"/cup(y)";
     go_Achievement.transform.FindChild(s).gameObject.SetActive(true);
 }
    public static void set_show(Achieve index)
    {
        string s = "scrollinglist/ScrollableArea/获得成就/Cup" + (int)index + "/cup(y)";

        go_Achievement.transform.Find(s).gameObject.SetActive(true);
    }