Beispiel #1
0
 void KeyUp(MoveSide side)
 {
     if (side == CurrentSide)
     {
         StopMoving();
     }
 }
Beispiel #2
0
 private void CallBallMoved(MoveSide side)
 {
     if (BallMoved != null)
     {
         BallMoved(this, side);
     }
 }
Beispiel #3
0
 private void CallBallMoveSide(MoveSide side)
 {
     if (BallMoveSide != null)
     {
         BallMoveSide(side);
     }
 }
Beispiel #4
0
 public void Turn(ConsoleKey moveKey)
 {
     if (moveKey == ConsoleKey.W)
     {
         if (nowMoveSite != MoveSide.down)
         {
             nowMoveSite = MoveSide.up;
         }
     }
     if (moveKey == ConsoleKey.S)
     {
         if (nowMoveSite != MoveSide.up)
         {
             nowMoveSite = MoveSide.down;
         }
     }
     if (moveKey == ConsoleKey.A)
     {
         if (nowMoveSite != MoveSide.right)
         {
             nowMoveSite = MoveSide.left;
         }
     }
     if (moveKey == ConsoleKey.D)
     {
         if (nowMoveSite != MoveSide.left)
         {
             nowMoveSite = MoveSide.right;
         }
     }
 }
Beispiel #5
0
 protected void StartMoving(MoveSide moveSide)
 {
     if (OnStartMoving != null)
     {
         OnStartMoving(moveSide);
     }
     isMoving = true;
 }
Beispiel #6
0
 private void StartMoving(MoveSide obj)
 {
     if (isPlaying)
     {
         if (sideMovingCor != null)
         {
             StopCoroutine(sideMovingCor);
         }
         sideMovingCor = StartCoroutine(sideMoving(obj));
         if (turningCor != null)
         {
             StopCoroutine(turningCor);
         }
         turningCor = StartCoroutine(turning(-movingAngleDivergence * (2 * obj.GetHashCode() - 1)));
     }
 }
Beispiel #7
0
    IEnumerator sideMoving(MoveSide side)
    {
        float delta = 0;

        if (side == MoveSide.Left)
        {
            delta = -sideMovingSpeed;
        }
        else
        {
            delta = sideMovingSpeed;
        }
        while (true)
        {
            starship.transform.position += new Vector3(delta * Time.deltaTime, 0, 0);
            yield return(null);
        }
    }
    private MoveSide GetRandomMoveSide()
    {
        MoveSide randomSide = MoveSide.Up;
        int      random     = UnityEngine.Random.Range(0, 81);

        if (random >= 0 && random < 20)
        {
            randomSide = MoveSide.Up;
        }
        else if (random >= 20 && random < 40)
        {
            randomSide = MoveSide.Right;
        }
        else if (random >= 40 && random < 60)
        {
            randomSide = MoveSide.Down;
        }
        else if (random >= 60 && random < 80)
        {
            randomSide = MoveSide.Left;
        }

        return(randomSide);
    }
Beispiel #9
0
 // =============== 発射 ================
 public void Shoot(GameObject Target)
 {
     Rescue   = Target;
     movetype = MoveType.RESCUE;
     moveside = MoveSide.NONE;
 }
Beispiel #10
0
 void KeyDown(MoveSide side)
 {
     StartMoving(side);
     CurrentSide = side;
 }
    private void SwipeRight()
    {
        playerMoveSide = MoveSide.Right;

        CalculateMovingPlayer();
    }
    private void SwipeLeft()
    {
        playerMoveSide = MoveSide.Left;

        CalculateMovingPlayer();
    }
    private void SwipeDown()
    {
        playerMoveSide = MoveSide.Down;

        CalculateMovingPlayer();
    }
    private void SwipeUp()
    {
        playerMoveSide = MoveSide.Up;

        CalculateMovingPlayer();
    }
    private void CalculateMovingPlayer()
    {
        if (playerPosOnGrid.y == density.x - 1 && playerMoveSide == MoveSide.Right)
        {
            playerMoveSide = MoveSide.Left;
        }
        else if (playerPosOnGrid.y == 0 && playerMoveSide == MoveSide.Left)
        {
            playerMoveSide = MoveSide.Right;
        }

        if (playerPosOnGrid.x == density.y - 1 && playerMoveSide == MoveSide.Up)
        {
            playerMoveSide = MoveSide.Down;
        }
        else if (playerPosOnGrid.x == 0 && playerMoveSide == MoveSide.Down)
        {
            playerMoveSide = MoveSide.Up;
        }

        // Calculate for player and spheres
        for (int i = 0; i < spherePosOnGrid.Count; i++)
        {
            // Check to swap with player
            if (playerMoveSide == MoveSide.Right &&
                sphereMoveSide[i] == MoveSide.Up &&
                spherePosOnGrid[i].x + 1 == playerPosOnGrid.x &&
                spherePosOnGrid[i].y - 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Right &&
                     sphereMoveSide[i] == MoveSide.Down &&
                     spherePosOnGrid[i].x - 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y - 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Left &&
                     sphereMoveSide[i] == MoveSide.Down &&
                     spherePosOnGrid[i].x - 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y + 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Left &&
                     sphereMoveSide[i] == MoveSide.Up &&
                     spherePosOnGrid[i].x + 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y + 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Up &&
                     sphereMoveSide[i] == MoveSide.Right &&
                     spherePosOnGrid[i].x - 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y + 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Up &&
                     sphereMoveSide[i] == MoveSide.Left &&
                     spherePosOnGrid[i].x - 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y - 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Down &&
                     sphereMoveSide[i] == MoveSide.Right &&
                     spherePosOnGrid[i].x + 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y + 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else if (playerMoveSide == MoveSide.Down &&
                     sphereMoveSide[i] == MoveSide.Left &&
                     spherePosOnGrid[i].x + 1 == playerPosOnGrid.x &&
                     spherePosOnGrid[i].y - 1 == playerPosOnGrid.y)
            {
                sphereSwap[i] = true;
                playerSwap    = true;
                return;
            }
            else
            {
                playerSwap    = false;
                sphereSwap[i] = false;
            }
        }
    }
    private void CreateSpheres(int nSphere)
    {
        sphereList      = new List <Transform>();
        spherePosOnGrid = new List <Vector2>();
        sphereSwap      = new List <bool>();
        sphereColor     = new List <Colors>();
        sphereMoveSide  = new List <MoveSide>();

        playerPosOnGrid = RandomPosition(density, ObjForRandom.Player);
        //playerPosOnGrid = new Vector2(2, 2);
        player          = Instantiate(spherePrefab, sphereContainer);
        player.position = new Vector3(pathGrid[
                                          (int)(playerPosOnGrid.x), (int)(playerPosOnGrid.y)].x,
                                      player.localScale.y / 2,
                                      pathGrid[(int)(playerPosOnGrid.x), (int)(playerPosOnGrid.y)].y);
        MeshRenderer meshRendererPlayer = player.GetComponent <MeshRenderer>();

        meshRendererPlayer.material.color = GetColor(0);
        playerMoveSide = MoveSide.Down;
        playerColor    = Colors.Blue;
        player.gameObject.AddComponent <PlayerController>();

        for (int i = 0; i < nSphere - 1; i++)
        {
            Transform sphere    = Instantiate(spherePrefab, sphereContainer);
            Vector2   randomPos = RandomPosition(density, ObjForRandom.Sphere);
            float     sphereHeightAboveGround = sphere.localScale.y / 2 * -1;
            sphere.position = new Vector3(pathGrid[(int)(randomPos.x), (int)(randomPos.y)].x, sphereHeightAboveGround, pathGrid[(int)(randomPos.x), (int)(randomPos.y)].y);
            MeshRenderer meshRendererSphere = sphere.GetComponent <MeshRenderer>();
            meshRendererSphere.material.color = GetColor(i + 1);
            sphereList.Add(sphere);
            spherePosOnGrid.Add(randomPos);
            sphereMoveSide.Add(GetRandomMoveSide());
            //sphereMoveSide.Add(MoveSide.Left);
            sphereSwap.Add(false);

            switch (i)
            {
            case 0:
                sphereColor.Add(Colors.Red);
                break;

            case 1:
                sphereColor.Add(Colors.Green);
                break;

            case 2:
                sphereColor.Add(Colors.Blue);
                break;

            case 3:
                sphereColor.Add(Colors.Red);
                break;

            case 4:
                sphereColor.Add(Colors.Green);
                break;
            }

            sphere.gameObject.AddComponent <SphereController>();
        }
    }
Beispiel #17
0
 // =============== 左右どちらにつくか ==================
 public void SetSide(MoveSide side)
 {
     moveside = side;
 }
Beispiel #18
0
        public void OnBallMoved(BallController ball, MoveSide side)
        {
            if (_allowMove)
            {
                int  x     = ball.Positinon.X;
                int  y     = ball.Positinon.Y;
                int  newX  = x;
                int  newY  = y;
                bool moved = false;
                switch (side)
                {
                case MoveSide.Down:
                    newY++;
                    if (newY < _gamePole.CountVertCell)
                    {
                        moved = true;
                    }
                    break;

                case MoveSide.Left:
                    newX--;
                    if (newX >= 0)
                    {
                        moved = true;
                    }
                    break;

                case MoveSide.Right:
                    newX++;
                    if (newX < _gamePole.CountHorCell)
                    {
                        moved = true;
                    }
                    break;

                case MoveSide.Up:
                    newY--;
                    if (newY >= 0)
                    {
                        moved = true;
                    }
                    break;
                }
                if (moved)
                {
                    _allowMove = false;
                    CallStartBallMoved();
                    var newBall = _ballPole[newX, newY];
                    _ballPole[newX, newY] = ball;
                    _ballPole[x, y]       = newBall;
                    if (newBall != null)
                    {
                        var ballReverce    = new MoveReverce(ball);
                        var newBallReverce = new MoveReverce(newBall);
                        Move(ball, newX, newY);
                        Move(newBall, x, y);
                        _movedBall += 2;
                        if (_checkBall.CheckChangedBall(ball, _ballPole, true) | _checkBall.CheckChangedBall(newBall, _ballPole, true))
                        {
                            _changed = true;
                            ball.BallAnimationEnd    += OnBallAnimationComplete;
                            newBall.BallAnimationEnd += OnBallAnimationComplete;
                        }
                        else
                        {
                            _reverces.Clear();
                            _reverces[ball]           = ballReverce;
                            _reverces[newBall]        = newBallReverce;
                            ball.BallAnimationEnd    += OnBallReverce;
                            newBall.BallAnimationEnd += OnBallReverce;
                        }
                    }
                }
            }
        }
Beispiel #19
0
 private void PointerObject_BallMoveSide(MoveSide side)
 {
     CallBallMoved(side);
 }
Beispiel #20
0
 public void MoveAside(MoveSide side)
 {
     Move(new Vector3((float)side, 0, 0)); // invoking local Method passing to it new value
 }