12
anonymous No title
C#
public class PlayerController : MonoBehaviour
{
    public Rigidbody2D rb;

    // Start is called before the first frame update
    void Start()
    {
        rb = this.GetComponent<Rigidbody2D>();
    }

    // Update is called once per frame
    void Update()
    {
        //左矢印が押された時
        if (Input.GetKeyDown(KeyCode.LeftArrow))
        {
            rb.velocity = new Vector3(-3f, 0, 0);
        }
        else if(Input.GetKeyUp(KeyCode.LeftArrow))
        {
            rb.velocity = new Vector3(0, 0, 0);
        }

        if (Input.GetKeyDown(KeyCode.RightArrow))
        {
            rb.velocity = new Vector3(3f, 0, 0);
        }
        else if (Input.GetKeyUp(KeyCode.RightArrow))
        {
            rb.velocity = new Vector3(0, 0, 0);
        }
    }
}
anonymous No title
C#
public class CarController : MonoBehaviour
{
    float speed = 0;
    Vector2 startPos;
    float starttime = 0f;
    float endtime = 0f;

    // Start is called before the first frame update
    void Start()
    {
       
    }

    // Update is called once per frame
    void Update()
    {
        //スワイプの長さを決める(追加)
        if (Input.GetMouseButtonDown(0))
        {
            //マウスをクリックした座標
            this.startPos = Input.mousePosition;

            //マウスをクリックした時間
            starttime = Time.time;
        }
        else if (Input.GetMouseButtonUp(0))
        {
            //マウスを離した座標
            Vector2 endPos = Input.mousePosition;
            float swipeLength = endPos.x - this.startPos.x;

            //マウスを離した時間
            endtime = Time.time;

            //経過時間
            float timespan = (endtime - starttime) * 1000;

            //スワイプの長さを初速度に変換する
            speed = swipeLength / timespan;
        }

        transform.Translate(speed, 0, 0); //移動
        speed *= 0.98f; //速度
    }
}
anonymous No title
C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class CarController : MonoBehaviour
{
    float speed = 0;
    Vector2 startPos;
    float strTime;
    float endTime;
    float spTime;

    // Start is called before the first frame update
    void Start()
    {
    

    }

    // Update is called once per frame
    void Update()
    {
        //スワイプの長さを決める(追加)
        if (Input.GetMouseButtonDown(0))
        {
            //マウスをクリックした座標
            this.startPos = Input.mousePosition;

            // マウスをクリックした時間
            strTime = Time.deltaTime;            

        }else if (Input.GetMouseButtonUp(0))
        {
            //マウスを離した座標
            Vector2 endPos = Input.mousePosition;
            float swipeLength = endPos.x - this.startPos.x;

            //マウスを離した時間
            endTime = Time.deltaTime;
            spTime = endTime - strTime;

            //スワイプの長さを初速度に変換する
            speed = swipeLength / spTime;
        }

        transform.Translate(speed, 0, 0); //移動
        speed *= 0.98f; //速度
    }
}
anonymous No title
C#
    public static void Main(){

            const float beginX = 800;//開始X座標
            const float endX = 340;//終了X座標
            const float rate = 0.05f;//移動量の係数(0fに近いほど遅く1fに近づくほど速い)
            float x = 0f;
            pictureBox1.Left = (int) beginX;
            while (Math.Abs(beginX - x - endX) >= 1) {
            	pictureBox1.Left = (int) (beginX - x);
            	x += (beginX - endX) * rate;
            	pictureBox1.Refresh();
            	wait();
            }
            pictureBox1.Left = (int) endX;
        }
        
        private static async void wait() {
            await Task.Delay(16);//60FPS(16ms)で再描画
        } 
anonymous No title
C#
public static void Main(){
        const float beginX = 800;//開始X座標
        const float endX = 340;//終了X座標
        const float rate = 0.01f;//移動量の係数(0fに近いほど遅く1fに近づくほど速い)
        float x = 0f;
        pictureBox1.Left = (int) beginX;
        while (Math.Abs(beginX - x - endX) >= 1) {
        	pictureBox1.Left = (int) (beginX - x);
        	x += (beginX - endX) * rate;
        	pictureBox1.Refresh();
        	wait();
        }
        pictureBox1.Left = (int) endX;
    }
    
    private static async void wait() {
        await Task.Delay(16);//60FPS(16ms)で再描画
    } 
anonymous No title
C#
Process process = new Process()

process.StartInfo.FileName = "python3";
process.StartInfo.Arguments = "<pythonのファイル名>";
process.StartInfo.UseShellExecute = true;
process.StartInfo.RedirectStandardOutput = true;
process.Start();

Console.WriteLine(process.StandardOutput.ReadToEnd()); //読み込み

process.WaitForExit(); //終わるまで待機
大翔士 Group Edge Separete
C#
// エッジグループを繋がってるエッジごとに別のエッジグループに分ける
string edge_group = chs("edge_group");
int edge_points[] = expandedgegroup(0, edge_group);
int edges[];
for (int i = 0; i < len(edge_points); i += 2)
{
    int src_pt = edge_points[i];
    int dst_pt = edge_points[i + 1];
    int edge = pointhedge(0, src_pt, dst_pt);
    edge = hedge_primary(0, edge);
    push(edges, edge);
}

int group_num = 0;
while (len(edges) > 0)
{
    int connected_edges[] = array(edges[0]);
    removeindex(edges, 0);
    int i = 0;
    while (i < len(connected_edges))
    {
        int src_edge = connected_edges[i];
        int edge_src_pt = hedge_srcpoint(0, src_edge);
        int edge_dst_pt = hedge_dstpoint(0, src_edge);
        int edge_pts[] = array(edge_src_pt, edge_dst_pt);
        foreach (int src_pt; edge_pts)
        {
            int nb_pts[] = neighbours(0, src_pt);
            foreach (int nb_pt; nb_pts)
            {
                if (!inedgegroup(0, edge_group, src_pt, nb_pt))
                    continue;
                int edge = pointhedge(0, src_pt, nb_pt);
                edge = hedge_primary(0, edge);
                if (find(connected_edges, edge) >= 0)
                    continue;
                push(connected_edges, edge);
                int index = find(edges, edge);
                if (index >= 0)
                    removeindex(edges, index);
            }
        }
        i += 1;
    }
    foreach (int edge; connected_edges)
    {
        int src_pt = hedge_srcpoint(0, edge);
        int dst_pt = hedge_dstpoint(0, edge);
        string group = "connected_edge" + itoa(group_num);
        setedgegroup(0, group, src_pt, dst_pt, 1);
    }
    group_num += 1;
}
anonymous No title
C#
using System.Collections;
using System.Collections.Generic;
using System.Threading;
using UnityEngine;

public class WatchMap : MonoBehaviour
{
    [SerializeField] private Camera mapCamera = null;
    [SerializeField] private Transform playerIcon = null;
    [SerializeField] private Transform goalIcon = null;
    [SerializeField] private int minShootingRange = 10;//zoom時の撮影範囲
    [SerializeField] private int maxShootingRange = 50;//map全体撮影用の範囲
    [SerializeField] private Vector3 defaultIconScale = new Vector3(1.0f, 1.0f, 1.0f);
    private bool isZoomed = true;
    private float zoomMag = 1.0f;
    private Vector3 defaultGoalPos;//ゴールアイコンの初期位置
    private int defaultCameraY = 63;
    private int defaultIconY = 62;

    public void ChangePosition()
    {
        Vector3 toCameraPostion;
        if (isZoomed)
        {
            mapCamera.transform.parent = null;//カメラの追従を切る
            toCameraPostion = new Vector3(0, defaultCameraY, 0);//ワールド座標(0,64,0)から撮影する
            mapCamera.transform.position = toCameraPostion;
            ChangeShootingRange(minShootingRange, maxShootingRange);
            isZoomed = false;

        }
        else
        {
            toCameraPostion = playerIcon.transform.position;//プレイヤの上空前方から撮影する
            toCameraPostion.y = 63; toCameraPostion.z += 5;
            mapCamera.transform.parent = playerIcon.parent.transform;//カメラをプレイヤーに追従させる
            mapCamera.transform.position = toCameraPostion;
            ChangeShootingRange(maxShootingRange, minShootingRange);
            isZoomed = true;
        }
    }
    public void ChangeShootingRange(double nowSize, double toSize)
    {
        zoomMag *=(float)(toSize / nowSize);
        mapCamera.orthographicSize = minShootingRange * zoomMag;
        playerIcon.localScale =defaultIconScale*zoomMag;
        goalIcon.localScale = defaultIconScale*zoomMag;
    }
    private bool CheckInsideMap()
    {
        Vector3 cameraPos = mapCamera.transform.position;
        Vector3 targetPos = goalIcon.position;
        cameraPos.y = targetPos.y = 0;
       // Debug.Log((minShootingRange - 1) * zoomMag);
        Debug.Log(Vector3.Distance(cameraPos, targetPos));
        return Vector3.Distance(cameraPos, targetPos) <= (minShootingRange-1) * zoomMag;//goalがマップの範囲内にあるか否かを返す

    }
    private IEnumerator DispIcon()
    {
        while (true)
        {
            if (CheckInsideMap())
            {
                Debug.Log(defaultGoalPos);
                goalIcon.position = defaultGoalPos;
                //Debug.Log("IN");
            }
            else
            {
                Vector3 cameraPos = mapCamera.transform.position;
                Vector3 offset = goalIcon.position - cameraPos;//カメラからゴールに向けたベクトルを計算
                Vector3 toGoalIconPos = cameraPos + Vector3.ClampMagnitude(offset, (float)(minShootingRange * zoomMag*0.85));//ゴールアイコンの位置を上のベクトルをもとに設定
                toGoalIconPos.y = defaultIconY;
                goalIcon.position = toGoalIconPos;
            }
           // Debug.Log("out");
            yield return new WaitForSeconds(0.1f);
        }
    }
    private void Start()
    {
        defaultGoalPos = goalIcon.position;//
        StartCoroutine("DispIcon");
    }
    private void Update()
    {
        if (Input.GetKeyDown(KeyCode.Space))
        {
            ChangePosition();
        }
    }
}
anonymous No title
C#
anonymous No title
C#
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Player : MonoBehaviour
{
	class BulletType
	{
		public enum Types
		{
			Small,
			TwoWay,
			Length
		}

		public GameObject Prefab;
		public Vector2 minOffset;
		public Vector2 maxOffset;

		public BulletType(GameObject prefab, float minOffsetX, float maxOffsetX, float minOffsetY, float maxOffsetY)
		{
			this.Prefab = prefab;
			this.minOffset = new Vector2(minOffsetX, minOffsetY);
			this.maxOffset = new Vector2(maxOffsetX, maxOffsetY);
		}
	}
	BulletType[] BulletTypes;
	BulletType CurrentBulletType;

	void Start()
	{
		InitBulletTypes();
		CurrentBulletType = BulletTypes[(int)BulletType.Types.Small];
	}

	void InitBulletTypes()
	{
		BulletTypes = new BulletType[(int)BulletType.Types.Length];
		BulletTypes[(int)BulletType.Types.Small] = new BulletType((GameObject)Resources.Load("Prefabs/Player_Bullet_Small"), 0.5f, 0.6f, -0.15f, 0.15f);
		BulletTypes[(int)BulletType.Types.TwoWay] = new BulletType((GameObject)Resources.Load("Prefabs/Player_Bullet_2way"), 0.5f, 0.6f, -0.15f, 0.15f);
	}

	void Fire1_Push()
	{
		ShootBullet(CurrentBulletType);
	}

	void ShootBullet( BulletType bullet ){
		Vector3 position = transform.position;
		position += transform.up * Random.Range(bullet.minOffset.y, bullet.maxOffset.y);
		position += transform.right * Random.Range(bullet.minOffset.x, bullet.maxOffset.x);
		Instantiate(bullet.Prefab, transform.position, transform.rotation);
	}
}
Don't you submit code?
Submit
12