private void SetType(TypeModel.TypeModelItem typeItem) { TypeItem = typeItem; var meshRenderer = _stateMachine.GetComponent <MeshRenderer>(); meshRenderer.material.color = TypeItem.Color; }
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); }
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); } } }
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); }
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); }
public void Initialize(Vector3 habitatSize, Vector3 rotationDelta, TypeModel.TypeModelItem typeItem, float authorityRadius) { _authorityRadius = authorityRadius; State = new LeaderState(this, habitatSize, rotationDelta, typeItem, authorityRadius); }