@@ -0,0 +1,219 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1001 &100100000
Prefab:
m_ObjectHideFlags: 1
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications: []
m_RemovedComponents: []
m_ParentPrefab: {fileID: 0}
m_RootGameObject: {fileID: 1493044479274970}
m_IsPrefabParent: 1
--- !u!1 &1391510109330554
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4417017702936306}
- component: {fileID: 212543251292582600}
m_Layer: 0
m_Name: Asteroid_tail
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1493044479274970
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 5
m_Component:
- component: {fileID: 4144443171470294}
- component: {fileID: 212770935385318646}
- component: {fileID: 114560361158127526}
- component: {fileID: 114733885555438352}
- component: {fileID: 50883031470443920}
- component: {fileID: 58437841657255322}
- component: {fileID: 114043778697428974}
m_Layer: 8
m_Name: LinearAsteroid
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4144443171470294
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 9.4, y: 7.9, z: 0}
m_LocalScale: {x: 4.21334, y: 4.67513, z: 9.880819}
m_Children:
- {fileID: 4417017702936306}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4417017702936306
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1391510109330554}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.06, y: -1.68, z: 0}
m_LocalScale: {x: 0.2373414, y: 0.21389781, z: 0.10120618}
m_Children: []
m_Father: {fileID: 4144443171470294}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!50 &50883031470443920
Rigidbody2D:
serializedVersion: 4
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_BodyType: 0
m_Simulated: 1
m_UseFullKinematicContacts: 0
m_UseAutoMass: 1
m_Mass: 20.77125
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 0
m_Material: {fileID: 6200000, guid: 534724d6e95bac84fa443a883227b774, type: 2}
m_Interpolate: 0
m_SleepingMode: 0
m_CollisionDetection: 0
m_Constraints: 4
--- !u!58 &58437841657255322
CircleCollider2D:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 6200000, guid: 534724d6e95bac84fa443a883227b774, type: 2}
m_IsTrigger: 0
m_UsedByEffector: 0
m_Offset: {x: 0, y: 0}
serializedVersion: 2
m_Radius: 0.55
--- !u!114 &114043778697428974
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: a3801afa9564b6e4cbf7f53ecdc61aa1, type: 3}
m_Name:
m_EditorClassIdentifier:
degree: 0
speed: 9
bullet: {fileID: 1262413042601760, guid: 02864b5a5a7a5a449ac768439a21767f, type: 2}
--- !u!114 &114560361158127526
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f8ed1e4bf23011f47bd48c32a1d3a89a, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!114 &114733885555438352
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 816c1398e140a87408fdd284e0b7477c, type: 3}
m_Name:
m_EditorClassIdentifier:
color: 3
colorUsingAssets: 0
--- !u!212 &212543251292582600
SpriteRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1391510109330554}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 03da332c3f9dd72479c438f9daef5aa1, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
--- !u!212 &212770935385318646
SpriteRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1493044479274970}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_MotionVectors: 1
m_LightProbeUsage: 0
m_ReflectionProbeUsage: 0
m_Materials:
- {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0}
m_StaticBatchInfo:
firstSubMesh: 0
subMeshCount: 0
m_StaticBatchRoot: {fileID: 0}
m_ProbeAnchor: {fileID: 0}
m_LightProbeVolumeOverride: {fileID: 0}
m_ScaleInLightmap: 1
m_PreserveUVs: 0
m_IgnoreNormalsForChartDetection: 0
m_ImportantGI: 0
m_SelectedEditorRenderState: 0
m_MinimumChartSize: 4
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: 0
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 1e42ea09faaf66b4dacf31921a0876a9, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

Large diffs are not rendered by default.

@@ -44,31 +44,33 @@ void OnBecameInvisible()

void OnCollisionEnter2D(Collision2D other)
{
if (gameObject.GetComponent<ColoredObject>().color == other.gameObject.GetComponent<ColoredObject>().color)
{
Destroy(gameObject);
Destroy(other.gameObject);
}
// get the point of contact
ContactPoint2D contact = other.contacts[0];

// reflect our old velocity off the contact point's normal vector
Vector3 reflectedVelocity = Vector3.Reflect(oldVelocity, contact.normal);

// assign the reflected velocity back tohe rigidbody
r2d.velocity = reflectedVelocity;
// rotate the object by the same ammount we changed its velocity
Quaternion rotation = Quaternion.FromToRotation(oldVelocity, reflectedVelocity);
transform.rotation = rotation * transform.rotation;


}

void OnTriggerEnter2D(Collider2D other)
{
if(other.GetComponent<EnemyScript>() == null) {
if (other.GetComponent<ColoredObject>() != null)
gameObject.GetComponent<ColoredObject>().SetColor(other.GetComponent<ColoredObject>().color);
if (other.gameObject.name.Equals("StartGameButton"))
SceneManager.LoadScene(sceneName);
}
else
{
if (gameObject.GetComponent<ColoredObject>().color == other.gameObject.GetComponent<ColoredObject>().color)
{
Destroy(gameObject);
Destroy(other.gameObject);
}
// get the point of contact

// reflect our old velocity off the contact point's normal vector
Vector3 reflectedVelocity = Vector3.Reflect(oldVelocity, other.transform.position.normalized);

// assign the reflected velocity back tohe rigidbody
r2d.velocity = reflectedVelocity;
// rotate the object by the same ammount we changed its velocity
Quaternion rotation = Quaternion.FromToRotation(oldVelocity, reflectedVelocity);
transform.rotation = rotation * transform.rotation;
}
}
}
@@ -0,0 +1,24 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class LinearMovement : MonoBehaviour {
private Rigidbody2D r2d;
public float degree;
public float speed;
private Vector3 oldVelocity;
public GameObject bullet;
// Use this for initialization
void Start () {
r2d = GetComponent<Rigidbody2D>();
Vector3 dest = new Vector3(Mathf.Cos(degree), Mathf.Sin(degree), 0f);
Vector3 dif = dest - transform.position.normalized;
transform.rotation = Quaternion.Euler(0f, 0f, 360 - degree);
r2d.AddForce(transform.up * speed * 10, ForceMode2D.Impulse);
}

// Update is called once per frame
void Update () {
oldVelocity = r2d.velocity;
}
}
@@ -13,7 +13,7 @@ TagManager:
- UI
-
-
- above image
- Asteroids
-
-
-