示例#1
0
    /// <summary>
    /// function called when the obj is created by the MooseManager in order to set all variables
    /// </summary>
    /// <param name="_cohW"></param>
    /// <param name="_sepW"></param>
    /// <param name="_aliW"></param>
    /// <param name="_sibW"></param>
    public void StartBehaviours(Bounds _movingBounds, float _padding, GameObject _predator)
    {
        cohesionInternal             = GetComponent <Cohesion>();
        cohesionInternal.weight      = coehVal.x;
        separationInternal           = GetComponent <Separation>();
        separationInternal.weight    = separVal.x;
        alignmentInternal            = GetComponent <Alignment>();
        alignmentInternal.weight     = aligVal.x;
        stayInBoundsInternal         = GetComponent <StayInBounds>();
        stayInBoundsInternal.weight  = stayInBVal.x;
        stayInBoundsInternal.bounds  = _movingBounds;
        stayInBoundsInternal.padding = _padding;
        constantSpeedInternal        = GetComponent <ConstantSpeed>();
        constantSpeedInternal.speed  = speed.x;
        fleeInternal        = GetComponent <Flee>();
        fleeInternal.evader = _predator.GetComponent <Vehicle>();



        GetComponent <Vehicle>().behaviours.Add(cohesionInternal);
        GetComponent <Vehicle>().behaviours.Add(separationInternal);
        GetComponent <Vehicle>().behaviours.Add(alignmentInternal);
        GetComponent <Vehicle>().behaviours.Add(stayInBoundsInternal);
        GetComponent <Vehicle>().behaviours.Add(constantSpeedInternal);
        GetComponent <Vehicle>().behaviours.Add(fleeInternal);

        fsm = GetComponent <FSM>();
        fsm.LoadState <FSMMooseWander>();
        fsm.LoadState <FSMMooseCauntion>();
        fsm.LoadState <FSMMooseRun>();
        fsm.ActivateState <FSMMooseWander>();
    }