public void SetCardBack(int id)
 {
     cardBackID = id;
     PlayerPrefs.SetInt("cardBackID", cardBackID);
     if (cardSpriteChangedCallback != null)
     {
         cardSpriteChangedCallback.Invoke();
     }
 }
예제 #2
0
        public void Start(Flow flow, DateTime timestamp)
        {
            var existing = GetFlow(flow.FlowId);

            if (existing != null)
            {
                RemoveFlow(existing);
            }

            AddFlow(flow);
            flow.Register(new FlowStep(flow.FlowId, flow.Configuration.StepNames[0], timestamp));

            FlowStarted?.Invoke(new FlowStarted(flow.FlowId, flow.Configuration.StepNames));
            FlowStepReached?.Invoke(new FlowStepReached(flow.Configuration.Name, flow.FlowId, flow.Configuration.StepNames[0], timestamp));
        }
        /// <summary>
        ///
        /// </summary>
        public static void RunGenericDelegate()
        {
            GenericDelegate <int, Computer> genericDelegate = (Computer computer) => computer.GetRandom();

            Console.WriteLine($"Случайное число из обобщенного делегата - {genericDelegate.Invoke(new Computer())}");

            GenericDelegate <string, int> genericDelegate1 = (x) => (x * x).ToString();
            int number = new Random().Next(0, 50);

            Console.WriteLine($"Квадрат числа {number} - {genericDelegate1.Invoke(number)}");
        }
예제 #4
0
        private void UpdateStatus(Flow flow, DateTime now)
        {
            var elapsedTime = now - flow.LastReachedStep.Timestamp;

            if (flow.Completed && !flow.Finished && elapsedTime > flow.Configuration.FinishTimeout)
            {
                flow.Finished = true;
                FlowFinished?.Invoke(new FlowFinished(flow.Configuration.Name, flow.FlowId));
            }
            else if (!flow.Failed && elapsedTime > flow.Configuration.StepTimeout)
            {
                flow.Failed = true;
                FlowFailed?.Invoke(new FlowFailed(flow.Configuration.Name, flow.FlowId));
            }
            else if (!flow.Finished && flow.Failed && elapsedTime > (flow.Configuration.StepTimeout + flow.Configuration.FinishTimeout))
            {
                flow.Finished = true;
                FlowFinished?.Invoke(new FlowFinished(flow.Configuration.Name, flow.FlowId));
            }
        }
예제 #5
0
    public static void TriggerEvent <T>(T param)
    {
        var type = typeof(T);

        if (!delegates.TryGetValue(type, out Delegate tempDel))
        {
            return;
        }

        GenericDelegate <T> del = tempDel as GenericDelegate <T>;

        del?.Invoke(param);
    }
예제 #6
0
        public void Step(string flowId, string stepName, DateTime timestamp)
        {
            var flow = GetFlow(flowId);

            flow.Register(new FlowStep(flowId, stepName, timestamp));

            FlowStepReached?.Invoke(new FlowStepReached(flow.Configuration.Name, flow.FlowId, flow.Configuration.StepNames[0], timestamp));

            if (flow.Completed)
            {
                FlowCompleted?.Invoke(new FlowCompleted(flow.Configuration.Name, flow.FlowId));
            }
        }
예제 #7
0
        static void Main(string[] args)
        {
            // Start delegation
            DelegateMathMethod myDelegateMathMethod = new DelegateMathMethod(MyMath.Add);

            Console.WriteLine($"Add: {myDelegateMathMethod(1, 2)}");

            // Append Delegation (Multicasting)
            myDelegateMathMethod += new DelegateMathMethod(MyMath.Multiply);
            Console.WriteLine($"Multiply: {myDelegateMathMethod(1, 2)}");

            //Execute Delegation by iteration
            foreach (Delegate del in myDelegateMathMethod.GetInvocationList())
            {
                Console.WriteLine($"Method: {del.Method}");
                Console.WriteLine($"Target (Type Name): {del.Target}");
            }

            // Using Custom Generic Delegate
            GenericDelegate <string> myGenericDelegate1 = new GenericDelegate <string>(MethodsForGenericDelegate.Print03);
            GenericDelegate <int>    myGenericDelegate2 = new GenericDelegate <int>(MethodsForGenericDelegate.Print01);

            myGenericDelegate1.Invoke("Hello");
            myGenericDelegate2.Invoke(5);

            // Using Action<> Generic Delegate
            Action <string> myActionDelegate = new Action <string>(MethodsForGenericDelegate.Print03);

            myActionDelegate.Invoke("Hello from Action Delegate");

            // Using Func Delegate (final parameter type is the return value)
            Func <int, int, int> myFuncDelegate = new Func <int, int, int>(MyMath.Add);
            int result = myFuncDelegate.Invoke(3, 4);

            Console.WriteLine($"3 + 4 = { result}");


            Console.ReadLine();
        }