Example #1
0
    /// <summary>
    /// Change the stats based of parents
    /// </summary>
    /// <param name="Parents"></param>
    public void Born(DataCubeBrain[] Parents)
    {
        int _Speedindex   = Mathf.RoundToInt(Random.Range(0, Parents.Length));
        int _Defenseindex = Mathf.RoundToInt(Random.Range(0, Parents.Length));
        int _DataType     = Mathf.RoundToInt(Random.Range(0, Parents.Length));

        if (Parents != null)
        {
            Speed    = Parents[_Speedindex].Speed;
            Defense  = Parents[_Defenseindex].Defense;
            DataCube = Parents[_DataType].DataCube;
        }

        float futureMb      = 0;
        float futureProcess = 0;

        foreach (DataCubeBrain i in Parents)
        {
            futureMb      += i.m_CurrentMB;
            futureProcess += i.m_CurrentProcess;
        }
        m_CurrentMB      = futureMb / Parents.Length;
        m_CurrentProcess = futureProcess / Parents.Length;
        m_MatingData     = new DataCubeMatingData
        {
            NeededCurrentMB = Random.Range(1, EnitiyManager.instance.DataCubeSettings.m_MaxMb),
            NeededProcess   = Random.Range(1, EnitiyManager.instance.DataCubeSettings.m_MaxProcess),
        };
        m_Steering.SetSpeed(Speed);
    }
Example #2
0
    /// <summary>
    /// Sets Random DataCube Stats
    /// </summary>
    public void SetRandomStats()
    {
        Speed            = Random.Range(0.1f, EnitiyManager.instance.DataCubeSettings.MaxSpeed);
        Defense          = Random.Range(0.1f, EnitiyManager.instance.DataCubeSettings.MaxDefense);
        m_CurrentMB      = Mathf.RoundToInt(Random.Range(EnitiyManager.instance.DataCubeSettings.m_MaxMb * 0.5f, EnitiyManager.instance.DataCubeSettings.m_MaxMb));
        m_CurrentProcess = Mathf.RoundToInt(Random.Range(EnitiyManager.instance.DataCubeSettings.m_MaxProcess * 0.5f, EnitiyManager.instance.DataCubeSettings.m_MaxProcess));
        m_MatingData     = new DataCubeMatingData
        {
            NeededCurrentMB = Mathf.RoundToInt(Random.Range(EnitiyManager.instance.DataCubeSettings.m_MaxMb * 0.5f, EnitiyManager.instance.DataCubeSettings.m_MaxMb)),
            NeededProcess   = Mathf.RoundToInt(Random.Range(EnitiyManager.instance.DataCubeSettings.m_MaxMb * 0.5f, EnitiyManager.instance.DataCubeSettings.m_MaxProcess)),
        };

        DataCube = GetRandomType();
    }