void Start() { rb = GetComponent <Rigidbody>(); GM = FindObjectOfType <GameManager>(); playerConfig = new PlayerConfig(gameObject); tweenData = new TweenData(); playerConfig.speed = 20; ph_Pointer = transform.Find("ph_pointer").gameObject; body = transform.Find("body").gameObject; ph_pointerRadius = (transform.position - ph_Pointer.transform.position).magnitude; fireDelegate += fireFeedback; fireDelegate += fireProjectile; fireDelegate += () => { windSource.Play(); }; fireDelegate += () => { if (!GM.gameOver) { GM.numberTimesFired++; } }; }
/// <summary> /// This replaces all older delegates rather than adding a new one to the list. /// See docs for () /// </summary> /// <param name="del">An OnFireDelegate</param> public void SetOnFireDelegate(OnFireDelegate del) { this.onFireDelegates = del; }
/// <summary> /// Removes a OnDetectedDelegate /// See docs for () /// </summary> /// <param name="del">An OnFireDelegate</param> public void RemoveOnFireDelegate(OnFireDelegate del) { this.onFireDelegates -= del; }
/// <summary> /// Add a new delegate to be triggered when it is time to fire/notify a target(s). /// The delegate signature is: delegate(TargetList targets) /// See TargetTracker documentation for usage of the provided 'Target' in this list. /// </summary> /// <param name="del">An OnFireDelegate</param> public void AddOnFireDelegate(OnFireDelegate del) { this.onFireDelegates += del; }
/// <summary> /// Add a new delegate to be triggered when it is time to fire/notify a target(s). /// The delegate signature is: delegate(TargetList targets) /// See TargetTracker documentation for usage of the provided 'Target' in this list. /// **This will only allow a delegate to be added once.** /// </summary> /// <param name="del">An OnFireDelegate</param> public void AddOnFireDelegate(OnFireDelegate del) { this.onFireDelegates -= del; // Cheap way to ensure unique (add only once) this.onFireDelegates += del; }