Пример #1
0
        public void UpdateAchievement(string id, int value)
        {
            Achievement achievement = achievements.FirstOrDefault(x => x.id == id);

            if (!achievements.Contains(achievement))
            {
                Debug.LogError($"Achievement by id {id} was not found!");
                return;
            }

            AchievementStatus status = achievement.status;

            if (status.unlocked)
            {
                return;
            }

            status.current += value;

            if (status.current < status.goal)
            {
                return;
            }

            status.current  = status.goal;
            status.unlocked = true;

            SoundManager.Instance.PlayNonDiegeticSound(achievementSound);

            StartCoroutine(ShowAchievement(achievement, 3));
        }
Пример #2
0
        public void EnemyKillAchievements(int _id, int _enemyKilled)
        {
            if (_enemyKilled >= enemyKillMark[killProgress])
            {
                GameApplication.Instance.GetService <IPlayerSaveService>().SetAchievementStatus(AchievementTypes.ENEMYKILLS, _id, 1);
                killProgress++;
            }
            AchievementStatus currentStatus = GameApplication.Instance.GetService <IPlayerSaveService>().GetAchievementStatus(AchievementTypes.ENEMYKILLS, _id);

            if (currentStatus == AchievementStatus.FINISHED)
            {
                OnAchievementCrossed.Invoke("Achievement Unlocked for player" + _id.ToString() + "Kill  " + enemyKillMark.ToString() + " Enemies!!");
                UnlockReward.Invoke(idToUnlock, _type);
            }
        }
Пример #3
0
        public void GamePlayedAchievements(int _id, int _gamesPlayed)
        {
            idToUnlock = 4;
            if (_gamesPlayed >= gamePlayedMark[gamePlayedProgress])
            {
                GameApplication.Instance.GetService <IPlayerSaveService>().SetAchievementStatus(AchievementTypes.GAMESJOINED, _id, 1);
                gamePlayedProgress++;
            }
            AchievementStatus currentStatus = GameApplication.Instance.GetService <IPlayerSaveService>().GetAchievementStatus(AchievementTypes.GAMESJOINED, _id);

            if (currentStatus == AchievementStatus.FINISHED)
            {
                OnAchievementCrossed.Invoke("Achievement Unlocked for player" + _id.ToString() + "Play  " + gamePlayedMark.ToString() + " Games!!");
                UnlockReward?.Invoke(idToUnlock, _type);
            }
        }
Пример #4
0
        public void HighScoreAchievements(int _id, int _highScore)
        {
            idToUnlock = 3;
            if (_highScore >= highScoreMark[highScoreProgress])
            {
                GameApplication.Instance.GetService <IPlayerSaveService>().SetAchievementStatus(AchievementTypes.HIGHSCORE, _id, 1);
                highScoreProgress++;
            }
            AchievementStatus currentStatus = GameApplication.Instance.GetService <IPlayerSaveService>().GetAchievementStatus(AchievementTypes.HIGHSCORE, _id);

            if (currentStatus == AchievementStatus.FINISHED)
            {
                OnAchievementCrossed.Invoke("Achievement Unlocked for player" + _id.ToString() + "Reach HighScore " + highScoreMark.ToString() + "!!");
                UnlockReward.Invoke(idToUnlock, _type);
            }
        }
Пример #5
0
        public void DieAchievements(int _id, int _dieCalled)
        {
            idToUnlock = 1;

            if (_dieCalled >= dieMark[dieProgress])
            {
                GameApplication.Instance.GetService <IPlayerSaveService>().SetAchievementStatus(AchievementTypes.PLAYERDEATHS, _id, 1);
                dieProgress++;
            }

            AchievementStatus currentStatus = GameApplication.Instance.GetService <IPlayerSaveService>().GetAchievementStatus(AchievementTypes.PLAYERDEATHS, _id);

            if (currentStatus == AchievementStatus.FINISHED)
            {
                OnAchievementCrossed.Invoke("Achievement Unlocked for player" + _id.ToString() + " Die " + dieMark.ToString() + " times");
                UnlockReward.Invoke(idToUnlock, _type);
            }
        }
Пример #6
0
        public override IDeepCopyable CopyTo(IDeepCopyable other)
        {
            var dest = other as Goal;

            if (dest == null)
            {
                throw new ArgumentException("Can only copy to an object of the same type", "other");
            }

            base.CopyTo(dest);
            if (Identifier != null)
            {
                dest.Identifier = new List <Hl7.Fhir.Model.Identifier>(Identifier.DeepCopy());
            }
            if (LifecycleStatusElement != null)
            {
                dest.LifecycleStatusElement = (Code <Hl7.Fhir.Model.Goal.GoalLifecycleStatus>)LifecycleStatusElement.DeepCopy();
            }
            if (AchievementStatus != null)
            {
                dest.AchievementStatus = (Hl7.Fhir.Model.CodeableConcept)AchievementStatus.DeepCopy();
            }
            if (Category != null)
            {
                dest.Category = new List <Hl7.Fhir.Model.CodeableConcept>(Category.DeepCopy());
            }
            if (Priority != null)
            {
                dest.Priority = (Hl7.Fhir.Model.CodeableConcept)Priority.DeepCopy();
            }
            if (Description != null)
            {
                dest.Description = (Hl7.Fhir.Model.CodeableConcept)Description.DeepCopy();
            }
            if (Subject != null)
            {
                dest.Subject = (Hl7.Fhir.Model.ResourceReference)Subject.DeepCopy();
            }
            if (Start != null)
            {
                dest.Start = (Hl7.Fhir.Model.Element)Start.DeepCopy();
            }
            if (Target != null)
            {
                dest.Target = new List <Hl7.Fhir.Model.Goal.TargetComponent>(Target.DeepCopy());
            }
            if (StatusDateElement != null)
            {
                dest.StatusDateElement = (Hl7.Fhir.Model.Date)StatusDateElement.DeepCopy();
            }
            if (StatusReasonElement != null)
            {
                dest.StatusReasonElement = (Hl7.Fhir.Model.FhirString)StatusReasonElement.DeepCopy();
            }
            if (ExpressedBy != null)
            {
                dest.ExpressedBy = (Hl7.Fhir.Model.ResourceReference)ExpressedBy.DeepCopy();
            }
            if (Addresses != null)
            {
                dest.Addresses = new List <Hl7.Fhir.Model.ResourceReference>(Addresses.DeepCopy());
            }
            if (Note != null)
            {
                dest.Note = new List <Hl7.Fhir.Model.Annotation>(Note.DeepCopy());
            }
            if (OutcomeCode != null)
            {
                dest.OutcomeCode = new List <Hl7.Fhir.Model.CodeableConcept>(OutcomeCode.DeepCopy());
            }
            if (OutcomeReference != null)
            {
                dest.OutcomeReference = new List <Hl7.Fhir.Model.ResourceReference>(OutcomeReference.DeepCopy());
            }
            return(dest);
        }
Пример #7
0
        /// <summary>
        /// Serialize to a JSON object
        /// </summary>
        public new void SerializeJson(Utf8JsonWriter writer, JsonSerializerOptions options, bool includeStartObject = true)
        {
            if (includeStartObject)
            {
                writer.WriteStartObject();
            }
            if (!string.IsNullOrEmpty(ResourceType))
            {
                writer.WriteString("resourceType", (string)ResourceType !);
            }


            ((fhirCsR4.Models.DomainResource) this).SerializeJson(writer, options, false);

            if ((Identifier != null) && (Identifier.Count != 0))
            {
                writer.WritePropertyName("identifier");
                writer.WriteStartArray();

                foreach (Identifier valIdentifier in Identifier)
                {
                    valIdentifier.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(LifecycleStatus))
            {
                writer.WriteString("lifecycleStatus", (string)LifecycleStatus !);
            }

            if (_LifecycleStatus != null)
            {
                writer.WritePropertyName("_lifecycleStatus");
                _LifecycleStatus.SerializeJson(writer, options);
            }

            if (AchievementStatus != null)
            {
                writer.WritePropertyName("achievementStatus");
                AchievementStatus.SerializeJson(writer, options);
            }

            if ((Category != null) && (Category.Count != 0))
            {
                writer.WritePropertyName("category");
                writer.WriteStartArray();

                foreach (CodeableConcept valCategory in Category)
                {
                    valCategory.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (Priority != null)
            {
                writer.WritePropertyName("priority");
                Priority.SerializeJson(writer, options);
            }

            if (Description != null)
            {
                writer.WritePropertyName("description");
                Description.SerializeJson(writer, options);
            }

            if (Subject != null)
            {
                writer.WritePropertyName("subject");
                Subject.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(StartDate))
            {
                writer.WriteString("startDate", (string)StartDate !);
            }

            if (_StartDate != null)
            {
                writer.WritePropertyName("_startDate");
                _StartDate.SerializeJson(writer, options);
            }

            if (StartCodeableConcept != null)
            {
                writer.WritePropertyName("startCodeableConcept");
                StartCodeableConcept.SerializeJson(writer, options);
            }

            if ((Target != null) && (Target.Count != 0))
            {
                writer.WritePropertyName("target");
                writer.WriteStartArray();

                foreach (GoalTarget valTarget in Target)
                {
                    valTarget.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (!string.IsNullOrEmpty(StatusDate))
            {
                writer.WriteString("statusDate", (string)StatusDate !);
            }

            if (_StatusDate != null)
            {
                writer.WritePropertyName("_statusDate");
                _StatusDate.SerializeJson(writer, options);
            }

            if (!string.IsNullOrEmpty(StatusReason))
            {
                writer.WriteString("statusReason", (string)StatusReason !);
            }

            if (_StatusReason != null)
            {
                writer.WritePropertyName("_statusReason");
                _StatusReason.SerializeJson(writer, options);
            }

            if (ExpressedBy != null)
            {
                writer.WritePropertyName("expressedBy");
                ExpressedBy.SerializeJson(writer, options);
            }

            if ((Addresses != null) && (Addresses.Count != 0))
            {
                writer.WritePropertyName("addresses");
                writer.WriteStartArray();

                foreach (Reference valAddresses in Addresses)
                {
                    valAddresses.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((Note != null) && (Note.Count != 0))
            {
                writer.WritePropertyName("note");
                writer.WriteStartArray();

                foreach (Annotation valNote in Note)
                {
                    valNote.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((OutcomeCode != null) && (OutcomeCode.Count != 0))
            {
                writer.WritePropertyName("outcomeCode");
                writer.WriteStartArray();

                foreach (CodeableConcept valOutcomeCode in OutcomeCode)
                {
                    valOutcomeCode.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if ((OutcomeReference != null) && (OutcomeReference.Count != 0))
            {
                writer.WritePropertyName("outcomeReference");
                writer.WriteStartArray();

                foreach (Reference valOutcomeReference in OutcomeReference)
                {
                    valOutcomeReference.SerializeJson(writer, options, true);
                }

                writer.WriteEndArray();
            }

            if (includeStartObject)
            {
                writer.WriteEndObject();
            }
        }