Skip to content

Commit

Permalink
Merge branch 'development' of http://github.com/benthemonkey/blorb
Browse files Browse the repository at this point in the history
The game looks pretty stable so it seemed like a good time to merge
  • Loading branch information
benthemonkey committed Feb 22, 2015
2 parents 1365ece + f72c179 commit 4c4ebf3
Show file tree
Hide file tree
Showing 78 changed files with 7,071 additions and 1,321 deletions.
85 changes: 61 additions & 24 deletions Assets/Base/Attachments/Attachments.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,42 +4,79 @@
public class Attachments : MonoBehaviour {

private float health = 100F;
private bool selected = false;

public bool[] takenSpots = new bool[4] { false, false, false, false };
public bool[] TakenSpot
{
get { return takenSpots; }
set { takenSpots = value; }
}

private bool[] takenSpots = new bool[16];

// Use this for initialization
void Start () {
public int Spot
{
get { return spot; }
set { spot = value; }
}

}
private int spot;

// Update is called once per frame
void Update () {
if (selected && Center.selectedBasePiece != this.transform.parent)
public void takeDamage(float damage)
{
health -= damage;
}

public void FindAllPossiblePlacements(Center centralController)
{
for (int i = 0; i < takenSpots.Length; i++)
{
SpriteRenderer sr = this.transform.parent.GetComponentInParent<SpriteRenderer>();
sr.color = new Color(255.0f, 255.0f, 255.0f);
selected = false;
if (!takenSpots[i])
{
//check to make sure it's not going to place on another branch of the structure that
// isn't necessarily a parent or child
if (!DetectOtherObjects(BuildDirection.ToDirFromSpot(i)))
centralController.SetPlacement(BuildDirection.ToDirFromSpot(i), this.transform);

}
}
}

void OnMouseDown() //will be selecting the tower piece, not the bottom piece
{
if (!selected && Input.GetButtonDown("Select"))
foreach (Transform child in this.transform)
{
Debug.Log("CLICKED ON ATTACHMENT!");

Center.selectedBasePiece = this.transform.parent;
SpriteRenderer sr = Center.selectedBasePiece.GetComponent<SpriteRenderer>();
sr.color = new Color(0.0f, 219.0f, 255.0f);
selected = true;
if (child.GetComponent<Attachments>() != null)
{
child.GetComponent<Attachments>().FindAllPossiblePlacements(centralController);
}
}
}

public void takeDamage(float damage)
private bool DetectOtherObjects(float[] dir)
{
health -= damage;
//raycast to find objects
RaycastHit2D[] hits;
hits = Physics2D.LinecastAll(new Vector2(this.transform.position.x + dir[0], this.transform.position.y + dir[1]),
new Vector2(this.transform.position.x + (dir[0] * 1.3f), this.transform.position.y + (dir[1] * 1.3f)));

//blacklist children, self, and placement pieces
ArrayList blackList = new ArrayList();
foreach (Transform child in this.transform) //iterate only immediate children
{
for (int j = 0; j < hits.Length; j++)
{
if (hits[j].collider.gameObject == child.gameObject ||
hits[j].collider.gameObject == this.gameObject)
{
blackList.Add(j);
}
}
}

for (int j = 0; j < hits.Length; j++)
{
if (blackList.Contains(j)) continue; //skip children and placement pieces

return true;
}

Debug.Log("ATTACHMENT HEALTH: " + health);
return false;
}
}
76 changes: 76 additions & 0 deletions Assets/Base/Attachments/Collector.prefab
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &100826
GameObject:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 4
m_Component:
- 4: {fileID: 400826}
- 212: {fileID: 21200826}
- 114: {fileID: 11418450}
m_Layer: 0
m_Name: Collector
m_TagString: Collector
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &400826
Transform:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100826}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!114 &11418450
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100826}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 70be8b78486f6b2449e77528a0d6451b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!212 &21200826
SpriteRenderer:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 100826}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_LightmapIndex: 255
m_LightmapTilingOffset: {x: 1, y: 1, z: 0, w: 0}
m_Materials:
- {fileID: 10754, guid: 0000000000000000e000000000000000, type: 0}
m_SubsetIndices:
m_StaticBatchRoot: {fileID: 0}
m_UseLightProbes: 0
m_LightProbeAnchor: {fileID: 0}
m_ScaleInLightmap: 1
m_SortingLayerID: 0
m_SortingOrder: 2
m_Sprite: {fileID: 21300012, guid: cac4650eae1214d7d92dd7b3fa9758b4, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
--- !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: 100826}
m_IsPrefabParent: 1
m_IsExploded: 1

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

46 changes: 3 additions & 43 deletions Assets/Base/Attachments/Turret.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,10 @@ GameObject:
m_Component:
- 4: {fileID: 455352}
- 212: {fileID: 21255352}
- 114: {fileID: 11477802}
- 50: {fileID: 5061682}
- 114: {fileID: 11468976}
- 61: {fileID: 6146754}
m_Layer: 0
m_Name: Turret
m_TagString: Untagged
m_TagString: Turret
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand All @@ -28,36 +25,10 @@ Transform:
m_GameObject: {fileID: 155352}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: .360000014, y: .360000014, z: .360000014}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!50 &5061682
Rigidbody2D:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155352}
m_Mass: 9.99999975e-05
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 0
m_FixedAngle: 0
m_IsKinematic: 1
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
--- !u!61 &6146754
BoxCollider2D:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155352}
m_Enabled: 1
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Size: {x: 5, y: 5}
m_Center: {x: 0, y: 0}
--- !u!114 &11468976
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -69,19 +40,8 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 719bfcc1471504bf4aa8869de4c10071, type: 3}
m_Name:
m_EditorClassIdentifier:
bullet: {fileID: 103078, guid: dc751d600c38a471c82bc52f386f623b, type: 2}
publicAngle: 0
--- !u!114 &11477802
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155352}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 817b781ff228144428fc78d532cd853b, type: 3}
m_Name:
m_EditorClassIdentifier:
takenSpots: 00000000
--- !u!212 &21255352
SpriteRenderer:
m_ObjectHideFlags: 1
Expand Down
34 changes: 3 additions & 31 deletions Assets/Base/Attachments/Wall.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ GameObject:
m_Component:
- 4: {fileID: 455352}
- 212: {fileID: 21255352}
- 114: {fileID: 11477802}
- 50: {fileID: 5046550}
m_Layer: 0
m_Name: Wall
m_TagString: Untagged
m_TagString: Wall
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
Expand All @@ -26,36 +24,10 @@ Transform:
m_GameObject: {fileID: 155352}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: .360000014, y: .360000014, z: .360000014}
m_LocalScale: {x: 1, y: 1, z: 0}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!50 &5046550
Rigidbody2D:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155352}
m_Mass: 9.99999975e-05
m_LinearDrag: 0
m_AngularDrag: 0
m_GravityScale: 0
m_FixedAngle: 0
m_IsKinematic: 1
m_Interpolate: 0
m_SleepingMode: 1
m_CollisionDetection: 0
--- !u!114 &11477802
MonoBehaviour:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 155352}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 817b781ff228144428fc78d532cd853b, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!212 &21255352
SpriteRenderer:
m_ObjectHideFlags: 1
Expand All @@ -76,7 +48,7 @@ SpriteRenderer:
m_ScaleInLightmap: 1
m_SortingLayerID: 0
m_SortingOrder: 2
m_Sprite: {fileID: 21300012, guid: cac4650eae1214d7d92dd7b3fa9758b4, type: 3}
m_Sprite: {fileID: 21300014, guid: cac4650eae1214d7d92dd7b3fa9758b4, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
--- !u!1001 &100100000
Prefab:
Expand Down
32 changes: 24 additions & 8 deletions Assets/Base/Bottom.prefab
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ GameObject:
m_Component:
- 4: {fileID: 476196}
- 212: {fileID: 21276196}
- 61: {fileID: 6176196}
- 114: {fileID: 11489702}
- 65: {fileID: 6514910}
- 54: {fileID: 5446624}
m_Layer: 0
m_Name: Bottom
m_TagString: Untagged
Expand All @@ -30,17 +31,33 @@ Transform:
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
--- !u!61 &6176196
BoxCollider2D:
--- !u!54 &5446624
Rigidbody:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 176196}
m_Enabled: 1
m_Material: {fileID: 6200000, guid: fc536ab374a262346b0522537d5aaf5c, type: 2}
serializedVersion: 2
m_Mass: 1
m_Drag: 0
m_AngularDrag: 0
m_UseGravity: 0
m_IsKinematic: 0
m_Interpolate: 2
m_Constraints: 126
m_CollisionDetection: 0
--- !u!65 &6514910
BoxCollider:
m_ObjectHideFlags: 1
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 176196}
m_Material: {fileID: 0}
m_IsTrigger: 0
m_Size: {x: 7.5, y: 7.5}
m_Center: {x: 0, y: 0}
m_Enabled: 1
serializedVersion: 2
m_Size: {x: 1.29999995, y: 1.29999995, z: 0}
m_Center: {x: 0, y: 0, z: 0}
--- !u!114 &11489702
MonoBehaviour:
m_ObjectHideFlags: 1
Expand All @@ -52,7 +69,6 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: 817b781ff228144428fc78d532cd853b, type: 3}
m_Name:
m_EditorClassIdentifier:
takenSpots: 00000000
--- !u!212 &21276196
SpriteRenderer:
m_ObjectHideFlags: 1
Expand Down
16 changes: 16 additions & 0 deletions Assets/Base/BottomPMat.physicMaterial
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!134 &13400000
PhysicMaterial:
m_ObjectHideFlags: 0
m_PrefabParentObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: BottomPMat
dynamicFriction: .400000006
staticFriction: .400000006
bounciness: 0
frictionCombine: 0
bounceCombine: 0
frictionDirection2: {x: 0, y: 0, z: 0}
dynamicFriction2: 0
staticFriction2: 0
Loading

0 comments on commit 4c4ebf3

Please sign in to comment.