/* ==== IActivable functions ==== */ public bool OnActivate(AbstractActivator activatorObject, bool state) { if (!(canBeTurnedOff == false && state == false)) { if (state) { activatorsOnCounter++; } else { activatorsOnCounter--; } if (state) { if (!needAllActivatorsOn || activatorsOnCounter == activators.Count) { /* We try to activate and inform the calling object whether the activation has been done */ bool hasBeenActivated = this.Activate(activatorObject, state); if (hasBeenActivated) { activateState = state; lastActivatorObject = activatorObject; startActivationTime = Time.time; if (!canBeTurnedOff) { foreach (AbstractActivator activator in activators) { activator.canBeTurnedOff = false; } } } return(hasBeenActivated); } } else { /* We try to activate and inform the calling object whether the activation has been done */ bool hasBeenActivated = this.Activate(activatorObject, state); if (hasBeenActivated) { activateState = state; lastActivatorObject = activatorObject; foreach (AbstractActivator activator in activators) { activator.TurnOff(); } } return(hasBeenActivated); } return(true); } return(false); }
protected override bool Activate(AbstractActivator activatorObject, bool state) { // AbstractActivator activatorObject if (this.IsActivationAuthorized(activatorObject)) { attachedGoal.Complete(); return(true); } return(false); }
/* ==== IActivable function ==== */ protected override bool Activate(AbstractActivator activatorObject, bool state) { // AbstractActivator activatorObject if (this.IsActivationAuthorized(activatorObject)) { if (bedAudioClip != null && BedGoal.isStarted()) { PlayAtPosition(this.transform.position); } return(true); } return(false); }
/* ==== IActivable function ==== */ protected override bool Activate(AbstractActivator activatorObject, bool state) { // AbstractActivator activatorObject if (this.IsActivationAuthorized(activatorObject)) { if (doorAudioClip != null) { PlayAtPosition(this.transform.position); OpenDoor(); } return(true); } return(false); }
/* ==== IActivable function ==== */ protected override bool Activate(AbstractActivator activatorObject, bool state) { // AbstractActivator activatorObject if (this.IsActivationAuthorized(activatorObject)) { if (TVGoal.isStarted()) { transform.GetChild(0).GetComponent <MeshRenderer>().enabled = true; PlayAtPosition(this.transform.position); } return(true); } return(false); }
protected abstract bool Activate(AbstractActivator activatorObject, bool state);
public bool IsActivationAuthorized(AbstractActivator activatorObject) { return(this.activators.Contains(activatorObject)); }