Пример #1
0
 private float ActivityFactor()
 {
     if (_person.Work == null)
     {
         return(UMath.Random(1.375f, 1.55f));
     }
     return(UMath.Random(1.6f, 1.8f));
 }
Пример #2
0
    private static Vector3 ReturnRandomPos(Vector3 origin, float howFar)
    {
        float x = UMath.Random(-howFar, howFar);
        float z = UMath.Random(-howFar, howFar);

        origin = new Vector3(origin.x + x, origin.y, origin.z + z);
        return(origin);
    }
Пример #3
0
    /// <summary>
    /// Returns Random position from origin. If fell inside a building will find another spot
    /// until is in a clear zone
    ///
    /// </summary>
    /// <param name="howFar">How far will go</param>
    public void AssignRandomIniPosition(Vector3 origin, Building building, float howFar = 8)
    {
        float x = UMath.Random(-howFar, howFar);
        float z = UMath.Random(-howFar, howFar);

        origin = new Vector3(origin.x + x, origin.y, origin.z + z);

        building.transform.position = origin;

        if (!IsBuildingGood(building) || !_person.IsOnTerrain(origin))
        {
            counter++;
            CheckIfCanRecurseAgain(origin, building, howFar);
        }
    }
Пример #4
0
Файл: Animal.cs Проект: Cdrix/SM
    /// <summary>
    /// Returns Random position from origin. If fell inside a building will find another spot
    /// until is in a clear zone
    /// If origin is not specified will assume is CamControl.CAMRTS.hitFront.point the center of terrain
    /// </summary>
    /// <param name="howFar">How far will go</param>
    public static Vector3 AssignRandomIniPosition(Vector3 origin, Rect area, float howFar = 0.75f, float animalDim = 0.15f)
    {
        float x = UMath.Random(-howFar, howFar);
        float z = UMath.Random(-howFar, howFar);

        origin = new Vector3(origin.x + x, origin.y, origin.z + z);

        if (!area.Contains(new Vector2(origin.x, origin.z)))
        {
            count++;
            if (count > 1000)
            {
                throw new Exception("AssignRandomIniPosition() animal.cs");
            }
            origin = AssignRandomIniPosition(origin, area);
        }
        return(origin);
    }
Пример #5
0
Файл: Animal.cs Проект: Cdrix/SM
    /// <summary>
    /// Returns Random position from origin. If fell inside a building will find another spot
    /// until is in a clear zone
    /// If origin is not specified will assume is CamControl.CAMRTS.hitFront.point the center of terrain
    /// </summary>
    /// <param name="howFar">How far will go</param>
    Vector3 AssignAnimalRandomIniPosition(Vector3 origin, Rect area, float howFar, float animalDim)
    {
        float x           = UMath.Random(-howFar, howFar);
        float z           = UMath.Random(-howFar, howFar);
        var   originMoved = new Vector3(origin.x + x, origin.y, origin.z + z);
        var   _bounds     = UPoly.CreatePolyFromVector3(originMoved, animalDim, animalDim);

        if (!area.Contains(new Vector2(originMoved.x, originMoved.z)) ||
            Spawner.CollideWithExistingAnimal(originMoved, Id, animalDim)
            )
        {
            aniCount++;
            if (aniCount > 1000)
            {
                return(new Vector3());
            }
            originMoved = AssignAnimalRandomIniPosition(origin, area, howFar, animalDim);
        }
        return(originMoved);
    }
Пример #6
0
Файл: Farmer.cs Проект: Cdrix/SM
    Vector3 AssignRandomIniPosition(Vector3 origin, Rect area)
    {
        var howFar = HowFar();

        float x = UMath.Random(-howFar, howFar);
        float z = UMath.Random(-howFar, howFar);

        origin = new Vector3(origin.x + x, origin.y, origin.z + z);

        if (!area.Contains(new Vector2(origin.x, origin.z)))
        {
            count++;
            if (count > 1000)
            {
                Debug.Log("AssignRandomIniPosition() Farmer.cs over 1000");
                //throw new Exception("AssignRandomIniPosition() Farmer.cs");
                count = 0;
                return(new Vector3());
            }
            origin = AssignRandomIniPosition(origin, area);
        }
        return(origin);
    }