Commit 4e8df52a authored by Nancy Wan's avatar Nancy Wan
Browse files

Adding mouse tracking and buoyancy effector

parent b36ca773
<Properties StartupConfiguration="{216EC53D-DB2C-3701-E2B5-3044A55DBC70}|">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/GarbageSpawner.cs">
<MonoDevelop.Ide.Workbench ActiveDocument="Assets/Scripts/GarbageController.cs">
<Files>
<File FileName="Assets/Scripts/Player.cs" Line="32" Column="69" />
<File FileName="Assets/Scripts/Singleton.cs" Line="25" Column="10" />
<File FileName="../../../UnityLearning/SimpleGame1/Assets/Scripts/PlayerController.cs" Line="23" Column="32" />
<File FileName="Assets/Scripts/BulletController.cs" Line="24" Column="6" />
<File FileName="Assets/Scripts/BulletController.cs" Line="23" Column="64" />
<File FileName="Assets/Scripts/GunController.cs" Line="30" Column="79" />
<File FileName="Assets/Scripts/GarbageSpawner.cs" Line="10" Column="9" />
<File FileName="Assets/Scripts/GarbageSpawner.cs" Line="20" Column="66" />
<File FileName="Assets/Scripts/GarbageController.cs" Line="1" Column="1" />
</Files>
<Pads>
<Pad Id="ProjectPad">
......@@ -14,7 +15,7 @@
<Node name="OceanNinja" expanded="True">
<Node name="Assets" expanded="True">
<Node name="Scripts" expanded="True">
<Node name="GarbageSpawner.cs" selected="True" />
<Node name="GarbageController.cs" selected="True" />
</Node>
</Node>
</Node>
......
......@@ -10,8 +10,8 @@ GameObject:
m_Component:
- component: {fileID: 6020449489788756185}
- component: {fileID: 6429767539480790038}
- component: {fileID: -5423864636472619440}
- component: {fileID: -156237567484142824}
- component: {fileID: -7877424564492715445}
m_Layer: 0
m_Name: Garbage 1
m_TagString: Untagged
......@@ -84,8 +84,20 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!70 &-5423864636472619440
CapsuleCollider2D:
--- !u!114 &-156237567484142824
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6325514029980851845}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51d31805684cc433d960f2b012ad619e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!61 &-7877424564492715445
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
......@@ -98,17 +110,15 @@ CapsuleCollider2D:
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_Direction: 0
--- !u!114 &-156237567484142824
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 6325514029980851845}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51d31805684cc433d960f2b012ad619e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EdgeRadius: 0
......@@ -10,8 +10,8 @@ GameObject:
m_Component:
- component: {fileID: 671431068947408836}
- component: {fileID: 301384062062691148}
- component: {fileID: -3675279061871757482}
- component: {fileID: 4334347255013846400}
- component: {fileID: 3783533889201853564}
m_Layer: 0
m_Name: Garbage 2
m_TagString: Untagged
......@@ -84,8 +84,20 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!70 &-3675279061871757482
CapsuleCollider2D:
--- !u!114 &4334347255013846400
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2353947567224724704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51d31805684cc433d960f2b012ad619e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!61 &3783533889201853564
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
......@@ -98,17 +110,15 @@ CapsuleCollider2D:
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_Direction: 0
--- !u!114 &4334347255013846400
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 2353947567224724704}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51d31805684cc433d960f2b012ad619e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EdgeRadius: 0
......@@ -10,8 +10,8 @@ GameObject:
m_Component:
- component: {fileID: 1739706219481186742}
- component: {fileID: 3977140436029445110}
- component: {fileID: -2141730718582170412}
- component: {fileID: 716964239567182284}
- component: {fileID: -4745869796791914458}
m_Layer: 0
m_Name: Garbage
m_TagString: Untagged
......@@ -84,8 +84,20 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!70 &-2141730718582170412
CapsuleCollider2D:
--- !u!114 &716964239567182284
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5392101437540806911}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51d31805684cc433d960f2b012ad619e, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!61 &-4745869796791914458
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
......@@ -98,17 +110,15 @@ CapsuleCollider2D:
m_UsedByEffector: 0
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 1, y: 1}
newSize: {x: 1, y: 1}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 1}
m_Direction: 0
--- !u!114 &716964239567182284
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 5392101437540806911}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 51d31805684cc433d960f2b012ad619e, type: 3}
m_Name:
m_EditorClassIdentifier:
m_EdgeRadius: 0
......@@ -2832,6 +2832,8 @@ GameObject:
m_Component:
- component: {fileID: 1736728514}
- component: {fileID: 1736728515}
- component: {fileID: 1736728517}
- component: {fileID: 1736728516}
m_Layer: 0
m_Name: sea_background
m_TagString: Untagged
......@@ -2904,6 +2906,51 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!253 &1736728516
BuoyancyEffector2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736728513}
m_Enabled: 1
m_UseColliderMask: 1
m_ColliderMask:
serializedVersion: 2
m_Bits: 4294967295
m_SurfaceLevel: 0
m_Density: 5
m_LinearDrag: 5
m_AngularDrag: 5
m_FlowAngle: 0
m_FlowMagnitude: 0
m_FlowVariation: 0
--- !u!61 &1736728517
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1736728513}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
m_UsedByEffector: 1
m_UsedByComposite: 0
m_Offset: {x: 0, y: 0}
m_SpriteTilingProperty:
border: {x: 0, y: 0, z: 0, w: 0}
pivot: {x: 0.5, y: 0.5}
oldSize: {x: 19.2, y: 10.8}
newSize: {x: 19.2, y: 10.8}
adaptiveTilingThreshold: 0.5
drawMode: 0
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 19.2, y: 10.8}
m_EdgeRadius: 0
--- !u!1 &1783462221
GameObject:
m_ObjectHideFlags: 0
......
......@@ -10,9 +10,16 @@ public class GarbageController : MonoBehaviour
}
private void OnTriggerEnter(Collider other)
{
}
// Update is called once per frame
void Update()
{
}
}
......@@ -4,7 +4,7 @@ using UnityEngine;
public class PlayerController : Singleton<PlayerController>
{
public float movementSpeed = 1.5f;
public float movementSpeed = 1.0f;
public float jumpForce = 1.0f;
public GameObject bulletPrefab;
......@@ -22,29 +22,34 @@ public class PlayerController : Singleton<PlayerController>
// Update is called once per frame
private void Update()
{
var movement = Input.GetAxis("Horizontal");
Vector3 moveVector = new Vector3(movement, 0, 0);
transform.position += moveVector * Time.deltaTime * movementSpeed;
//var movement = Input.GetAxis("Horizontal");
//Vector3 moveVector = new Vector3(movement, 0, 0);
//transform.position += moveVector * Time.deltaTime * movementSpeed;
// Flipping character's physical direction
if (!Mathf.Approximately(0, movement))
{
transform.rotation = movement > 0 ? Quaternion.Euler(0, 180, 0) : Quaternion.identity;
}
//if (!Mathf.Approximately(0, movement))
//{
// transform.rotation = movement > 0 ? Quaternion.Euler(0, 180, 0) : Quaternion.identity;
//}
if (Input.GetKeyDown(KeyCode.Space))
{
_rigidbody.AddForce(new Vector2(0, jumpForce), ForceMode2D.Impulse);
}
//Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
//float rotateY = 0f;
//if (mousePos.x < transform.position.x)
//{
// rotateY = 180f;
//}
Vector3 mousePos = Camera.main.ScreenToWorldPoint(Input.mousePosition);
float rotateY = 0f;
if (mousePos.x > transform.position.x)
{
rotateY = 180f;
}
transform.eulerAngles = new Vector3(transform.rotation.x, rotateY, transform.rotation.z);
mousePos.z = Camera.main.transform.position.z + Camera.main.nearClipPlane;
Vector3 moveVector = (mousePos - transform.position).normalized;
transform.position += moveVector * Time.deltaTime * movementSpeed;
//transform.eulerAngles = new Vector3(transform.rotation.x, rotateY, transform.rotation.z);
if (Input.GetButtonDown("Fire1")) {
Shoot();
}
......
No preview for this file type
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment