Ejemplo n.º 1
0
        /// <summary>
        /// アカウントの順序を変更します。
        /// </summary>
        public static void MoveAccount(AccountInfo info, MoveDirection direction)
        {
            var idx = accounts.IndexOf(info);

            if (idx < 0)
            {
                throw new InvalidOperationException();
            }
            switch (direction)
            {
            case MoveDirection.Up:
                if (idx > 0)
                {
                    accounts.RemoveAt(idx);
                    accounts.Insert(idx - 1, info);
                }
                break;

            case MoveDirection.Down:
                if (idx < accounts.Count - 1)
                {
                    accounts.RemoveAt(idx);
                    accounts.Insert(idx + 1, info);
                }
                break;

            default:
                throw new ArgumentException("移動方向指定がちゃんちゃらおかしい :" + direction.ToString());
            }
            OnAccountsChanged(EventArgs.Empty);
        }
Ejemplo n.º 2
0
    // Update is called once per frame
    void Update()
    {
        MoveDirection newDirection = MoveDirection.Invalid;

        if (Input.GetKeyDown(_upKeyCode))
        {
            newDirection = MoveDirection.Up;
        }
        else if (Input.GetKeyDown(_downKeyCode))
        {
            newDirection = MoveDirection.Down;
        }
        else if (Input.GetKeyDown(_leftKeyCode))
        {
            newDirection = MoveDirection.Left;
        }
        else if (Input.GetKeyDown(_rightKeyCode))
        {
            newDirection = MoveDirection.Right;
        }

        if (newDirection != MoveDirection.Invalid)
        {
            if (!Move(newDirection))
            {
                Debug.Log("Could not move player in direction " + newDirection.ToString());
            }
        }
    }
Ejemplo n.º 3
0
    public void Move(MoveDirection md)
    {
        Debug.Log(md.ToString() + " move.");

        moveMade = false;

        ResetMergedFlags();
        if (delay > 0)
        {
            StartCoroutine(MoveCoroutine(md));
        }
        else
        {
            for (int i = 0; i < rows.Count; i++)
            {
                switch (md)
                {
                case MoveDirection.Down:
                    while (MakeOneMoveUpIndex(columns [i]))
                    {
                        moveMade = true;
                    }
                    break;

                case MoveDirection.Left:
                    while (MakeOneMoveDownIndex(rows [i]))
                    {
                        moveMade = true;
                    }
                    break;

                case MoveDirection.Right:
                    while (MakeOneMoveUpIndex(rows [i]))
                    {
                        moveMade = true;
                    }
                    break;

                case MoveDirection.Up:
                    while (MakeOneMoveDownIndex(columns [i]))
                    {
                        moveMade = true;
                    }
                    break;
                }
            }
        }

        if (moveMade)
        {
            UpdateEmptyTiles();
            Generate();

            if (!CanMove())
            {
                GameOver();
            }
        }
    }
Ejemplo n.º 4
0
        /// <summary>
        /// Returns a <see cref="System.String" /> that represents this instance.
        /// </summary>
        /// <returns>
        /// A <see cref="System.String" /> that represents this instance.
        /// </returns>
        public override string ToString()
        {
            JObject play = new JObject();

            play["Name"]      = Name;
            play["Direction"] = MoveDirection.ToString();
            return(play.ToString());
        }
Ejemplo n.º 5
0
        /// <summary>
        ///     serialize Move obj to json string.
        /// </summary>
        /// <returns>
        ///     json represantation of Move.
        /// </returns>
        public string ToJson()
        {
            JObject play = new JObject();

            play["Name"]      = Name;
            play["Direction"] = MoveDirection.ToString();
            play["Id"]        = ClientId;
            return(play.ToString());
        }
Ejemplo n.º 6
0
        private string MoveResult(Coordinates nextCoordinate, MoveDirection moveDirection)
        {
            if (World.Obstacles.Exists(o => o.Coordinates.X == nextCoordinate.X && o.Coordinates.Y == nextCoordinate.Y))
            {
                return($"{obstacleDetectedString}{nextCoordinate.X},{nextCoordinate.Y}");
            }

            CurrentCoords = nextCoordinate;
            return($"Moved {moveDirection.ToString().ToLower()} to {nextCoordinate.X},{nextCoordinate.Y}");
        }
Ejemplo n.º 7
0
 internal void SetCurrentMove(MoveDirection direction)
 {
     if (direction != MoveDirection.OtherKey)
     {
         Moves.NavigateMovesByKey(direction);
     }
     else
     {
         IntInterface.CallBack.Panic("SetCurrentMove invalid direction=" + direction.ToString());
     }
 }
Ejemplo n.º 8
0
 public void setAnimation(MoveDirection dir)
 {
     if (!_animations.ContainsKey(dir))
     {
         Logger.message(LogLevel.LOG_ERROR, "Animation for MoveDirection " + dir.ToString() + " is not assigned!");
     }
     else
     {
         _sprite.Play(_animations[dir]);
     }
 }
Ejemplo n.º 9
0
    public void Move(MoveDirection md)
    {
        Debug.Log(md.ToString() + " move.");
        bool moveMade = false;

        ResetMergerFlags();
        for (int i = 0; i < rows.Count; i++)
        {
            switch (md)
            {
            case MoveDirection.Down:
                while (MakeOneMoveUpIndex(columns[i]))
                {
                    moveMade = true;
                }
                break;

            case MoveDirection.Left:
                while (MakeOneMoveDownIndex(rows[i]))
                {
                    moveMade = true;
                }
                break;

            case MoveDirection.Right:
                while (MakeOneMoveUpIndex(rows[i]))
                {
                    moveMade = true;
                }
                break;

            case MoveDirection.Up:
                while (MakeOneMoveDownIndex(columns[i]))
                {
                    moveMade = true;
                }
                break;
            }
        }
        if (moveMade)
        {
            UpdateEmptyTiles();
            Generate();
            if (!CanMove())
            {
                GameOver();
            }
            if (check == 0)
            {
                Invoke("XuLyGameOverTre", 3);
            }
        }
    }
Ejemplo n.º 10
0
    public void Move(MoveDirection moveDirection)
    {
        Debug.Log(moveDirection.ToString() + " move.");

        bool moveFinished = false;

        ResetMergedFlags();
        for (int i = 0; i < _rows.Count; i++)
        {
            switch (moveDirection)
            {
            case MoveDirection.Down:
                while (MakeOneMoveUpIndex(_columns[i]))
                {
                    moveFinished = true;
                }
                break;

            case MoveDirection.Left:
                while (MakeOneMoveDownIndex(_rows[i]))
                {
                    moveFinished = true;
                }
                break;

            case MoveDirection.Right:
                while (MakeOneMoveUpIndex(_rows[i]))
                {
                    moveFinished = true;
                }
                break;

            case MoveDirection.Up:
                while (MakeOneMoveDownIndex(_columns[i]))
                {
                    moveFinished = true;
                }
                break;
            }
        }

        if (moveFinished)
        {
            UpdateEmptyTiles();
            GenerateNewCells();

            if (!IsNextMoveAvailable())
            {
                GameOver();
            }
        }
    }
Ejemplo n.º 11
0
    public void Move(MoveDirection md)
    {
        Debug.Log(md.ToString() + " move.");
        moveMade = false;

        ResetMergeFlags();

        AudioManager.Instance.PlaySFX(audioMoveTile);

        if (delay > 0)
        {
            StartCoroutine(MoveCoroutine(md));
        }
        else
        {
            for (int i = 0; i < rows.Count; i++)
            {
                switch (md)
                {
                case MoveDirection.Down:
                    while (MakeOneMoveOnUpIndex(columns [i]))
                    {
                        moveMade = true;
                    }
                    break;

                case MoveDirection.Left:
                    while (MakeOneMoveOnDownIndex(rows [i]))
                    {
                        moveMade = true;
                    }
                    break;

                case MoveDirection.Right:
                    while (MakeOneMoveOnUpIndex(rows [i]))
                    {
                        moveMade = true;
                    }
                    break;

                case MoveDirection.Up:
                    while (MakeOneMoveOnDownIndex(columns [i]))
                    {
                        moveMade = true;
                    }
                    break;
                }
            }
        }

        AfterMoveMade();
    }
 public static void SetDirection(MoveDirection dir)
 {
     print("SetDirection " + dir.ToString());
     direction = dir;
     if (dir == MoveDirection.none)
     {
         active = false;
     }
     else
     {
         active = true;
     }
 }
Ejemplo n.º 13
0
 public void Move(MoveDirection moveDirection)
 {
     Debug.Log(string.Format("Try Move {0}", moveDirection.ToString()));
     this.isMoved    = false;
     this.gameStatus = GameStatus.WaitingForMoveToEnd;
     if (this.Delay > 0f)
     {
         StartCoroutine(this.InternalMoveWithDelay(moveDirection));
     }
     else
     {
         this.InternalMove(moveDirection);
     }
 }
Ejemplo n.º 14
0
    public void Move(MoveDirection _move)
    {
        Debug.Log(_move.ToString() + " move");
        isMovemade = false;
        ResetMergedTiles();
        if (delay > 0.000f)
        {
            StartCoroutine(MoveCoroutine(_move));
        }
        else
        {
            for (int i = 0; i < row; i++)
            {
                switch (_move)
                {
                case MoveDirection.Down:
                    while (MakeOneTileUpIndex(coloumsTiles[i]))
                    {
                        isMovemade = true;
                    }
                    break;

                case MoveDirection.Left:
                    while (MakeOneTileDownIndex(rowsTiles[i]))
                    {
                        isMovemade = true;
                    }
                    break;

                case MoveDirection.Right:
                    while (MakeOneTileUpIndex(rowsTiles[i]))
                    {
                        isMovemade = true;
                    }
                    break;

                case MoveDirection.Up:
                    while (MakeOneTileDownIndex(coloumsTiles[i]))
                    {
                        isMovemade = true;
                    }
                    break;
                }
            }
        }


        MadeMove();
    }
Ejemplo n.º 15
0
    //// Update is called once per frame
    //void Update()
    //{
    //    if (Input.GetKeyDown(KeyCode.G))
    //    {
    //        Generate();
    //    }
    //}

    public void Move(MoveDirection direction)
    {
        ResetMerged();
        Debug.Log(direction.ToString() + " move.");
        bool movemade = false;

        for (int i = 0; i < rows.Count; i++)
        {
            switch (direction)
            {
            case MoveDirection.Down:
                while (MakeOneMoveUpIndex(columns[i]))
                {
                    movemade = true;
                }
                break;

            case MoveDirection.Up:
                while (MakeOneMoveDownIndex(columns[i]))
                {
                    movemade = true;
                }
                break;

            case MoveDirection.Left:
                while (MakeOneMoveDownIndex(rows[i]))
                {
                    movemade = true;
                }
                break;

            case MoveDirection.Right:
                while (MakeOneMoveUpIndex(rows[i]))
                {
                    movemade = true;
                }
                break;
            }
        }
        if (movemade)
        {
            UpdateEmptyTiles();
            Generate();
        }
    }
Ejemplo n.º 16
0
    public bool DoJudgeDirect(MoveDirection judgeDirect)
    {
        if (_stateID_Curr != (int)SquareState_ID.Move)
        {
            Debug.Log("current isn't Move");
            return(false);
        }
        if (!((_needToJudgeDirect & judgeDirect) == judgeDirect))
        {
            Debug.Log("ThisSquare" + _worldCoordinate + ",Don't need to judge " + judgeDirect.ToString());
            return(true);
        }
        switch (judgeDirect)
        {
        case MoveDirection.Left:
            if (_worldCoordinate.x == 0)
            {
                return(false);
            }
            return(!(FSMActor_GameSystemController.One.GetGridList()[(int)_worldCoordinate.x - 1][(int)_worldCoordinate.y]));

        case MoveDirection.Right:
            if (_worldCoordinate.x == FSMActor_GameSystemController.SceneWidthGridNumber - 1)
            {
                return(false);
            }
            return(!(FSMActor_GameSystemController.One.GetGridList()[(int)_worldCoordinate.x + 1][(int)_worldCoordinate.y]));

        default:
            if (_worldCoordinate.y == 0)
            {
                return(false);
            }
            return(!(FSMActor_GameSystemController.One.GetGridList()[(int)_worldCoordinate.x][(int)_worldCoordinate.y - 1]));
        }
    }
Ejemplo n.º 17
0
 /// <summary>
 /// アカウントの並び順を変更します。
 /// </summary>
 /// <param name="elem">対象アカウント</param>
 /// <param name="dir">移動先</param>
 public static void MoveAccountElement(string id, MoveDirection dir)
 {
     var elem = GetAccountElement(id);
     if(elem==null)return;
     var idx = accountModels.IndexOf(elem);
     if (idx < 0) return;
     switch (dir)
     {
         case MoveDirection.Up:
             if (idx > 0)
             {
                 accountModels.RemoveAt(idx);
                 accountModels.Insert(idx - 1, elem);
             }
             break;
         case MoveDirection.Down:
             if (idx < accountModels.Count - 1)
             {
                 accountModels.RemoveAt(idx);
                 accountModels.Insert(idx + 1, elem);
             }
             break;
         default:
             throw new ArgumentException("移動方向指定がちゃんちゃらおかしい :" + dir.ToString());
     }
     AccountsChanged();
 }
Ejemplo n.º 18
0
 public override string ToString()
 {
     return(Direction.ToString());
 }
Ejemplo n.º 19
0
	public void Move(MoveDirection md)
	{
		Debug.Log (md.ToString () + " move.");
	    moveMade = false;
		ResetMergedFlags ();
		if (delay > 0)
			StartCoroutine (MoveCoroutine (md));
		else 
		{
			for (int i =0; i< rows.Count; i++) 
			{
				switch (md) 
				{
				case MoveDirection.Down:
					while (MakeOneMoveUpIndex(columns[i])) 
					{
						moveMade = true;
					}
					break;
				case MoveDirection.Left:
					while (MakeOneMoveDownIndex(rows[i])) 
					{
						moveMade =true;
					}
					break;
				case MoveDirection.Right:
					while (MakeOneMoveUpIndex(rows[i])) 
					{
						moveMade =true;
					}
					break;
				case MoveDirection.Up:
					while (MakeOneMoveDownIndex(columns[i])) 
					{
						moveMade =true;
					}
					break;
				}
			}

			if (moveMade) 
			{
				UpdateEmptyTiles ();
				Generate ();

				if (!CanMove())
				{
					GameOver();
				}
			
			}
		}
	}
Ejemplo n.º 20
0
 /// <summary>
 /// アカウントの順序を変更します。
 /// </summary>
 public static void MoveAccount(string id, MoveDirection direction)
 {
     var info = Get(id);
     if (info == null)
         throw new ArgumentException("アカウント @" + id + " は存在しません。");
     var idx = accounts.IndexOf(info);
     if (idx < 0)
         throw new InvalidOperationException();
     switch (direction)
     {
         case MoveDirection.Up:
             if (idx > 0)
             {
                 accounts.RemoveAt(idx);
                 accounts.Insert(idx - 1, info);
             }
             break;
         case MoveDirection.Down:
             if (idx < accounts.Count - 1)
             {
                 accounts.RemoveAt(idx);
                 accounts.Insert(idx + 1, info);
             }
             break;
         default:
             throw new ArgumentException("移動方向指定がちゃんちゃらおかしい :" + direction.ToString());
     }
     OnAccountsChanged(EventArgs.Empty);
 }
Ejemplo n.º 21
0
        private Position GetDestinaionPosition(Position start, MoveDirection dir)
        {
            Position end;

            switch (dir)
            {
            case MoveDirection.Left:
                end = new Position(start.X - 1, start.Y);
                break;

            case MoveDirection.UpLeft:
                end = new Position(start.X - 1, start.Y + 1);
                break;

            case MoveDirection.Up:
                end = new Position(start.X, start.Y + 1);
                break;

            case MoveDirection.UpRight:
                end = new Position(start.X + 1, start.Y + 1);
                break;

            case MoveDirection.Right:
                end = new Position(start.X + 1, start.Y);
                break;

            case MoveDirection.DownRight:
                end = new Position(start.X + 1, start.Y - 1);
                break;

            case MoveDirection.Down:
                end = new Position(start.X, start.Y - 1);
                break;

            case MoveDirection.DownLeft:
                end = new Position(start.X - 1, start.Y - 1);
                break;

            default:
                throw new ArgumentException(string.Format(ErrorMessages.UnrecognizedEnumValue, dir.ToString()));
            }

            return(end);
        }
Ejemplo n.º 22
0
        public static string GetDescription(this MoveDirection moveDirection)
        {
            var fi = moveDirection.GetType().GetField(moveDirection.ToString());

            return(fi.GetCustomAttributes(typeof(DescriptionAttribute), false) is DescriptionAttribute[] attributes && attributes.Length > 0 ? attributes[0].Description : null);
        }
Ejemplo n.º 23
0
 public override string ToString()
 {
     return(MoveDirection.ToString() + "_" + ExtData.TimeStap.ToString());
 }
Ejemplo n.º 24
0
 public void setAnimation(MoveDirection dir)
 {
     if (!_animations.ContainsKey(dir))
     {
         Logger.message(LogLevel.LOG_ERROR, "Animation for MoveDirection "+dir.ToString()+" is not assigned!");
     }
     else
     {
         _sprite.Play(_animations[dir]);
     }
 }
Ejemplo n.º 25
0
    public void Move(MoveDirection md)
    {
        Debug.Log(md.ToString() + " move.");

        // there is a sinatio: if no moves and merges when trigger a direction
        // it should not generate a new tile.
        // MoveMade is to aviod this bug.
        MoveMade = false;

        // reset merged flag to false
        ResetMergedFlags();

        // check delay is/not set
        if (delay > 0)
        {
            StartCoroutine(MoveCoroutine(md));
        }
        else
        {
            // create game logic.
            // there are 4 rows and 4 columns
            // so, for each line should affect
            for (int i = 0; i < rows.Count; i++)
            {
                // switch four direction moves
                switch (md)
                {
                case MoveDirection.Down:
                    // shift tiles, which means if there exist empty tile, then shift
                    // correct tile to that position.
                    while (MakeOneMoveUpIndex(columns[i]))
                    {
                        // set MoveMade = true
                        MoveMade = true;
                    }
                    break;

                case MoveDirection.Left:
                    while (MakeOneMoveDownIndex(rows[i]))
                    {
                        MoveMade = true;
                    }
                    break;

                case MoveDirection.Right:
                    while (MakeOneMoveUpIndex(rows[i]))
                    {
                        MoveMade = true;
                    }
                    break;

                case MoveDirection.Up:
                    while (MakeOneMoveDownIndex(columns[i]))
                    {
                        MoveMade = true;
                    }
                    break;
                }
            }

            // ckeck the MoveMade value, avoid generating a new tile when there have no moves
            if (MoveMade)
            {
                // update empty tile list
                UpdateEmptyTiles();
                // add a new tile after the move finished
                Generate();

                // check game is/not over
                if (!CanMove())
                {
                    GameOver();
                }
            }
        }
    }
Ejemplo n.º 26
0
        private static bool Calc(MoveDirection key)
        {
            _isMoved = false;

            #region Calc

            List<int> list = new List<int>();
            if (key == MoveDirection.Up)
            {
                for (int col = 0; col < MATRIX_NUM; col++)
                {
                    list = _dic.Where(item => item.Key.Item2 == col).OrderBy(item => item.Key.Item1).Select(item => item.Value).ToList();
                    list = CalcSingle(list);

                    for (int index = 0; index < MATRIX_NUM; index++)
                    {
                        _dic[new Tuple<int, int>(index, col)] = list[index];
                    }
                }
            }
            else if (key == MoveDirection.Down)
            {
                for (int col = 0; col < MATRIX_NUM; col++)
                {
                    list = _dic.Where(item => item.Key.Item2 == col).OrderByDescending(item => item.Key.Item1).Select(item => item.Value).ToList();
                    list = CalcSingle(list);
                    list.Reverse();

                    for (int index = 0; index < MATRIX_NUM; index++)
                    {
                        _dic[new Tuple<int, int>(index, col)] = list[index];
                    }
                }
            }
            else if (key == MoveDirection.Left)
            {
                for (int row = 0; row < MATRIX_NUM; row++)
                {
                    list = _dic.Where(item => item.Key.Item1 == row).OrderBy(item => item.Key.Item2).Select(item => item.Value).ToList();
                    list = CalcSingle(list);

                    for (int index = 0; index < MATRIX_NUM; index++)
                    {
                        _dic[new Tuple<int, int>(row, index)] = list[index];
                    }
                }
            }
            else if (key == MoveDirection.Right)
            {
                for (int row = 0; row < MATRIX_NUM; row++)
                {
                    list = _dic.Where(item => item.Key.Item1 == row).OrderByDescending(item => item.Key.Item2).Select(item => item.Value).ToList();
                    list = CalcSingle(list);
                    list.Reverse();

                    for (int index = 0; index < MATRIX_NUM; index++)
                    {
                        _dic[new Tuple<int, int>(row, index)] = list[index];
                    }
                }
            }
            else
            {
                return true; //输入非法, 不做处理
            }

            #endregion

            if (!_isMoved) //没有产生移动
                return CheckCanContinue();

            if (CheckHasHole())
            {
                var listEmpty = _dic.Where(item => item.Value == 0).Select(item => item.Key).ToList();
                var tuple = listEmpty[_random.Next(listEmpty.Count)];
                _dic[tuple] = FILL_VALUE;

                _step++;
                Console.WriteLine("===============" + key.ToString() + "    Step:" + _step);
                Print();

                return CheckCanContinue();
            }
            else
            {
                return CheckHasNearSameValue();
            }
        }
Ejemplo n.º 27
0
        private Boolean IsLandingSquareEmpty(Byte startSquare, MoveDirection jumpDirection)
        {
            Boolean answer = false;
            String start = startSquare.ToString() + jumpDirection.ToString().ToLower();
            Byte landingSquare = JumpLandingSquareLookup[start];
            UInt64 landingBitBoard = squareTable[landingSquare];

            if ((emptySquares & landingBitBoard) != 0UL)
                answer = true;

            return answer;
        }
Ejemplo n.º 28
0
        private Move CreateMoveFromJump(Byte index, MoveDirection direction)
        {
            String key = index.ToString() + direction.ToString().ToLower();
            Byte landingSquare = JumpLandingSquareLookup[key];
            Move move = new Move(index, landingSquare, true);

            return move;
        }
Ejemplo n.º 29
0
 public static Task <bool> FlyDirection(this ITelloClient tello, MoveDirection direction, int cm)
 {
     CommandConstraints.CheckDistance(cm);
     return(tello.SendAction($"{direction.ToString().ToLower()} {cm}"));
 }
Ejemplo n.º 30
0
 internal void Move(MoveDirection direction)
 {
     _playerProvider.DoSourceCommand(_source, "Move"+direction.ToString());
 }