Esempio n. 1
0
    /// <summary>
    /// Change the stats based of parents
    /// </summary>
    /// <param name="Parents"></param>
    public void Born(ViriusBrain[] 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;
            viriusT = Parents[_DataType].viriusT;
        }

        float futureMb      = 0;
        float futureProcess = 0;

        foreach (ViriusBrain 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);
        m_VirusUI.UpdateUi();
    }
Esempio n. 2
0
 /// <summary>
 /// Sets Random virius Stats
 /// </summary>
 public void SetRandomStats()
 {
     Speed            = Random.Range(0.1f, EnitiyManager.instance.DataCubeSettings.MaxSpeed);
     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_MaxMb * 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)),
     };
     viriusT = GetRandomType();
 }