Exemplo n.º 1
0
        public void UpdateParadoxes(float time)
        {
            int activeItemParadoxes     = 0;
            int activeCharacterParadoxe = 0;

            for (int i = 0, count = characters.Count; i < count; i++)
            {
                Character character = characters[i];

                for (int s = 0, paradoxCount = character.currentParadoxes.Count; s < paradoxCount; s++)
                {
                    Paradox paradox = character.currentParadoxes[s];
                    bool    warning = paradox.time > time;

                    if (paradox.type == Paradox.ParadoxType.Character)
                    {
                        if (warning == false)
                        {
                            ParadoxEffect characterParadoxEffect = GetCharacterParadox(activeCharacterParadoxe);
                            characterParadoxEffect.transform.position = paradox.character.transform.position;

                            if (warning)
                            {
                                characterParadoxEffect.main.startColor       = new ParticleSystem.MinMaxGradient(Color.yellow, Color.black);
                                characterParadoxEffect.main.startSize        = 0.1f;
                                characterParadoxEffect.main.maxParticles     = 50;
                                characterParadoxEffect.emission.rateOverTime = 50;
                            }
                            else
                            {
                                characterParadoxEffect.main.startColor       = new ParticleSystem.MinMaxGradient(Color.red, Color.black);
                                characterParadoxEffect.main.startSize        = 0.2f;
                                characterParadoxEffect.main.maxParticles     = 300;
                                characterParadoxEffect.emission.rateOverTime = 300;
                            }

                            activeCharacterParadoxe++;
                        }
                    }
                    else if (paradox.type == Paradox.ParadoxType.Item)
                    {
                        ParadoxEffect itemParadoxEffect = GetItemParadox(activeItemParadoxes);
                        itemParadoxEffect.main.startColor    = new ParticleSystem.MinMaxGradient((warning ? Color.yellow : Color.red), Color.black);
                        itemParadoxEffect.transform.position = paradox.itemProfile.position;
                        activeItemParadoxes++;
                    }
                }
            }

            for (int i = activeItemParadoxes, count = itemParadoxEffectPool.Count; i < count; i++)
            {
                itemParadoxEffectPool[i].gameObject.SetActive(false);
            }

            for (int i = activeCharacterParadoxe, count = characterParadoxEffectPool.Count; i < count; i++)
            {
                characterParadoxEffectPool[i].gameObject.SetActive(false);
            }
        }
Exemplo n.º 2
0
        public void CompareObservations(Observation currentObservation, Observation expectedObservation)
        {
            List <Character> currentCharacters = new List <Character>(currentObservation.characters);

            //Expected Characters
            for (int i = 0, count = expectedObservation.characters.Count; i < count; i++)
            {
                Character character = expectedObservation.characters[i];

                if (currentCharacters.Remove(character) == false)
                {
                    Paradox paradox = new Paradox(currentObservation.time, visualsMeet, character);
                    currentParadoxes.Add(paradox);
                }
            }

            //Unexpected Characters
            for (int i = 0, count = currentCharacters.Count; i < count; i++)
            {
                Paradox paradox = new Paradox(currentObservation.time, visualsMeet, currentCharacters[i]);
                currentParadoxes.Add(paradox);
            }

            //Expected Items
            List <ItemProfile> currentItemProfiles = new List <ItemProfile>(currentObservation.itemProfiles);

            for (int i = 0, count = expectedObservation.itemProfiles.Count; i < count; i++)
            {
                ItemProfile expectedProfile = expectedObservation.itemProfiles[i];

                if (currentItemProfiles.Remove(expectedProfile) == false)
                {
                    //Expected item not found, locate paradoxes
                    for (int s = 0, currentCount = currentItemProfiles.Count; s < currentCount; s++)
                    {
                        ItemProfile currentProfile = currentItemProfiles[s];

                        if (currentProfile.CompareSurface(expectedProfile))
                        {
                            for (int t = 0; t < expectedProfile.itemsInsideProfiles.Length; t++)
                            {
                                ItemProfile expectedInsideProfile = expectedProfile.itemsInsideProfiles[t];

                                if (currentProfile.itemsInsideProfiles.Length <= t || expectedInsideProfile != currentProfile.itemsInsideProfiles[t])
                                {
                                    Paradox paradox = new Paradox(currentObservation.time, visualsMeet, expectedInsideProfile);
                                    currentParadoxes.Add(paradox);
                                }
                            }
                        }
                    }
                }
            }
        }
Exemplo n.º 3
0
        int SimulateTime(int timeStart, float timeTarget, bool ignoreParadoxes)
        {
            int  time         = timeStart;
            bool paradoxFound = false;

            while (time < timeTarget && (paradoxFound == false || ignoreParadoxes))
            {
                time++;

                //Perform actions
                for (int i = 0; i < characters.Count; i++)
                {
                    Character character = characters[i];

                    Action action = null;
                    for (int k = 0, count = character.history.Count; k < count; k++)
                    {
                        Action a = character.history[k];
                        //if (timeInstant > a.time)
                        if (time > a.time && time < a.time + a.duration + 1)
                        {
                            action = a;
                            break;
                        }
                    }

                    if (action != null)
                    {
                        character.previousLocation = character.currentLocation;
                        action.Perform(character);
                    }
                }

                //Current Observations
//                for (int i = 0, count = characters.Count; i < count; i++)
//                {
//                    Character character = characters[i];
//
//                    character.CreateCurrentObservation(time, characters);
//                }

                for (int i = 0, count = characters.Count; i < count; i++)
                {
                    Character character = characters[i];

                    if (character != currentPlayer)
                    {
                        character.CreateCurrentObservation(time, characters);

                        character.CheckObservations(time);

                        if (character.currentParadoxes.Count > 0)
                        {
                            paradoxFound = true;
                        }

                        //Check crossing characters
                        if (character.previousLocation != character.currentLocation && currentPlayer.currentLocation == character.previousLocation && currentPlayer.previousLocation == character.currentLocation)
                        {
                            Paradox paradox = new Paradox(time, character.visualsMeet, currentPlayer);
                            character.currentParadoxes.Add(paradox);
                            paradoxFound = true;
                        }
                    }
                }
            }

            return(time);
        }