/// <summary> /// Retourne la collection filtrée. /// </summary> /// <param name="collection">La collection à filtrer.</param> /// <returns>La collection filtrée.</returns> /// <remarks>Utilisé dans Kinetix.WebControls.</remarks> public static ICollection Filter(ICollection collection) { if (collection == null) { throw new ArgumentNullException("collection"); } Type collectionType = collection.GetType(); Type[] innerTypes = collectionType.GetGenericArguments(); if (innerTypes.Length != 1) { throw new NotSupportedException(); } Type genericType = typeof(List <>).MakeGenericType(innerTypes[0]); if (!(genericType is IActivable)) { return(collection); } IList newCollection = (IList)Activator.CreateInstance(genericType); foreach (object obj in collection) { IActivable iActivable = obj as IActivable; if (iActivable != null && iActivable.IsActif != null && iActivable.IsActif == true) { newCollection.Add(obj); } } return(newCollection); }
public void Init() { if (!doorsContainer || !buttonsContainer) { return; } //tokenMng = _tokenMng; for (int i = 0; i < doorsContainer.childCount; i++) { IActivable _current = doorsContainer.GetChild(i).GetComponent <IActivable>(); if (_current != null) { _current.Init(); doors.Add(_current); } } for (int i = 0; i < buttonsContainer.childCount; i++) { IButton _current = buttonsContainer.GetChild(i).GetComponent <IButton>(); if (_current != null) { _current.Init(); buttons.Add(_current); } } //tokenMng.FinishToken += HandleFinishToken; LevelManager.OnPlayerDeath += HandlePlayerDeath; }
void Start() { attachedActivables = new List <IActivable>(); foreach (GameObject element in attachedObjects) { IActivable activableComponent = element.GetComponent <IActivable>(); attachedActivables.Add(activableComponent); } }
public static void Activate(this IActivable source) { if (null == source) { throw new ArgumentNullException("source"); } source.IsActive = true; }
protected virtual void Start() { _activable = _activableObject?.GetComponent <IActivable>() ?? _activableObject?.GetComponentInChildren <IActivable>() ?? _activableObject?.GetComponentInParent <IActivable>(); SetActiveColor(_active); if (_triggerOnStart) { SetActive(_active); } }
public override void Activate() { foreach (GameObject _current in targets) { IActivable _temp = _current.GetComponent <IActivable>(); if (_temp != null) { _temp.Activate(); } } }
// Use this for initialization public void Start () { //Inicializacion del puzzle //Guarda las referencias a los scripts de los objetos //Y marca los objetos como parte del puzzle para que adapten su comportamiento UsableObject aux; foreach(GameObject o in objectList) { aux = o.GetComponent<UsableObject>(); aux.puzzleManager = this; aux.inPuzzle = true; usables.Add(aux); } targetActivable = result.GetComponent<IActivable>(); }
private void OnTriggerStay(Collider other) { if (Input.GetKeyUp(KeyCode.Mouse0)) { Debug.Log("GTFO mundo TOMAR" + other.gameObject.name); IActivable activador = other.gameObject.GetComponent <IActivable>(); if (activador is null) { return; } activador.Activar(); Brazo.LongitudMaxima += Multiplicador; } }
// Update is called once per frame void Update() { if (Input.GetKeyUp(KeyCode.Mouse0)) { alcance.OverlapCollider(new ContactFilter2D().NoFilter(), results); IActivable activable = results.FirstOrDefault(c => c.gameObject.GetComponent <IActivable>() != null)?.GetComponent <IActivable>(); Debug.Log("Click + " + activable?.ToString()); if (activable is null) { return; } activable.Activar(); } }
public virtual void Initialize() { //Si il y a des objets dans le tableau if (objectsToActive != null) { IActivable[] temp = new IActivable[objectsToActive.Length]; for (int i = 0; i < temp.Length; i++) { IActivable tempz = objectsToActive[i].GetComponent <IActivable>(); if (tempz != null) { temp[i] = tempz; } } activables = temp; } else if (objectsToActive == null || objectsToActive.Length == 0) { Debug.Log(this + " Tableau d'objet a activer vide!"); } }
/// <summary> /// the player can turn on the feature of any item he is carrying such as flashlight and lightsource of location /// </summary> /// <param name="item"></param> public override void EnableFeature(IActivable item) { if (Items.Any(i => i.ToString() == item.ToString())) { (Items.First(i => i.ToString() == item.ToString()) as IActivable).Enable(); if (CurrentLocation is NoDayLightLocation && item is FlashLight) (CurrentLocation as NoDayLightLocation).FlashLightOn = true; } else { Console.WriteLine("You don't have this feature"); } }
public AreaTrigger(int x, int y, int w, int h, IActivable target = null) : base(x, y) { this.width = w; this.height = h; this.target = target; }
public override void update() { base.update(); if (target == null) { if (targetId > 0) { bEntity e = world.find(targetId); if (e is IActivable) target = e as IActivable; else return; } } if (placeMeeting(x, y, "player")) target.activate(null); else target.deactivate(null); }
public virtual void EnableFeature(IActivable activable) { }
private void Awake() { this.activable = this.ToActivate.GetComponent <IActivable>(); }
private void Start() { interfaceActivable = objectToActivate.GetComponent <IActivable>(); }
/// <summary> /// the player can turn off the feature of the item he is carrying /// </summary> /// <param name="item"></param> public override void DisableFeature(IActivable item) { if (Items.Any(i => i.ToString() == item.ToString())) { (Items.First(i => i.ToString() == item.ToString()) as IActivable).Disable(); if (CurrentLocation is NoDayLightLocation && item is FlashLight) (CurrentLocation as NoDayLightLocation).FlashLightOn = false; } else { Console.WriteLine("You don't have this feature.");//warns the user if thwere is no ityem that he is carrying } }
protected virtual void Start() { _activable = _activableObject?.GetComponent <IActivable>() ?? _activableObject?.GetComponentInChildren <IActivable>() ?? _activableObject?.GetComponentInParent <IActivable>(); SetActiveColor(AccessGrant.None); }