Esempio n. 1
0
    private void Awake()
    {
        // 各ステートを初期化
        entryState = GetComponent <NewsUIEntryState>();
        exitState  = GetComponent <NewsUIExitState>();
        idleState  = GetComponent <NewsUIIdleState>();
        showState  = GetComponent <NewsUIShowState>();

        newsUIContext = new NewsUIContext();
        ReadTextParameter();
    }
Esempio n. 2
0
    /// <summary>
    /// EntryStateのEntry処理をする関数
    /// </summary>
    public void StartEntry()
    {
        // 初期化処理
        showState = GetComponent <NewsUIShowState>();
        // スプライトの設定
        var newsUIImage = gameObject.GetComponent <Image>();

        switch (newsMode)
        {
        case NEWSMODE.DEAD:
            newsUIImage.sprite = newsUISprite.deadSprite[(int)playerNo];
            break;

        case NEWSMODE.GOAL:
            newsUIImage.sprite = newsUISprite.goalSprite[(int)playerNo];
            break;

        case NEWSMODE.RAIN:
            newsUIImage.sprite = newsUISprite.rainSprite;
            break;

        case NEWSMODE.START:
            newsUIImage.sprite = newsUISprite.startSprite;
            break;

        case NEWSMODE.WIN:
            newsUIImage.sprite = newsUISprite.winSprite[(int)playerNo];
            break;
        }
        var newsUIRect = gameObject.GetComponent <RectTransform>();

        sizeDiference.x = sizeMax.x - gameObject.GetComponent <RectTransform>().sizeDelta.x;
        sizeDiference.y = sizeMax.y - gameObject.GetComponent <RectTransform>().sizeDelta.y;
        // スタート地点を設定
        startPos   = newsUIRect.localPosition;
        startPos.y = (Screen.height / 2f) - (newsUIRect.sizeDelta.y / 2f) - offsetY;
        newsUIRect.localPosition = startPos;
        // 目標地点を設定
        float targetPosX = (-Screen.width / 2f) + (newsUIRect.sizeDelta.x / 2f) + (sizeDiference.x / 2f);
        float targetPosY = (Screen.height / 2f) - (newsUIRect.sizeDelta.y / 2f) - offsetY;
        float targetPosZ = newsUIRect.localPosition.z;

        targetPos = new Vector3(targetPosX, targetPosY, targetPosZ);
        // スタート地点から目標地点までの方向を計算
        var moveVec = targetPos - startPos;

        // 正規化
        normalMoveVec = moveVec.normalized;
        // スタート地点から目標地点までの距離を計算
        distance    = Vector3.Distance(startPos, targetPos);
        nowDistance = 0f;
    }