Ejemplo n.º 1
0
 private void OnTriggerStay(Collider other)
 {
     if (other.gameObject.layer == 8)
     {
         objectDetected.Invoke(other);
     }
 }
Ejemplo n.º 2
0
        public void Select(UIListItem item)
        {
            if ((!_allowReselectSame && item.isSelected) || !_listItems.Contains(item))
            {
                return;
            }

            _listItems.ForEach(li => li.SetSelected(li == item));

            selectedValue = item.item;

            _onSelected?.Invoke(selectedValue);
        }
Ejemplo n.º 3
0
        public void FixedUpdate()
        {
#if UNITY_EDITOR
            if (!Application.isPlaying)
            {
                return;
            }
#endif

            if (Animator != null && ActivatedBoolHash != 0)
            {
                Animator.SetBool(ActivatedBoolHash, Activated);
            }

            if (Activators.Count <= 0)
            {
                return;
            }

            OnActivateStay.Invoke(Activator);

            foreach (var activator in new List <HedgehogController>(Activators))
            {
                OnActivatorStay.Invoke(activator);
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Deactivates the object with the ability to specify the controller that deactivated it, if any.
        /// </summary>
        /// <param name="controller"></param>
        public void Deactivate(HedgehogController controller = null)
        {
            if (controller != null)
            {
                Activators.Remove(controller);
                OnActivatorExit.Invoke(controller);
            }

            var any = Activators.Any();

            if (!AllowMultiple && any)
            {
                return;
            }

            if (!any)
            {
                Activated = false;
            }

            if (DeactivateSound != null)
            {
                SoundManager.Instance.PlayClipAtPoint(DeactivateSound, transform.position);
            }

            OnDeactivate.Invoke(controller);
            BubbleEvent(controller, true);
        }
Ejemplo n.º 5
0
        public static void TriggerEvent(string eventName, object data = null, GameObject trigger = null) //adds a new event in the dictionary
        {
            ObjectEvent thisEvent = null;

            if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
            {
                thisEvent.Invoke(data, trigger);
            }
        }
Ejemplo n.º 6
0
    void Fire()
    {
        //Instantiate (projectilePrefab, transform.position, transform.rotation);
        GameObject obj = projectilePrefab.GetInstance();

        obj.transform.position = transform.position;
        obj.transform.rotation = transform.rotation;
        OnFire.Invoke(obj);
    }
Ejemplo n.º 7
0
    public static void TriggerEvent(string eventName, object obj)
    {
        ObjectEvent thisEvent = null;

        if (instance.objectEventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(obj);
        }
    }
Ejemplo n.º 8
0
    public static void Send(string eventName, object[] param)
    {
        ObjectEvent thisEvent = null;

        if (instance.eventDictionary.TryGetValue(eventName, out thisEvent))
        {
            thisEvent.Invoke(param);
        }
    }
Ejemplo n.º 9
0
 void Captured(team t)
 {
     startTime = false;
     timer     = 0.0f;
     if (t == team.red)
     {
         controlled    = team.red;
         myLight.color = new Color(1.0f, 0.0f, 0.0f, 1.0f);
         GetComponent <MeshRenderer>().material.color = new Color(1.0f, 0.0f, 0.0f, 0.588f);
         ObjectiveSecured.Invoke(team.red, this);
     }
     else if (t == team.blue)
     {
         controlled    = team.blue;
         myLight.color = new Color(0.0f, 0.682f, 1.0f, 1.0f);
         GetComponent <MeshRenderer>().material.color = new Color(0.0f, 0.685f, 1.0f, 0.588f);
         ObjectiveSecured.Invoke(team.blue, this);
     }
 }
        private void SetUnityObject(UnityObject obj)
        {
            if (!isSceneObject)
            {
                throw new NotSupportedException($"Non-scene objects are not supported.");
            }

            if (obj == null)
            {
                ModifyPropertyValue(new ComponentDataWrapper(0), true);
                onValueChanged.Invoke(null);
            }
            else
            {
                if (obj is ILevelEditorObject levelObject)
                {
                    if (BoundProperty.Type == typeof(GameObject))
                    {
                        ModifyPropertyValue(new ComponentDataWrapper(levelObject.MyGameObject), true);
                        onValueChanged.Invoke(levelObject.MyGameObject);
                    }
                    else
                    {
                        Component value = levelObject.MyGameObject.GetComponent(BoundProperty.Type);
                        ModifyPropertyValue(new ComponentDataWrapper(value), true);
                        onValueChanged.Invoke(value);
                    }
                }
                else if (obj is GameObject go)
                {
                    ModifyPropertyValue(new ComponentDataWrapper(go), true);
                    onValueChanged.Invoke(obj);
                }
                else
                {
                    ModifyPropertyValue(new ComponentDataWrapper((Component)obj), true);
                    onValueChanged.Invoke(obj);
                }
            }

            EndEdit();
            UpdateLabel(obj);
        }
Ejemplo n.º 11
0
    void OnTriggerEnter2D(Collider2D other)
    {
        GameObject gmOb = other.gameObject;
        int        id   = gmOb.GetInstanceID();

        if (gmOb.layer == 8 && !hit_objects.Contains(id))
        {
            hit_objects.Add(id);
            if (move == 1)
            {
                Move1.Invoke(gmOb);
            }
            else if (move == 2)
            {
                Move2.Invoke(gmOb);
            }
            else if (move == 3)
            {
                Move3.Invoke(gmOb);
            }
        }
    }
Ejemplo n.º 12
0
        /// <summary>
        /// Activates the object with the ability to specify the controller that activated it, if any.
        /// </summary>
        /// <param name="controller"></param>
        public void Activate(HedgehogController controller = null)
        {
            if (!enabled || !gameObject.activeInHierarchy)
            {
                return;
            }
            if (Activators.Count > 0 && !AllowMultiple)
            {
                return;
            }

            if (controller != null && !Activators.Contains(controller))
            {
                Activators.Add(controller);
                OnActivatorEnter.Invoke(controller);
            }

            var any = Activators.Any();

            if (!AllowMultiple && any)
            {
                return;
            }

            Activated = true;

            if (ActivateSound != null)
            {
                SoundManager.Instance.PlayClipAtPoint(ActivateSound, transform.position);
            }

            OnActivate.Invoke(controller);
            BubbleEvent(controller);

            if (Animator != null && ActivatedTriggerHash != 0)
            {
                Animator.SetTrigger(ActivatedTriggerHash);
            }
        }
Ejemplo n.º 13
0
    // Update is called once per frame
    void Update()
    {
        if (held && isCooking)
        {
            cookTime -= Time.deltaTime;
            print("Time left: " + cookTime);
            if (cookTime <= 0)
            {
                //Make the new one!
                GameObject next = ingredient.FinishCooking(performedAction);
                //Move it to the next one!
                Destroy(held);
                ObjectPlacement.instance.Replace(transform.position, next);

                onFinishCooking.Invoke(next);
                if (cookingParticles)
                {
                    cookingParticles.Stop();
                }

                StartCooking(next);
            }
        }
    }
Ejemplo n.º 14
0
 public void SetOwner(GameObject newOwner)
 {
     owner = newOwner;
     OnChangeOwner.Invoke(owner);
 }
Ejemplo n.º 15
0
 public virtual void SetObjectPicked(object obj)
 {
     onObjectPickedChanged.Invoke(obj);
 }
Ejemplo n.º 16
0
 public void OnSignalRaised(object parameter)
 {
     Event.Invoke(parameter);
 }
Ejemplo n.º 17
0
 public void PassObject(GameObject obj)
 {
     OnPickup.Invoke(obj);
 }
Ejemplo n.º 18
0
 /// <summary>
 /// Calls the UnityEvent reponse when listener receives an event with a Unity Object value.
 /// </summary>
 public void OnEventRaised(Object value)
 {
     objectResponse.Invoke(value);
 }
 public void OnEventRaised(object data)
 {
     Response.Invoke(data);
 }
 public void Raise(object obj)
 {
     action?.Invoke(obj);
 }
 private void OnTriggerEnter(Collider other)
 {
     triggerEvent.Invoke(other.gameObject);
 }