Пример #1
0
    // Start is called before the first frame update
    void Start()
    {
        squareMaxSpeed        = maxSpeed * maxSpeed;
        squareNeighbourRadius = neighbourRadius * neighbourRadius;
        squareAvoidanceRadius = squareNeighbourRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;

        for (int i = 0; i < startingAgentCount; i++)
        {
            Vector3 SpawnPos = Random.insideUnitSphere * startingAgentCount * AgentDensity;
            if (!threeDimMovement)
            {
                SpawnPos.y = 0;
            }

            FlockAgent newAgent = Instantiate(
                agentPrefab,
                SpawnPos,
                Quaternion.Euler(Vector3.up * Random.Range(0f, 360f)),
                transform
                );
            newAgent.name = "Agent " + i;
            newAgent.Init(this);

            agents.Add(newAgent);
        }
    }
Пример #2
0
    // Start is called before the first frame update
    public virtual void Init()
    {
        m_squareMaxspeed        = maxSpeed * maxSpeed;
        m_squareNeightborRadius = neighborRadius * neighborRadius;
        m_squareAvoidanceRadius = m_squareNeightborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;



        for (int i = 0; i < startingCount; i++)
        {
            FlockAgent newAgent = Instantiate(
                agentPrefab,
                Random.insideUnitCircle * startingCount * AGENT_DENSITY,
                Quaternion.Euler(Vector3.forward * Random.Range(0f, 360f)),
                transform
                );

            newAgent.name = "Agent " + i;
            newAgent.Init(this);
            agents.Add(newAgent);
        }
    }
Пример #3
0
    // Start is called before the first frame update
    void Start()
    {
        _sqrMaxSpeed        = maxSpeed * maxSpeed;
        _sqrNeighborRadius  = neighborRadius * neighborRadius;
        _sqrAvoidanceRadius = _sqrNeighborRadius * avoidanceRadiusMultiplier * avoidanceRadiusMultiplier;

        for (int i = 0; i < startingCount; i++)
        {
            FlockAgent newAgent = Instantiate(agentPrefab,
                                              Random.insideUnitCircle * startingCount * AGENT_DENSITY,
                                              Quaternion.Euler(Vector3.forward * Random.Range(0, 360)),
                                              transform);
            newAgent.Init(this);
            if (_icon == FlockIcon.CIRCLE)
            {
                newAgent.sr.sprite = Services.GameManager.AvailableIcons[1];
            }
            newAgent.sr.color = _transparent;

            newAgent.name = "Agent " + i;
            _agents.Add(newAgent);
        }
    }