Vector GetInputs()
    {
        Vector input = new Vector(0);
        int    half  = visions / 2;

        for (int i = 0; i < visions; i++)
        {
            float   val          = ((float)i - half + (visions % 2 == 0 ? 0.5f : 0f)) * (visionAngle * (1f / (float)visions));
            Vector2 dir          = MathOperations.AngleToVector(val + transform.rotation.eulerAngles.z + 90);
            Vector  visionVector = GetVision(dir);
            input.JoinVector(visionVector);
            //Debug.DrawLine(transform.position, transform.position + (Vector3)dir * visionDst, Color.blue);
        }
        input.JoinVector(GetSound());
        float[] arr = { vitality / maxVitality };
        input.JoinVector(new Vector(arr));
        input.JoinVector(op);

        return(input);
    }
예제 #2
0
 void Init(TreeGenes genes)
 {
     this.genes = genes;
     cooldown   = new Cooldown(4f);
     sr         = GetComponent <SpriteRenderer>();
     sr.color   = genes.color;
     branches   = new LineRenderer[genes.maxBranch];
     for (int i = 0; i < branches.Length; i++)
     {
         GameObject go = new GameObject($"Branch {i}");
         branches[i]           = go.AddComponent <LineRenderer>();
         go.transform.position = transform.position;
         go.transform.parent   = transform;
         branches[i].material  = branchMaterial;
         Vector3[] positions = { transform.position, (Vector2)transform.position + MathOperations.AngleToVector(Random.Range(0, 360), genes.branchLenght) };
         branches[i].positionCount = 2;
         branches[i].SetPositions(positions);
         branches[i].startWidth     = 0.1f;
         branches[i].endWidth       = 0.1f;
         branches[i].startColor     = Color.Lerp(genes.color, genes.fruitColor, 0.5f);         //genes.color;
         branches[i].endColor       = Color.Lerp(genes.color, genes.fruitColor, 0.5f);
         branches[i].numCapVertices = 3;
     }
     GetSpawnPoints();
     maxGrow = genes.maxBranch;
 }