public void OnTriggerEnter(Collider collider)
        {
            PersonIdentifier identifier = collider.GetComponentInChildren <PersonIdentifier>();

            if (identifier != null)
            {
                person.Trigger(TriggerType.PersonCollision);
                int rand = PRNG.GetNumber(0, 100);
                if (rand < 15 && identifier.person.GetType() == typeof(Walker) && person.GetType() == typeof(Walker))
                {
                    Talker t1 = new Talker(person);
                    Talker t2 = new Talker(identifier.person);
                    t1.TalksTo = t2;
                    t2.TalksTo = t1;
                    PersonManager.INSTANCE.UpdatePerson(person, t1);
                    PersonManager.INSTANCE.UpdatePerson(identifier.person, t2);
                    SetEditorValues();
                    identifier.SetEditorValues();
                    t1.Trigger(TriggerType.PersonStartTalking);
                }
            }
            else
            {
                person.Trigger(TriggerType.Collision);
            }
        }
Exemple #2
0
        protected Person()
        {
            if (!PRNG.IsInitialized)
            {
                PRNG.ChangeSeed(0);
            }

            // Generate some random values
            gender  = (Gender)PRNG.GetNumber(0, 1);
            hearing = PRNG.GetFloatNumber(0, 1);
            scared  = PRNG.GetFloatNumber(0, 1);
            buying  = PRNG.GetFloatNumber(0, 1);
            angry   = PRNG.GetFloatNumber(0, 1);
            sad     = PRNG.GetFloatNumber(0, 1);
            speed   = PRNG.GetFloatNumber(5, 10);
            voice   = gender == Gender.Male ? PRNG.GetFloatNumber(0.90f, 1.00f) : PRNG.GetFloatNumber(1.05f, 1.15f);

            walking  = false;
            paranoid = false;
            robbed   = false;
            running  = false;

            walkingInterval = PRNG.GetFloatNumber(0.5f, 0.9f);
            stepPitch       = PRNG.GetFloatNumber(1f, 1.2f, 3);

            hasPosition = false;
            timePassed  = 0f;

            // Generate a random name
            GenerateRandomName();
        }
Exemple #3
0
        public override void Draw(Vector2 origin, Vector2 relativeDistance)
        {
            gameObject = ObjectPool.Instantiate("marketstand");
            gameObject.transform.position    = new Vector3(origin.x + X + relativeDistance.x, 0, origin.y + Y + relativeDistance.y);
            gameObject.transform.parent      = LevelGenerator.INSTANCE.ParentObject;
            gameObject.transform.eulerAngles = new Vector3(0, PRNG.GetNumber(0, 1) * 90, 0);

            IsDrawn = true;
        }
Exemple #4
0
        public static Person GenerateNew()
        {
            // Get all possible person types
            Assembly current = Assembly.GetExecutingAssembly();

            Type[] people = current.GetTypes().Where(x => x.Namespace == "Assets.Scripts.AI.People" && x.BaseType == typeof(Person)).ToArray();

            // Generate one of the people
            Person p = Activator.CreateInstance(people[PRNG.GetNumber(0, people.Length - 1)]) as Person;

            return(p);
        }
        private void GenerateMarketStands()
        {
            int amount = PRNG.GetNumber(10, 20);

            for (int i = 0; i < amount; i++)
            {
                int x = PRNG.GetNumber(3, squareWidth - 3);
                int y = PRNG.GetNumber(3, squareHeight - 3);

                grid.AddGridObject(new GridMarktetStand(x, y));
            }
        }
        private void CollideWithOtherPerson()
        {
            // Play the sound for the collision with the other
            string[]      collisionTekst = new string[] { "sorry", "pardon", "hey", "oef", "pasop", "" }; // The "" causes the walker to say nothing, being impolite
            AudioFragment tekst          = AudioManager.GetFragment(collisionTekst[PRNG.GetNumber(0, collisionTekst.Length - 1)]);

            sourceManager.PlaySound(tekst, voice);


            // Give the walker a new position to walk to
            position    = lastPosition;
            destination = null;
        }
        private void GenerateSquare()
        {
            squareWidth  = PRNG.GetNumber(10, 20);
            squareHeight = PRNG.GetNumber(10, 20);

            for (int i = 0; i < squareWidth; i++)
            {
                for (int j = 0; j < squareHeight; j++)
                {
                    grid.AddGridObject(new GridStone(i, j));
                }
            }
        }
Exemple #8
0
        private void GenerateRandomName()
        {
            // Load the names from prefabs
            string[] firstnames;
            string[] lastnames = PrefabSelector.INSTANCE.Surnames.text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            if (gender == Gender.Female)
            {
                firstnames = PrefabSelector.INSTANCE.FemaleNames.text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            }
            else
            {
                firstnames = PrefabSelector.INSTANCE.MaleNames.text.Split(new char[] { '\n' }, StringSplitOptions.RemoveEmptyEntries);
            }

            // Generate a random name
            name = firstnames[PRNG.GetNumber(0, firstnames.Length - 1)] + " " + lastnames[PRNG.GetNumber(0, lastnames.Length - 1)];
        }
        private void GenerateRoads()
        {
            roadWidth    = PRNG.GetNumber(2, 4);
            parkingSpots = PRNG.GetNumber(0, 1);
            const int margin = 10;

            for (int i = -roadWidth - margin; i < squareWidth + roadWidth + parkingSpots + margin; i++)
            {
                for (int j = -roadWidth; j < 0; j++)
                {
                    if (i == -roadWidth - margin || i == squareWidth + roadWidth + parkingSpots + margin - 1)
                    {
                        grid.AddGridObject(new GridSpawnPoint(i, j));
                        grid.AddGridObject(new GridSpawnPoint(i, j + squareWidth + roadWidth));
                    }
                    else
                    {
                        grid.AddGridObject(new GridRoad(i, j));
                        grid.AddGridObject(new GridRoad(i, j + squareWidth + roadWidth));
                    }
                }
            }

            for (int i = -roadWidth - margin; i < squareHeight + roadWidth + parkingSpots + margin; i++)
            {
                for (int j = -roadWidth; j < 0; j++)
                {
                    if (i == -roadWidth - margin || i == squareHeight + roadWidth + parkingSpots + margin - 1)
                    {
                        grid.AddGridObject(new GridSpawnPoint(j, i));
                        grid.AddGridObject(new GridSpawnPoint(j + squareHeight + roadWidth, i));
                    }
                    else
                    {
                        grid.AddGridObject(new GridRoad(j, i));
                        grid.AddGridObject(new GridRoad(j + squareHeight + roadWidth, i));
                    }
                }
            }
        }
Exemple #10
0
        public override void Trigger(TriggerType trigger)
        {
            if (gameObject == null)
            {
                return;
            }

            if (trigger == TriggerType.PersonTalk || trigger == TriggerType.PersonStartTalking)
            {
                // Play a random text for a conversation
                string[]      randomTextForConversation = new string[] { "zin1", "zin2", "zin3", "zin4", "zin5", "zin6", "zin7", "zin8", "zin9", "zin10", "goed", "redelijk", "slecht", "hoeishet", "metjou", "straks" };
                AudioFragment tekst = AudioManager.GetFragment(randomTextForConversation[PRNG.GetNumber(0, randomTextForConversation.Length - 1)]);
                current = sourceManager.PlaySound(tekst, voice);
                signalOtherToStartTalking = true;
            }
            else if (trigger == TriggerType.PersonSaysBye)
            {
                // Play a random text to end the conversation
                string[]      randomTextForConversation = new string[] { "totziens", "doei", "ciya" };
                AudioFragment tekst = AudioManager.GetFragment(randomTextForConversation[PRNG.GetNumber(0, randomTextForConversation.Length - 1)]);
                current = sourceManager.PlaySound(tekst, voice);
            }
        }