ゲームプログラマーの寄り道

ゲームプログラマの寄り道

ソースコード公開系ブログ

ソースコード公開系ブログ

フェードイン・フェードアウトするUIプログラム

www.youtube.com

早い話がボンバーマンみたいなREADY、GOみたいな演出がしたかったんです。
また、量産型クソコード

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public class UIstart : MonoBehaviour {
   
    private RectTransform hoge;
	private int frame = 0;
    private RectTransform ret;
    private RectTransform go;
    private RectTransform end;
    private RectTransform hurry;
    int i= -10;
    TimerScript timerScript;
    float j = -1.5f;
    int end_frame = 0;
    void Start()
    {
        hoge = transform.GetChild(0).gameObject.GetComponent<RectTransform>();
		hoge.sizeDelta = new Vector2(1920, -30);
        ret = transform.GetChild(1).gameObject.GetComponent<RectTransform>();
        ret.localPosition = new Vector3(1500, 0, 0);
        go = transform.GetChild(2).gameObject.GetComponent<RectTransform>();
        go.localPosition = new Vector3(1500, 0, 0);
        hurry = transform.GetChild(3).gameObject.GetComponent<RectTransform>();
        hurry.localPosition = new Vector3(1500, 0, 0);
        timerScript= GetComponent<TimerScript>();
        end = transform.GetChild(4).gameObject.GetComponent<RectTransform>();
        end.localPosition = new Vector3(1500, 200, 0);
    }

    // Update is called once per frame
    void Update()
    {
        if (timerScript.count <= 0)
        {
            ++end_frame;
        }
       
        if (frame <= 10 || (timerScript.count <= 0 && end_frame <= 10))
        {
            if(timerScript.count <= 0 && end_frame == 1)
            {
                hoge.localPosition= new Vector3(0, 200, 0);
            }
            hoge.sizeDelta += new Vector2(0, 30);
        }
        else if (20 < frame && frame <= 30)
        {
            ++i;
            ret.localPosition = new Vector3(1500.0f * (Mathf.Pow(i, 2) / 100.0f), 0, 0);

        }
        else if (50 < frame && frame <= 60)
        {
            ++i;
            ret.localPosition = new Vector3(1500.0f * (-Mathf.Pow(i, 2) / 100.0f), 0, 0);

        }
        else if (70 < frame && frame <= 80)
        {
            ++i;
            go.localPosition = new Vector3(1500.0f * (Mathf.Pow(i, 2) / 100.0f), 0, 0);
        }
        else if (90 < frame && frame <= 100)
        {
            ++i;
            go.localPosition = new Vector3(1500.0f * (-Mathf.Pow(i, 2) / 100.0f), 0, 0);
            hoge.sizeDelta -= new Vector2(0, 30);
        }
        if (timerScript.count <= 60 && j <= 1.5f)
        {
            j += 0.025f;
            hurry.localPosition = new Vector3(1500.0f * (-Mathf.Tan(j) / 15.0f), 0, 0);
        }
        if(timerScript.count <= 0 && 20 < end_frame && end_frame <= 30)
        {
            ++i;
            end.localPosition = new Vector3(1500.0f * (Mathf.Pow(i, 2) / 100.0f), 200, 0);
        }
        if (i>=10)
        {
            i = -10;
        }
		++frame;
	}
}

#1

 if (timerScript.count <= 60 && j <= 1.5f)
        {
            j += 0.025f;
            hurry.localPosition = new Vector3(1500.0f * (-Mathf.Tan(j) / 15.0f), 0, 0);
        }

ここだけtanの値をつかって画面中央辺りに来たらゆっくりになる奴にしてます。

***募集***
一緒にブログを運営してくれる人募集しています。
主な作業は修理作業です。画像足りなかったら拾ってくるとか、誤字の修正などです。
見出し増やすなど、見た目に関する所お願いします。
Twitterに連絡くれれば反応できます。

しんーーご (@shi_k_7) | Twitter