Beispiel #1
0
 public void setPersonality(Setup.PersonSetup personality)
 {
     this.personality = personality;
     if (personality != null && personality.specialIcon != null)
     {
         SpecialIcon specialIcon = gameObject.GetComponent <SpecialIcon>();
         specialIcon.setIcon(personality.specialIcon);
     }
 }
Beispiel #2
0
    public void addPerson(Setup.PersonSetup personSetup)
    {
        setup.people.Add(personSetup);
        setup.people.Sort((p1, p2) => Mathf.RoundToInt((p1.time - p2.time) * 100));

        if (placePeople == null)
        {
            restart();
        }
    }
Beispiel #3
0
    private void setSkinColor()
    {
        Color skinColor;

        Setup.PersonSetup personality = GetComponentInParent <HumanLogic> ().personality;
        if (personality != null && personality.skinColor != null)
        {
            // Set specific skin color
            skinColor = Misc.parseColor(personality.skinColor);
        }
        else
        {
            // Check if we should lookup get specific base color
            Color baseColor = Color.magenta;

            bool haveBaseColor = false;
            if (personality != null && personality.country != null)
            {
                baseColor = getBaseColorForCountry(personality.country, out haveBaseColor);
            }
            else if (Game.instance.loadedLevel != null && Game.instance.loadedLevel.country != null)
            {
                baseColor = getBaseColorForCountry(Game.instance.loadedLevel.country, out haveBaseColor);
            }

            if (!haveBaseColor)
            {
                baseColor = getBaseSkinColor();
            }

            float r = ((float)HumanLogic.HumanRNG.NextDouble()) * 0.06f - 0.03f;
            float g = ((float)HumanLogic.HumanRNG.NextDouble()) * 0.06f - 0.03f;
            float b = ((float)HumanLogic.HumanRNG.NextDouble()) * 0.06f - 0.03f;

            float skinRed   = Mathf.Clamp(baseColor.r + r, 0f, 1f);
            float skinGreen = Mathf.Clamp(baseColor.g + g, 0f, 1f);
            float skinBlue  = Mathf.Clamp(baseColor.b + b, 0f, 1f);

            skinColor = new Color(skinRed, skinGreen, skinBlue, 0f);
        }

        Renderer[] renderers = GetComponentsInChildren <Renderer> ();
        foreach (Renderer renderer in renderers)
        {
            if (renderer.gameObject.name == "skinmesh")
            {
                foreach (Material material in renderer.materials)
                {
                    material.SetColor("_Color", skinColor);
                }
            }
        }
    }
Beispiel #4
0
 private void setWaypointsInfo(Setup.PersonSetup personality)
 {
     if (personality != null && personality.wayPoints != null)
     {
         this.wayPoints     = NodeIndex.getPosById(personality.wayPoints);
         this.wayPointsLoop = personality.wayPointsLoop;
     }
     else
     {
         this.wayPoints = new List <Pos>();
     }
 }
Beispiel #5
0
    private void setShirtColor()
    {
        Color shirtColor;

        Setup.PersonSetup personality = GetComponentInParent <HumanLogic> ().personality;
        if (personality != null && personality.shirtColor != null)
        {
            shirtColor = Misc.parseColor(personality.shirtColor);
        }
        else
        {
            float r = (float)HumanLogic.HumanRNG.NextDouble();
            float g = (float)HumanLogic.HumanRNG.NextDouble();
            float b = (float)HumanLogic.HumanRNG.NextDouble();
            shirtColor = new Color(r, g, b, 0f);
        }
        Renderer renderer = GetComponent <Renderer> ();

        renderer.material.SetColor("_Color", shirtColor);
    }
Beispiel #6
0
    public IEnumerator placeOutPeople()
    {
        yield return(null);

        while (setup.people.Count > 0 && setup.people [0].time == -1)
        {
            Setup.PersonSetup person = setup.people [0];
            Game.instance.giveBirth(person);
            setup.people.RemoveAt(0);
        }
        while (setup.people.Count > 0)
        {
            Setup.PersonSetup person = setup.people [0];
            float             inTime = person.time - GameTimer.elapsedTime();
            yield return(new WaitForSeconds(inTime));

            Game.instance.giveBirth(person);
            setup.people.RemoveAt(0);
        }
        placePeople = null;
    }
Beispiel #7
0
    public void initInformation()
    {
        type = TYPE_HUMAN;
        // Check for stored information in HumanLogic
        HumanLogic human   = GetComponent <HumanLogic>();
        Vehicle    vehicle = GetComponent <Vehicle> ();

        Setup.PersonSetup data = null;
        if (human != null)
        {
            data        = human.personality;
            destination = findInformationPOI(human.targetPos);
        }
        else if (vehicle != null && vehicle.characteristics != null)
        {
            long personId;
            if (passengerIndex == -1)
            {
                personId = vehicle.characteristics.driverId;
            }
            else
            {
                personId = vehicle.characteristics.passengerIds [passengerIndex];
            }
            data = Game.instance.loadedLevel.setup.getReferencePerson(personId);
        }

        if (data != null)
        {
            if (data.name == null)
            {
                if (data.country != null || Game.instance.loadedLevel.country != null)
                {
                    name = NameGenerator.generate(data.country != null ? data.country : Game.instance.loadedLevel.country);
                }
                else
                {
                    name = NameGenerator.generate();
                }
            }
            else
            {
                name = data.name;
            }
            if (data.dob != null)
            {
                dateOfBirth = Misc.parseDate(data.dob);
            }
            else
            {
                DateTime now     = DateTime.Now;
                int      daysOld = Misc.randomRange(6574, 29220);                  // 18-80 years old in days
                dateOfBirth = new DateTime(now.Ticks - Misc.daysToTicks(daysOld)); // Days to ticks
            }
            if (data.money != 0f)
            {
                money = data.money;
            }
            else
            {
                money = Misc.randomRange(0f, 500f);
            }
            return;
        }
        else
        {
            // TODO - Also handle random names from countries specified in <person>?
            if (Game.instance.loadedLevel != null && Game.instance.loadedLevel.country != null)
            {
                name = NameGenerator.generate(Game.instance.loadedLevel.country);
            }
            else
            {
                name = NameGenerator.generate();
            }
            // TODO - Make sure random ranges are valid dates
            DateTime now     = DateTime.Now;
            int      daysOld = Misc.randomRange(6574, 29220);                  // 18-80 years old in days
            dateOfBirth = new DateTime(now.Ticks - Misc.daysToTicks(daysOld)); // Days to ticks
            money       = Misc.randomRange(0f, 500f);
        }

//		Debug.Log("New human: " + name);
    }
Beispiel #8
0
    public void setStartAndEndInfo(Tuple3 <Pos, WayReference, Vector3> startInfo, Tuple3 <Pos, WayReference, Vector3> endInfo, Setup.PersonSetup personality, Pos targetPos)
    {
        setWaypointsInfo(personality);

        path     = Game.calculateCurrentPaths(startInfo.First, endInfo.First, null, wayPoints, false, true);
        walkPath = Misc.posToVector3(path);

        this.targetPos = targetPos;
        InformationHuman informationHuman = GetComponent <InformationHuman> ();

        PubSub.publish("TargetPOI(" + targetPos.Id + "):Add", informationHuman);

        if (path.Count == 1)
        {
            Destroy(gameObject);
            return;
        }
        // Rotate human...
        Pos pos1 = path [0];
        Pos pos2 = path [1];

        Pos lastPos         = path [path.Count - 1];
        Pos secondToLastPos = path [path.Count - 2];

        WayReference startWay = startInfo.Second;

        if (personality != null && personality.startVector != null || startWay.hasNodes(pos1, pos2))
        {
            walkPath.RemoveAt(0);
            path.RemoveAt(0);
        }
        walkPath.Insert(0, startInfo.Third);
        path.Insert(0, Game.createTmpPos(startInfo.Third));

        endWay = endInfo.Second;
        if (endWay.hasNodes(secondToLastPos, lastPos))
        {
            walkPath.RemoveAt(walkPath.Count - 1);
            path.RemoveAt(path.Count - 1);
        }
        walkPath.Add(endInfo.Third);
        path.Add(Game.createTmpPos(endInfo.Third));

        // Adjust position to side of bigger ways
        adjustPositionsOnBiggerWays(path, walkPath, startWay, endWay);

        DebugFn.DebugPath(walkPath);

        Vector3 vec1 = walkPath [0];
        Vector3 vec2 = walkPath [1];

        positionHuman(vec1);
        rotateHuman(vec2, vec1);

        walkPath.RemoveAt(0);
    }