コード例 #1
0
 public virtual Dictionary <Guid, IntegrityCheck>?EntityIntegrityCheck()
 {
     using (Mixins.OfType <CorruptMixin>().Any(c => c.Corrupt) ? Corruption.AllowScope() : null)
     {
         return(EntityIntegrityCheckBase());
     }
 }
コード例 #2
0
ファイル: Customer.cs プロジェクト: lulzzz/southwind
 public override Dictionary <Guid, IntegrityCheck> EntityIntegrityCheck()
 {
     using (this.Corrupt ? Corruption.AllowScope() : null)
     {
         return(base.EntityIntegrityCheck());
     }
 }
コード例 #3
0
ファイル: Radio.cs プロジェクト: mattstark256/radioActiveLWRP
    private void OnTriggerExit(Collider other)
    {
        Corruption corruption = other.GetComponent <Corruption>();

        if (corruption != null && corruption == nearbyCorruption)
        {
            nearbyCorruption = null;
        }
    }
コード例 #4
0
ファイル: Radio.cs プロジェクト: mattstark256/radioActiveLWRP
    private void OnTriggerEnter(Collider other)
    {
        Corruption corruption = other.GetComponent <Corruption>();

        if (corruption != null && nearbyCorruption == null)
        {
            nearbyCorruption = corruption;
        }
    }
コード例 #5
0
    void Start()
    {
        adjacentCorruption = new List <Corruption>();
        GameObject[] sources = GameObject.FindGameObjectsWithTag("AssT");

        float dist  = int.MaxValue;
        int   index = 0;

        for (int i = 0; i < sources.Length; i++)
        {
            float distance = Vector3.Distance(sources[i].transform.position, transform.position);
            if (distance < dist)
            {
                index = i;
                dist  = distance;
            }
        }

        corruptionSource = sources[index].GetComponent <CorruptionSource>();

        corruptionSource.allcorupted.Add(this);


        //find adjacent
        GameObject[] corruptions = GameObject.FindGameObjectsWithTag("Tree");

        for (int i = 0; i < corruptions.Length; i++)
        {
            float distance = Vector3.Distance(transform.position, corruptions[i].transform.position);

            if (distance <= radius)
            {
                Corruption c = corruptions[i].GetComponent <Corruption>();
                adjacentCorruption.Add(c);
            }
        }

        // get corrupt and healed versions

        foreach (Transform child in transform)
        {
            if (child.tag == "CTree")
            {
                corrupSide = child.gameObject;
            }
            if (child.tag == "GTree")
            {
                healedSide = child.gameObject;
            }
        }

        //set as healed
        SetCorrupted();
        corruptionSource.AddTree();
    }
コード例 #6
0
    void Awake()
    {
        Auras = new Dictionary<string, Aura>();

        Auras["test"] = new AuraTemplate("test");
        Auras["heal"] = new Heal("heal");
        Auras["Corruption"] = new Corruption("Corruption");
        Auras["BlessingOfMight"] = new BlessingOfMight("Blessing of Might");

        Auras["shadowStun"] = new Shadowstun("shadowStun");
        Auras["root"] = new Root("root");
        Auras["slow"] = new Slow("slow");
        Auras["dervishslow"] = new DervishSlow("dervishslow");
        Auras["chaosbarrage"] = new chaosbarrage("chaosbarrage");
        Auras["fireballbarrage"] = new fireballbarrage("fireballbarrage");
    }
コード例 #7
0
        private void Submit()
        {
            if (App.Instance.CorruptionSubmitted != null)
            {
                var location    = new Location("");
                var videoPath   = "";
                var audioPath   = "";
                var imagePath   = "";
                var description = "";

                Corruption corruption = new Corruption {
                    Location  = location, Description = description,
                    AudioPath = audioPath, VideoPath = videoPath, ImagePath = imagePath
                };

                App.Instance.CorruptionSubmitted(corruption);
            }
        }
コード例 #8
0
ファイル: CorruptMixin.cs プロジェクト: goldenauge/framework
    protected internal override void PreSaving(PreSavingContext ctx)
    {
        base.PreSaving(ctx);

        if (Corrupt)
        {
            var integrity = ((Entity)MainEntity).EntityIntegrityCheckBase(); // So, no corruption allowed
            if (integrity == null)
            {
                this.Corrupt = false;
                if (!((Entity)MainEntity).IsNew)
                {
                    Corruption.OnCorruptionRemoved((Entity)MainEntity);
                }
            }
            else if (((Entity)MainEntity).IsNew)
            {
                Corruption.OnSaveCorrupted((Entity)MainEntity, integrity);
            }
        }
    }
コード例 #9
0
    // Start is called before the first frame update
    void Awake()
    {
        GameObject[] asteroids = GameObject.FindGameObjectsWithTag("AssT");

        sources = asteroids.Length;

        for (int i = 0; i < asteroids.Length; i++)
        {
            asteroids[i].AddComponent <CorruptionSource>();
        }

        GameObject[] trees = GameObject.FindGameObjectsWithTag("Tree");
        for (int i = 0; i < trees.Length; i++)
        {
            Corruption c = trees[i].AddComponent <Corruption>();
            c.timerMin = recorruptTimeMin;
            c.timerMax = recorruptTimeMax;
        }

        treeAmount = trees.Length;
        healed     = treeAmount;
    }
コード例 #10
0
    public override string ToString()
    {
        return("Wealth=" + Wealth.ToString() + "\n" +
               "Wealth=" + Police.ToString() + "\n" +
               "Wealth=" + Heterogenity.ToString() + "\n" +
               "Wealth=" + Pollution.ToString() + "\n" +
               "Wealth=" + Corruption.ToString() + "\n\n" +

               "Wealth=" + Infrastructure.ToString() + "\n" +
               "Wealth=" + HealthServices.ToString() + "\n" +
               "Wealth=" + Crime.ToString() + "\n" +
               "Wealth=" + Religion.ToString() + "\n" +
               "Wealth=" + Food.ToString() + "\n" +
               "Wealth=" + Cleanness.ToString() + "\n" +
               "Wealth=" + Employment.ToString() + "\n" +
               "Wealth=" + Information.ToString() + "\n\n" +

               "Wealth=" + Nourishment.ToString() + "\n" +
               "Wealth=" + Health.ToString() + "\n" +
               "Wealth=" + Shelter.ToString() + "\n" +
               "Wealth=" + Trust.ToString() + "\n" +
               "Wealth=" + Safety.ToString());
    }
コード例 #11
0
        private bool ValidateModifiableEntity(ValidationContext validationContext, ModifiableEntity mod)
        {
            if (mod is Entity && validationContext.Visited.Contains(mod))
            {
                return(true);
            }

            validationContext.Visited.Add(mod);

            bool          isValid       = true;
            PropertyScope propertyScope = new PropertyScope();

            validationContext.KeyBuilders.Push(propertyScope);

            var entity = mod as Entity;

            using (entity == null ? null : entity.Mixins.OfType <CorruptMixin>().Any(c => c.Corrupt) ? Corruption.AllowScope() : Corruption.DenyScope())
            {
                foreach (var kvp in PropertyConverter.GetPropertyConverters(mod.GetType()))
                {
                    if (kvp.Value.AvoidValidate)
                    {
                        continue;
                    }

                    propertyScope.PropertyName = kvp.Key;
                    if (SignumValidate(validationContext, kvp.Value.GetValue(mod)) ?? true)
                    {
                        isValid = false;
                    }

                    string error = kvp.Value.PropertyValidator.PropertyCheck(mod);

                    if (error != null)
                    {
                        string key = CalculateKey(validationContext);
                        if (validationContext.ModelState.IsValidField(key))
                        {
                            isValid = false;
                            validationContext.ModelState.AddModelError(key, error);
                        }
                    }
                }
            }

            if (entity != null && entity.Mixins.Any())
            {
                propertyScope.PropertyName = "mixins";
                PropertyScope mixinScope = new PropertyScope();
                validationContext.KeyBuilders.Push(mixinScope);
                foreach (var mixin in entity.Mixins)
                {
                    mixinScope.PropertyName = mixin.GetType().Name;
                    if (!ValidateModifiableEntity(validationContext, mixin))
                    {
                        isValid = false;
                    }
                }
                validationContext.KeyBuilders.Pop();
            }

            validationContext.KeyBuilders.Pop();

            validationContext.Visited.Remove(mod);
            return(isValid);
        }
コード例 #12
0
        private bool ValidateModifiableEntity(ModifiableEntity mod)
        {
            using (Validator.ModelBinderScope())
            {
                bool isValid = true;

                var entity = mod as Entity;
                using (entity == null ? null : entity.Mixins.OfType <CorruptMixin>().Any(c => c.Corrupt) ? Corruption.AllowScope() : Corruption.DenyScope())
                {
                    foreach (var kvp in PropertyConverter.GetPropertyConverters(mod.GetType()))
                    {
                        if (kvp.Value.AvoidValidate)
                        {
                            continue;
                        }

                        string?error = kvp.Value.PropertyValidator !.PropertyCheck(mod);
                        if (error != null)
                        {
                            isValid = false;
                            ModelState.AddModelError(this.Key + "." + kvp.Key, error);
                        }

                        var val = kvp.Value.GetValue !(mod);
                        if (val != null && this.CurrentPath.Push(val))
                        {
                            using (StateManager.Recurse(this, this.Key + "." + kvp.Key, null, val, null))
                            {
                                if (this.SignumValidate() == false)
                                {
                                    isValid = false;
                                }
                            }
                        }
                    }
                }

                if (entity != null && entity.Mixins.Any())
                {
                    foreach (var mixin in entity.Mixins)
                    {
                        if (this.CurrentPath.Push(mixin))
                        {
                            using (StateManager.Recurse(this, "mixins[" + mixin.GetType().Name + "].element", null, mixin, null))
                            {
                                isValid &= ValidateModifiableEntity(mixin);
                            }
                        }
                    }
                }

                return(isValid);
            }
        }
コード例 #13
0
    private IEnumerator GameCoroutine()
    {
        SetInputLocked(true);
        GameObject tutorialPanel = Instantiate(tutorialPanelPrefab, popupParent);

        while (tutorialPanel != null)
        {
            yield return(null);
        }
        SetInputLocked(false);

        yield return(new WaitForSeconds(1));

        audioController.PlayVoiceOver();

        yield return(new WaitForSeconds(4));

        tutorialCorruption.ActivateCorruption();
        corruptionController.ExpandFromPoint(tutorialCorruption.transform.position, 60, 50);


        // Wait until game over or radio delivered
        while (true)
        {
            if (corruptionController.GameIsOver())
            {
                tutorialCorruption.MakeUnstoppable();
                GameOver();
                yield break;
            }
            else if (!tutorialCorruption.IsActivated())
            {
                corruptionController.Dissappear(2);
                break;
            }

            yield return(null);
        }


        // Make bridge appear
        tutorialBridge.GoToNextPosition();


        for (int i = 0; i < shuffledCorruptions.Count; i++)
        {
            Corruption corruption = shuffledCorruptions[i];
            corruption.transform.position = shuffledCorruptionLocations[i].position;
            corruption.ActivateCorruption();
            corruptionController.ExpandFromPoint(corruption.transform.position, corruptionDurations[i], 80);

            // Wait until game over or radio delivered
            while (true)
            {
                if (corruptionController.GameIsOver())
                {
                    corruption.MakeUnstoppable();
                    GameOver();
                    yield break;
                }
                else if (!corruption.IsActivated())
                {
                    corruptionController.Dissappear(2);
                    StartCoroutine(ReturnAllRadios());
                    break;
                }

                yield return(null);
            }
        }

        yield return(new WaitForSeconds(4));

        Win();
    }
コード例 #14
0
        /// <summary>
        /// Fixes specified corruption
        /// </summary>
        /// <param name="corruptionEntry"></param>
        public static void Fix(Corruption corruptionEntry)
        {
            // Has topic been loaded yet ?
            if (_Data.ContainsKey(corruptionEntry.topic))
            {
                // Data access
                TduFile[]  files = _Data[corruptionEntry.topic];
                DB         db    = files[0] as DB;
                DBResource res   = files[1] as DBResource;

                TduFile[]  refFiles = _Data[corruptionEntry.referencedTopic];
                DB         refDb    = refFiles[0] as DB;
                DBResource refRes   = refFiles[1] as DBResource;

                TduFile[]  backupFiles = _BackupData[corruptionEntry.topic];
                DB         backupDb    = backupFiles[0] as DB;
                DBResource backupRes   = backupFiles[1] as DBResource;

                TduFile[]  backupRefFiles = _BackupData[corruptionEntry.referencedTopic];
                DB         backupRefDb    = backupRefFiles[0] as DB;
                DBResource backupRefRes   = backupRefFiles[1] as DBResource;

                // Integrity checks
                if (db == null || res == null || refDb == null || refRes == null)
                {
                    throw new Exception("Database loading error.");
                }
                if (backupDb == null || backupRes == null || backupRefDb == null || backupRefRes == null)
                {
                    throw new Exception("Database backup loading error.");
                }

                string colName = corruptionEntry.corruptedCell.name;

                // According to corruption kind
                switch (corruptionEntry.kind)
                {
                case CorruptionKind.UnknownReferencedTopic:
                    throw new Exception("UnknownReferencedTopic issue can't be solved yet.");

                case CorruptionKind.StructureMissingColumns:
                    throw new Exception("StructureMissingColumns issue can't be solved yet.");

                case CorruptionKind.MissingReference:
                    // If referenced entry does not exist in backup, restore referenced id from backup
                    // else restore entry
                    string          referencedEntryPk = corruptionEntry.corruptedValue;
                    List <DB.Entry> entries           = DatabaseHelper.SelectAllCellsFromTopicWherePrimaryKey(backupRefDb, new[] { referencedEntryPk });

                    if (entries.Count == 0)
                    {
                        DB.Entry currentEntry =
                            DatabaseHelper.SelectAllCellsFromTopicWhereId(db, corruptionEntry.entryId)[0];
                        string         entryPk     = currentEntry.primaryKey;
                        List <DB.Cell> backupCells =
                            DatabaseHelper.SelectCellsFromTopicWherePrimaryKey(colName, backupDb, new[] { entryPk });

                        if (backupCells.Count == 0)
                        {
                            // Worst case : referenced item not found in backup > must restore original reference
                            DB.Cell cleanCell = DatabaseHelper.SelectCellsFromTopicWithEntryId(colName, backupDb, new[] { corruptionEntry.entryId })[0];

                            DatabaseHelper.UpdateCellFromTopicWithEntryId(db, colName, cleanCell.value,
                                                                          corruptionEntry.entryId);
                            Log.Info("Fixed issue : " + corruptionEntry.kind + " by setting new reference: " + cleanCell.value + " in " + colName + ", line " + corruptionEntry.entryId);
                        }
                        else
                        {
                            DatabaseHelper.UpdateCellFromTopicWherePrimaryKey(db, colName, entryPk,
                                                                              backupCells[0].value);
                            Log.Info("Fixed issue : " + corruptionEntry.kind + " by setting new reference: " + backupCells[0].value + " in " + colName + ", line " + corruptionEntry.entryId);
                        }

                        db.Save();
                    }
                    else
                    {
                        DatabaseHelper.InsertAllCellsIntoTopic(refDb, entries[0]);
                        refDb.Save();

                        Log.Info("Fixed issue : " + corruptionEntry.kind + " by creating new line.");
                    }
                    break;

                case CorruptionKind.MissingResource:
                    // If resource exists in backup, restore resource id
                    // else restore referenced resource id from backup
                    DBResource backupResource;
                    DBResource resource;

                    if (corruptionEntry.topic == corruptionEntry.referencedTopic)
                    {
                        // Resource is in the same topic
                        backupResource = backupRes;
                        resource       = res;
                    }
                    else
                    {
                        // Resource is in another topic
                        backupResource = backupRefRes;
                        resource       = refRes;
                    }

                    DBResource.Entry backupResEntry = backupResource.GetEntryFromId(corruptionEntry.corruptedValue);

                    if (backupResEntry.isValid)
                    {
                        resource.InsertEntry(backupResEntry);
                        resource.Save();

                        Log.Info("Fixed issue : " + corruptionEntry.kind + " by creating new resource: " + backupResEntry.value + " in " + resource.CurrentTopic + ", id=" + backupResEntry.id);
                    }
                    else
                    {
                        DB.Cell backupCell =
                            DatabaseHelper.SelectCellsFromTopicWithEntryId(colName, backupDb, corruptionEntry.entryId)[0];

                        // Trying to get resource from backup
                        backupResEntry = backupResource.GetEntryFromId(backupCell.value);

                        if (backupResEntry.isValid)
                        {
                            DatabaseHelper.UpdateCellFromTopicWithEntryId(db, colName, backupCell.value,
                                                                          corruptionEntry.entryId);
                            db.Save();

                            Log.Info("Fixed issue : " + corruptionEntry.kind + " by setting new reference to resource: " + backupCell.value + " in " + colName + ", line " + corruptionEntry.entryId);
                        }
                        else
                        {
                            // Applying default resource value
                            backupResEntry.id      = new ResourceIdentifier(backupCell.value, backupResource.CurrentTopic);
                            backupResEntry.isValid = true;
                            backupResEntry.value   = _DEFAULT_RESOURCE_VALUE;
                            backupResEntry.index   = resource.EntryList.Count;

                            resource.InsertEntry(backupResEntry);
                            resource.Save();

                            Log.Info("Fixed issue : " + corruptionEntry.kind + " by creating new resource: " +
                                     backupResEntry.value + " in " + resource.CurrentTopic + ", id=" +
                                     backupResEntry.id);
                        }
                    }

                    break;
                }
            }
            else
            {
                throw new Exception("Please load corresponding data and resource first!");
            }
        }
コード例 #15
0
        private void OnCorruptionSubmitted(Corruption corruption)
        {
            FacebookClient client = new FacebookClient(StringSource.FaceBookAccessToken);

            client.PostTaskAsync(StringSource.FaceBookPage, new { message = corruption.Description });
        }