예제 #1
0
 void OnComplete(AchievementBase baseobj)
 {
     //If the OnComplete event is coming from this MajorAchievement, call the RoomManager and add points
     //Do I really want to let this script handle this kind of active operations???
     if (baseobj == majorAchievement)
     {
         teleporter.Activated = true;
         FindObjectOfType <RoomManager>()._ScoreManager.AddPoints(AchievementPoints);
     }
 }
예제 #2
0
    void Awake()
    {
        //Start listening to the OnComplete event of all achievementbases
        AchievementBase.AchievementCompleted += OnComplete;

        //Get its own components to use
        majorAchievement = GetComponentInChildren <AchievementBase>();
        teleporter       = GetComponentInChildren <Teleporter>();
        SpawnPoint       = GetComponentInChildren <SpawnPoint>();
    }
예제 #3
0
    public void AddAchievement(AchievementBase _Achievement)
    {
        if (_Achievement == null)
        {
            return;
        }
        if (AchievementList.ContainsKey(_Achievement.AchievementName))
        {
            return;
        }

        _Achievement.Init(m_playerstats);
        AchievementList.Add(_Achievement.AchievementName, _Achievement);
    }
예제 #4
0
    void Awake()
    {
        achievementList = new List <AchievementBase>();
        foreach (GameObject a in achievementPrefabList)
        {
            GameObject      clone = Instantiate(a, this.transform);
            AchievementBase abase = clone.GetComponent <AchievementBase>();
            abase.aSystem = this;
            achievementList.Add(abase);

            if (abase.IsCompletedCheck()) //deactivate it if it is done
            {
                clone.SetActive(false);
            }
        }
        activepanels = new List <ActivePanelInfo>();
    }
예제 #5
0
    public void UpdateAchievement(AchievementBase _Achievement)
    {
        foreach (KeyValuePair <string, AchievementBase> qb in AchievementList)
        {
            if (qb.Key != _Achievement.AchievementName)
            {
                continue;
            }
            qb.Value.UpdateAchievement();
            Debug.Log(qb.Key + " is now " + qb.Value.AchievementCompleted + "(AchievementCompleted)");

            if (qb.Value.AchievementCompleted)
            {
                qb.Value.AchievementReward();
                qb.Value.AchievementActive = false;
            }
        }
    }
예제 #6
0
    void TriggerAchievementAnimation(AchievementBase ach)
    {
        RectTransform canvasRect = canvas.GetComponent <RectTransform>();
        float         midX       = canvasRect.rect.width * 0.5f;
        float         height     = canvasRect.rect.height;
        GameObject    panel      = Instantiate(achievementPanel);
        RectTransform panelRect  = panel.GetComponent <RectTransform>();

        //Set Parent
        panel.transform.SetParent(canvas.transform, false);
        //Set Scale
        float dx = canvasRect.rect.width - panelinfo.width;
        float dy = height - panelinfo.height;

        panelRect.sizeDelta = new Vector2(-dx, -dy);

        //Set Pos
        Vector3 endPos; //= new Vector3(0, height * 0.5f - panelinfo.height * 0.5f - panelinfo.offsetFromTop - panelinfo.height * activepanels.Count);
        Vector3 firstEndReference = new Vector3(0, height * 0.5f - panelinfo.height * 0.5f - panelinfo.offsetFromTop);

        if (activepanels.Count <= 0)
        {
            endPos = new Vector3(0, 0, 0);
        }
        else
        {
            endPos = new Vector3(0, -panelinfo.height);
        }
        Vector3 startPos = new Vector3(0, height * 0.5f + panelinfo.height * 0.5f);

        panelRect.localPosition = startPos;
        float moveSpd = (firstEndReference - startPos).magnitude / panelinfo.moveTime;

        //Init values/text
        AchievementPanel panelScript = panel.GetComponent <AchievementPanel>();

        panelScript.Init(ach.ach_name, ach.description);

        ActivePanelInfo api = new ActivePanelInfo(panel, panelinfo.lifeTime, startPos, endPos, panelinfo.moveTime);

        api.moveSpd = moveSpd;
        activepanels.Add(api);
    }
예제 #7
0
        public void UnlockAchievement(AchievementBase achievement)
        {
            var achievementDto = AchievementRepository.GetAchievements().Single(a => a.AchievementType == achievement.GetType());

            achievementDto.IsCompleted = true;

            var staticAnalysisAchievement = achievement as StaticAnalysisAchievementBase;

            if (staticAnalysisAchievement != null)
            {
                achievementDto.CodeOrigin = staticAnalysisAchievement.AchievementCodeOrigin;
            }

            AchievementRepository.MarkAchievementAsCompleted(achievementDto);

            OnAchievementsUnlocked(this, new AchievementEventArgs
            {
                UnlockedAchievements = new[] { achievementDto }
            });
        }
예제 #8
0
 public void ChangeAchievementStatus(AchievementBase achievement)
 {
     PlayerPrefs.SetInt("Achievement_" + achievement.Id, (int)achievement.AchievementStatus);
 }
예제 #9
0
 public void AchievementUnlocked(AchievementBase ach)
 {
     //queue up the visual effect of achievement unlock thing
     TriggerAchievementAnimation(ach);
     Debug.Log("Achievement Unlocked: " + ach.ach_name);
 }