Example #1
0
        /// <summary>
        /// 完成对齐操作
        /// </summary>
        public void Complete()
        {
            this.Termimal();
            ///只有两条线平齐的情况下,才能做偏移操作
            if (targetLine.Direction.IsAlmostEqualTo(referLine.Direction) || targetLine.Direction.IsAlmostEqualTo(-referLine.Direction))
            {
                if (!targetLine.IsAlmostEqualTo(referLine))
                {
                    //计算要偏移的距离
                    Vector2D v     = targetLine.Start.ProjectOn(referLine);
                    Vector2D movev = v - targetLine.Start;
                    this.tagert.Move(movev);
                    this.tagert.Update();

                    if (DrawCompleteEvent != null)
                    {
                        DrawCompleteEvent(new ActionEventArgs(tagert));
                    }
                    if (RecordCommand != null)
                    {
                        MoveFunction mf = new MoveFunction(this.tagert);
                        mf.Offset = movev;
                        RecordCommand(this, mf);
                    }
                }
            }
            else
            {
                if (DrawCompleteEvent != null)
                {
                    DrawCompleteEvent(null);
                }
            }
        }
Example #2
0
File: fsm.cs Project: r57s/fsm
 public void OnMove(string from, string to, MoveFunction fn)
 {
     Moves.Add(new MoveInfo() {
         f = from,
         t = to,
         fn = fn
     });
 }
Example #3
0
        public Task <string> MoveRequestAsync(string src, string dst, BigInteger wad)
        {
            var moveFunction = new MoveFunction();

            moveFunction.Src = src;
            moveFunction.Dst = dst;
            moveFunction.Wad = wad;

            return(ContractHandler.SendRequestAsync(moveFunction));
        }
Example #4
0
        public Task <TransactionReceipt> MoveRequestAndWaitForReceiptAsync(string src, string dst, BigInteger wad, CancellationTokenSource cancellationToken = null)
        {
            var moveFunction = new MoveFunction();

            moveFunction.Src = src;
            moveFunction.Dst = dst;
            moveFunction.Wad = wad;

            return(ContractHandler.SendRequestAndWaitForReceiptAsync(moveFunction, cancellationToken));
        }
Example #5
0
File: fsm.cs Project: r57s/fsm
 public void OnMove(string[] moveInfos, MoveFunction fn)
 {
     foreach(var moveInfo in moveInfos)
     {
         var rule = moveInfo.Split('>');
         if (rule.Length != 2) {
             return;
         }
         OnMove(rule[0], rule[1], fn);
     }
 }
Example #6
0
 void Awake()
 {
     DontDestroyOnLoad(this);
     moveFunction = GetComponent <MoveFunction>();
     moveFunction.Init(
         GetComponent <Rigidbody2D>(),
         GetComponentInChildren <AnimScript>(),
         GetComponentInChildren <Collion>(),
         GetComponentInChildren <BetterJump>()
         );
 }
 /// <summary>
 /// Adds the assets needed for each move
 /// </summary>
 /// <param name="playTime">The time it takes for the animation to run</param>
 /// <param name="imageSize">The size of each individual image</param>
 /// <param name="spriteSheet">The spritesheet to draw as the animation for this move</param>
 /// <param name="scale">The scale needed to fit the textures on the screen properly</param>
 /// <param name="hitboxes">The texture of the hitboxes for moves. Must be the same image size AND scale as
 /// spriteSheet</param>
 /// <param name="function">The function to run when this move is used</param>
 /// <param name="effect">Any effects to play when this move is used</param>
 public MoveAssets(float playTime, Point imageSize, Texture2D spriteSheet, int scale, Texture2D hitboxes,
                   MoveFunction function, params SoundEffect[] effect)
 {
     HitboxTexture = hitboxes;
     Animation     = new CharacterAction(playTime, imageSize, spriteSheet, scale);
     if (effect != null)
     {
         Sound = new AudioHandler(effect);
     }
     HitboxVertices = CreateVerticesFromTexture(hitboxes, scale, imageSize);
     Function       = function;
     Started        = DateTime.Now;
 }
 //flyttar formen beroende på vilken knapp som trycks
 private void checkCounter(Keys type, MoveFunction move)
 {
     if (!oldState.IsKeyDown(type))
     {
         move();
         counterInput = 0;
     }
     else
     {
         counterInput++;
         if (counterInput > threshold)
         {
             move();
         }
     }
 }
Example #9
0
 //Moves the Shape if the according key was pressed.
 //type - key type to compare with.
 //move - the movement the shape should perform depending on the key.
 private void checkCounter(Keys type, MoveFunction move)
 {
     // If not down last update, key has just been pressed.
     if (!oldState.IsKeyDown(type))
     {
         move();
         counterInput = 0;                 //reset counter with every new keystroke
     }
     else
     {
         counterInput++;
         if (counterInput > threshold)
         {
             move();
         }
     }
 }
 public Turmit(TurmitRule rule, TurmiteMatrix matrix)
 {
     currentRule = rule;
     this.matrix = matrix;
     i = this.matrix.GetLength() / 2; k = i;
     currentState = 'A';
     currentDirection = Direction.North;
     MoveFunction[] moveFunctions = new MoveFunction[4]
     {
         new MoveFunction(MoveNorth),
         new MoveFunction(MoveSouth),
         new MoveFunction(MoveEast),
         new MoveFunction(MoveWest)
     };
     mapping.Add(Direction.East, moveFunctions[2]);
     mapping.Add(Direction.North, moveFunctions[0]);
     mapping.Add(Direction.South, moveFunctions[1]);
     mapping.Add(Direction.West, moveFunctions[3]);
 }
Example #11
0
        /// <summary>
        /// 完成当前的任务操作
        /// </summary>
        public void Complete()
        {
            this.Termimal();
            //移动距离
            Vector2D moveDistance = this.end - this.start;

            //开始移动目标对象
            this.tagert.Move(moveDistance);
            //更新当前的目标对象
            this.tagert.Update();
            //当前命令操作完成
            if (DrawCompleteEvent != null)
            {
                GeometryShape.UnSelect();
                this.DrawCompleteEvent(null);
            }

            if (RecordCommand != null)
            {
                MoveFunction mf = new MoveFunction(this.tagert);
                mf.Offset = moveDistance;
                RecordCommand(this, mf);
            }
        }
Example #12
0
 public Task <string> MoveRequestAsync(MoveFunction moveFunction)
 {
     return(ContractHandler.SendRequestAsync(moveFunction));
 }
Example #13
0
 private void Start()
 {
     anim = FindObjectOfType <AnimScript>();
     move = FindObjectOfType <MoveFunction>();
     sr   = GetComponent <SpriteRenderer>();
 }
Example #14
0
 private Move(string name, MoveFunction action)
 {
     this.Name   = name;
     this.Action = action;
 }
Example #15
0
 static void AddMove(string name, MoveFunction action)
 {
     allMoves.Add(name, new Move(name, action));
 }
Example #16
0
 void Awake()
 {
     _instance = this;
 }
Example #17
0
 private float desiredPos(float initialPosition, float period, float amplitude, float t, MoveFunction move)
 {
     return(GetMoveValue(initialPosition, t, period, amplitude, move));
 }
Example #18
0
 private float desiredV(float initialPosition, float period, float amplitude, float t, float timestep, MoveFunction move, float targetBodyVelocity)
 {
     return((desiredPos(initialPosition, period, amplitude, t + timestep, move)
             - desiredPos(initialPosition, period, amplitude, t, move))
            / timestep + targetBodyVelocity);
 }
Example #19
0
    private float GetMoveValue(float initial, float timestep, float period, float amplitude, MoveFunction mode)
    {
        switch (mode)
        {
        case MoveFunction.Sin:
            return(initial + amplitude * Mathf.Sin(2 * Mathf.PI * timestep / period));

        case MoveFunction.Cos:
            return(initial + amplitude * Mathf.Cos(2 * Mathf.PI * timestep / period));

        case MoveFunction.Swap:
            var timeMod0   = timestep % period;
            var timeRatio0 = timeMod0 / period;
            //Debug.Log("timeratio: " + timeRatio0 + ", " + (initial + (timeRatio0 < 0.5f ? amplitude : -amplitude)) + "(" + timestep + ")");
            return(initial + (timeRatio0 < 0.5f ? amplitude : -amplitude));

        case MoveFunction.Linear:
            var timeMod   = timestep % period;
            var timeRatio = timeMod / period;
            return(initial + 2 * amplitude * (timeRatio < 0.5f ? timeRatio : 1 - timeRatio));
        }
        return(initial);
    }
Example #20
0
File: fsm.cs Project: r57s/fsm
 public void OnMove(string pattern, MoveFunction fn)
 {
     OnMove(pattern.Split(','), fn);
 }
Example #21
0
 public Task <TransactionReceipt> MoveRequestAndWaitForReceiptAsync(MoveFunction moveFunction, CancellationTokenSource cancellationToken = null)
 {
     return(ContractHandler.SendRequestAndWaitForReceiptAsync(moveFunction, cancellationToken));
 }
Example #22
0
 public MovePair(int distance, MoveFunction action)
 {
     this.distance = distance;
     this.action   = action;
 }