Exemplo n.º 1
0
        public void Released()
        {
            switch (_method)
            {
            case Method.Raycast:
                if (_currentRaycast != null)
                {
                    _currentRaycast.SendMessage("Released", SendMessageOptions.DontRequireReceiver);
                    if (OnReleased != null)
                    {
                        OnReleased.Invoke(_currentRaycast.gameObject);
                    }
                }
                break;

            case Method.RaycastAll:
                if (_current.Count > 0)
                {
                    foreach (var item in _current)
                    {
                        item.SendMessage("Released", SendMessageOptions.DontRequireReceiver);
                        if (OnReleased != null)
                        {
                            OnReleased.Invoke(item.gameObject);
                        }
                    }
                }

                break;
            }
        }
Exemplo n.º 2
0
        /// <summary>Pick Up Logic. It can be called by the ANimator</summary>
        public void PickUpItem()
        {
            item = FocusedItem;

            if (item)
            {
                item.Picker = gameObject;  //Set on the Item who did the Picking
                item.Pick();               //Tell the Item that it was picked

                OnPicking.Invoke(item.ID); //Invoke the Method
                CanPickUp.Invoke(false);
                OnItem.Invoke(item.gameObject);

                if (Holder)
                {
                    item.transform.parent           = Holder;       //Parent it to the Holder
                    item.transform.localPosition    = PosOffset;    //Offset the Position
                    item.transform.localEulerAngles = RotOffset;    //Offset the Rotation
                }

                // FocusedItem.OnFocused.Invoke(false);
                FocusedItem = null;                             //Remove the Focused Item


                if (m_HidePickArea.Value)
                {
                    PickUpArea.gameObject.SetActive(false);        //Disable the Pick Up Area
                }
                // Debug.Log("PickUpItem");
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Select the Item if is not locked and the amount is greater than zero, also instantiate it if Instantiate Item is enabled.
        /// </summary>
        public virtual void SelectItem()
        {
            if (!ItemSelected)
            {
                return;                                                         //If there's no Item Skip
            }
            if (!ItemSelected.Locked && ItemSelected.Amount > 0)                //If the items is not locked and the we have one or More Item ....
            {
                if (InstantiateItems)
                {
                    InstantiateItem();
                    OnSelected.Invoke(Last_SpawnedItem);
                }
                else
                {
                    OnSelected.Invoke(ItemSelected.originalItem);
                }
                Controller.CurrentItem.OnSelected.Invoke();                     //Invoke Events on the Selected Item
            }

            if (UI)
            {
                UI.UpdateSelectedItemUI(ItemSelected.gameObject);           //Update the UI
            }
        }
Exemplo n.º 4
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if ((_mask.value & (1 << collision.gameObject.layer)) != 0)
     {
         _detectEvent.Invoke(collision.gameObject);
     }
 }
Exemplo n.º 5
0
        private void Start()
        {
            if (Collection != null)
            {
                switch (type)
                {
                case RuntimeSetTypeGameObject.First:
                    Raise.Invoke(Collection.Item_GetFirst());
                    break;

                case RuntimeSetTypeGameObject.Random:
                    Raise.Invoke(Collection.Item_GetRandom());
                    break;

                case RuntimeSetTypeGameObject.Index:
                    Raise.Invoke(Collection.Item_Get(Index));
                    break;

                case RuntimeSetTypeGameObject.ByName:
                    Raise.Invoke(Collection.Item_Get(m_name));
                    break;

                case RuntimeSetTypeGameObject.Closest:
                    Raise.Invoke(Collection.Item_GetClosest(gameObject));
                    break;

                default:
                    break;
                }
            }
        }
        private void Use()
        {
            if (isWait)
            {
                var list = action?.GetListComponents();
                _methodWaitForCount = list.Count;

                if (list.IsAlmostSpecificCount())
                {
                    FarUsableObj(_colliderObj);
                    _isEnable = false;

                    foreach (var element in list)
                    {
                        WaitManager.Wait(element, OnFinishWait);
                    }

                    action?.Invoke(_colliderObj);
                }
                else
                {
                    LogManager.LogWarning("There isn't one action with IWaitAction interface");
                }
            }
            else
            {
                action?.Invoke(_colliderObj);
            }
        }
Exemplo n.º 7
0
        // PUBLIC

        public void Set(PlayerInfo player)
        {
            Team          = player.Team;
            OwnerKartRoot = player.gameObject;
            OwnerNickname = player.Nickname;
            OwnerID       = player.OwnerID;

            OnOwnershipSet.Invoke(OwnerKartRoot);
        }
 void OnCollisionEnter(Collision collision)
 {
     if (lastCollision != collision.gameObject)
     {
         OnHitGameObject.Invoke(collision.gameObject);
         OnCollision.Invoke();
         lastCollision = collision.gameObject;
     }
 }
Exemplo n.º 9
0
 private void OnTriggerEnter(Collider other)
 {
     if (other.CompareTag(ObjectTag) && !ObjectsDetected.Contains(other.gameObject))
     {
         ObjectDetected = other.gameObject;
         ObjectsDetected.Add(other.gameObject);
         OnObjectChange.Invoke(ObjectDetected);
     }
 }
Exemplo n.º 10
0
        public virtual void MountTriggerEnter(Mount mount, MountTriggers mountTrigger)
        {
            Montura      = mount;                                       //Set to Mount on this Rider
            MonturaAI    = Montura.GetComponent <IAIControl>();
            MountTrigger = mountTrigger;                                //Send the side transform to mount
            OnFindMount.Invoke(mount.transform.root.gameObject);        //Invoke Found Animal
            Montura.OnCanBeMounted.Invoke(Montura.CanBeMountedByState); //Invoke Can Be mounted to true ???
            Montura.NearbyRider = true;

            UpdateCanMountDismount();
        }
 public void IterateList(int iterator)
 {
     if (iterator < GameObjectList.Count)
     {
         Debug.Log(GameObjectList[iterator].name + " " + iterator);
         IteratedGameObject.Invoke(GameObjectList[iterator]);
     }
     else
     {
         OnIterationComplete.Invoke();
     }
 }
Exemplo n.º 12
0
        private void Update()
        {
            if (_completed)
            {
                return;
            }

            SetValueByPercent(_during_time / _duration);


            if (null != _on_value_changed)
            {
                _on_value_changed.Invoke(this.gameObject);
            }

            if (_during_time >= _duration)
            {
                //if completed set to from value or to value
                SetValueByPercent(1f);

                switch (_loop_type)
                {
                case LoopType.Once:
                    _completed = true;
                    if (null != _on_completed)
                    {
                        _on_completed.Invoke(this.gameObject);
                    }

                    break;

                case LoopType.Loop:
                    Play();
                    break;

                case LoopType.PingPong:
                    _ping_pong_temp = (_ping_pong_temp <= float.Epsilon) ? 1f : 0f;
                    _completed      = true;
                    if (null != _on_completed)
                    {
                        _on_completed.Invoke(this.gameObject);
                    }

                    break;

                default:
                    break;
                }
            }

            _during_time += (_ignore_time_scale) ? Time.unscaledDeltaTime : Time.deltaTime;
        }
Exemplo n.º 13
0
    IEnumerator PlayOnce()
    {
        // if already playing, bail
        if (Application.isPlaying && playing)
        {
            yield break;
        }

        // setup audio source
        audioSource.clip = clip;
        if (masterVolume != null)
        {
            audioSource.volume = clipVolume * masterVolume.Value;
        }
        else
        {
            audioSource.volume = clipVolume;
        }
        audioSource.pitch = clipPitch;

        // start playback
        playing          = true;
        audioSource.loop = false;
        audioSource.Play();

        // start volume watcher
        if (masterVolume != null)
        {
            StartCoroutine(VolumeWatcher());
        }

        // wait for clip to be done (or stopped)
        var timer        = clip.length;
        var startTime    = Time.fixedTime;
        var currentDelta = Time.fixedTime - startTime;

        while (playing && (currentDelta < timer))
        {
            yield return(null);

            currentDelta = Time.fixedTime - startTime;
        }
        playing = false;
        audioSource.Stop();

        // raise onDone event
        onDone.Invoke(gameObject);
    }
Exemplo n.º 14
0
 private void OnTriggerExit(Collider other)
 {
     if (other.tag == PlayerTag)
     {
         PlayerExited.Invoke(other.gameObject);
     }
 }
Exemplo n.º 15
0
 private void OnTriggerEnter2D(Collider2D collision)
 {
     if (collision.CompareTag("WallEnd"))
     {
         wallEvent.Invoke(gameObject);
     }
 }
 private IEnumerator PeriodicallyCheckBounds()
 {
     for (;;)
     {
         if (_boundary != null)
         {
             if (_boundary.IsInBounds(this.transform.position) && _outOfBounds)
             {
                 OnEnterBounds.Invoke(this.gameObject);
                 _outOfBounds      = false;
                 _outOfBoundsTimer = 0F;
             }
             else if (!_boundary.IsInBounds(this.transform.position) && !_outOfBounds)
             {
                 _outOfBoundsTimer += _checkPeriod;
                 if (_outOfBoundsTimer >= _waitTime)
                 {
                     OnLeaveBounds.Invoke(this.gameObject);
                     _outOfBounds = true;
                 }
             }
         }
         yield return(new WaitForSecondsRealtime(_checkPeriod));
     }
 }
        //returns true if spawned successfully
        private bool SpawnObject(SpaceOccupier newObject)
        {
            int     containerIndex = 0;
            Vector3 spawnPosition  = spawnPoint.position;

            while (containerIndex < containers.Length)
            {
                EquipmentContainer container = containers[containerIndex];
                if (container.Capacity.y >= newObject.Volume.y)
                {
                    spawnPosition.y = container.transform.position.y + newObject.Volume.y * 0.5f;
                    newObject.transform.position = spawnPosition;
                    Equipment equipment = newObject.GetComponent <Equipment>();
                    equipment.Initialize(container);
                    onEquipmentSpawned?.Invoke(equipment.gameObject);
                    return(true);
//                    break;
                }
                containerIndex++;
                if (containerIndex >= containers.Length)
                {
                    Destroy(newObject.gameObject);
                    return(false);
                }
            }
            return(true);
        }
        private IEnumerator LoadReconstructionCoroutine(string environmentProfileName)
        {
            Validate();

            IEnvironmentProfile environmentProfile   = GetEnvironmentByName(environmentProfileName);
            GameObject          loadedReconstruction = new GameObject("LoadedReconstruction");

            List <MeshData> meshesData = new List <MeshData>();
            List <Thread>   threads    = new List <Thread>();

            _loadFinished = false;

            for (int i = 0; i < environmentProfile.Meshes.Count; i++)
            {
                string meshPath = environmentProfile.Meshes[i];
                Thread thread   = new Thread(
                    () =>
                {
                    lock (meshesData)
                    {
                        meshesData.Add(_modelFileManipulator.LoadMeshFromFile(meshPath));
                    }
                });
                thread.Start();
                threads.Add(thread);
                yield return(null);
            }

            Thread invokeOnFinished = new Thread(() => ScanThreads(threads, out _loadFinished));

            invokeOnFinished.Start();

            // wait for the end of the loading threads
            yield return(new WaitWhile(() => !_loadFinished));

            foreach (MeshData meshData in meshesData)
            {
                GameObject newMesh    = new GameObject(meshData.Name);
                MeshFilter meshFilter = newMesh.AddComponent <MeshFilter>();
                meshFilter.mesh.vertices  = meshData.Vertices.ToArray();
                meshFilter.mesh.triangles = meshData.Triangles.ToArray();
                newMesh.AddComponent <MeshRenderer>().material = _scanningMaterial;

                Rigidbody rigidbody = newMesh.AddComponent <Rigidbody>();
                rigidbody.isKinematic = true;
                rigidbody.useGravity  = false;
                newMesh.AddComponent <MeshCollider>();
                newMesh.transform.SetParent(loadedReconstruction.transform);
                meshFilter.mesh.RecalculateNormals();
            }

            // Remove object from the scene if there is no saved mesh for this environment profile
            if (loadedReconstruction.transform.childCount == 0)
            {
                Destroy(loadedReconstruction);
            }

            _loadedReconstruction = loadedReconstruction;
            _reconstructionLoaded.Invoke(loadedReconstruction);
        }
Exemplo n.º 19
0
        public virtual void ReleaseArrow(Vector3 direction)
        {
            if (!releaseArrow)
            {
                DestroyArrow();
                return;
            }

            if (ArrowInstance == null)
            {
                return;
            }

            ArrowInstance.transform.parent = null;

            IArrow arrow = ArrowInstance.GetComponent <IArrow>();

            arrow.HitMask            = HitLayer;                        //Transfer the same Hit Mask to the Arrow
            arrow.TriggerInteraction = TriggerInteraction;              //Link the Trigger Interatction

            arrow.Damage = Mathf.Lerp(MinDamage, MaxDamage, BowTension);
            arrow.ShootArrow(Mathf.Lerp(MinForce, MaxForce, BowTension), direction.normalized);

            OnReleaseArrow.Invoke(ArrowInstance);

            ArrowInstance = null;
        }
Exemplo n.º 20
0
 protected override void Invoke(GameObject parameter)
 {
     if (unityEvent != null)
     {
         unityEvent.Invoke(parameter);
     }
 }
Exemplo n.º 21
0
 void OnDisConnected(IPortItem[] nodes)
 {
     foreach (var item in nodes)
     {
         onDisConnect.Invoke(item.Render);
     }
 }
Exemplo n.º 22
0
 public void OnValidatePrefab(GameObject go, int i)
 {
     if (i == prefab)
     {
         onValid.Invoke(go);
     }
 }
Exemplo n.º 23
0
 public virtual void EquipItem(int Slot)
 {
     if (Slot < Inventory.Count)
     {
         OnEquipItem.Invoke(Inventory[Slot]);
     }
 }
Exemplo n.º 24
0
 void OnCollisionLeave(Collision c)
 {
     if (ShouldRespond(c.gameObject))
     {
         CollisionLeave.Invoke(c.collider.gameObject);
     }
 }
Exemplo n.º 25
0
        /// <summary>
        /// Select the Item if is not locked and the amount is greater than zero, also instantiate it if Instantiate Item is enabled.
        /// </summary>
        public virtual void SelectItem()
        {
            if (!ItemSelected)
            {
                return;                                                         //If there's no Item Skip
            }
            if (!ItemSelected.Locked && ItemSelected.Amount > 0)                //If the items is not locked and the we have one or More Item ....
            {
                if (InstantiateItems)
                {
                    InstantiateItem();
                }
                OnSelected.Invoke(Last_SpawnedItem);

                Debug.Log("Item Selected");

                // Change the player material
                player.GetComponent <MeshRenderer>().material = ItemSelected.gameObject.GetComponent <MeshRenderer>().material;

                // Change the particle system color
                player.GetComponent <Paint_Management>().SetParticleSystemColor();
            }

            if (UI)
            {
                UI.UpdateSelectedItemUI(ItemSelected.gameObject);           //Update the UI
            }
        }
Exemplo n.º 26
0
    protected void Collide(Collider2D x, GameObjectEvent ev)
    {
        var b = x.GetComponent <Box>();

        if (b)
        {
            if (ignores.Contains(b.owner))
            {
                return;
            }

            if (ev == onEnter)
            {//if youre checking  enter collide, and its already contained, dont bother
                if (Contains(b.owner))
                {
                    return;
                }
            }
            if (ev == onExit)
            {// if youre checking exit and it doesnt ontain it already, dont gbother
                if (!Contains(b.owner))
                {
                    return;
                }
            }
            if (Box.CheckValid(this, b))
            {
                ev.Invoke(b.owner);
            }
        }
    }
Exemplo n.º 27
0
        public virtual void Released()
        {
            if (_released)
            {
                return;
            }
            _pressed  = false;
            _released = true;

            if (_selectedCount != 0)
            {
                ColorSelected();
                ScaleSelected();
            }

            if (_clicking)
            {
                if (OnClick != null)
                {
                    OnClick.Invoke(gameObject);
                }
            }
            _clicking = false;
            if (OnReleased != null)
            {
                OnReleased.Invoke(gameObject);
            }
        }
Exemplo n.º 28
0
    private void GenerateField()
    {
        if (meteorsNum % 2 != 0)
        {
            meteorsNum++;
        }

        List <GameObject> staticObjects = new List <GameObject>();

        for (int i = -meteorsNum / 2; i < meteorsNum / 2; i++)
        {
            for (int j = -meteorsNum / 2; j < meteorsNum / 2; j++)
            {
                if (i == 0 && j == 0)
                {
                    continue;
                }

                GameObject go = MakeMeteor(i, j);
                go.name = go.name + namePart;
                namePart++;
                CS.Insert(go);
                staticObjects.Add(go);
            }
        }

        OnPlayerReady.Invoke(Instantiate(Player));
        //CS.InsertToStatic(staticObjects);
    }
Exemplo n.º 29
0
        /// <summary>
        /// Exit the current state.
        /// </summary>
        public void Exit()
        {
            if (currentState == null)
            {
                return;
            }
            Log("(-) " + name + " EXITED state: " + currentState.name);
            int currentIndex = currentState.transform.GetSiblingIndex();

            //no longer at first:
            if (currentIndex == 0)
            {
                AtFirst = false;
            }

            //no longer at last:
            if (currentIndex == transform.childCount - 1)
            {
                AtLast = false;
            }

            if (OnStateExited != null)
            {
                OnStateExited.Invoke(currentState);
            }
            currentState.SetActive(false);
            currentState = null;
        }
Exemplo n.º 30
0
 public void OnF9(InputAction.CallbackContext context)
 {
     if (context.started)
     {
         onF9.Invoke(gameObject);
     }
 }