-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add HAL logo; update text sizes; namespacing
PatHealy
authored and
PatHealy
committed
Apr 11, 2019
1 parent
e321473
commit 930bdd7
Showing
52 changed files
with
3,037 additions
and
1,842 deletions.
There are no files selected for viewing
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,207 @@ | ||
%YAML 1.1 | ||
%TAG !u! tag:unity3d.com,2011: | ||
--- !u!1 &1741977377832216643 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 1741977377832216640} | ||
- component: {fileID: 1741977377832216654} | ||
- component: {fileID: 1741977377832216641} | ||
m_Layer: 0 | ||
m_Name: HAL_Label_Shadow | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!224 &1741977377832216640 | ||
RectTransform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977377832216643} | ||
m_LocalRotation: {x: -0, y: -0, z: -0.0000032708049, w: 1} | ||
m_LocalPosition: {x: 0, y: 0, z: 0} | ||
m_LocalScale: {x: 0.043049738, y: 0.043049738, z: 0.04304975} | ||
m_Children: [] | ||
m_Father: {fileID: 1741977378404311146} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 8.865001} | ||
m_AnchorMin: {x: 0.5, y: 0.5} | ||
m_AnchorMax: {x: 0.5, y: 0.5} | ||
m_AnchoredPosition: {x: -0.30004215, y: -0.23658371} | ||
m_SizeDelta: {x: 277.689, y: 219.389} | ||
m_Pivot: {x: 0.5, y: 0.5} | ||
--- !u!222 &1741977377832216654 | ||
CanvasRenderer: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977377832216643} | ||
m_CullTransparentMesh: 0 | ||
--- !u!114 &1741977377832216641 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977377832216643} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
m_Material: {fileID: 0} | ||
m_Color: {r: 0.31, g: 0.09331, b: 0.09331, a: 1} | ||
m_RaycastTarget: 1 | ||
m_OnCullStateChanged: | ||
m_PersistentCalls: | ||
m_Calls: [] | ||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, | ||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | ||
m_FontData: | ||
m_Font: {fileID: 12800000, guid: d9dc210cd372144a08cdddba18ee856e, type: 3} | ||
m_FontSize: 152 | ||
m_FontStyle: 0 | ||
m_BestFit: 0 | ||
m_MinSize: 10 | ||
m_MaxSize: 163 | ||
m_Alignment: 4 | ||
m_AlignByGeometry: 1 | ||
m_RichText: 1 | ||
m_HorizontalOverflow: 0 | ||
m_VerticalOverflow: 0 | ||
m_LineSpacing: 1 | ||
m_Text: HAL | ||
--- !u!1 &1741977378289287073 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 1741977378289287086} | ||
- component: {fileID: 1741977378289287085} | ||
- component: {fileID: 1741977378289287084} | ||
m_Layer: 0 | ||
m_Name: HAL_Label | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!224 &1741977378289287086 | ||
RectTransform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977378289287073} | ||
m_LocalRotation: {x: -0, y: -0, z: -0.0000032708049, w: 1} | ||
m_LocalPosition: {x: 0, y: 0, z: 0} | ||
m_LocalScale: {x: 0.04305184, y: 0.04305184, z: 0.043051843} | ||
m_Children: [] | ||
m_Father: {fileID: 1741977378404311146} | ||
m_RootOrder: 1 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 8.865001} | ||
m_AnchorMin: {x: 0.5, y: 0.5} | ||
m_AnchorMax: {x: 0.5, y: 0.5} | ||
m_AnchoredPosition: {x: -0, y: 0} | ||
m_SizeDelta: {x: 277.689, y: 219.389} | ||
m_Pivot: {x: 0.5, y: 0.5} | ||
--- !u!222 &1741977378289287085 | ||
CanvasRenderer: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977378289287073} | ||
m_CullTransparentMesh: 0 | ||
--- !u!114 &1741977378289287084 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977378289287073} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
m_Material: {fileID: 0} | ||
m_Color: {r: 1, g: 0, b: 0, a: 1} | ||
m_RaycastTarget: 1 | ||
m_OnCullStateChanged: | ||
m_PersistentCalls: | ||
m_Calls: [] | ||
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, | ||
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null | ||
m_FontData: | ||
m_Font: {fileID: 12800000, guid: d9dc210cd372144a08cdddba18ee856e, type: 3} | ||
m_FontSize: 152 | ||
m_FontStyle: 0 | ||
m_BestFit: 0 | ||
m_MinSize: 10 | ||
m_MaxSize: 163 | ||
m_Alignment: 4 | ||
m_AlignByGeometry: 1 | ||
m_RichText: 1 | ||
m_HorizontalOverflow: 0 | ||
m_VerticalOverflow: 0 | ||
m_LineSpacing: 1 | ||
m_Text: HAL | ||
--- !u!1 &1741977378404311149 | ||
GameObject: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
serializedVersion: 6 | ||
m_Component: | ||
- component: {fileID: 1741977378404311146} | ||
- component: {fileID: 1741977378404311147} | ||
m_Layer: 0 | ||
m_Name: HAL_Logo | ||
m_TagString: Untagged | ||
m_Icon: {fileID: 0} | ||
m_NavMeshLayer: 0 | ||
m_StaticEditorFlags: 0 | ||
m_IsActive: 1 | ||
--- !u!4 &1741977378404311146 | ||
Transform: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977378404311149} | ||
m_LocalRotation: {x: 0, y: 0, z: 0.07728459, w: 0.9970091} | ||
m_LocalPosition: {x: 14.26, y: -11.45, z: 0} | ||
m_LocalScale: {x: 1, y: 1, z: 1} | ||
m_Children: | ||
- {fileID: 1741977377832216640} | ||
- {fileID: 1741977378289287086} | ||
m_Father: {fileID: 0} | ||
m_RootOrder: 0 | ||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 8.865001} | ||
--- !u!114 &1741977378404311147 | ||
MonoBehaviour: | ||
m_ObjectHideFlags: 0 | ||
m_CorrespondingSourceObject: {fileID: 0} | ||
m_PrefabInstance: {fileID: 0} | ||
m_PrefabAsset: {fileID: 0} | ||
m_GameObject: {fileID: 1741977378404311149} | ||
m_Enabled: 1 | ||
m_EditorHideFlags: 0 | ||
m_Script: {fileID: 11500000, guid: 1d87a06ece74c495fa9c2d91990c196a, type: 3} | ||
m_Name: | ||
m_EditorClassIdentifier: | ||
yRange: 0.2 | ||
speed: 0.01 |
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,154 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using CardDirection; | ||
|
||
namespace Actors | ||
{ | ||
public class BallController : MonoBehaviour | ||
{ | ||
enum possession { PLAYER1, PLAYER2, BOTH }; | ||
possession ballpossesssion = possession.PLAYER1; | ||
|
||
public GameObject player1EnglishTarget; | ||
public GameObject player2EnglishTarget; | ||
|
||
// TODO: Implement quirk where both resets pressed forces ball to middle of screen | ||
|
||
const float minMaxSpeed = 0.1f; | ||
const float maxMaxSpeed = 0.5f; | ||
public float full_speed = 5f; | ||
public float ball_english_lag = 10; | ||
|
||
public bool wallBounce = false; | ||
public bool wallExtinguish = false; | ||
public bool playerExtinguish = false; | ||
|
||
public bool resetExtinguishBall = false; | ||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
full_speed /= 10; | ||
if (full_speed > maxMaxSpeed) full_speed = maxMaxSpeed; | ||
if (full_speed < minMaxSpeed) full_speed = minMaxSpeed; | ||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate() | ||
{ | ||
if (!Director.instance.paused) | ||
{ | ||
// Speed is a function of the current position on the screen, running from the full speed value to some fraction of full speed at min | ||
// Makes a modifier as a fraction of the screen, and ensures that 1 <= modifier <= 0.5 (so we never stop) | ||
// Do it as an offset from the left so that the coordinates are always positive | ||
float coordinate_offset_from_left = gameObject.transform.position.x + Screen.width; | ||
float speed_modifier = (coordinate_offset_from_left / Screen.width) / 2 + 0.5f; | ||
// If player 2 has possession of the ball, we have to flip it | ||
if (ballpossesssion == possession.PLAYER2) speed_modifier = speed_modifier * -1; | ||
// If BOTH players have possession, need to set it so that it will go to the center | ||
// Do this by just enabling both behaviours | ||
if (ballpossesssion == possession.BOTH) | ||
{ | ||
if (gameObject.transform.position.x > 0) speed_modifier = speed_modifier * -1; | ||
else if (Mathf.Abs(gameObject.transform.position.x) < 0.05) speed_modifier = 0; | ||
} | ||
|
||
float speed = full_speed * speed_modifier; | ||
float newx = gameObject.transform.position.x + speed; | ||
if (newx > 7) newx = 7; | ||
if (newx < -7) newx = -7; | ||
// Also need to implement it going to the English of P1 and P2 | ||
float tgty = 0f; | ||
if (ballpossesssion == possession.PLAYER1) tgty = player1EnglishTarget.transform.position.y; | ||
if (ballpossesssion == possession.PLAYER2) tgty = player2EnglishTarget.transform.position.y; | ||
if (ballpossesssion == possession.BOTH) tgty = (player1EnglishTarget.transform.position.y + player2EnglishTarget.transform.position.y) / 2; | ||
float oldy = gameObject.transform.position.y; | ||
|
||
// Closes distance in the same way the playerspots do | ||
// Though tbh this doesn't match console behaviour very well, so we'll have to fix it up a little | ||
float newy = (tgty - oldy) / ball_english_lag + gameObject.transform.position.y; | ||
if (Mathf.Abs(newy - oldy) < 0.05) newy = oldy; | ||
|
||
// Now scoot along, little ball | ||
gameObject.transform.position = new Vector3(newx, newy, gameObject.transform.position.z); | ||
|
||
//Debug.Log(ballpossesssion); | ||
} | ||
} | ||
|
||
void swapPossession() | ||
{ | ||
if (ballpossesssion == possession.PLAYER1) | ||
{ | ||
ballpossesssion = possession.PLAYER2; | ||
} | ||
else if (ballpossesssion == possession.PLAYER2) | ||
{ | ||
ballpossesssion = possession.PLAYER1; | ||
} | ||
} | ||
|
||
//called resetButton instead of reset as to not mess with Reset function built into unity | ||
public void resetButton(string player) | ||
{ | ||
if (!((ballpossesssion == possession.PLAYER1 && player.Equals("Player1")) || (ballpossesssion == possession.PLAYER2 && player.Equals("Player2")))) | ||
{ | ||
unExtinguish(); | ||
swapPossession(); | ||
} | ||
if (resetExtinguishBall) | ||
{ | ||
extinguish(); | ||
} | ||
} | ||
|
||
public void resetButtonUp(string player) | ||
{ | ||
unExtinguish(); | ||
} | ||
|
||
void unExtinguish() | ||
{ | ||
gameObject.GetComponent<MeshRenderer>().enabled = true; | ||
gameObject.GetComponent<BoxCollider>().enabled = true; | ||
} | ||
|
||
void extinguish() | ||
{ | ||
gameObject.GetComponent<MeshRenderer>().enabled = false; | ||
gameObject.GetComponent<BoxCollider>().enabled = false; | ||
} | ||
|
||
private void OnTriggerEnter(Collider other) | ||
{ | ||
// Basically when you run into the player, you turn around and the player takes possession | ||
if (other.gameObject.tag == "Player1") | ||
{ | ||
ballpossesssion = possession.PLAYER1; | ||
} | ||
else if (other.gameObject.tag == "Player2") | ||
{ | ||
if (playerExtinguish) | ||
{ | ||
other.gameObject.GetComponent<MeshRenderer>().enabled = false; | ||
} | ||
else | ||
{ | ||
ballpossesssion = possession.PLAYER2; | ||
} | ||
} | ||
else if (other.gameObject.tag == "Wall") | ||
{ | ||
if (wallBounce) | ||
{ | ||
swapPossession(); | ||
} | ||
else if (wallExtinguish) | ||
{ | ||
extinguish(); | ||
} | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using d = CardDirection.Director; | ||
|
||
namespace Actors | ||
{ | ||
public class PlayerCubeController : MonoBehaviour | ||
{ | ||
private Vector3 newPos; | ||
public GameObject tgt; | ||
public float lagfactor; | ||
float normalLag = 10; | ||
float slowLag = 50; | ||
public bool inertia = false; | ||
public bool playerExtinguish = false; | ||
|
||
void FixedUpdate() | ||
{ | ||
if (!d.instance.paused) | ||
{ | ||
if (inertia) | ||
{ | ||
lagfactor = slowLag; | ||
} | ||
else | ||
{ | ||
lagfactor = normalLag; | ||
} | ||
|
||
float tgtx = tgt.transform.position.x; | ||
float tgty = tgt.transform.position.y; | ||
|
||
// Goes 1/8 of the distance to the target (hopefully will have some lag) | ||
// Also if the target distance is pretty close, stop moving. Close enough counts in horseshoes, hand grenades, and the Magnavox Odyssey | ||
float oldx = gameObject.transform.position.x; | ||
float destx = (tgtx - oldx) / lagfactor + gameObject.transform.position.x; | ||
//if (Mathf.Abs(oldx - destx) < 0.05) destx = oldx; | ||
|
||
float oldy = gameObject.transform.position.y; | ||
float desty = (tgty - oldy) / lagfactor + gameObject.transform.position.y; | ||
//if (Mathf.Abs(oldy - desty) < 0.05) desty = oldy; | ||
newPos = new Vector3(destx, desty, gameObject.transform.position.z); | ||
gameObject.transform.SetPositionAndRotation(newPos, gameObject.transform.rotation); | ||
} | ||
} | ||
|
||
private void OnTriggerEnter(Collider other) | ||
{ | ||
if (other.gameObject.tag == "Player1") | ||
{ | ||
if (playerExtinguish) | ||
{ | ||
extinguish(); | ||
} | ||
} | ||
} | ||
|
||
void unExtinguish() | ||
{ | ||
gameObject.GetComponent<MeshRenderer>().enabled = true; | ||
gameObject.GetComponent<BoxCollider>().enabled = true; | ||
} | ||
|
||
void extinguish() | ||
{ | ||
gameObject.GetComponent<MeshRenderer>().enabled = false; | ||
gameObject.GetComponent<BoxCollider>().enabled = false; | ||
} | ||
} | ||
} |
File renamed without changes.
229 changes: 229 additions & 0 deletions
229
OdysseyNow/Assets/Scripts/Actors/PlayerTargetController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,229 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using InControl; | ||
using System; | ||
using CardDirection; | ||
using HardwareInterface; | ||
|
||
namespace Actors | ||
{ | ||
public class PlayerTargetController : MonoBehaviour | ||
{ | ||
public GameObject playerCube; | ||
public float startx, starty; | ||
public float speed = 5f; | ||
public KeyCode up, down, left, right, reset; | ||
public bool resetExtinguish; | ||
int player; | ||
|
||
InputDevice con; | ||
|
||
private void Start() | ||
{ | ||
player = 1; | ||
switch (gameObject.tag) | ||
{ | ||
case "Player1": | ||
player = 1; | ||
break; | ||
case "Player2": | ||
player = 2; | ||
break; | ||
case "Player1English": | ||
player = 3; | ||
break; | ||
case "Player2English": | ||
player = 4; | ||
break; | ||
} | ||
|
||
ConnectController(); | ||
} | ||
|
||
void ConnectController() | ||
{ | ||
try | ||
{ | ||
con = InputManager.ActiveDevices[(player - 1) % 2]; | ||
} | ||
catch (Exception e) | ||
{ | ||
//Debug.Log(e.Message); | ||
//Debug.Log("Missing gamepad: " + ((player - 1) % 2)); | ||
} | ||
} | ||
|
||
int GetControlScheme() | ||
{ | ||
LocalInputManager.ControlScheme scheme = LocalInputManager.ControlScheme.Keyboard; | ||
|
||
if (player == 1 || player == 3) | ||
{ | ||
scheme = LocalInputManager.instance.p1Scheme; | ||
} | ||
else if (player == 2 || player == 4) | ||
{ | ||
scheme = LocalInputManager.instance.p2Scheme; | ||
} | ||
|
||
switch (scheme) | ||
{ | ||
case LocalInputManager.ControlScheme.Keyboard: | ||
return 0; | ||
case LocalInputManager.ControlScheme.Traditional: | ||
return 1; | ||
case LocalInputManager.ControlScheme.OdysseyCon: | ||
return 2; | ||
case LocalInputManager.ControlScheme.OriginalConsole: | ||
return 3; | ||
case LocalInputManager.ControlScheme.AI: | ||
return 4; | ||
} | ||
|
||
return 0; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
if (InputManager.ActiveDevices.Count > 0 && con == null) | ||
{ | ||
ConnectController(); | ||
} | ||
|
||
if (!Director.instance.paused) | ||
{ | ||
if (GetControlScheme() == 0) | ||
{ | ||
//player target & english control for keyboard controls | ||
float x = gameObject.transform.position.x; | ||
float y = gameObject.transform.position.y; | ||
|
||
float adjustedspeed = speed / 10; | ||
|
||
if (Input.GetKey(up) && y < 6) | ||
{ | ||
y += adjustedspeed; | ||
} | ||
if (Input.GetKey(down) && y > -6) | ||
{ | ||
y -= adjustedspeed; | ||
} | ||
if (Input.GetKey(left) && x > -8) | ||
{ | ||
x -= adjustedspeed; | ||
} | ||
if (Input.GetKey(right) && x < 8) | ||
{ | ||
x += adjustedspeed; | ||
} | ||
|
||
gameObject.transform.position = new Vector3(x, y, gameObject.transform.position.z); | ||
|
||
if (Input.GetKeyDown(reset)) | ||
{ | ||
ResetButtonDown(); | ||
} | ||
|
||
if (Input.GetKeyUp(reset)) | ||
{ | ||
ResetButtonUp(); | ||
} | ||
} | ||
|
||
else if (GetControlScheme() == 1 && player < 3) | ||
{ | ||
//Player target controll for traditional gamepad | ||
try | ||
{ | ||
if (Math.Abs(con.LeftStickX.RawValue) < 0.05f || Math.Abs(con.LeftStickY.RawValue) < 0.05f || Math.Abs(con.RightStickX.RawValue) < 0.05f) | ||
{ | ||
gameObject.transform.position = new Vector3(10 * con.LeftStickX.RawValue, 10 * con.LeftStickY.RawValue, transform.position.z); | ||
} | ||
else | ||
{ | ||
gameObject.transform.position = new Vector3(10 * con.ReadRawAnalogValue(0), -10 * con.ReadRawAnalogValue(1), transform.position.z); | ||
} | ||
|
||
if (con.Action1.WasPressed) | ||
{ | ||
print("Blah!!!"); | ||
ResetButtonDown(); | ||
} | ||
|
||
if (con.Action2.WasReleased) | ||
{ | ||
print("Up!!!"); | ||
ResetButtonUp(); | ||
} | ||
} | ||
catch (Exception e) { } | ||
} | ||
|
||
else if (GetControlScheme() == 1) | ||
{ | ||
//Control for english with gamepad | ||
try | ||
{ | ||
if (con.RightStickX.RawValue != 0) | ||
{ | ||
gameObject.transform.position = new Vector3(transform.position.x, 6 * con.RightStickX.RawValue, transform.position.z); | ||
} | ||
else | ||
{ | ||
gameObject.transform.position = new Vector3(transform.position.x, -6 * con.ReadRawAnalogValue(3), transform.position.z); | ||
} | ||
} | ||
catch (Exception e) { } | ||
} | ||
|
||
else if (GetControlScheme() == 2 && player < 3) | ||
{ | ||
//control for player target with OdysseyCon | ||
} | ||
else if (GetControlScheme() == 3 && player < 3) | ||
{ | ||
ConsoleMirror.instance.pluggedIn = true; | ||
if (player == 1) | ||
{ | ||
ConsoleMirror.instance.p1Console = true; | ||
} | ||
if (player == 2) | ||
{ | ||
ConsoleMirror.instance.p2Console = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
private void ResetButtonDown() | ||
{ | ||
if (resetExtinguish) | ||
{ | ||
extinguish(); | ||
} | ||
GameObject.FindWithTag("Ball").GetComponent<BallController>().resetButton(gameObject.tag); | ||
} | ||
|
||
private void ResetButtonUp() | ||
{ | ||
GameObject.FindWithTag("Ball").GetComponent<BallController>().resetButtonUp(gameObject.tag); | ||
unExtinguish(); | ||
if (gameObject.CompareTag("Player1")) | ||
ConsoleMirror.instance.p1Reset(); | ||
} | ||
|
||
void unExtinguish() | ||
{ | ||
playerCube.GetComponent<MeshRenderer>().enabled = true; | ||
playerCube.GetComponent<BoxCollider>().enabled = true; | ||
} | ||
|
||
void extinguish() | ||
{ | ||
playerCube.GetComponent<MeshRenderer>().enabled = false; | ||
playerCube.GetComponent<BoxCollider>().enabled = false; | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Actors | ||
{ | ||
public class WallBehavior : MonoBehaviour | ||
{ | ||
float yTall = 0f; | ||
float yShort = -5f; | ||
|
||
float xMid = 0f; | ||
float xLeft = -5f; | ||
float xRight = 5f; | ||
|
||
float x; | ||
float y; | ||
float z; | ||
|
||
public float xOffset; | ||
|
||
private void Start() | ||
{ | ||
x = xMid; | ||
y = yTall; | ||
z = transform.position.z; | ||
xOffset = 0; | ||
} | ||
|
||
private void Update() | ||
{ | ||
updatePosition(); | ||
} | ||
|
||
void updatePosition() | ||
{ | ||
transform.position = new Vector3(x + xOffset, y, z); | ||
} | ||
|
||
public void setHeight(float height) | ||
{ | ||
if (height == 1) | ||
{ | ||
y = yTall; | ||
} | ||
else if (height == 0) | ||
{ | ||
y = yShort; | ||
} | ||
} | ||
|
||
public void setHorizontal(float horizontal) | ||
{ | ||
if (horizontal == 0) | ||
{ | ||
x = xLeft; | ||
} | ||
else if (horizontal == 1) | ||
{ | ||
x = xMid; | ||
} | ||
else if (horizontal == 2) | ||
{ | ||
x = xRight; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
76 changes: 40 additions & 36 deletions
76
OdysseyNow/Assets/Scripts/BOTbehavior/BOTCubeController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,45 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using d = Director; | ||
|
||
public class BOTCubeController : MonoBehaviour { | ||
|
||
private Vector3 newPos; | ||
public GameObject tgt; | ||
static public int lagfactor = 5; | ||
static private float offset = 0; | ||
|
||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
using d = CardDirection.Director; | ||
|
||
namespace BOT | ||
{ | ||
public class BOTCubeController : MonoBehaviour | ||
{ | ||
|
||
private Vector3 newPos; | ||
public GameObject tgt; | ||
static public int lagfactor = 5; | ||
static private float offset = 0; | ||
|
||
|
||
// Use this for initialization | ||
void Start() | ||
{ | ||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate() | ||
{ | ||
if (!d.instance.paused) | ||
{ | ||
float tgtx = tgt.transform.position.x; | ||
float tgty = tgt.transform.position.y; | ||
|
||
// Goes 1/8 of the distance to the target (hopefully will have some lag) | ||
// Also if the target distance is pretty close, stop moving. Close enough counts in horseshoes, hand grenades, and the Magnavox Odyssey | ||
float oldx = gameObject.transform.position.x; | ||
float destx = (tgtx - oldx) / lagfactor + gameObject.transform.position.x; | ||
if (Mathf.Abs(oldx - destx) < 0.05) destx = oldx; | ||
|
||
float oldy = gameObject.transform.position.y; | ||
float desty = (tgty - oldy) / lagfactor + gameObject.transform.position.y; | ||
if (Mathf.Abs(oldy - desty) < 0.05) desty = oldy; | ||
newPos = new Vector3(destx, desty + offset, gameObject.transform.position.z); | ||
gameObject.transform.SetPositionAndRotation(newPos, gameObject.transform.rotation); | ||
} | ||
} | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void FixedUpdate() | ||
{ | ||
if (!d.instance.paused) | ||
{ | ||
float tgtx = tgt.transform.position.x; | ||
float tgty = tgt.transform.position.y; | ||
|
||
// Goes 1/8 of the distance to the target (hopefully will have some lag) | ||
// Also if the target distance is pretty close, stop moving. Close enough counts in horseshoes, hand grenades, and the Magnavox Odyssey | ||
float oldx = gameObject.transform.position.x; | ||
float destx = (tgtx - oldx) / lagfactor + gameObject.transform.position.x; | ||
if (Mathf.Abs(oldx - destx) < 0.05) destx = oldx; | ||
|
||
float oldy = gameObject.transform.position.y; | ||
float desty = (tgty - oldy) / lagfactor + gameObject.transform.position.y; | ||
if (Mathf.Abs(oldy - desty) < 0.05) desty = oldy; | ||
newPos = new Vector3(destx, desty+offset, gameObject.transform.position.z); | ||
gameObject.transform.SetPositionAndRotation(newPos, gameObject.transform.rotation); | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
using System.Collections; | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
|
||
namespace CardDirection | ||
{ | ||
public class Director : MonoBehaviour | ||
{ | ||
public static Director instance; | ||
public bool paused = false; | ||
public GameObject menu; | ||
public GameObject plainMenu; | ||
public int cardNumber; | ||
|
||
public enum ControlScheme { Keyboard, Traditional, OdysseyCon }; | ||
public ControlScheme p1Scheme = ControlScheme.Keyboard; | ||
public ControlScheme p2Scheme = ControlScheme.Keyboard; | ||
|
||
private void Awake() | ||
{ | ||
if (Director.instance != null) | ||
{ | ||
Destroy(gameObject); | ||
} | ||
else | ||
{ | ||
instance = this; | ||
} | ||
} | ||
|
||
/* For reference: | ||
* public void UpdateAll( | ||
* bool _secondPlayer, | ||
* bool _includeBall, | ||
* bool _includeWall, | ||
* int _wallPosition: 0, 1, 2 | ||
* int _wallHeight: 0, 1 | ||
* string _wallBallCollision : Pass, Extinguish, None | ||
* string _p1P2Collision : None, Extinguish | ||
* string _p2BallCollision : Bounce, Extinguish | ||
* bool _p2Inertia, | ||
* string _onResetExtinguish : None, P1 & P2, P2. Ball | ||
* ) | ||
*/ | ||
|
||
private void Start() | ||
{ | ||
switch (cardNumber) | ||
{ | ||
case 1: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, true, 1, 1, "Pass", "None", "Bounce", false, "None"); | ||
break; | ||
case 2: | ||
menu.GetComponent<MenuDirector>().UpdateAll(false, false, false, 1, 1, "Pass", "None", "Bounce", false, "None"); | ||
break; | ||
case 3: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, false, 1, 1, "Pass", "None", "Bounce", false, "None"); | ||
break; | ||
case 4: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, false, false, 1, 1, "Pass", "Extinguish", "Bounce", false, "P2"); | ||
break; | ||
case 5: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, false, 1, 1, "Pass", "None", "Extinguish", false, "P2"); | ||
break; | ||
case 6: | ||
menu.GetComponent<MenuDirector>().UpdateAll(false, false, false, 1, 1, "Pass", "None", "Bounce", true, "None"); | ||
break; | ||
case 7: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, true, 1, 0, "Extinguish", "None", "Bounce", false, "Ball"); | ||
break; | ||
case 8: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, true, 0, 1, "Bounce", "None", "Bounce", false, "None"); | ||
break; | ||
case 9: | ||
menu.GetComponent<MenuDirector>().UpdateAll(false, false, false, 1, 1, "Pass", "None", "Bounce", false, "P2"); | ||
break; | ||
case 10: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, false, 1, 1, "Pass", "None", "Bounce", false, "Ball"); | ||
break; | ||
case 11: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, true, 0, 1, "Bounce", "None", "Bounce", false, "None"); | ||
break; | ||
case 12: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, false, false, 1, 1, "Pass", "Extinguish", "Bounce", true, "P2"); | ||
break; | ||
case 13: | ||
//TODO - implement the weird stuff this card does | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, true, 0, 1, "Bounce", "None", "Bounce", false, "None"); | ||
break; | ||
case 14: | ||
//TODO - implement the weird stuff this card does | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, true, 1, 1, "Pass", "None", "Bounce", false, "None"); | ||
break; | ||
case 15: | ||
//TODO - implement the weird stuff this card does | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, true, false, 1, 1, "Pass", "None", "Bounce", true, "None"); | ||
break; | ||
case 16: | ||
menu.GetComponent<MenuDirector>().UpdateAll(true, false, false, 1, 1, "Pass", "None", "Bounce", false, "P1 & P2"); | ||
break; | ||
} | ||
menu.SetActive(false); | ||
if (cardNumber > 0) | ||
{ | ||
menu = plainMenu; | ||
} | ||
|
||
if (ElementSettings.instance != null) | ||
{ | ||
ElementSettings.instance.updateAllSizes(); | ||
} | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
if (Input.GetKeyDown(KeyCode.Escape)) | ||
{ | ||
accessMenu(); | ||
} | ||
} | ||
|
||
public void accessMenu() | ||
{ | ||
paused = !paused; | ||
menu.SetActive(paused); | ||
} | ||
|
||
public void MainMenu() | ||
{ | ||
SceneManager.LoadScene("MainMenu"); | ||
} | ||
|
||
public void UpdateControls(int player, string scheme) | ||
{ | ||
|
||
} | ||
} | ||
} |
File renamed without changes.
103 changes: 103 additions & 0 deletions
103
OdysseyNow/Assets/Scripts/CardDirection/ElementSettings.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace CardDirection | ||
{ | ||
public class ElementSettings : MonoBehaviour | ||
{ | ||
public static ElementSettings instance; | ||
public float p1Size; | ||
public float p2Size; | ||
public float wallSize; | ||
public float ballSize; | ||
|
||
private void Awake() | ||
{ | ||
p1Size = 1f; | ||
p2Size = 1f; | ||
wallSize = 0.5f; | ||
ballSize = 0.5f; | ||
|
||
if (instance != null) | ||
{ | ||
p1Size = instance.p1Size; | ||
p2Size = instance.p2Size; | ||
wallSize = instance.wallSize; | ||
ballSize = instance.ballSize; | ||
Destroy(instance.gameObject); | ||
} | ||
|
||
instance = this; | ||
DontDestroyOnLoad(gameObject); | ||
} | ||
|
||
GameObject FindFromNameAndTag(string name, string tag) | ||
{ | ||
GameObject[] withTag = GameObject.FindGameObjectsWithTag(tag); | ||
for (int i = 0; i < withTag.Length; i++) | ||
{ | ||
if (withTag[i].name.Equals(name)) | ||
{ | ||
return withTag[i]; | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public void updateAllSizes() | ||
{ | ||
GameObject p1 = FindFromNameAndTag("PlayerBody", "Player1"); | ||
p1.transform.localScale = new Vector3(p1Size, p1Size, p1Size); | ||
|
||
GameObject p2 = FindFromNameAndTag("PlayerBody", "Player2"); | ||
p2.transform.localScale = new Vector3(p2Size, p2Size, p2Size); | ||
|
||
GameObject wall = FindFromNameAndTag("Wall", "Wall"); | ||
wall.transform.localScale = new Vector3(wallSize, wall.transform.localScale.y, wallSize); | ||
|
||
GameObject ball = FindFromNameAndTag("Ball", "Ball"); | ||
ball.transform.localScale = new Vector3(ballSize, ballSize, ballSize); | ||
} | ||
|
||
public void setAllSizes() | ||
{ | ||
float masterSize = GameObject.Find("OverallSize").GetComponent<Slider>().value; | ||
GameObject.Find("P1Size").GetComponent<Slider>().value = masterSize; | ||
GameObject.Find("P2Size").GetComponent<Slider>().value = masterSize; | ||
GameObject.Find("WallSize").GetComponent<Slider>().value = masterSize; | ||
GameObject.Find("BallSize").GetComponent<Slider>().value = masterSize; | ||
|
||
p1Size = GameObject.Find("P1Size").GetComponent<Slider>().value / 15.0f; | ||
p2Size = GameObject.Find("P2Size").GetComponent<Slider>().value / 15.0f; | ||
wallSize = GameObject.Find("WallSize").GetComponent<Slider>().value / 30.0f; | ||
ballSize = GameObject.Find("BallSize").GetComponent<Slider>().value / 30.0f; | ||
updateAllSizes(); | ||
} | ||
|
||
public void setP1Size() | ||
{ | ||
p1Size = GameObject.Find("P1Size").GetComponent<Slider>().value / 15.0f; | ||
updateAllSizes(); | ||
} | ||
|
||
public void setP2Size() | ||
{ | ||
p2Size = GameObject.Find("P2Size").GetComponent<Slider>().value / 15.0f; | ||
updateAllSizes(); | ||
} | ||
|
||
public void setWallSize() | ||
{ | ||
wallSize = GameObject.Find("WallSize").GetComponent<Slider>().value / 30.0f; | ||
updateAllSizes(); | ||
} | ||
|
||
public void setBallSize() | ||
{ | ||
ballSize = GameObject.Find("BallSize").GetComponent<Slider>().value / 30.0f; | ||
updateAllSizes(); | ||
} | ||
} | ||
} |
File renamed without changes.
148 changes: 148 additions & 0 deletions
148
OdysseyNow/Assets/Scripts/CardDirection/LocalInputManager.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,148 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
|
||
namespace CardDirection | ||
{ | ||
public class LocalInputManager : MonoBehaviour | ||
{ | ||
public static LocalInputManager instance; | ||
public enum ControlScheme { Keyboard, Traditional, OdysseyCon, OriginalConsole, AI }; | ||
public ControlScheme p1Scheme = ControlScheme.Keyboard; | ||
public ControlScheme p2Scheme = ControlScheme.Keyboard; | ||
|
||
GameObject p1Option; | ||
GameObject p2Option; | ||
|
||
private void Awake() | ||
{ | ||
if (LocalInputManager.instance != null) | ||
{ | ||
Destroy(gameObject); | ||
} | ||
else | ||
{ | ||
instance = this; | ||
DontDestroyOnLoad(gameObject); | ||
} | ||
} | ||
|
||
public void Init() | ||
{ | ||
StartCoroutine(InitSoon()); | ||
} | ||
|
||
IEnumerator InitSoon() | ||
{ | ||
yield return new WaitForSeconds(1f); | ||
InitialControls(); | ||
} | ||
|
||
void InitialControls() | ||
{ | ||
if (p1Option == null || p2Option == null) | ||
{ | ||
p1Option = GameObject.Find("P1ControllerDropdown"); | ||
p2Option = GameObject.Find("P2ControllerDropdown"); | ||
|
||
if (p1Option == null || p2Option == null) | ||
{ | ||
Debug.Log("Trouble initing!"); | ||
Init(); | ||
return; | ||
} | ||
} | ||
|
||
switch (p1Scheme) | ||
{ | ||
case ControlScheme.Keyboard: | ||
p1Option.GetComponent<Dropdown>().value = 0; | ||
break; | ||
case ControlScheme.Traditional: | ||
p1Option.GetComponent<Dropdown>().value = 1; | ||
break; | ||
case ControlScheme.OdysseyCon: | ||
p1Option.GetComponent<Dropdown>().value = 2; | ||
break; | ||
case ControlScheme.OriginalConsole: | ||
p1Option.GetComponent<Dropdown>().value = 3; | ||
break; | ||
case ControlScheme.AI: | ||
p1Option.GetComponent<Dropdown>().value = 4; | ||
break; | ||
} | ||
|
||
switch (p2Scheme) | ||
{ | ||
case ControlScheme.Keyboard: | ||
p2Option.GetComponent<Dropdown>().value = 0; | ||
break; | ||
case ControlScheme.Traditional: | ||
p2Option.GetComponent<Dropdown>().value = 1; | ||
break; | ||
case ControlScheme.OdysseyCon: | ||
p2Option.GetComponent<Dropdown>().value = 2; | ||
break; | ||
case ControlScheme.OriginalConsole: | ||
p2Option.GetComponent<Dropdown>().value = 3; | ||
break; | ||
case ControlScheme.AI: | ||
p2Option.GetComponent<Dropdown>().value = 4; | ||
break; | ||
} | ||
} | ||
|
||
private void OnDestroy() | ||
{ | ||
LocalInputManager.instance.Init(); | ||
} | ||
|
||
public void UpdateControls() | ||
{ | ||
if (p1Option == null || p2Option == null) | ||
{ | ||
p1Option = GameObject.Find("P1ControllerDropdown"); | ||
p2Option = GameObject.Find("P2ControllerDropdown"); | ||
} | ||
|
||
switch (p1Option.GetComponent<Dropdown>().value) | ||
{ | ||
case 0: | ||
p1Scheme = ControlScheme.Keyboard; | ||
break; | ||
case 1: | ||
p1Scheme = ControlScheme.Traditional; | ||
break; | ||
case 2: | ||
p1Scheme = ControlScheme.Keyboard; | ||
break; | ||
case 3: | ||
p1Scheme = ControlScheme.OriginalConsole; | ||
break; | ||
case 4: | ||
p1Scheme = ControlScheme.AI; | ||
break; | ||
} | ||
|
||
switch (p2Option.GetComponent<Dropdown>().value) | ||
{ | ||
case 0: | ||
p2Scheme = ControlScheme.Keyboard; | ||
break; | ||
case 1: | ||
p2Scheme = ControlScheme.Traditional; | ||
break; | ||
case 2: | ||
p2Scheme = ControlScheme.Keyboard; | ||
break; | ||
case 3: | ||
p2Scheme = ControlScheme.OriginalConsole; | ||
break; | ||
case 4: | ||
p2Scheme = ControlScheme.AI; | ||
break; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
244 changes: 244 additions & 0 deletions
244
OdysseyNow/Assets/Scripts/CardDirection/MenuDirector.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,244 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using Actors; | ||
|
||
namespace CardDirection | ||
{ | ||
public class MenuDirector : MonoBehaviour | ||
{ | ||
bool secondPlayer = true; | ||
bool includeBall = true; | ||
bool includeWall = true; | ||
int wallPosition = 1; | ||
int wallHeight = 1; | ||
string wallBallCollision = "Pass"; | ||
string p1P2Collision = "None"; | ||
string p2BallCollision = "Bounce"; | ||
bool p2Inertia = false; | ||
string onResetExtinguish = "None"; | ||
|
||
public GameObject p1; | ||
public GameObject p2; | ||
public PlayerTargetController p1Target; | ||
public PlayerTargetController p2Target; | ||
public GameObject ball; | ||
public GameObject wall; | ||
|
||
public void UpdateAll() | ||
{ | ||
//UpdateSecondPlayer | ||
p1.SetActive(secondPlayer); | ||
//UpdateIncludeBall | ||
ball.SetActive(includeBall); | ||
//UpdateIncludeWall | ||
wall.SetActive(includeWall); | ||
//UpdateWallPosition | ||
wall.GetComponent<WallBehavior>().setHorizontal(wallPosition); | ||
//UpdateWallHeight | ||
wall.GetComponent<WallBehavior>().setHeight(wallHeight); | ||
//UpdateWallBallCollision | ||
BallController b = ball.GetComponent<BallController>(); | ||
if (wallBallCollision.Equals("Pass")) | ||
{ | ||
b.wallBounce = false; | ||
b.wallExtinguish = false; | ||
} | ||
else if (wallBallCollision.Equals("Extinguish")) | ||
{ | ||
b.wallBounce = false; | ||
b.wallExtinguish = true; | ||
} | ||
else if (wallBallCollision.Equals("Bounce")) | ||
{ | ||
b.wallBounce = true; | ||
b.wallExtinguish = false; | ||
} | ||
//UpdateP1P2Collision | ||
PlayerCubeController p = p2.GetComponentInChildren<PlayerCubeController>(); | ||
if (p1P2Collision.Equals("None")) | ||
{ | ||
p.playerExtinguish = false; | ||
} | ||
else if (p1P2Collision.Equals("Extinguish")) | ||
{ | ||
p.playerExtinguish = true; | ||
} | ||
//UpdateP2BallCollision | ||
if (p2BallCollision.Equals("Bounce")) | ||
{ | ||
b.playerExtinguish = false; | ||
} | ||
else if (p2BallCollision.Equals("Extinguish")) | ||
{ | ||
b.playerExtinguish = true; | ||
} | ||
//UpdateP2Inertia | ||
p2.GetComponent<PlayerCubeController>().inertia = p2Inertia; | ||
//UpdateOnResetExtinguish | ||
if (onResetExtinguish.Equals("None")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = false; | ||
p1Target.resetExtinguish = false; | ||
p2Target.resetExtinguish = false; | ||
} | ||
else if (onResetExtinguish.Equals("P1 & P2")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = false; | ||
p1Target.resetExtinguish = true; | ||
p2Target.resetExtinguish = true; | ||
} | ||
else if (onResetExtinguish.Equals("P2")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = false; | ||
p1Target.resetExtinguish = false; | ||
p2Target.resetExtinguish = true; | ||
} | ||
else if (onResetExtinguish.Equals("Ball")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = true; | ||
p1Target.resetExtinguish = false; | ||
p2Target.resetExtinguish = false; | ||
} | ||
} | ||
|
||
public void UpdateAll(bool _secondPlayer, bool _includeBall, bool _includeWall, int _wallPosition, int _wallHeight, string _wallBallCollision, string _p1P2Collision, string _p2BallCollision, bool _p2Inertia, string _onResetExtinguish) | ||
{ | ||
secondPlayer = _secondPlayer; | ||
includeBall = _includeBall; | ||
includeWall = _includeBall; | ||
wallPosition = _wallPosition; | ||
wallHeight = _wallHeight; | ||
wallBallCollision = _wallBallCollision; | ||
p1P2Collision = _p1P2Collision; | ||
p2BallCollision = _p2BallCollision; | ||
p2Inertia = _p2Inertia; | ||
onResetExtinguish = _onResetExtinguish; | ||
UpdateAll(); | ||
} | ||
|
||
void RemoveOptions() | ||
{ | ||
|
||
} | ||
|
||
/* The following methods update card variables. | ||
* These methods are called by the UI elements in the menu. | ||
*/ | ||
|
||
public void UpdateSecondPlayer(Toggle tg) | ||
{ | ||
secondPlayer = tg.isOn; | ||
p1.SetActive(secondPlayer); | ||
} | ||
|
||
public void UpdateIncludeBall(Toggle tg) | ||
{ | ||
includeBall = tg.isOn; | ||
ball.SetActive(includeBall); | ||
} | ||
|
||
public void UpdateIncludeWall(Toggle tg) | ||
{ | ||
includeWall = tg.isOn; | ||
wall.SetActive(includeWall); | ||
} | ||
|
||
public void UpdateWallPosition(Slider sl) | ||
{ | ||
wallPosition = (int)sl.value; | ||
wall.GetComponent<WallBehavior>().setHorizontal(wallPosition); | ||
} | ||
|
||
public void UpdateWallHeight(Slider sl) | ||
{ | ||
wallHeight = (int)sl.value; | ||
wall.GetComponent<WallBehavior>().setHeight(wallHeight); | ||
} | ||
|
||
public void UpdateWallBallCollision(Dropdown dr) | ||
{ | ||
wallBallCollision = dr.options[dr.value].text; | ||
BallController b = ball.GetComponent<BallController>(); | ||
if (wallBallCollision.Equals("Pass")) | ||
{ | ||
b.wallBounce = false; | ||
b.wallExtinguish = false; | ||
} | ||
else if (wallBallCollision.Equals("Extinguish")) | ||
{ | ||
b.wallBounce = false; | ||
b.wallExtinguish = true; | ||
} | ||
else if (wallBallCollision.Equals("Bounce")) | ||
{ | ||
b.wallBounce = true; | ||
b.wallExtinguish = false; | ||
} | ||
} | ||
|
||
public void UpdateP1P2Collision(Dropdown dr) | ||
{ | ||
p1P2Collision = dr.options[dr.value].text; | ||
PlayerCubeController p = p2.GetComponentInChildren<PlayerCubeController>(); | ||
if (p1P2Collision.Equals("None")) | ||
{ | ||
p.playerExtinguish = false; | ||
} | ||
else if (p1P2Collision.Equals("Extinguish")) | ||
{ | ||
p.playerExtinguish = true; | ||
} | ||
} | ||
|
||
public void UpdateP2BallCollision(Dropdown dr) | ||
{ | ||
p2BallCollision = dr.options[dr.value].text; | ||
BallController b = ball.GetComponent<BallController>(); | ||
if (p2BallCollision.Equals("Bounce")) | ||
{ | ||
b.playerExtinguish = false; | ||
} | ||
else if (p2BallCollision.Equals("Extinguish")) | ||
{ | ||
b.playerExtinguish = true; | ||
} | ||
} | ||
|
||
public void UpdateP2Inertia(Toggle tg) | ||
{ | ||
p2Inertia = tg.isOn; | ||
p2.GetComponent<PlayerCubeController>().inertia = p2Inertia; | ||
} | ||
|
||
public void UpdateOnResetExtinguish(Dropdown dr) | ||
{ | ||
onResetExtinguish = dr.options[dr.value].text; | ||
if (onResetExtinguish.Equals("None")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = false; | ||
p1Target.resetExtinguish = false; | ||
p2Target.resetExtinguish = false; | ||
} | ||
else if (onResetExtinguish.Equals("P1 & P2")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = false; | ||
p1Target.resetExtinguish = true; | ||
p2Target.resetExtinguish = true; | ||
} | ||
else if (onResetExtinguish.Equals("P2")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = false; | ||
p1Target.resetExtinguish = false; | ||
p2Target.resetExtinguish = true; | ||
} | ||
else if (onResetExtinguish.Equals("Ball")) | ||
{ | ||
ball.GetComponent<BallController>().resetExtinguishBall = true; | ||
p1Target.resetExtinguish = false; | ||
p2Target.resetExtinguish = false; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace Graphics | ||
{ | ||
|
||
public class HoverText : MonoBehaviour | ||
{ | ||
float startY; | ||
public float yRange; | ||
public float speed; | ||
bool goUp; | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
startY = transform.position.y; | ||
goUp = true; | ||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
float tempSpeed; | ||
if (goUp) | ||
{ | ||
tempSpeed = speed * ((startY + yRange) - transform.position.y); | ||
if (tempSpeed <= speed * 0.4f) | ||
tempSpeed = speed * 0.4f; | ||
|
||
transform.Translate(tempSpeed * transform.up); | ||
if (transform.position.y > (startY + yRange)) | ||
{ | ||
goUp = false; | ||
} | ||
} | ||
else | ||
{ | ||
tempSpeed = speed * (transform.position.y - (startY - yRange)); | ||
if (tempSpeed <= speed * 0.4f) | ||
tempSpeed = speed * 0.4f; | ||
|
||
transform.Translate(-tempSpeed * transform.up); | ||
if (transform.position.y < (startY - yRange)) | ||
{ | ||
goUp = true; | ||
} | ||
} | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
using UnityEngine.UI; | ||
|
||
namespace Graphics | ||
{ | ||
public class MenuButtonBehavior : MonoBehaviour | ||
{ | ||
public bool load; | ||
public GameObject otherMenu; | ||
|
||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
gameObject.GetComponent<Button>().onClick.AddListener(ButtonClicked); | ||
} | ||
|
||
|
||
|
||
void ButtonClicked() | ||
{ | ||
if (load) | ||
{ | ||
SceneManager.LoadScene(gameObject.name.Replace(" ", "")); | ||
} | ||
else if (otherMenu != null) | ||
{ | ||
otherMenu.SetActive(true); | ||
transform.parent.gameObject.SetActive(false); | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
using UnityEngine.UI; | ||
using UnityEngine.SceneManagement; | ||
|
||
namespace Graphics | ||
{ | ||
public class SceneLabelBehavior : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
gameObject.GetComponent<Text>().text = SceneManager.GetActiveScene().name.Replace("Card", "Card "); | ||
} | ||
} | ||
} | ||
|
File renamed without changes.
Oops, something went wrong.
10 changes: 10 additions & 0 deletions
10
OdysseyNow/Assets/Scripts/HardwareInterface/ConsoleData.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using UnityEngine; | ||
|
||
namespace HardwareInterface | ||
{ | ||
[System.Serializable] | ||
public class ConsoleData | ||
{ | ||
public float P1_X_READ, P1_Y_READ, P2_X_READ, P2_Y_READ, P3_X_READ, P3_Y_READ, P4_X_READ, P4_Y_READ, BALL_X_READ, BALL_Y_READ, WALL_X_READ, NOT_ENGLISH_WEAK_Q_READ, NOT_BALL_WEAK_Q_READ, NOT_CROWBAR_READ; | ||
} | ||
} |
File renamed without changes.
124 changes: 124 additions & 0 deletions
124
OdysseyNow/Assets/Scripts/HardwareInterface/ConsoleMirror.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,124 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
namespace HardwareInterface | ||
{ | ||
public class ConsoleMirror : MonoBehaviour | ||
{ | ||
public static ConsoleMirror instance; | ||
|
||
public Transform p1; | ||
public Transform p2; | ||
public Transform ball; | ||
public Transform line; | ||
public bool p1Console; | ||
public bool p2Console; | ||
|
||
public bool pluggedIn; | ||
|
||
float p1X = 0f; | ||
float p1Y = 0f; | ||
|
||
float p2X = 0f; | ||
float p2Y = 0f; | ||
|
||
float ballX = 0f; | ||
float ballY = 0f; | ||
|
||
float wallX = 0f; | ||
|
||
SerialController sc; | ||
|
||
public void p1Reset() | ||
{ | ||
//if(pluggedIn) | ||
//sc.SendSerialMessage("p1Reset"); | ||
} | ||
|
||
private void Awake() | ||
{ | ||
if (ConsoleMirror.instance != null) | ||
{ | ||
Destroy(gameObject); | ||
} | ||
else | ||
{ | ||
instance = this; | ||
} | ||
|
||
pluggedIn = false; | ||
sc = gameObject.GetComponent<SerialController>(); | ||
} | ||
|
||
private void LateUpdate() | ||
{ | ||
if (pluggedIn) | ||
{ | ||
if (!p1Console) | ||
{ | ||
//sc.SendSerialMessage("setP1 " + xConvertToConsole(p1.position.x) + " " + yConvertToConsole(p1.position.y) + " "); | ||
} | ||
|
||
if (!p2Console) | ||
{ | ||
|
||
} | ||
|
||
p1.position = new Vector2(p1X, p1Y); | ||
p2.position = new Vector2(p2X, p2Y); | ||
ball.position = new Vector2(ballX, ballY); | ||
line.position = new Vector2(wallX, line.position.y); | ||
} | ||
} | ||
|
||
float xConvertToUnity(float x) | ||
{ | ||
x = x - 115.0f; | ||
x = (x / 47.0f) * -6.75f; | ||
return x; | ||
} | ||
|
||
float xConvertToConsole(float x) | ||
{ | ||
x = (x / -6.75f) * 47.0f; | ||
x = x + 115.0f; | ||
return x; | ||
} | ||
|
||
float yConvertToUnity(float y) | ||
{ | ||
y = y - 126.0f; | ||
y = (y / 52.0f) * 5.0f; | ||
return y; | ||
} | ||
|
||
float yConvertToConsole(float y) | ||
{ | ||
y = (y / 5.0f) * 52.0f; | ||
y = y + 126.0f; | ||
return y; | ||
} | ||
|
||
void OnMessageArrived(string msg) | ||
{ | ||
msg = msg.Substring(0, msg.Length - 3) + "}"; | ||
ConsoleData data = JsonUtility.FromJson<ConsoleData>(msg); | ||
p1X = xConvertToUnity(data.P1_X_READ); | ||
p1Y = yConvertToUnity(data.P1_Y_READ); | ||
p2X = xConvertToUnity(data.P2_X_READ); | ||
p2Y = yConvertToUnity(data.P2_Y_READ); | ||
ballX = xConvertToUnity(data.BALL_X_READ); | ||
ballY = yConvertToUnity(data.BALL_Y_READ); | ||
wallX = xConvertToUnity(data.WALL_X_READ); | ||
} | ||
|
||
void OnConnectionEvent(bool success) | ||
{ | ||
if (!success) | ||
{ | ||
pluggedIn = false; | ||
} | ||
} | ||
} | ||
} |
File renamed without changes.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.