コード例 #1
0
    /// <summary>
    /// 画面外から来るオブジェクトの動き
    /// </summary>
    private void OutsideAreaMove()
    {
        if (!isMove)
        {
            return;
        }

        if (outsideStartPos > 0)
        {
            transform.position += transform.right * PlaySceneManager.SceneManager.GetSpeed() / 4 * angle; // オブジェクトをステージに向かって動かす

            if (transform.position.x <= outsidePos.x)                                                     //生成された位置のX座標になったら通常のオブジェクトの動きになる
            {
                transform.position = new Vector3(outsidePos.x, transform.position.y, transform.position.z);
                targetMoveType     = TargetMoveType.Nomal;
            }
        }
        else if (outsideStartPos < 0)
        {
            transform.position -= transform.right * PlaySceneManager.SceneManager.GetSpeed() / 4 * angle;

            if (transform.position.x >= outsidePos.x)
            {
                transform.position = new Vector3(outsidePos.x, transform.position.y, transform.position.z);
                targetMoveType     = TargetMoveType.Nomal;
            }
        }
    }
コード例 #2
0
    IEnumerator MoveReverseSide()
    {
        Debug.Log("MoveReverseSide");
        targetMoveType = TargetMoveType.Nomal;
        const float m_moveTime = 1.2f;

        isMove = false;
        transform.DOMoveX(-spawnPosX, m_moveTime);
        Doudge(spawnPosX < 0);
        yield return(new WaitForSeconds(m_moveTime));

        isMove = true;
    }
コード例 #3
0
    IEnumerator MoveReverseLane()
    {
        isMove = false;
        Debug.Log("MoveReverseLane");
        targetMoveType = TargetMoveType.Nomal;
        const float m_laneDifference = 6f;
        const float m_moveTime       = 0.7f;

        isMove = false;
        if (targetType == TargetType.OverArm)
        {
            transform.DOMoveY(transform.position.y - m_laneDifference, m_moveTime);
        }
        else if (targetType == TargetType.EnergyGun)
        {
            transform.DOMoveY(transform.position.y + m_laneDifference, m_moveTime);
        }
        yield return(new WaitForSeconds(m_moveTime));

        isMove = true;
    }
コード例 #4
0
        // キューブのモーターを目標指定付き制御します
        public override void TargetMove(
            int targetX,
            int targetY,
            int targetAngle,
            int configID = 0,
            int timeOut  = 0,
            TargetMoveType targetMoveType = TargetMoveType.RotatingMove,
            int maxSpd = 80,
            TargetSpeedType targetSpeedType       = TargetSpeedType.UniformSpeed,
            TargetRotationType targetRotationType = TargetRotationType.AbsoluteLeastAngle,
            ORDER_TYPE order = ORDER_TYPE.Strong
            )
        {
            if (!this.isConnected)
            {
                return;
            }
            #if !RELEASE
            if (65534 < targetX || (targetX < 0 && targetX != -1))
            {
                Debug.LogErrorFormat("[Cube.TargetMove]X座標範囲を超えました. targetX={0}", targetX);
            }
            if (65534 < targetY || (targetY < 0 && targetY != -1))
            {
                Debug.LogErrorFormat("[Cube.TargetMove]Y座標範囲を超えました. targetY={0}", targetY);
            }
            if (8191 < targetAngle || targetAngle < 0)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]回転角度範囲を超えました. targetAngle={0}", targetAngle);
            }
            if (255 < configID || configID < 0)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]制御識別値範囲を超えました. configID={0}", configID);
            }
            if (255 < timeOut || timeOut < 0)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]制御時間範囲を超えました. timeOut={0}", timeOut);
            }
            if (this.maxSpd < maxSpd || maxSpd < 10)
            {
                Debug.LogErrorFormat("[Cube.TargetMove]速度範囲を超えました. maxSpd={0}", maxSpd);
            }
            #endif

            targetX     = targetX == -1 ? 65535 : Mathf.Clamp(targetX, 0, 65534);
            targetY     = targetY == -1 ? 65535 : Mathf.Clamp(targetY, 0, 65534);
            targetAngle = Mathf.Clamp(targetAngle, 0, 8191);
            configID    = Mathf.Clamp(configID, 0, 255);
            timeOut     = Mathf.Clamp(timeOut, 0, 255);
            maxSpd      = Mathf.Clamp(maxSpd, 10, this.maxSpd);

            byte[] buff = new byte[13];
            buff[0]  = 3;
            buff[1]  = (byte)configID;
            buff[2]  = (byte)timeOut;
            buff[3]  = (byte)targetMoveType;
            buff[4]  = (byte)maxSpd;
            buff[5]  = (byte)targetSpeedType;
            buff[6]  = 0;
            buff[7]  = (byte)(targetX & 0xFF);
            buff[8]  = (byte)((targetX >> 8) & 0xFF);
            buff[9]  = (byte)(targetY & 0xFF);
            buff[10] = (byte)((targetY >> 8) & 0xFF);
            buff[11] = (byte)(targetAngle & 0xFF);
            buff[12] = (byte)((((int)targetRotationType & 0x0007) << 5) | ((targetAngle & 0x1FFF) >> 8));

            this.Request(CHARACTERISTIC_MOTOR, buff, false, order, "TargetMove",
                         targetX, targetY, targetAngle, configID, timeOut, targetMoveType, maxSpd, targetSpeedType, targetRotationType);
        }