Exemplo n.º 1
0
    ///<summary>
    /// Add an interactive text that will be updated each frame.
    ///</summary>
    public void AddText(System.Func <string> GetText)
    {
        var go     = debuggerBehaviour.InstantiateInCanvas(DebugType.Text);
        var uiText = go.GetComponent <Text>();

        uiText.text = GetText?.Invoke();
        debuggerBehaviour.OnUpdate += () => uiText.text = GetText?.Invoke();
    }
Exemplo n.º 2
0
 private void SelectEnum()
 {
     var subString = Constants.LastEndActionClickedName.Substring(10);
     int id = int.Parse(subString);
     Constants.DecreaseInputLayer();
     _resultAction?.Invoke(id);
     Destroy(gameObject);
 }
Exemplo n.º 3
0
 public override void Raise()
 {
     if (condition.Invoke(obj))
     {
         callback.Invoke();
     }
 }
Exemplo n.º 4
0
    protected internal override void CopyScriptableObjects(
        System.Func <ScriptableObject, ScriptableObject> replaceSerializableObject)
    {
        // Get the fields of the specified class.
        FieldInfo[] myField = this.GetType().GetFields();
        foreach (var x in myField)
        {
            // if(x.FieldType is FloatRemap)
            if (x.GetValue(this) is FloatRemap)
            {
                FloatRemap fr = (FloatRemap)x.GetValue(this);  //its a struct this makes a copy
                //                Debug.Log(x + " " + x.FieldType + " " + x.GetType() + " " + x.ReflectedType+" fr val:"+fr.m_Value);

                if (fr.m_Replacement != null)
                {
                    NodeKnob  knob    = fr.m_Replacement;
                    NodeInput replace = replaceSerializableObject.Invoke(knob) as NodeInput;
                    if (replace != null)
                    {
                        fr.m_Replacement = replace;
                    }
                    else
                    {
                        fr.m_Replacement = null;
                    }
                }
                x.SetValue(this, fr); //its a god damn struct it needs to be saved back out
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        pointsInTime = new List <PointInTime>();
        rb           = GetComponent <Rigidbody>();

        doSomething  = (index) => { };
        getSomething = (anybool, anystring) =>
        {
            return(anybool ? 1 : 0);
        };

        DictionaryOfStrings.Add("Roman", 25);
//		DictionaryOfStrings.Add("Roman", 25);
        if (DictionaryOfStrings.ContainsKey("Roman"))
        {
            Debug.Log("Yes, " + DictionaryOfStrings["Roman"]);
        }

        DictionaryOfStrings.Remove("Roman");

        var getfromDelegate = getSomething.Invoke(true, "");

        CallMyself(0);
        var GetFT = GetFromTuples();

        // anyST == Changred
    }
Exemplo n.º 6
0
    void OnGUI()
    {
        if (!string.IsNullOrEmpty(m_desc))
        {
            EditorGUILayout.Space();
            EditorGUILayout.LabelField(m_desc, GUI.skin.customStyles[20]);
            EditorGUILayout.Space();
        }

        data = EditorGUILayout.TextField("", data);

        if (GUILayout.Button("OK"))
        {
            if (onValidate != null)
            {
                if (onValidate.Invoke(data))
                {
                    Close();
                }
            }
            else if (onInput != null)
            {
                onInput.Invoke(data);
                Close();
            }
            else
            {
                Close();
            }
        }
    }
Exemplo n.º 7
0
 public virtual void ExitOverBlendTitle()
 {
     _state = -1;
     Constants.InputLocked = false;
     _resultAction?.Invoke(true);
     Destroy(gameObject);
 }
 bool IsShow()
 {
     if (condition == null)
     {
         return(true);
     }
     return(condition.Invoke());
 }
Exemplo n.º 9
0
 private object OnPositiveAction(bool result)
 {
     if (result)
     {
         SetButtons();
         _sceneUpdateAction?.Invoke();
     }
     return(result);
 }
Exemplo n.º 10
0
 // Update is called once per frame
 void Update()
 {
     if (_state == 0)
     {
         transform.position    = Vector3.Lerp(transform.position, _activePosition, 0.25f);
         _spriteRenderer.color = Color.Lerp(_spriteRenderer.color, Constants.ColorPlain, 0.2f);
         if (Helper.FloatEqualsPrecision(transform.position.x, _activePosition.x, 0.05f))
         {
             transform.position    = _activePosition;
             _spriteRenderer.color = Constants.ColorPlain;
             _state = 1;
             if (_overBlendType == OverBlendType.StartActionLoadingEnd)
             {
                 _resultAction?.Invoke(true);
             }
         }
     }
     else if (_state == 1)
     {
         if (_constantLoadingSpeed != null)
         {
             AddLoadingPercent(_constantLoadingSpeed ?? 0);
         }
     }
     else if (_state == 2)
     {
         transform.position    = Vector3.Lerp(transform.position, _endPosition, 0.25f);
         _spriteRenderer.color = Color.Lerp(_spriteRenderer.color, Constants.ColorPlainTransparent, 0.1f);
         if (Helper.FloatEqualsPrecision(transform.position.x, _endPosition.x, 0.01f))
         {
             transform.position    = _endPosition;
             _spriteRenderer.color = Constants.ColorPlainTransparent;
             _state = 3;
         }
     }
     else if (_state == 3)
     {
         if (_overBlendType == OverBlendType.StartLoadingEndAction)
         {
             _resultAction?.Invoke(true);
         }
         ExitOverBlend();
     }
 }
Exemplo n.º 11
0
    void UpdateTexture(System.Func <float, float, float, float> generator)
    {
        var scale = frequency / size;
        var time  = Time.time * speed;

        for (var y = 0; y < size; y++)
        {
            for (var x = 0; x < size; x++)
            {
                float n = generator.Invoke(x * scale, y * scale, time);

                // n = Mathf.Max(n, 0.0f);

                // Re-map to 0 - 1
                n += .5f;

                n *= amplitude;

                if (clamp)
                {
                    n = Mathf.Clamp(n, 0.0f, 1.0f);
                }

                n = Mathf.Pow(n, power);

                if (n < .001f)
                {
                    // Debug.Log(n);
                }

                float d1 = 0.0f;
                float d2 = 0.0f;
                float d3 = 0.0f;

                // Pulse
                if (x < _WavePos1)
                {
                    d1 = 1.0f - Mathf.Clamp((float)(_WavePos1 - x) / (float)FadeDistance, 0.0f, 1.0f);
                }
                if (x < _WavePos2)
                {
                    d2 = 1.0f - Mathf.Clamp((float)(_WavePos2 - x) / (float)FadeDistance, 0.0f, 1.0f);
                }
                if (x < _WavePos3)
                {
                    d2 = 1.0f - Mathf.Clamp((float)(_WavePos3 - x) / (float)FadeDistance, 0.0f, 1.0f);
                }

                Color finalC = Color.white * n;// * (d1+d2+d3);

                texture.SetPixel(x, y, finalC);
            }
        }

        texture.Apply();
    }
Exemplo n.º 12
0
 private T Decorate <T>(System.Func <T> p)
 {
     lock (_lock)
     {
         Random.state = s;
         T t = p.Invoke();
         s = Random.state;
         return(t);
     }
 }
Exemplo n.º 13
0
    private void SelectDevice()
    {
        var subString = Constants.LastEndActionClickedName.Substring(12);
        int id        = int.Parse(subString);
        int i         = 0;
        DeviceDescriptor resultDevice = new DeviceDescriptor();

        foreach (var device in _devices)
        {
            if (i == id)
            {
                resultDevice = device;
                break;
            }
            ++i;
        }
        Constants.DecreaseInputLayer();
        _resultAction?.Invoke(resultDevice);
        Destroy(gameObject);
    }
Exemplo n.º 14
0
 public static bool Complies <T>(this T[] arr, System.Func <T, bool> func)
 {
     foreach (T element in arr)
     {
         if (!func.Invoke(element))
         {
             return(false);
         }
     }
     return(true);
 }
Exemplo n.º 15
0
    private void Update()
    {
        if (NeverLoseTarget && target != null)
        {
            OnUpdate();
            return;
        }

        if (onScreenLingerTimer > 0f)
        {
            onScreenLingerTimer -= Time.deltaTime;
        }

        refreshTargetTimer -= Time.deltaTime;

        if (refreshTargetTimer <= 0)
        {
            refreshTargetTimer = RefreshTargetTime;

            if (target == null)
            {
                target = GetNewTarget.Invoke();

                if (target != null)
                {
                    OnGainTarget.Invoke();
                }
            }
            else
            {
                target = GetNewTarget.Invoke();

                if (target == null)
                {
                    OnLoseTarget.Invoke();
                }
            }
        }

        OnUpdate();
    }
Exemplo n.º 16
0
 void UpdateTexture(System.Func <int, int, float> generator)
 {
     for (var y = 0; y < size; y++)
     {
         for (var x = 0; x < size; x++)
         {
             var n = (generator.Invoke(x, y) + 1) / 2;
             texture.SetPixel(x, y, new Color(n, n, n));
         }
     }
     texture.Apply();
 }
Exemplo n.º 17
0
 bool[,] Pass(System.Func <int, int, bool> rule)
 {
     bool[,] output = new bool[tiles.GetLength(0), tiles.GetLength(1)];
     for (int i = 0; i < tiles.GetLength(0); i++)
     {
         for (int j = 0; j < tiles.GetLength(1); j++)
         {
             output[i, j] = rule.Invoke(i, j);
         }
     }
     return(output);
 }
Exemplo n.º 18
0
    private void PositiveDelegate()
    {
        Constants.DecreaseInputLayer();
        var tmpList = new List <float>();

        for (int i = 0; i < 5; ++i)
        {
            tmpList.Add(_currentFrequencies[i][0].Frequency);
        }
        _resultAction.Invoke(tmpList, _currentPeaksNumber);
        Destroy(gameObject);
    }
Exemplo n.º 19
0
    //	if you return false from this lambda, the search will abort early
    public static void ForEachChild(this GameObject go, System.Func <GameObject, bool> Lambda)
    {
        var t = go.transform;

        for (var c = 0; c < t.childCount; c++)
        {
            var Child = t.GetChild(c);
            if (!Lambda.Invoke(Child.gameObject))
            {
                break;
            }
        }
    }
Exemplo n.º 20
0
    public void OnDamage(MeteorUnit attacker)
    {
        int realDamage = CalcDamage(attacker);

        //非铁箱子, 木箱子,酒坛, 桌子 椅子的受击处理
        if (MethodOnAttack != null)
        {
            MethodOnAttack.Invoke(GameBattleEx.Instance.Script, new object[] { InstanceId, attacker.InstanceId, realDamage });
        }
        else if (OnAttackCallBack != null)
        {
            OnAttackCallBack.Invoke(InstanceId, Index, realDamage);
        }
    }
Exemplo n.º 21
0
    IEnumerator AnimateCoroutine(float duration, System.Func <float, bool> update, EASING easing, System.Action onComplete = null)
    {
        AnimationCurve curve = this.linear;

        switch (easing)
        {
        case EASING.ELASTIC_IN:
            curve = this.elasticIn;
            break;

        case EASING.ELASTIC_OUT:
            curve = this.elasticOut;
            break;

        case EASING.EASE_IN:
            curve = this.easeIn;
            break;

        case EASING.EASE_OUT:
            curve = this.easeOut;
            break;

        case EASING.EASE_INOUT:
            curve = this.easeInOut;
            break;
        }

        update(0f);

        for (float time = 0f; time < duration; time += Time.deltaTime)
        {
            float t = time / duration;


            float t1 = curve.Evaluate(t);

            if (update.Invoke(t1))
            {
            }
            else
            {
                yield break;
            }
            yield return(null);
        }

        update(1f);

        onComplete?.Invoke();
    }
Exemplo n.º 22
0
    public void OnDamage(MeteorUnit attacker, AttackDes attck = null)
    {
        int realDamage = CalcDamage(attacker, attck);

        //非铁箱子, 木箱子,酒坛, 桌子 椅子的受击处理
        if (MethodOnAttack != null)
        {
            MethodOnAttack.Invoke(CombatData.Ins.GScript, new object[] { InstanceId, attacker.InstanceId, realDamage });
        }
        else if (OnAttackCallBack != null)
        {
            OnAttackCallBack.Invoke(InstanceId, Index, realDamage);
        }
    }
Exemplo n.º 23
0
    private void VisualizeData(System.Func <double, int> heightCallback, ref double[] data, ref Texture2D tex, int windowSamples = -1)
    {
        if (!_enableDebugVisualization)
        {
            return;
        }

        Color[] vizTexCols = tex.GetPixels();
        int     height     = 0;

        if (tex.width != data.GetUpperBound(0) + 1)
        {
            tex.Resize(data.GetUpperBound(0) + 1, tex.height);
        }

        for (int i = 0; i < vizTexCols.Length; ++i)
        {
            vizTexCols [i] = Color.black;
        }
        //tex.SetPixels (vizTexCols);
        //tex.Apply ();

        for (int i = 0; i < data.Length; ++i)
        {
            if (windowSamples != -1)
            {
                int m = i % windowSamples;
                if (m == 0)
                {
                    for (int j = 0; j < tex.height; ++j)
                    {
                        vizTexCols [(j * tex.width) + i] = Color.green;
                    }
                }
            }
            height = heightCallback.Invoke(data [i]);             // (data [i]);  (int)((data [i]/ tex.height)  * 10);
            if (height > tex.height - 1)
            {
                height = tex.height - 1;
            }
            //vizTexCols [i * height] = Color.red;
            for (int j = 0; j < height; ++j)
            {
                vizTexCols [(j * tex.width) + i] = Color.red;
            }
        }
        tex.SetPixels(vizTexCols);
        tex.Apply();
    }
    /// <summary>
    /// Iterate each component of given type and invoke a function callback for each list component. If callback function returns false stop iteraton.
    /// </summary>
    /// <typeparam name="T">Casted component type</typeparam>
    /// <param name="list">Extension</param>
    /// <param name="callback">Callback fucntion</param>
    /// <returns>List of components</returns>
    public static List <Component> Each <T>(this List <Component> list, System.Func <T, bool> callback) where T : Component
    {
        T comp = null;

        List <Component> .Enumerator listIter = list.GetEnumerator();
        while (listIter.MoveNext())
        {
            comp = listIter.Current as T;
            if (comp && !callback.Invoke(comp))
            {
                break;
            }
        }
        return(list);
    }
Exemplo n.º 25
0
 public override void Finish()
 {
     if (getBranchTagHandler != null)
     {
         string wannaTag = getBranchTagHandler.Invoke();
         for (int i = 0; i < nextNodes.Count; i++)
         {
             var nextNode = nextNodes[i];
             if (string.Equals(wannaTag, nextNode.tag))
             {
                 onFinishHandler += (n) => { nextNode.Start(); };;
             }
         }
     }
     base.Finish();
 }
Exemplo n.º 26
0
    string DoTest(System.Func <float> generator)
    {
        var sum = 0.0f;
        var min = 0.0f;
        var max = 0.0f;

        for (var i = 0; i < _iteration; i++)
        {
            var n = generator.Invoke();
            sum += n / _iteration;
            min  = Mathf.Min(min, n);
            max  = Mathf.Max(max, n);
        }

        return("avg=" + (sum / _iteration) + ", min=" + min + ", max=" + max);
    }
Exemplo n.º 27
0
    public static Color[] ColorArrayFromGrayscaleMap(float[,] map, System.Func <float, Color> mapper)
    {
        int width  = map.GetLength(0);
        int height = map.GetLength(1);

        Color[] colorMap = new Color[width * height];
        for (int y = 0; y < height; y++)
        {
            for (int x = 0; x < width; x++)
            {
                colorMap[y * width + x] = mapper.Invoke(map[x, y]);
            }
        }

        return(colorMap);
    }
Exemplo n.º 28
0
    protected override void SetupControls(string name, System.Func <object> getterFunc, System.Action <object> setterAction, IEnumerable <object> attributes = null)
    {
        // Set name
        nameText.text = name;

        // Set initial value
        SetColor((Color32)getterFunc.Invoke());
        colorButton.onClick.AddListener(() => PixelsApp.Instance.ShowColorPicker("Select " + name, (Color32)getterFunc.Invoke(), (res, newColor) =>
        {
            if (res)
            {
                SetColor(newColor);
                setterAction?.Invoke((Color32)newColor);
            }
        }));
    }
Exemplo n.º 29
0
    void UpdateTexture(System.Func <float, float, float, float> generator)
    {
        var scale = 1.0f / size;
        var time  = Time.time;

        for (var y = 0; y < size; y++)
        {
            for (var x = 0; x < size; x++)
            {
                var n = generator.Invoke(x * scale, y * scale, time);
                texture.SetPixel(x, y, Color.white * (n / 1.4f + 0.5f));
            }
        }

        texture.Apply();
    }
Exemplo n.º 30
0
    public void                     Encode(bool Async)
    {
        if (EncodeConcurrent >= MaxEncodeConcurrent)
        {
            return;
        }

        if (EncodeQueue.Count == 0)
        {
            return;
        }

        if (OnlySendLatest && EncodeQueue.Count > 1)
        {
            EncodeQueue.RemoveRange(0, EncodeQueue.Count - 1);
        }

        var Data = EncodeQueue[0];

        EncodeQueue.RemoveAt(0);

        Interlocked.Increment(ref EncodeConcurrent);

        System.Action DoEncode = () =>
        {
            var Output = EncodeFunction.Invoke(Data);
            Interlocked.Decrement(ref EncodeConcurrent);
            SendQueue.Add(Output);
        };

        if (Async)
        {
        #if WINDOWS_UWP
            Windows.System.Threading.ThreadPool.RunAsync((workitem) =>
        #else
            System.Threading.ThreadPool.QueueUserWorkItem((workitem) =>
        #endif
            {
                DoEncode.Invoke();
            });
        }
        else
        {
            DoEncode.Invoke();
        }
    }