Пример #1
0
    public void ReturnAllFlocksInSwarmToHive(SwarmTravelController swarmCtrl)
    {
        while (swarmCtrl.flockBehaviors.Count > 0)
        {
            ReturnFlockInSwarmToHive(swarmCtrl);
        }

        OnHomeWorkerCountChange.Invoke(originSwarm.flockBehaviors.Count);
    }
Пример #2
0
    public void AssignWorkersToResourcePoint(SwarmTravelController targetSwarm, int countWorkers)
    {
        SetDestinationSwarm(targetSwarm);

        for (int c = 0; c < countWorkers; c++)
        {
            SendFlockBetweenSwarms();
        }
    }
Пример #3
0
    public void ReturnFlockInSwarmToHive(SwarmTravelController swarmCtrl)
    {
        UnityFlock flock = swarmCtrl.UnregisterRandomFlock();

        if (flock == null)
        {
            return;
        }

        originSwarm.RegisterFlock(flock);
        //foreach(UnityFlock flock in swarm)
    }
Пример #4
0
    // Use this for initialization
    void Start()
    {
        treeCtrl        = gameObject.GetComponentInChildren <TreeLifecycleController>();
        swarmTravelCtrl = gameObject.GetComponentInChildren <SwarmTravelController>();

        // SET GLOBALS
        durationCollectionPeriod     = 1f;
        amountWorkerCollectsResource = 1f;
        capacityWorkerForResource    = 20f;
        durationSamplePeriod         = 5f;

        minVisitsPerFlowerForPollination = 2;
        maxVisitsPerFlowerForPollination = 5;
    }
    void OnTriggerEnter(Collider other)
    {
        Debug.Log("OnSwarmTargetDetectedEvent :" + swarmTargetMarker.ToString());

        OnSwarmTargetDetectedEvent.Invoke(swarmTargetMarker);

        targetSwarmCtrl = swarmTargetMarker.parent.gameObject.GetComponentInChildren <SwarmTravelController>();

        Debug.Log("OnNewSwarmTarget " + targetSwarmCtrl.ToString());
        Debug.Log(targetSwarmCtrl);

        OnNewSwarmTarget.Invoke(targetSwarmCtrl);
        ActivateTarget();
    }
Пример #6
0
    // there is a fixed number of bees
    // allocate all swarm arrays for the max number of bees


    // Use this for initialization
    void Start()
    {
        travelOrigin = null;

        randomFreq = 1.0f / randomFreq;//获取随机变化的频率
        //设置父节点为origin
        origin = transform.parent;

        transformCompont = transform;

        //临时组件数组
        Component[] tempFlocks = null;

        if (transform.parent)
        {
            tempFlocks = transform.parent.GetComponentsInChildren <UnityFlock>();
        }

        //   objects=new Transform[tempFlocks.Length];
        //   otherFlocks=new UnityFlock[tempFlocks.Length];

        //   //将群体的位置信息和群体加载到数组
        //for (int i = 0; i < tempFlocks.Length; i++)
        //{
        //    objects[i] = tempFlocks[i].transform;
        //    otherFlocks[i] = (UnityFlock)tempFlocks[i];
        //}

        int maxBees = 4;

        travelOrigin = transform.parent.GetComponent <SwarmTravelController>();

        for (int i = 0; i < tempFlocks.Length; i++)
        {
            travelOrigin.RegisterFlock((UnityFlock)tempFlocks[i]);
        }



        // parent to root level in game world
        transform.parent = GameObject.Find("GameWorld").transform;

        StartCoroutine(UpdateRandom());
    }
Пример #7
0
 public void SetDestinationSwarm(SwarmTravelController swarmCtrl)
 {
     print("SetDestinationSwarm: " + swarmCtrl.ToString());
     destinationSwarm = swarmCtrl;
 }