示例#1
0
        private void SetType(TypeModel.TypeModelItem typeItem)
        {
            TypeItem = typeItem;

            var meshRenderer = _stateMachine.GetComponent <MeshRenderer>();

            meshRenderer.material.color = TypeItem.Color;
        }
示例#2
0
 public SlaveState(BoidStateMachine stateMachine, float authorityRadius, TypeModel.TypeModelItem typeItem)
 {
     _stateMachine    = stateMachine;
     _authorityRadius = authorityRadius;
     _transform       = stateMachine.transform;
     _rigidbody       = stateMachine.GetComponent <Rigidbody>();
     _thisCollider    = stateMachine.GetComponent <Collider>();
     SetType(typeItem);
 }
示例#3
0
        public bool TryChangeType(TypeModel.TypeModelItem typeItem, float autority)
        {
            if (autority > Authority)
            {
                Authority = autority;
                SetType(typeItem);

                return(true);
            }

            return(false);
        }
        public virtual void DistributeAuthority(Transform origin, float radius, TypeModel.TypeModelItem typeItem)
        {
            var boids = Physics.OverlapSphere(origin.position, radius);

            foreach (var boid in boids)
            {
                var behaviorComponent = boid.gameObject.GetComponent <BoidStateMachine>().State;
                if (behaviorComponent is IChangeType)
                {
                    (behaviorComponent as IChangeType).TryChangeType(typeItem, Authority);
                }
            }
        }
示例#5
0
        public bool TryChangeType(TypeModel.TypeModelItem typeItem, float autority)
        {
            if (autority > Authority)
            {
                Authority = autority;
                SetType(typeItem);

                _stateMachine.State = new SlaveState(_stateMachine, _authorityRadius, TypeItem);

                return(true);
            }

            return(false);
        }
示例#6
0
 public LeaderState(BoidStateMachine stateMachine, Vector3 habitatSize, Vector3 rotationDelta, TypeModel.TypeModelItem typeItem, float authorityRadius)
 {
     _stateMachine    = stateMachine;
     _transform       = stateMachine.transform;
     _rigidbody       = stateMachine.GetComponent <Rigidbody>();
     _habitatSize     = habitatSize;
     _rotationDelta   = rotationDelta;
     Authority        = CalculateAuthority();
     _authorityRadius = authorityRadius;
     SetType(typeItem);
 }
示例#7
0
 public void Initialize(Vector3 habitatSize, Vector3 rotationDelta, TypeModel.TypeModelItem typeItem, float authorityRadius)
 {
     _authorityRadius = authorityRadius;
     State            = new LeaderState(this, habitatSize, rotationDelta, typeItem, authorityRadius);
 }