Пример #1
0
 public override void Start()
 {
     if (ThrowEventOnStart)
     {
         OnValueChangedEvent.Invoke(CurrentValue);
         OnValueChanged?.Invoke(CurrentValue);
     }
 }
Пример #2
0
        /// <summary>
        /// set anim false generally means move entity to one place instantly without move cost (e.g. by skill effect).
        /// </summary>
        /// <param name="targetLoc"></param>
        /// <param name="isInstance"></param>
        public virtual int MoveToTile(Location targetLoc, int moveCost, bool isInstance = false)
        {
            if (targetLoc == Loc)
            {
                return(0);
            }
            // Calculate movement path
            if (!isInstance)
            {
                Stack <Location> path = GridManager.Instance.Nav.GetPath(Loc, targetLoc);

                if (path.Count * moveCost > ActionPoints)
                {
                    return(0);
                }

                MovePath = path.ToArray();
            }

            if (isInstance)
            {
                Loc.GetTileController().OnEntityLeaving();
                Loc = targetLoc;
                Loc.GetTileController().OnEntityEntering(Hash);
                AnimationManager.Instance.AddAnimClip(new MoveInstantAnimClip(Hash, targetLoc, 0.2f));
                AnimationManager.Instance.PlayOnce();
            }
            else
            {
                int stepID = 0, passedCount = 0;
                for (int i = 0; i < MovePath.Length; i++)
                {
                    if (MovePath[i].GetTileController().HasImpacts || i == MovePath.Length - 1)
                    {
                        if (stepID * moveCost > ActionPoints)
                        {
                            OnMovedEvent?.Invoke(i);
                            return(i);
                        }
                        SubMoveToTile(passedCount, stepID);

                        stepID      = 0;
                        passedCount = i + 1;
                        continue;
                    }
                    stepID++;
                }
                // AP cost
                ImpactActionPoints(passedCount * moveCost, true);
            }
            int movementSteps = isInstance ? 0 : MovePath.Length;

            // Pass move condition
            OnMovedEvent?.Invoke(movementSteps);
            return(movementSteps);
        }
Пример #3
0
    private void AttackInput()
    {
        bool attackOne    = Input.GetKeyDown(this.attackOne);
        bool attackTwo    = Input.GetKeyDown(this.attackTwo);
        bool ultiActivate = Input.GetKeyDown(ultiKey);

        mouseAttackPositionDelegate.Invoke();

        if (attackOne)
        {
            attackDelegate?.Invoke(1);
        }
        else if (attackTwo)
        {
            attackDelegate?.Invoke(0);
        }
        else if (ultiActivate)
        {
            attackDelegate?.Invoke(2);
        }
    }
Пример #4
0
        static void Main(string[] args)
        {
            MultiCastDelegate MCD = new MultiCastDelegate();
            MYDelegate        m   = new MYDelegate(MCD.Hello1);

            m += MCD.Hello2;
            m.Invoke();

            MultiCastDelegate2 mcd2 = new MultiCastDelegate2();
            IntDelegate        IDel = new IntDelegate(mcd2.add);

            IDel += mcd2.sub;
            IDel += mcd2.div;
            IDel.Invoke(100, 200);
            Console.WriteLine();
        }
        public DispatchConfiguredMatchingCallBenchmark()
        {
            _interfaceProxy = Substitute.For <IInterfaceWithSingleMethod>();
            _interfaceProxy.IntMethod("42").Returns(42);
            _interfaceProxy.When(x => x.VoidMethod("42")).Do(delegate {  });

            _abstractClassProxy = Substitute.For <AbstractClassWithSingleMethod>();
            _abstractClassProxy.IntMethod("42").Returns(42);
            _abstractClassProxy.When(x => x.VoidMethod("42")).Do(delegate {  });

            _classPartialProxy = Substitute.For <ClassWithSingleMethod>();
            _classPartialProxy.IntMethod("42").Returns(42);
            _classPartialProxy.When(x => x.VoidMethod("42")).Do(delegate {  });

            _intDelegateProxy = Substitute.For <IntDelegate>();
            _intDelegateProxy.Invoke("42").Returns(42);

            _voidDelegateProxy = Substitute.For <VoidDelegate>();
            _voidDelegateProxy.When(x => x.Invoke("42")).Do(delegate {  });
        }
Пример #6
0
    private void Move()
    {
        int  dir   = 0;
        bool left  = Input.GetKey(leftKeyCode);
        bool right = Input.GetKey(rightKeyCode);

        if (left == right)
        {
            dir = 0;
        }
        else if (left)
        {
            dir = -1;
        }
        else
        {
            dir = 1;
        }
        moveDelegate?.Invoke(dir);
    }
Пример #7
0
    private void Move()
    {
        int  dir   = 0;
        bool right = Input.GetKey(rightKey);
        bool left  = Input.GetKey(leftKey);

        if (right)
        {
            dir = 1;
        }
        else if (left)
        {
            dir = -1;
        }
        else
        {
            dir = 0;
        }
        moveDelegate?.Invoke(dir);
        GlobalStatistics.playerDirection = dir;
    }
Пример #8
0
 public int DispatchDelegateCall_Int() => _intDelegateProxy.Invoke(null);