Skip to content

Commit

Permalink
Some GUI.
Browse files Browse the repository at this point in the history
  • Loading branch information
tomciokotar committed Sep 17, 2017
1 parent 6b9e884 commit c0a90c0
Show file tree
Hide file tree
Showing 16 changed files with 448 additions and 4 deletions.
31 changes: 27 additions & 4 deletions Assets/ConnectGUI.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using UnityEngine;
using UnityEngine.UI;
using System.Collections;
using KopernikusWrapper;
using AssemblyCSharp;
Expand All @@ -12,6 +13,10 @@ public enum ConnectionState
}

public Renderer cameraDisplay;
public GameObject plane;
public GameObject menuBackground;
public InputField ipInput;
public Button driveBtn;
Texture2D imageTexture;

Vehicle vehicle;
Expand All @@ -23,9 +28,22 @@ public enum ConnectionState
// Use this for initialization
void Start () {
imageTexture = new Texture2D(255, 255);
pedalInputController = new PedalInputController ();
pedalInputController = new PedalInputController();
steeringInputController = new SteeringInputController();
Debug.Log("CREATED");

driveBtn.onClick.AddListener(handleDriveBtnClick);
plane.SetActive(false);
ipInput.text = serverIp;
}

void handleDriveBtnClick () {
if (!isConnected) {
menuBackground.SetActive(false);
plane.SetActive(true);

vehicle = Kopernikus.Instance.Vehicle(ipInput.text);
}
}

// Update is called once per frame
Expand All @@ -36,9 +54,15 @@ void Update () {
{
Debug.Log("VehicleAvailable");
Vehicle.INSTANCE = vehicle;

if (SpriteToggle.INSTANCE != null) {
SpriteToggle.INSTANCE.Appear();
}

if (PedalButton.instance != null) {
PedalButton.instance.Appear();
}

isConnected = true;
}

Expand All @@ -63,7 +87,7 @@ void Update () {
}
}

Rect scaledCenteredRect(float ratioWidth, float ratioHeight, float ratioDx = 0f, float ratioDy = 0f) {
/*Rect scaledCenteredRect(float ratioWidth, float ratioHeight, float ratioDx = 0f, float ratioDy = 0f) {
float width = Screen.width * ratioWidth;
float height = Screen.height * ratioHeight;
float dx = Screen.width * ratioDx;
Expand All @@ -79,7 +103,6 @@ GUIStyle scaledSizeStyle(GUIStyle style) {
void drawServerIpTextField() {
serverIp = GUI.TextField(scaledCenteredRect(0.8f, 0.1f, 0f, -0.3f), serverIp, 25, scaledSizeStyle(GUI.skin.textField));

}
void OnGUI() {
Expand All @@ -89,5 +112,5 @@ void OnGUI() {
vehicle = Kopernikus.Instance.Vehicle(serverIp);
}
}
}
}*/
}
9 changes: 9 additions & 0 deletions Assets/Obrazki.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Obrazki/background.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions Assets/Obrazki/background.jpg.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Obrazki/button-background.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions Assets/Obrazki/button-background.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Binary file added Assets/Obrazki/pedal.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
74 changes: 74 additions & 0 deletions Assets/Obrazki/pedal.png.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

43 changes: 43 additions & 0 deletions Assets/PedalButton.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
using UnityEngine;
using System.Collections;
using KopernikusWrapper;

public class PedalButton : MonoBehaviour {

public Sprite pedal;
private SpriteRenderer spriteRenderer;

public static PedalButton instance;

void Start() {
spriteRenderer = gameObject.GetComponent<SpriteRenderer>();
instance = this;
Debug.Log("pedal button setup");
}

public float GetY() {
return transform.position.y;
}

public void Appear() {
spriteRenderer.enabled = true;
spriteRenderer.sprite = pedal;
}

public void Go(float touchY) {
//transform.position = Vector3.Lerp(transform.position, new Vector3(7, touchY, 0), Time.time);
Vector3 oldPos = transform.position;
float newY = (float)touchY / Screen.height * 10.0f - 5.0f;
oldPos.y = newY;
transform.position = oldPos;
Debug.Log(touchY);
}

/*public void GoUp() {
transform.Translate(Vector3.up * Time.deltaTime * 5);
}
public void GoDown() {
transform.Translate(Vector3.down * Time.deltaTime * 5);
}*/
}
12 changes: 12 additions & 0 deletions Assets/PedalButton.cs.meta

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit c0a90c0

Please sign in to comment.