예제 #1
0
    public void GetNetPos()
    {
        //nextPosition=transform.position+ new Vector3(diretion[Random.Range(0, diretion.Length)][0],0,diretion[ Random.Range(0, diretion.Length)][1]);
        float scale = 0;

        float[] slist = new float[9];
        pos = nextPos;
        SetPheromone();
        TargetCheck();
        for (int i = 0; i < diretion.Length; i++)
        {
            var p = pheromone.GetPreomone(pos[0] + diretion[i][0], pos[1] + diretion[i][1]);
            if (targetType == PheromoneType.none)
            {
                break;
            }
            if (p.scale[targetType] > 0)
            {
                scale       += p.scale[targetType];
                slist[i + 1] = scale;
            }
            else
            {
                slist[i + 1] = scale;
            }
        }
        if (scale > 0)
        {
            float r = Random.Range(0, scale);
            for (int i = 0; i < slist.Length - 1; i++)
            {
                if (r >= slist[i] && r < slist[i + 1])
                {
                    nextPos      = new int[] { pos[0] + diretion[i][0], pos[1] + diretion[i][1] };
                    nextPosition = PheromoneMap.GetVector3(nextPos[0], nextPos[1]);

                    break;
                }
            }
        }
        else
        {
            int r = Random.Range(0, 8);
            nextPos      = new int[] { pos[0] + diretion[r][0], pos[1] + diretion[r][1] };
            nextPosition = PheromoneMap.GetVector3(nextPos[0], nextPos[1]);

            Debug.Log(diretion[r][0] + "," + diretion[r][1]);
        }
    }
예제 #2
0
    private void SetPheromone()
    {
        var pos = PheromoneMap.GetPos(transform.position);
        var p   = pheromone.GetPreomone(pos);

        //Debug.Log(pos[0] + "," + pos[1]);
        p.scale[PheromoneType.Queen] += 400;
        if (p.scale[PheromoneType.Queen] > 600)
        {
            p.scale[PheromoneType.Queen] = 600;
        }
    }