A 2D Versus Shmup made in Unity
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

Comment Blocks

Not actually commented, just placed there for future filling

james7132 c9c2be31 94357401

+1719 -465
+3
.gitignore
··· 15 15 16 16 #Unity3D Generated File On Crash Reports 17 17 sysinfo.txt 18 + 19 + #Other Project Files 20 + *.sublime-workspace
+13 -2
Assets/BulletCancelArea.cs
··· 1 - using UnityEngine; 1 + using UnityEngine; 2 2 using System.Collections; 3 3 using BaseLib; 4 4 5 + /// <summary> 6 + /// Bullet cancel area. 7 + /// </summary> 5 8 [RequireComponent(typeof(ProjectileBoundary))] 6 9 [RequireComponent(typeof(Collider2D))] 7 10 public class BulletCancelArea : CachedObject { 8 11 9 12 //TODO: Finish this class 10 13 11 - 14 + /// <summary> 15 + /// The max scale. 16 + /// </summary> 12 17 [SerializeField] 13 18 private float maxScale = 8f; 14 19 public float MaxScale { ··· 20 25 } 21 26 } 22 27 28 + /// <summary> 29 + /// Start this instance. 30 + /// </summary> 23 31 void Start() { 24 32 StartCoroutine (Execute ()); 25 33 } 26 34 35 + /// <summary> 36 + /// Execute this instance. 37 + /// </summary> 27 38 private IEnumerator Execute() { 28 39 throw new System.NotImplementedException(); 29 40 }
+61
Assets/Editor/FindMissingScripts.cs
··· 1 + using UnityEngine; 2 + using UnityEditor; 3 + 4 + public class FindMissingScripts : EditorWindow 5 + { 6 + static int go_count = 0, components_count = 0, missing_count = 0; 7 + 8 + [MenuItem("Window/FindMissingScriptsRecursively")] 9 + public static void ShowWindow() 10 + { 11 + EditorWindow.GetWindow(typeof(FindMissingScripts)); 12 + } 13 + 14 + public void OnGUI() 15 + { 16 + if (GUILayout.Button("Find Missing Scripts in selected GameObjects")) 17 + { 18 + FindInSelected(); 19 + } 20 + } 21 + private static void FindInSelected() 22 + { 23 + GameObject[] go = Selection.gameObjects; 24 + go_count = 0; 25 + components_count = 0; 26 + missing_count = 0; 27 + foreach (GameObject g in go) 28 + { 29 + FindInGO(g); 30 + } 31 + Debug.Log(string.Format("Searched {0} GameObjects, {1} components, found {2} missing", go_count, components_count, missing_count)); 32 + } 33 + 34 + private static void FindInGO(GameObject g) 35 + { 36 + go_count++; 37 + Component[] components = g.GetComponents<Component>(); 38 + for (int i = 0; i < components.Length; i++) 39 + { 40 + components_count++; 41 + if (components[i] == null) 42 + { 43 + missing_count++; 44 + string s = g.name; 45 + Transform t = g.transform; 46 + while (t.parent != null) 47 + { 48 + s = t.parent.name +"/"+s; 49 + t = t.parent; 50 + } 51 + Debug.Log (s + " has an empty script attached in position: " + i, g); 52 + } 53 + } 54 + // Now recurse through each child GO (if there are any): 55 + foreach (Transform childT in g.transform) 56 + { 57 + //Debug.Log("Searching " + childT.name + " " ); 58 + FindInGO(childT.gameObject); 59 + } 60 + } 61 + }
-15
Assets/EnableController.cs
··· 1 - using UnityEngine; 2 - using System.Collections; 3 - 4 - public class EnableController : MonoBehaviour { 5 - 6 - // Use this for initialization 7 - void Start () { 8 - 9 - } 10 - 11 - // Update is called once per frame 12 - void Update () { 13 - 14 - } 15 - }
+1 -1
Assets/EnableController.cs.meta Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectileData.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: b7e605b539133c84b969d487b6139c2a 2 + guid: fe790d6868ffd7b44b1828a37524555c 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
-48
Assets/Scripts/AttackPattern.cs
··· 1 - using UnityEngine; 2 - using BaseLib; 3 - using System; 4 - using System.Collections; 5 - 6 - public abstract class AttackPattern : CachedObject { 7 - private PlayerFieldController targetField; 8 - public PlayerFieldController TargetField { 9 - get { 10 - return targetField; 11 - } 12 - } 13 - 14 - public void Initialize(PlayerFieldController targetField) { 15 - this.targetField = targetField; 16 - } 17 - 18 - [SerializeField] 19 - private float timeout; 20 - 21 - private bool attackActive; 22 - 23 - protected abstract void MainLoop(float dt); 24 - 25 - protected void Deactivate() { 26 - attackActive = false; 27 - } 28 - 29 - public void Fire() { 30 - StartCoroutine (Execute ()); 31 - } 32 - 33 - private IEnumerator Execute() { 34 - float executionTime = 0f, dt; 35 - attackActive = true; 36 - while((executionTime < timeout || timeout < 0) && attackActive) { 37 - dt = Time.fixedDeltaTime; 38 - MainLoop(dt); 39 - yield return new WaitForFixedUpdate(); 40 - executionTime += dt; 41 - } 42 - } 43 - 44 - protected float AngleToEntity(Vector3 location, Vector3 entity) { 45 - //TODO: Implement this function 46 - throw new NotImplementedException (); 47 - } 48 - }
Assets/Scripts/AttackPattern.cs.meta Assets/Scripts/AttackPatterns/AttackPattern.cs.meta
+5
Assets/Scripts/AttackPatterns.meta
··· 1 + fileFormatVersion: 2 2 + guid: 77b47bc461fbef44592d577559b3383c 3 + folderAsset: yes 4 + DefaultImporter: 5 + userData:
+117
Assets/Scripts/AttackPatterns/AttackPattern.cs
··· 1 + using UnityEngine; 2 + using BaseLib; 3 + using System; 4 + using System.Collections; 5 + 6 + /// <summary> 7 + /// Attack pattern. 8 + /// </summary> 9 + public abstract class AttackPattern : CachedObject { 10 + 11 + private PlayerFieldController targetField; 12 + 13 + /// <summary> 14 + /// Gets or sets the target field. 15 + /// </summary> 16 + /// <value>The target field.</value> 17 + public PlayerFieldController TargetField { 18 + get { 19 + return targetField; 20 + } 21 + set { 22 + targetField = value; 23 + } 24 + } 25 + 26 + /// <summary> 27 + /// The timeout. 28 + /// </summary> 29 + [SerializeField] 30 + private float timeout; 31 + 32 + /// <summary> 33 + /// The attack active. 34 + /// </summary> 35 + private bool attackActive; 36 + 37 + /// <summary> 38 + /// Raises the execution start event. 39 + /// </summary> 40 + protected virtual void OnExecutionStart() { 41 + } 42 + 43 + /// <summary> 44 + /// Mains the loop. 45 + /// </summary> 46 + /// <param name="dt">Dt.</param> 47 + protected abstract void MainLoop(float dt); 48 + 49 + /// <summary> 50 + /// Raises the execution finish event. 51 + /// </summary> 52 + protected virtual void OnExecutionFinish() { 53 + } 54 + 55 + /// <summary> 56 + /// Fires the linear bullet. 57 + /// </summary> 58 + /// <returns>The linear bullet.</returns> 59 + /// <param name="bulletType">Bullet type.</param> 60 + /// <param name="location">Location.</param> 61 + /// <param name="rotation">Rotation.</param> 62 + /// <param name="velocity">Velocity.</param> 63 + protected Projectile FireLinearBullet(ProjectilePrefab bulletType, 64 + Vector2 location, 65 + float rotation, 66 + float velocity) { 67 + return FireCurvedBullet(bulletType, location, rotation, velocity, 0f); 68 + } 69 + 70 + /// <summary> 71 + /// Fires the curved bullet. 72 + /// </summary> 73 + /// <returns>The curved bullet.</returns> 74 + /// <param name="bulletType">Bullet type.</param> 75 + /// <param name="location">Location.</param> 76 + /// <param name="rotation">Rotation.</param> 77 + /// <param name="velocity">Velocity.</param> 78 + /// <param name="angularVelocity">Angular velocity.</param> 79 + protected Projectile FireCurvedBullet(ProjectilePrefab bulletType, 80 + Vector2 location, 81 + float rotation, 82 + float velocity, 83 + float angularVelocity) { 84 + Projectile bullet = targetField.SpawnProjectile (bulletType, location, rotation); 85 + bullet.Velocity = velocity; 86 + bullet.AngularVelocity = angularVelocity; 87 + return bullet; 88 + } 89 + 90 + /// <summary> 91 + /// Terminate this instance. 92 + /// </summary> 93 + protected void Terminate() { 94 + attackActive = false; 95 + } 96 + 97 + /// <summary> 98 + /// Fire this instance. 99 + /// </summary> 100 + public void Fire() { 101 + StartCoroutine (Execute ()); 102 + } 103 + 104 + /// <summary> 105 + /// Execute this instance. 106 + /// </summary> 107 + private IEnumerator Execute() { 108 + float executionTime = 0f, dt; 109 + attackActive = true; 110 + while((executionTime < timeout || timeout < 0) && attackActive) { 111 + dt = Time.fixedDeltaTime; 112 + executionTime += dt; 113 + MainLoop(dt); 114 + yield return new WaitForFixedUpdate(); 115 + } 116 + } 117 + }
+44
Assets/Scripts/AttackPatterns/BasicCircularBurst.cs
··· 1 + using UnityEngine; 2 + using System.Collections; 3 + 4 + /// <summary> 5 + /// Basic circular burst. 6 + /// </summary> 7 + public class BasicCircularBurst : AttackPattern { 8 + 9 + /// <summary> 10 + /// The prefab. 11 + /// </summary> 12 + public ProjectilePrefab prefab; 13 + 14 + /// <summary> 15 + /// The spawn location. 16 + /// </summary> 17 + public Vector2 spawnLocation; 18 + 19 + /// <summary> 20 + /// The bullet count. 21 + /// </summary> 22 + public int bulletCount; 23 + 24 + /// <summary> 25 + /// The velocity. 26 + /// </summary> 27 + public float velocity; 28 + 29 + /// <summary> 30 + /// The ang v. 31 + /// </summary> 32 + public float angV; 33 + 34 + /// <summary> 35 + /// Mains the loop. 36 + /// </summary> 37 + /// <param name="dt">Dt.</param> 38 + protected override void MainLoop (float dt) { 39 + for(int i = 0; i < bulletCount; i++) { 40 + FireCurvedBullet(prefab, spawnLocation, 360f / (float) bulletCount * (float)i, velocity, angV); 41 + } 42 + Terminate (); 43 + } 44 + }
+270
Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectileData.cs
··· 1 + using UnityEngine; 2 + using System.Collections; 3 + using BaseLib; 4 + 5 + /// <summary> 6 + /// Projectile data. 7 + /// </summary> 8 + public class ProjectileData { 9 + 10 + /// <summary> 11 + /// The quad mesh. 12 + /// </summary> 13 + private static Mesh quadMesh; 14 + 15 + /// <summary> 16 + /// The group. 17 + /// </summary> 18 + private ProjectileGroup group; 19 + 20 + /// <summary> 21 + /// The position. 22 + /// </summary> 23 + private Vector3 position = Vector3.zero; 24 + 25 + /// <summary> 26 + /// The rotation. 27 + /// </summary> 28 + private Quaternion rotation = Quaternion.identity; 29 + 30 + /// <summary> 31 + /// The scale. 32 + /// </summary> 33 + private Vector3 scale = Vector3.zero; 34 + 35 + /// <summary> 36 + /// The velocity. 37 + /// </summary> 38 + private float velocity = 0f; 39 + 40 + /// <summary> 41 + /// The angular velocity. 42 + /// </summary> 43 + private Quaternion angularVelocity = Quaternion.identity; 44 + 45 + /// <summary> 46 + /// The collision handler. 47 + /// </summary> 48 + private ProjectileCollisionHandler collisionHandler; 49 + 50 + public static Mesh ProjectileMesh { 51 + get { 52 + if(quadMesh == null) { 53 + //Magic numbers woooooo! 54 + quadMesh = new Mesh(); 55 + Vector3[] verts = new Vector3[]{ 56 + new Vector3( 1, 0, 1), 57 + new Vector3( 1, 0, -1), 58 + new Vector3(-1, 0, 1), 59 + new Vector3(-1, 0, -1), 60 + }; 61 + Vector2[] uv = new Vector2[] { 62 + new Vector2(1, 1), 63 + new Vector2(1, 0), 64 + new Vector2(0, 1), 65 + new Vector2(0, 0), 66 + }; 67 + int[] tris = new int[]{0, 1, 2, 2, 1, 3}; 68 + quadMesh.vertices = verts; 69 + quadMesh.uv = uv; 70 + quadMesh.triangles = tris; 71 + } 72 + return quadMesh; 73 + } 74 + } 75 + 76 + /// <summary> 77 + /// Gets or sets the position. 78 + /// </summary> 79 + /// <value>The position.</value> 80 + public Vector3 Position { 81 + get { 82 + return position; 83 + } 84 + set { 85 + position = value; 86 + } 87 + } 88 + 89 + /// <summary> 90 + /// Gets or sets the rotation. 91 + /// </summary> 92 + /// <value>The rotation.</value> 93 + public Quaternion Rotation { 94 + get { 95 + return rotation; 96 + } 97 + set { 98 + rotation = value; 99 + } 100 + } 101 + 102 + /// <summary> 103 + /// Gets or sets the scale. 104 + /// </summary> 105 + /// <value>The scale.</value> 106 + public Vector3 Scale { 107 + get { 108 + return position; 109 + } 110 + set { 111 + position = value; 112 + } 113 + } 114 + 115 + /// <summary> 116 + /// Gets or sets the velocity. 117 + /// </summary> 118 + /// <value>The velocity.</value> 119 + public float Velocity { 120 + get { 121 + return velocity; 122 + } 123 + set { 124 + velocity = value; 125 + } 126 + } 127 + 128 + /// <summary> 129 + /// Gets or sets the angular velocity. 130 + /// </summary> 131 + /// <value>The angular velocity.</value> 132 + public Quaternion AngularVelocity { 133 + get { 134 + return angularVelocity; 135 + } 136 + set { 137 + angularVelocity = value; 138 + } 139 + } 140 + 141 + /// <summary> 142 + /// Gets or sets the collision handler. 143 + /// </summary> 144 + /// <value>The collision handler.</value> 145 + public ProjectileCollisionHandler CollisionHandler { 146 + get { 147 + return collisionHandler; 148 + } 149 + set { 150 + collisionHandler = value; 151 + } 152 + } 153 + 154 + /// <summary> 155 + /// Gets or sets the group. 156 + /// </summary> 157 + /// <value>The group.</value> 158 + public ProjectileGroup Group { 159 + get { 160 + return group; 161 + } 162 + set { 163 + group = value; 164 + } 165 + } 166 + 167 + /// <summary> 168 + /// Draw this instance. 169 + /// </summary> 170 + public void Draw() { 171 + Graphics.DrawMesh (ProjectileMesh, Matrix4x4.TRS (position, rotation, scale), group.ProjectileMaterial, group.Layer, group.TargetCamera); 172 + } 173 + 174 + /// <summary> 175 + /// Update the specified dt. 176 + /// </summary> 177 + /// <param name="dt">Dt.</param> 178 + public void Update(float dt) 179 + { 180 + Quaternion newRotation = Quaternion.Slerp (rotation, rotation * angularVelocity, dt); 181 + Vector3 movementVector = velocity * dt * (newRotation * Vector3.up); 182 + 183 + //TODO: add support for ProjectileControllers here 184 + 185 + //RaycastHit2D[] hits = collisionHandler.CheckCollision (this, movementVector); 186 + 187 + rotation = newRotation; 188 + position += movementVector; 189 + } 190 + } 191 + 192 + /// <summary> 193 + /// Projectile collision handler. 194 + /// </summary> 195 + public abstract class ProjectileCollisionHandler { 196 + public abstract RaycastHit2D[] CheckCollision(ProjectileData projectile, Vector3 movementVector); 197 + } 198 + 199 + /// <summary> 200 + /// Box projectile collision handler. 201 + /// </summary> 202 + public class BoxProjectileCollisionHandler : ProjectileCollisionHandler { 203 + private Vector2 boxOffset; 204 + private Vector2 boxSize; 205 + 206 + /// <summary> 207 + /// Initializes a new instance of the <see cref="BoxProjectileCollisionHandler"/> class. 208 + /// </summary> 209 + /// <param name="offset">Offset.</param> 210 + /// <param name="size">Size.</param> 211 + public BoxProjectileCollisionHandler(Vector2 offset, Vector2 size) { 212 + boxOffset = offset; 213 + boxSize = size; 214 + } 215 + 216 + /// <summary> 217 + /// Checks the collision. 218 + /// </summary> 219 + /// <returns>The collision.</returns> 220 + /// <param name="projectile">Projectile.</param> 221 + /// <param name="movementVector">Movement vector.</param> 222 + public override RaycastHit2D[] CheckCollision (ProjectileData projectile, Vector3 movementVector) { 223 + Vector2 origin = Util.To2D (projectile.Position) + Util.ComponentProduct2 (projectile.Scale, boxOffset); 224 + Vector2 size = Util.ComponentProduct2 (projectile.Scale, boxSize); 225 + return Physics2D.BoxCastAll (origin, size, projectile.Rotation.eulerAngles.z, movementVector, movementVector.magnitude); 226 + } 227 + } 228 + 229 + /// <summary> 230 + /// Circle projectile collision handler. 231 + /// </summary> 232 + public class CircleProjectileCollisionHandler : ProjectileCollisionHandler { 233 + private Vector2 circleOffset; 234 + private float circleRadius; 235 + 236 + /// <summary> 237 + /// Initializes a new instance of the <see cref="CircleProjectileCollisionHandler"/> class. 238 + /// </summary> 239 + /// <param name="offset">Offset.</param> 240 + /// <param name="radius">Radius.</param> 241 + public CircleProjectileCollisionHandler(Vector2 offset, float radius) { 242 + circleOffset = offset; 243 + circleRadius = radius; 244 + } 245 + 246 + /// <summary> 247 + /// Minimums the abs scale. 248 + /// </summary> 249 + /// <returns>The abs scale.</returns> 250 + /// <param name="values">Values.</param> 251 + private float MinAbsScale(params float[] values) { 252 + float min = float.MaxValue; 253 + for(int i = 0; i < values.Length; i++) 254 + if(values[i] < min) 255 + min = Mathf.Abs(values[i]); 256 + return min; 257 + } 258 + 259 + /// <summary> 260 + /// Checks the collision. 261 + /// </summary> 262 + /// <returns>The collision.</returns> 263 + /// <param name="projectile">Projectile.</param> 264 + /// <param name="movementVector">Movement vector.</param> 265 + public override RaycastHit2D[] CheckCollision (ProjectileData projectile, Vector3 movementVector) { 266 + Vector2 origin = Util.To2D (projectile.Position) + Util.ComponentProduct2 (projectile.Scale, circleOffset); 267 + float size = circleRadius * MinAbsScale (projectile.Scale.x, projectile.Scale.y, projectile.Scale.z); 268 + return Physics2D.CircleCastAll(origin, size, movementVector, movementVector.magnitude, projectile.Group.Layer); 269 + } 270 + }
+150 -40
Assets/Scripts/Avatar.cs
··· 2 2 using BaseLib; 3 3 using System.Collections.Generic; 4 4 5 + /// <summary> 6 + /// Avatar. 7 + /// </summary> 5 8 [RequireComponent(typeof(Collider2D))] 6 - public class Avatar : CachedObject 7 - { 9 + public class Avatar : CachedObject { 10 + 8 11 private PlayerFieldController fieldController; 12 + /// <summary> 13 + /// Gets the field controller. 14 + /// </summary> 15 + /// <value>The field controller.</value> 9 16 public PlayerFieldController FieldController { 10 17 get { 11 18 return fieldController; ··· 13 20 } 14 21 15 22 private PlayerAgent agent; 23 + /// <summary> 24 + /// Gets or sets the agent. 25 + /// </summary> 26 + /// <value>The agent.</value> 16 27 public PlayerAgent Agent { 17 28 get { 18 29 return agent; ··· 22 33 } 23 34 } 24 35 36 + /// <summary> 37 + /// The normal movement speed. 38 + /// </summary> 25 39 [SerializeField] 26 40 private float normalMovementSpeed = 5f; 27 41 42 + /// <summary> 43 + /// The focus movement speed. 44 + /// </summary> 28 45 [SerializeField] 29 46 private float focusMovementSpeed = 3f; 30 47 48 + /// <summary> 49 + /// The type of the shot. 50 + /// </summary> 31 51 [SerializeField] 32 52 private ProjectilePrefab shotType; 33 53 54 + /// <summary> 55 + /// The shot offset. 56 + /// </summary> 34 57 [SerializeField] 35 58 private Vector2 shotOffset; 36 59 60 + /// <summary> 61 + /// The shot velocity. 62 + /// </summary> 37 63 [SerializeField] 38 64 private float shotVelocity; 39 65 40 - [SerializeField] 41 - private float shotDamage; 42 - 66 + /// <summary> 67 + /// The charge capacity regen. 68 + /// </summary> 43 69 [SerializeField] 44 70 private float chargeCapacityRegen; 45 71 72 + /// <summary> 73 + /// The current charge capacity. 74 + /// </summary> 46 75 [SerializeField] 47 76 private float currentChargeCapacity; 48 77 78 + /// <summary> 79 + /// The attack patterns. 80 + /// </summary> 49 81 [SerializeField] 50 82 private AttackPattern[] attackPatterns; 51 83 52 84 private bool charging; 53 - public bool IsCharging 54 - { 55 - get { return charging; } 85 + /// <summary> 86 + /// Gets a value indicating whether this instance is charging. 87 + /// </summary> 88 + /// <value><c>true</c> if this instance is charging; otherwise, <c>false</c>.</value> 89 + public bool IsCharging { 90 + get { 91 + return charging; 92 + } 56 93 } 57 94 58 95 private float chargeLevel = 0f; 59 - public float CurrentChargeLevel 60 - { 96 + /// <summary> 97 + /// Gets the current charge level. 98 + /// </summary> 99 + /// <value>The current charge level.</value> 100 + public float CurrentChargeLevel { 61 101 get { return chargeLevel; } 62 102 } 63 103 64 - public int MaxChargeLevel 65 - { 104 + /// <summary> 105 + /// Gets the max charge level. 106 + /// </summary> 107 + /// <value>The max charge level.</value> 108 + public int MaxChargeLevel { 66 109 get { return attackPatterns.Length + 1; } 67 110 } 68 111 112 + /// <summary> 113 + /// Gets the current charge capacity. 114 + /// </summary> 115 + /// <value>The current charge capacity.</value> 69 116 public float CurrentChargeCapacity { 70 117 get { 71 118 return currentChargeCapacity; ··· 73 120 } 74 121 75 122 private int livesRemaining; 123 + /// <summary> 124 + /// Gets the lives remaining. 125 + /// </summary> 126 + /// <value>The lives remaining.</value> 76 127 public int LivesRemaining { 77 128 get { 78 129 return livesRemaining; 79 130 } 80 131 } 81 132 82 - [HideInInspector] 133 + /// <summary> 134 + /// The charge rate. 135 + /// </summary> 83 136 [SerializeField] 84 137 private float chargeRate = 1.0f; 85 138 139 + /// <summary> 140 + /// The fire rate. 141 + /// </summary> 86 142 [SerializeField] 87 143 private float fireRate = 4.0f; 88 144 private float fireDelay; 89 145 146 + /// <summary> 147 + /// The death cancel radius. 148 + /// </summary> 90 149 [SerializeField] 91 150 private float deathCancelRadius; 92 151 93 152 private bool firing = false; 153 + /// <summary> 154 + /// Gets a value indicating whether this instance is firing. 155 + /// </summary> 156 + /// <value><c>true</c> if this instance is firing; otherwise, <c>false</c>.</value> 94 157 public bool IsFiring 95 158 { 96 159 get { return firing && !charging; } 97 160 } 98 161 99 162 private Vector2 forbiddenMovement = Vector3.zero; 163 + /// <summary> 164 + /// Gets a value indicating whether this instance can move horizontal. 165 + /// </summary> 166 + /// <value><c>true</c> if this instance can move horizontal; otherwise, <c>false</c>.</value> 100 167 public int CanMoveHorizontal 101 168 { 102 169 get { return -(int)Util.Sign(forbiddenMovement.x); } 103 170 } 171 + /// <summary> 172 + /// Gets a value indicating whether this instance can move vertical. 173 + /// </summary> 174 + /// <value><c>true</c> if this instance can move vertical; otherwise, <c>false</c>.</value> 104 175 public int CanMoveVertical 105 176 { 106 177 get { return -(int)Util.Sign(forbiddenMovement.y); } 107 178 } 108 179 180 + /// <summary> 181 + /// Initialize the specified playerField and targetField. 182 + /// </summary> 183 + /// <param name="playerField">Player field.</param> 184 + /// <param name="targetField">Target field.</param> 109 185 public void Initialize(PlayerFieldController playerField, PlayerFieldController targetField) { 110 186 this.fieldController = playerField; 111 187 for(int i = 0; i < attackPatterns.Length; i++) 112 188 if(attackPatterns[i] != null) 113 - attackPatterns[i].Initialize(targetField); 189 + attackPatterns[i].TargetField = targetField; 114 190 } 115 191 116 - public virtual void Move(float horizontalDirection, float verticalDirection, bool focus, float dt = 1.0f) 117 - { 192 + /// <summary> 193 + /// Move the specified horizontalDirection, verticalDirection, focus and dt. 194 + /// </summary> 195 + /// <param name="horizontalDirection">Horizontal direction.</param> 196 + /// <param name="verticalDirection">Vertical direction.</param> 197 + /// <param name="focus">If set to <c>true</c> focus.</param> 198 + /// <param name="dt">Dt.</param> 199 + public virtual void Move(float horizontalDirection, float verticalDirection, bool focus, float dt = 1.0f) { 118 200 float movementSpeed = (focus) ? focusMovementSpeed : normalMovementSpeed; 119 201 Vector2 dir = new Vector2 (Util.Sign(horizontalDirection), Util.Sign(verticalDirection)); 120 202 Vector3 movementVector = movementSpeed * Vector3.one; ··· 124 206 Transform.position += movementVector * dt; 125 207 } 126 208 127 - public void AllowMovement(Vector2 direction) 128 - { 129 - if(Util.Sign(direction.x) == Util.Sign(forbiddenMovement.x)) 130 - { 209 + /// <summary> 210 + /// Allows the movement. 211 + /// </summary> 212 + /// <param name="direction">Direction.</param> 213 + public void AllowMovement(Vector2 direction) { 214 + if(Util.Sign(direction.x) == Util.Sign(forbiddenMovement.x)) { 131 215 forbiddenMovement.x = 0; 132 216 } 133 - if(Util.Sign(direction.y) == Util.Sign(forbiddenMovement.y)) 134 - { 217 + if(Util.Sign(direction.y) == Util.Sign(forbiddenMovement.y)) { 135 218 forbiddenMovement.y = 0; 136 219 } 137 220 } 138 221 139 - public void ForbidMovement(Vector2 direction) 140 - { 141 - if(direction.x != 0) 142 - { 222 + /// <summary> 223 + /// Forbids the movement. 224 + /// </summary> 225 + /// <param name="direction">Direction.</param> 226 + public void ForbidMovement(Vector2 direction) { 227 + if(direction.x != 0) { 143 228 forbiddenMovement.x = direction.x; 144 229 } 145 - if(direction.y != 0) 146 - { 230 + if(direction.y != 0) { 147 231 forbiddenMovement.y = direction.y; 148 232 } 149 233 } 150 234 151 - public void StartFiring() 152 - { 235 + /// <summary> 236 + /// Starts the firing. 237 + /// </summary> 238 + public void StartFiring() { 153 239 firing = true; 154 240 } 155 241 156 - public void StopFiring() 157 - { 242 + /// <summary> 243 + /// Stops the firing. 244 + /// </summary> 245 + public void StopFiring(){ 158 246 firing = false; 159 247 } 160 248 249 + /// <summary> 250 + /// Fire this instance. 251 + /// </summary> 161 252 public virtual void Fire() { 162 253 if(FieldController != null) { 163 254 Vector2 offset1, offset2, location; ··· 167 258 Projectile shot1 = FieldController.SpawnProjectile(shotType, location + offset1, 0f, PlayerFieldController.CoordinateSystem.AbsoluteWorld); 168 259 Projectile shot2 = FieldController.SpawnProjectile(shotType, location + offset2, 0f, PlayerFieldController.CoordinateSystem.AbsoluteWorld); 169 260 shot1.Velocity = shot2.Velocity = shotVelocity; 170 - shot1.Damage = shot2.Damage = shotDamage; 171 261 } 172 262 } 173 263 264 + /// <summary> 265 + /// Specials the attack. 266 + /// </summary> 267 + /// <param name="level">Level.</param> 174 268 public virtual void SpecialAttack(int level) { 175 269 int index = level - 1; 176 270 if (index >= 0 && index < attackPatterns.Length) { ··· 184 278 currentChargeCapacity -= level; 185 279 } 186 280 187 - public void StartCharging() 188 - { 281 + /// <summary> 282 + /// Starts the charging. 283 + /// </summary> 284 + public void StartCharging() { 189 285 charging = true; 190 286 } 191 287 192 - public void ReleaseCharge() 193 - { 194 - if(charging) 195 - { 288 + /// <summary> 289 + /// Releases the charge. 290 + /// </summary> 291 + public void ReleaseCharge() { 292 + if(charging) { 196 293 SpecialAttack(Mathf.FloorToInt(CurrentChargeLevel)); 197 294 } 198 295 charging = false; 199 296 } 200 297 298 + /// <summary> 299 + /// Hit this instance. 300 + /// </summary> 201 301 public void Hit() { 202 302 livesRemaining--; 203 303 float radius = deathCancelRadius * Util.MaxComponent2(Util.To2D(Transform.lossyScale)); ··· 207 307 } 208 308 } 209 309 310 + /// <summary> 311 + /// Reset the specified maxLives. 312 + /// </summary> 313 + /// <param name="maxLives">Max lives.</param> 210 314 public void Reset(int maxLives) { 211 315 livesRemaining = maxLives; 212 316 } 213 317 318 + /// <summary> 319 + /// Graze this instance. 320 + /// </summary> 214 321 public void Graze() { 215 - 322 + //TODO: Implement 216 323 } 217 324 325 + /// <summary> 326 + /// Fixeds the update. 327 + /// </summary> 218 328 void FixedUpdate() { 219 329 float dt = Time.fixedDeltaTime; 220 330 currentChargeCapacity += chargeCapacityRegen * dt;
+26 -21
Assets/Scripts/BaseLib/CachedObject.cs
··· 1 1 using System; 2 2 using UnityEngine; 3 3 4 - namespace BaseLib 5 - { 6 - public class CachedObject : MonoBehaviour 7 - { 4 + namespace BaseLib { 5 + /// <summary> 6 + /// Cached object. 7 + /// </summary> 8 + public class CachedObject : MonoBehaviour { 8 9 private GameObject gameObj; 9 10 private Transform trans; 10 - 11 - public Transform Transform 12 - { 13 - get 14 - { 15 - if(trans == null) 16 - { 11 + 12 + /// <summary> 13 + /// Gets the transform. 14 + /// </summary> 15 + /// <value>The transform.</value> 16 + public Transform Transform { 17 + get { 18 + if(trans == null) { 17 19 trans = transform; 18 20 } 19 21 return trans; 20 22 } 21 23 } 22 - 23 - public GameObject GameObject 24 - { 25 - get 26 - { 27 - if(gameObj == null) 28 - { 24 + 25 + /// <summary> 26 + /// Gets the game object. 27 + /// </summary> 28 + /// <value>The game object.</value> 29 + public GameObject GameObject { 30 + get { 31 + if(gameObj == null) { 29 32 gameObj = gameObject; 30 33 } 31 34 return gameObj; 32 35 } 33 36 } 34 - 35 - public virtual void Awake() 36 - { 37 + 38 + /// <summary> 39 + /// Awake this instance. 40 + /// </summary> 41 + public virtual void Awake() { 37 42 trans = transform; 38 43 gameObj = gameObject; 39 44 }
+43 -20
Assets/Scripts/BaseLib/DynamicValueType.cs
··· 1 1 using System; 2 2 using UnityEngine; 3 3 4 - namespace BaseLib 5 - { 6 - public abstract class AbstractDynamicValue<T> 7 - { 4 + namespace BaseLib { 5 + 6 + /// <summary> 7 + /// Abstract dynamic value. 8 + /// </summary> 9 + public abstract class AbstractDynamicValue<T> { 10 + 11 + /// <summary> 12 + /// Gets the value. 13 + /// </summary> 14 + /// <value>The value.</value> 8 15 public abstract T Value { get; } 9 16 10 - public static implicit operator T(AbstractDynamicValue<T> adv) 11 - { 12 - if(adv == null) 13 - { 17 + /// <param name="adv">Adv.</param> 18 + public static implicit operator T(AbstractDynamicValue<T> adv) { 19 + if(adv == null) { 14 20 return default(T); 15 21 } 16 22 return adv.Value; 17 23 } 18 24 } 19 25 20 - public class FixedFloat : AbstractDynamicValue<float> 21 - { 26 + /// <summary> 27 + /// Fixed float. 28 + /// </summary> 29 + public class FixedFloat : AbstractDynamicValue<float> { 22 30 private float value; 23 31 24 - public override float Value 25 - { 32 + /// <summary> 33 + /// Gets the value. 34 + /// </summary> 35 + /// <value>The value.</value> 36 + public override float Value { 26 37 get { return value; } 27 38 } 28 39 29 - public FixedFloat (float value) 30 - { 40 + /// <summary> 41 + /// Initializes a new instance of the <see cref="BaseLib.FixedFloat"/> class. 42 + /// </summary> 43 + /// <param name="value">Value.</param> 44 + public FixedFloat (float value) { 31 45 this.value = value; 32 46 } 33 47 } 34 48 35 - public class RandomRangeFloat : AbstractDynamicValue<float> 36 - { 49 + /// <summary> 50 + /// Random range float. 51 + /// </summary> 52 + public class RandomRangeFloat : AbstractDynamicValue<float> { 37 53 private float min; 38 54 private float max; 39 55 40 - public override float Value 41 - { 56 + /// <summary> 57 + /// Gets the value. 58 + /// </summary> 59 + /// <value>The value.</value> 60 + public override float Value { 42 61 get { return UnityEngine.Random.Range (min, max); } 43 62 } 44 63 45 - public RandomRangeFloat(float rangeMin, float rangeMax) 46 - { 64 + /// <summary> 65 + /// Initializes a new instance of the <see cref="BaseLib.RandomRangeFloat"/> class. 66 + /// </summary> 67 + /// <param name="rangeMin">Range minimum.</param> 68 + /// <param name="rangeMax">Range max.</param> 69 + public RandomRangeFloat(float rangeMin, float rangeMax) { 47 70 min = rangeMin; 48 71 max = rangeMax; 49 72 }
+29 -4
Assets/Scripts/BaseLib/GUI/FPSCounter.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// FPS counter. 6 + /// </summary> 4 7 [RequireComponent(typeof(GUIText))] 5 8 public class FPSCounter : MonoBehaviour { 9 + 10 + /// <summary> 11 + /// The update interval. 12 + /// </summary> 6 13 private float updateInterval = 0.5f; 7 - 14 + 15 + /// <summary> 16 + /// The accum. 17 + /// </summary> 8 18 private float accum = 0.0f; // FPS accumulated over the interval 19 + 20 + /// <summary> 21 + /// The frames. 22 + /// </summary> 9 23 private float frames = 0f; // Frames drawn over the interval 24 + 25 + /// <summary> 26 + /// The timeleft. 27 + /// </summary> 10 28 private float timeleft; // Left time for current interval 11 29 30 + /// <summary> 31 + /// The display. 32 + /// </summary> 12 33 private GUIText display; 13 34 14 - // Use this for initialization 35 + /// <summary> 36 + /// Start this instance. 37 + /// </summary> 15 38 void Start () { 16 39 display = guiText; 17 40 } 18 - 19 - // Update is called once per frame 41 + 42 + /// <summary> 43 + /// Update this instance. 44 + /// </summary> 20 45 void Update () { 21 46 float dt = Time.deltaTime; 22 47 timeleft -= dt ;
+36
Assets/Scripts/BaseLib/GUI/MultiObjectValueIndicator.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Multi object value indicator. 6 + /// </summary> 4 7 public abstract class MultiObjectValueIndicator : MonoBehaviour { 8 + 9 + /// <summary> 10 + /// The game controller. 11 + /// </summary> 5 12 [SerializeField] 6 13 protected GameController gameController; 14 + 15 + /// <summary> 16 + /// The player. 17 + /// </summary> 7 18 [SerializeField] 8 19 protected bool player; 20 + 21 + /// <summary> 22 + /// The base indicator. 23 + /// </summary> 9 24 [SerializeField] 10 25 protected GameObject baseIndicator; 26 + 27 + /// <summary> 28 + /// The additional offset. 29 + /// </summary> 11 30 [SerializeField] 12 31 protected Vector2 additionalOffset; 13 32 33 + /// <summary> 34 + /// The indicators. 35 + /// </summary> 14 36 protected GameObject[] indicators; 15 37 38 + /// <summary> 39 + /// Gets the max value. 40 + /// </summary> 41 + /// <returns>The max value.</returns> 16 42 protected abstract int GetMaxValue(); 17 43 44 + /// <summary> 45 + /// Gets the value. 46 + /// </summary> 47 + /// <returns>The value.</returns> 18 48 protected abstract int GetValue (); 19 49 50 + /// <summary> 51 + /// Start this instance. 52 + /// </summary> 20 53 void Start() 21 54 { 22 55 indicators = new GameObject[GetMaxValue()]; ··· 30 63 } 31 64 } 32 65 66 + /// <summary> 67 + /// Update this instance. 68 + /// </summary> 33 69 void Update() 34 70 { 35 71 Vector3 basePosition = baseIndicator.transform.position;
+51 -6
Assets/Scripts/BaseLib/GameObjectPool.cs
··· 3 3 using System.Collections.Generic; 4 4 5 5 namespace BaseLib { 6 + 7 + /// <summary> 8 + /// I pool. 9 + /// </summary> 6 10 public interface IPool { 7 11 void Return (object obj); 8 12 } 9 13 14 + /// <summary> 15 + /// Game object pool. 16 + /// </summary> 10 17 public class GameObjectPool<T, P> : CachedObject, IPool where T : PooledObject<P> where P : MonoBehaviour{ 11 18 private Queue<T> inactive; 12 19 private bool valid = true; 20 + 21 + /// <summary> 22 + /// The initial spawn count. 23 + /// </summary> 13 24 [SerializeField] 14 25 private int initialSpawnCount; 26 + 27 + /// <summary> 28 + /// The spawn count. 29 + /// </summary> 15 30 [SerializeField] 16 31 private int spawnCount; 32 + 33 + /// <summary> 34 + /// The base prefab. 35 + /// </summary> 17 36 [SerializeField] 18 37 private GameObject basePrefab; 38 + 39 + /// <summary> 40 + /// The container. 41 + /// </summary> 19 42 [SerializeField] 20 43 private GameObject container; 44 + 45 + /// <summary> 46 + /// The active count. 47 + /// </summary> 21 48 private int activeCount = 0; 22 - 49 + 50 + /// <summary> 51 + /// Awake this instance. 52 + /// </summary> 23 53 public override void Awake() { 24 54 base.Awake (); 25 55 T[] po = basePrefab.GetComponents<T> (); ··· 31 61 Spawn (initialSpawnCount); 32 62 } 33 63 } 34 - 64 + 65 + /// <summary> 66 + /// Return the specified po. 67 + /// </summary> 68 + /// <param name="po">Po.</param> 35 69 public void Return(T po) { 36 70 if(valid) { 37 71 inactive.Enqueue (po); ··· 40 74 } 41 75 } 42 76 43 - public void Return (object obj) 44 - { 77 + /// <summary> 78 + /// Return the specified obj. 79 + /// </summary> 80 + /// <param name="obj">Object.</param> 81 + public void Return (object obj) { 45 82 Return ((T)obj); 46 83 } 47 - 84 + 85 + /// <summary> 86 + /// Get the specified prefab. 87 + /// </summary> 88 + /// <param name="prefab">Prefab.</param> 48 89 public PooledObject<P> Get(P prefab = null) { 49 90 if(valid) { 50 91 if(inactive.Count <= 0) ··· 58 99 } 59 100 return null; 60 101 } 61 - 102 + 103 + /// <summary> 104 + /// Spawn the specified count. 105 + /// </summary> 106 + /// <param name="count">Count.</param> 62 107 private void Spawn(int count) { 63 108 Transform parentTrans = container.transform; 64 109 for(int i = 0; i < count; i++) {
+32 -1
Assets/Scripts/BaseLib/PooledObject.cs
··· 3 3 using System.Collections.Generic; 4 4 5 5 namespace BaseLib { 6 + 7 + /// <summary> 8 + /// Pooled object. 9 + /// </summary> 6 10 public abstract class PooledObject<T> : CachedObject where T : MonoBehaviour { 7 11 private IPool parentPool; 8 12 9 13 private T prefab; 14 + 15 + /// <summary> 16 + /// Gets or sets the prefab. 17 + /// </summary> 18 + /// <value>The prefab.</value> 10 19 public T Prefab { 11 20 get { 12 21 return prefab; ··· 18 27 } 19 28 20 29 private bool is_active = false; 30 + 31 + /// <summary> 32 + /// Gets or sets a value indicating whether this <see cref="BaseLib.PooledObject`1"/> is active. 33 + /// </summary> 34 + /// <value><c>true</c> if active; otherwise, <c>false</c>.</value> 21 35 public bool Active { 22 36 get { 23 - return Active; 37 + return is_active; 24 38 } 25 39 set { 26 40 //Debug.Log(value); ··· 35 49 } 36 50 } 37 51 52 + /// <summary> 53 + /// Start this instance. 54 + /// </summary> 38 55 void Start() { 39 56 GameObject.SetActive (false); 40 57 } 41 58 59 + /// <summary> 60 + /// Initialize the specified pool. 61 + /// </summary> 62 + /// <param name="pool">Pool.</param> 42 63 public void Initialize(IPool pool) { 43 64 //Debug.Log ("initlaized"); 44 65 parentPool = pool; 45 66 } 46 67 68 + /// <summary> 69 + /// Matchs the prefab. 70 + /// </summary> 71 + /// <param name="gameObj">Game object.</param> 47 72 public abstract void MatchPrefab (T gameObj); 48 73 74 + /// <summary> 75 + /// Activate this instance. 76 + /// </summary> 49 77 protected virtual void Activate() { 50 78 } 51 79 80 + /// <summary> 81 + /// Deactivate this instance. 82 + /// </summary> 52 83 protected virtual void Deactivate() { 53 84 } 54 85 }
+45 -13
Assets/Scripts/BaseLib/ScreenBoundary.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Screen boundary. 6 + /// </summary> 4 7 [RequireComponent(typeof(BoxCollider2D))] 5 8 public class ScreenBoundary : BaseLib.CachedObject { 6 9 10 + /// <summary> 11 + /// The fixed points. 12 + /// </summary> 7 13 public enum Edge { Top = 0, Bottom = 1, Left = 2, Right = 3} 14 + 8 15 private static Vector2[] fixedPoints = new Vector2[] { 9 16 new Vector2 (0.5f, 1f), 10 17 new Vector2 (0.5f, 0f), 11 18 new Vector2 (0f, 0.5f), 12 19 new Vector2 (1f, 0.5f) 13 20 }; 14 - 21 + 22 + /// <summary> 23 + /// The reference camera. 24 + /// </summary> 15 25 public Camera referenceCamera; 26 + 27 + /// <summary> 28 + /// The location. 29 + /// </summary> 16 30 public Edge location; 31 + 32 + /// <summary> 33 + /// The camera size buffer ratio. 34 + /// </summary> 17 35 public float cameraSizeBufferRatio; 36 + 37 + /// <summary> 38 + /// The camera size space ratio. 39 + /// </summary> 18 40 public float cameraSizeSpaceRatio; 41 + 42 + /// <summary> 43 + /// The constantly update. 44 + /// </summary> 19 45 public bool constantlyUpdate = true; 20 - private BoxCollider2D boundary; 21 46 47 + /// <summary> 48 + /// The boundary. 49 + /// </summary> 50 + private BoxCollider2D boundary; 22 51 23 - public override void Awake () 24 - { 52 + /// <summary> 53 + /// Awake this instance. 54 + /// </summary> 55 + public override void Awake () { 25 56 base.Awake (); 26 57 boundary = GetComponent<BoxCollider2D> (); 27 58 UpdatePosition (); 28 59 } 29 60 30 - // Update is called once per frame 31 - void Update () 32 - { 61 + /// <summary> 62 + /// Update this instance. 63 + /// </summary> 64 + void Update () { 33 65 if(constantlyUpdate) { 34 66 UpdatePosition(); 35 67 } 36 68 } 37 69 38 - private void UpdatePosition() 39 - { 70 + /// <summary> 71 + /// Updates the position. 72 + /// </summary> 73 + private void UpdatePosition() { 40 74 float cameraSize = referenceCamera.orthographicSize; 41 75 Vector2 fixedPoint = fixedPoints [(int)location]; 42 76 Vector3 viewportPoint = new Vector3 (fixedPoint.x, fixedPoint.y, 0f); ··· 45 79 float space = cameraSizeSpaceRatio * cameraSize;; 46 80 47 81 Vector2 area = boundary.size; 48 - switch(location) 49 - { 82 + switch(location) { 50 83 case Edge.Top: 51 84 case Edge.Bottom: 52 85 area.y = cameraSizeBufferRatio * cameraSize; ··· 61 94 boundary.size = area; 62 95 63 96 Bounds oldBounds = boundary.bounds; 64 - switch(location) 65 - { 97 + switch(location) { 66 98 case Edge.Top: 67 99 newPosition.y += oldBounds.extents.y + space; 68 100 break;
+30 -22
Assets/Scripts/BaseLib/StaticGameObject.cs
··· 2 2 using System; 3 3 4 4 namespace BaseLib { 5 + /// <summary> 6 + /// Static game object. 7 + /// </summary> 5 8 [Serializable] 6 - public abstract class StaticGameObject<T> : CachedObject where T : StaticGameObject<T> 7 - { 9 + public abstract class StaticGameObject<T> : CachedObject where T : StaticGameObject<T> { 10 + 8 11 private static T instance; 9 - 10 - public static T Instance 11 - { 12 - get 13 - { 14 - if(instance == null) 15 - { 12 + 13 + /// <summary> 14 + /// Gets the instance. 15 + /// </summary> 16 + /// <value>The instance.</value> 17 + public static T Instance { 18 + get { 19 + if(instance == null) { 16 20 instance = FindObjectOfType<T>(); 17 21 } 18 22 return instance; 19 23 } 20 24 } 21 - 25 + 26 + /// <summary> 27 + /// The keep between scenes. 28 + /// </summary> 22 29 public bool keepBetweenScenes; 30 + 31 + /// <summary> 32 + /// The destroy new instances. 33 + /// </summary> 23 34 public bool destroyNewInstances; 24 - 25 - public override void Awake () 26 - { 35 + 36 + /// <summary> 37 + /// Awake this instance. 38 + /// </summary> 39 + public override void Awake () { 27 40 base.Awake (); 28 - if(instance != null) 29 - { 30 - if(instance.destroyNewInstances) 31 - { 41 + if(instance != null) { 42 + if(instance.destroyNewInstances) { 32 43 Destroy (gameObject); 33 44 return; 34 - } 35 - else 36 - { 45 + } else { 37 46 Destroy (instance.GameObject); 38 47 } 39 48 } 40 49 41 50 instance = (T)this; 42 51 43 - if(keepBetweenScenes) 44 - { 52 + if(keepBetweenScenes) { 45 53 DontDestroyOnLoad (gameObject); 46 54 } 47 55 }
+73 -9
Assets/Scripts/BaseLib/Util.cs
··· 3 3 4 4 namespace BaseLib 5 5 { 6 - public static class Util 7 - { 6 + /// <summary> 7 + /// Util. 8 + /// </summary> 9 + public static class Util { 10 + 11 + /// <summary> 12 + /// The degree2 RAD. 13 + /// </summary> 8 14 public const float Degree2Rad = Mathf.PI / 180f; 15 + 16 + /// <summary> 17 + /// The rad2 degree. 18 + /// </summary> 9 19 public const float Rad2Degree = 180 / Mathf.PI; 10 20 11 - public static float Sign(float e) 12 - { 21 + /// <summary> 22 + /// Sign the specified e. 23 + /// </summary> 24 + /// <param name="e">E.</param> 25 + public static float Sign(float e) { 13 26 return (e == 0f) ? 0f : Mathf.Sign (e); 14 27 } 15 28 29 + /// <summary> 30 + /// To2s the d. 31 + /// </summary> 32 + /// <returns>The d.</returns> 33 + /// <param name="v">V.</param> 16 34 public static Vector2 To2D(Vector3 v) { 17 35 return new Vector2(v.x, v.y); 18 36 } 19 37 38 + /// <summary> 39 + /// To3s the d. 40 + /// </summary> 41 + /// <returns>The d.</returns> 42 + /// <param name="v">V.</param> 43 + /// <param name="z">The z coordinate.</param> 20 44 public static Vector3 To3D(Vector2 v, float z = 0f) { 21 45 return new Vector3 (v.x, v.y, z); 22 46 } 23 - 47 + 48 + /// <summary> 49 + /// Components the product2. 50 + /// </summary> 51 + /// <returns>The product2.</returns> 52 + /// <param name="v1">V1.</param> 53 + /// <param name="v2">V2.</param> 24 54 public static Vector2 ComponentProduct2(Vector2 v1, Vector2 v2) { 25 55 return new Vector2(v1.x * v2.x, v1.y * v2.y); 26 56 } 27 - 57 + 58 + /// <summary> 59 + /// Components the product3. 60 + /// </summary> 61 + /// <returns>The product3.</returns> 62 + /// <param name="v1">V1.</param> 63 + /// <param name="v2">V2.</param> 28 64 public static Vector3 ComponentProduct3(Vector3 v1, Vector3 v2) { 29 65 return new Vector3(v1.x * v2.x, v1.y * v2.y, v1.z * v2.z); 30 66 } 31 67 68 + /// <summary> 69 + /// Maxs the component2. 70 + /// </summary> 71 + /// <returns>The component2.</returns> 72 + /// <param name="v">V.</param> 32 73 public static float MaxComponent2(Vector2 v) { 33 74 return (v.x > v.y) ? v.x : v.y; 34 75 } 35 76 77 + /// <summary> 78 + /// Maxs the component3. 79 + /// </summary> 80 + /// <returns>The component3.</returns> 81 + /// <param name="v">V.</param> 36 82 public static float MaxComponent3(Vector3 v) { 37 83 if(v.x > v.y) 38 84 return (v.z > v.y) ? v.z : v.y; 39 85 else 40 86 return (v.z > v.x) ? v.z : v.x; 41 87 } 42 - 88 + 89 + /// <summary> 90 + /// Minimums the component2. 91 + /// </summary> 92 + /// <returns>The component2.</returns> 93 + /// <param name="v">V.</param> 43 94 public static float MinComponent2(Vector2 v) { 44 95 return (v.x < v.y) ? v.x : v.y; 45 96 } 46 - 97 + 98 + /// <summary> 99 + /// Minimums the component3. 100 + /// </summary> 101 + /// <returns>The component3.</returns> 102 + /// <param name="v">V.</param> 47 103 public static float MinComponent3(Vector3 v) { 48 104 if(v.x < v.y) 49 105 return (v.z < v.y) ? v.z : v.y; 50 106 else 51 107 return (v.z < v.x) ? v.z : v.x; 52 108 } 53 - 109 + /// <summary> 110 + /// Berziers the curve vector lerp. 111 + /// </summary> 112 + /// <returns>The curve vector lerp.</returns> 113 + /// <param name="start">Start.</param> 114 + /// <param name="end">End.</param> 115 + /// <param name="c1">C1.</param> 116 + /// <param name="c2">C2.</param> 117 + /// <param name="t">T.</param> 54 118 public static Vector3 BerzierCurveVectorLerp(Vector3 start, Vector3 end, Vector3 c1, Vector3 c2, float t) { 55 119 float u, uu, uuu, tt, ttt; 56 120 Vector3 p, p0 = start, p1 = c1, p2 = c2, p3 = end;
+26 -3
Assets/Scripts/Enemy.cs
··· 2 2 using BaseLib; 3 3 using System.Collections; 4 4 5 + /// <summary> 6 + /// Enemy. 7 + /// </summary> 5 8 [RequireComponent(typeof(Rigidbody2D))] 6 9 [RequireComponent(typeof(Collider2D))] 7 10 [RequireComponent(typeof(FieldMovementPattern))] 8 11 public class Enemy : CachedObject { 9 12 13 + /// <summary> 14 + /// The death reflect radius. 15 + /// </summary> 10 16 [SerializeField] 11 17 private float deathReflectRadius; 12 18 19 + /// <summary> 20 + /// The max health. 21 + /// </summary> 13 22 [SerializeField] 14 - private float maxHealth; 15 - private float health; 23 + private int maxHealth; 24 + private int health; 16 25 17 26 private AttackPattern attacks; 18 27 private FieldMovementPattern fmp; 19 28 29 + /// <summary> 30 + /// Start this instance. 31 + /// </summary> 20 32 void Start() { 21 33 health = maxHealth; 22 34 EnemyManager.RegisterEnemy (this); 23 35 fmp = GetComponent<FieldMovementPattern> (); 24 36 attacks = GetComponent<AttackPattern> (); 25 37 if (attacks != null) { 26 - attacks.Initialize (fmp.field); 38 + attacks.TargetField = fmp.field; 27 39 attacks.Fire (); 28 40 } 29 41 } 30 42 43 + /// <summary> 44 + /// Raises the trigger enter2 d event. 45 + /// </summary> 46 + /// <param name="other">Other.</param> 31 47 void OnTriggerEnter2D(Collider2D other) { 32 48 if (other.CompareTag ("Player Shot")) { 33 49 Projectile proj = other.GetComponent<Projectile>(); ··· 37 53 } 38 54 } 39 55 56 + /// <summary> 57 + /// Hit the specified proj. 58 + /// </summary> 59 + /// <param name="proj">Proj.</param> 40 60 public void Hit(Projectile proj) { 41 61 health -= proj.Damage; 42 62 proj.Active = false; ··· 45 65 } 46 66 } 47 67 68 + /// <summary> 69 + /// Die this instance. 70 + /// </summary> 48 71 private void Die() { 49 72 float radius = Util.MaxComponent3 (Transform.lossyScale) * deathReflectRadius; 50 73 //TODO: FINISH
+32
Assets/Scripts/EnemyBasicAttack.cs Assets/Scripts/AttackPatterns/EnemyBasicAttack.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Enemy basic attack. 6 + /// </summary> 4 7 public class EnemyBasicAttack : AttackPattern { 5 8 9 + /// <summary> 10 + /// The fire delay. 11 + /// </summary> 6 12 public float fireDelay; 13 + 14 + /// <summary> 15 + /// The velocity. 16 + /// </summary> 7 17 public float velocity; 18 + 19 + /// <summary> 20 + /// The ang v. 21 + /// </summary> 8 22 public float angV; 23 + 24 + /// <summary> 25 + /// The current delay. 26 + /// </summary> 9 27 private float currentDelay; 28 + 29 + /// <summary> 30 + /// The general range. 31 + /// </summary> 10 32 [SerializeField] 11 33 private float generalRange; 12 34 35 + /// <summary> 36 + /// The basic prefab. 37 + /// </summary> 13 38 public ProjectilePrefab basicPrefab; 14 39 40 + /// <summary> 41 + /// Start this instance. 42 + /// </summary> 15 43 void Start() { 16 44 currentDelay = fireDelay; 17 45 } 18 46 47 + /// <summary> 48 + /// Mains the loop. 49 + /// </summary> 50 + /// <param name="dt">Dt.</param> 19 51 protected override void MainLoop (float dt) { 20 52 currentDelay -= dt; 21 53 if (currentDelay <= 0f) {
Assets/Scripts/EnemyBasicAttack.cs.meta Assets/Scripts/AttackPatterns/EnemyBasicAttack.cs.meta
+84
Assets/Scripts/FieldMovementPattern.cs
··· 3 3 using System.Collections; 4 4 using BaseLib; 5 5 6 + /// <summary> 7 + /// Field movement pattern. 8 + /// </summary> 6 9 public class FieldMovementPattern : CachedObject { 10 + 11 + //TODO: Document Comment 7 12 public enum LocationType { Relative, Absolute, WorldRelative, WorldAbsolute } 13 + 14 + //TODO: Document Comment 8 15 public enum MovementType { Linear, Curve } 9 16 17 + /// <summary> 18 + /// The field. 19 + /// </summary> 10 20 public PlayerFieldController field; 21 + 22 + /// <summary> 23 + /// The test start point. 24 + /// </summary> 11 25 public Vector2 testStartPoint; 26 + 27 + /// <summary> 28 + /// The test invert y. 29 + /// </summary> 12 30 public bool testInvertY; 31 + 32 + /// <summary> 33 + /// The test invert x. 34 + /// </summary> 13 35 public bool testInvertX; 36 + 37 + /// <summary> 38 + /// The destroy on end. 39 + /// </summary> 14 40 public bool DestroyOnEnd; 15 41 42 + //TODO: Document Comment 16 43 [Serializable] 17 44 public class AtomicMovement { 45 + 46 + /// <summary> 47 + /// The type of the location. 48 + /// </summary> 18 49 public LocationType locationType; 50 + 51 + /// <summary> 52 + /// The type of the movement. 53 + /// </summary> 19 54 public MovementType movementType; 55 + 56 + /// <summary> 57 + /// The time. 58 + /// </summary> 20 59 public float time; 60 + 61 + /// <summary> 62 + /// The target location. 63 + /// </summary> 21 64 public Vector2 targetLocation; 65 + 66 + /// <summary> 67 + /// The curve control point1. 68 + /// </summary> 22 69 public Vector2 curveControlPoint1; 70 + 71 + /// <summary> 72 + /// The curve control point2. 73 + /// </summary> 23 74 public Vector2 curveControlPoint2; 24 75 76 + /// <summary> 77 + /// Nexts the location. 78 + /// </summary> 79 + /// <returns>The location.</returns> 80 + /// <param name="field">Field.</param> 81 + /// <param name="startLocation">Start location.</param> 25 82 public Vector3 NextLocation(PlayerFieldController field, Vector3 startLocation) { 26 83 return Interpret (targetLocation, field, startLocation); 27 84 } 28 85 86 + /// <summary> 87 + /// Nexts the control point1. 88 + /// </summary> 89 + /// <returns>The control point1.</returns> 90 + /// <param name="field">Field.</param> 91 + /// <param name="startLocation">Start location.</param> 29 92 public Vector3 NextControlPoint1(PlayerFieldController field, Vector3 startLocation) { 30 93 return Interpret (curveControlPoint1, field, startLocation); 31 94 } 32 95 96 + /// <summary> 97 + /// Nexts the control point2. 98 + /// </summary> 99 + /// <returns>The control point2.</returns> 100 + /// <param name="field">Field.</param> 101 + /// <param name="startLocation">Start location.</param> 33 102 public Vector3 NextControlPoint2(PlayerFieldController field, Vector3 startLocation) { 34 103 return Interpret (curveControlPoint2, field, startLocation); 35 104 } 36 105 106 + /// <summary> 107 + /// Interpret the specified loc, field and startLocation. 108 + /// </summary> 109 + /// <param name="loc">Location.</param> 110 + /// <param name="field">Field.</param> 111 + /// <param name="startLocation">Start location.</param> 37 112 private Vector3 Interpret(Vector2 loc, PlayerFieldController field, Vector3 startLocation) { 38 113 Vector3 nextLocation = Util.To3D(loc); 39 114 switch(locationType) { ··· 51 126 } 52 127 } 53 128 129 + /// <summary> 130 + /// The movements. 131 + /// </summary> 54 132 public AtomicMovement[] movements; 55 133 134 + /// <summary> 135 + /// Start this instance. 136 + /// </summary> 56 137 void Start() { 57 138 PlayerFieldController[] controllers = FindObjectsOfType<PlayerFieldController> (); 58 139 float minDist = float.MaxValue; ··· 66 147 StartCoroutine (Move ()); 67 148 } 68 149 150 + /// <summary> 151 + /// Move this instance. 152 + /// </summary> 69 153 private IEnumerator Move() { 70 154 for(int i = 0; i < movements.Length; i++) { 71 155 if(movements[i] != null) {
+22
Assets/Scripts/GUI/ChargeBarGUI.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Charge bar GU. 6 + /// </summary> 4 7 public class ChargeBarGUI : MonoBehaviour { 8 + 9 + /// <summary> 10 + /// The field controller. 11 + /// </summary> 5 12 [SerializeField] 6 13 private PlayerFieldController fieldController; 7 14 private Avatar player; 8 15 16 + /// <summary> 17 + /// The charge capacity. 18 + /// </summary> 9 19 [SerializeField] 10 20 private Transform chargeCapacity; 11 21 22 + /// <summary> 23 + /// The charge level. 24 + /// </summary> 12 25 [SerializeField] 13 26 private Transform chargeLevel; 14 27 28 + /// <summary> 29 + /// The indicator. 30 + /// </summary> 15 31 [SerializeField] 16 32 private GameObject indicator; 17 33 34 + /// <summary> 35 + /// Start this instance. 36 + /// </summary> 18 37 void Start() { 19 38 player = fieldController.PlayerController.PlayerAvatar; 20 39 int maxIndicatorLevel = player.MaxChargeLevel - 1; ··· 30 49 } 31 50 } 32 51 52 + /// <summary> 53 + /// Update this instance. 54 + /// </summary> 33 55 void Update() { 34 56 Vector3 capacityScale = chargeCapacity.localScale; 35 57 Vector3 levelScale = chargeCapacity.localScale;
+11
Assets/Scripts/GUI/PlayerLifeIndicator.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Player life indicator. 6 + /// </summary> 4 7 public class PlayerLifeIndicator : MultiObjectValueIndicator { 5 8 9 + /// <summary> 10 + /// Gets the max value. 11 + /// </summary> 12 + /// <returns>The max value.</returns> 6 13 protected override int GetMaxValue () { 7 14 return gameController.MaximumLives; 8 15 } 9 16 17 + /// <summary> 18 + /// Gets the value. 19 + /// </summary> 20 + /// <returns>The value.</returns> 10 21 protected override int GetValue () { 11 22 return ((player) ? gameController.player1 : gameController.player2).Field.LivesRemaining; 12 23 }
+11
Assets/Scripts/GUI/PlayerScoreIndicator.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Player score indicator. 6 + /// </summary> 4 7 public class PlayerScoreIndicator : MultiObjectValueIndicator { 5 8 9 + /// <summary> 10 + /// Gets the max value. 11 + /// </summary> 12 + /// <returns>The max value.</returns> 6 13 protected override int GetMaxValue () { 7 14 return gameController.winningScore; 8 15 } 9 16 17 + /// <summary> 18 + /// Gets the value. 19 + /// </summary> 20 + /// <returns>The value.</returns> 10 21 protected override int GetValue() { 11 22 return ((player) ? gameController.player1 : gameController.player2).score; 12 23 }
+24
Assets/Scripts/GUI/RoundTimer.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Round timer. 6 + /// </summary> 4 7 [RequireComponent(typeof(GUIText))] 5 8 public class RoundTimer : MonoBehaviour { 6 9 10 + /// <summary> 11 + /// The game controller. 12 + /// </summary> 7 13 [SerializeField] 8 14 private GameController gameController; 15 + 16 + /// <summary> 17 + /// The color of the flash. 18 + /// </summary> 9 19 [SerializeField] 10 20 private Color flashColor; 21 + 22 + /// <summary> 23 + /// The flash interval. 24 + /// </summary> 11 25 [SerializeField] 12 26 private float flashInterval; 27 + 28 + /// <summary> 29 + /// The flash threshold. 30 + /// </summary> 13 31 [SerializeField] 14 32 private float flashThreshold; 15 33 ··· 18 36 private float flashDelay; 19 37 private GUIText label; 20 38 39 + /// <summary> 40 + /// Start this instance. 41 + /// </summary> 21 42 void Start() { 22 43 label = guiText; 23 44 normalColor = label.color; ··· 25 46 flashDelay = 0f; 26 47 } 27 48 49 + /// <summary> 50 + /// Update this instance. 51 + /// </summary> 28 52 void Update() { 29 53 int timeSec = Mathf.FloorToInt (gameController.RemainingRoundTime); 30 54 int seconds = timeSec % 60;
+61 -6
Assets/Scripts/GameController.cs
··· 2 2 using System; 3 3 using System.Collections; 4 4 5 - public class GameController : MonoBehaviour 6 - { 5 + /// <summary> 6 + /// Game controller. 7 + /// </summary> 8 + public class GameController : MonoBehaviour { 9 + 10 + //TODO: Document Comment 7 11 [Serializable] 8 12 public class PlayerData { 13 + 9 14 [SerializeField] 10 15 private PlayerFieldController field; 16 + /// <summary> 17 + /// Gets the field. 18 + /// </summary> 19 + /// <value>The field.</value> 11 20 public PlayerFieldController Field { 12 21 get { 13 22 return field; 14 23 } 15 24 } 16 25 26 + /// <summary> 27 + /// The score. 28 + /// </summary> 17 29 public int score; 18 30 } 19 31 32 + /// <summary> 33 + /// The player1. 34 + /// </summary> 20 35 public PlayerData player1; 36 + 37 + /// <summary> 38 + /// The player2. 39 + /// </summary> 21 40 public PlayerData player2; 22 41 23 42 [SerializeField] 24 43 public int winningScore; 44 + /// <summary> 45 + /// Gets the winning score. 46 + /// </summary> 47 + /// <value>The winning score.</value> 25 48 public int WinningScore { 26 49 get { 27 50 return winningScore; ··· 30 53 31 54 [SerializeField] 32 55 private int maximumLives; 56 + /// <summary> 57 + /// Gets the maximum lives. 58 + /// </summary> 59 + /// <value>The maximum lives.</value> 33 60 public int MaximumLives { 34 61 get { 35 62 return maximumLives; 36 63 } 37 64 } 38 65 39 - 66 + /// <summary> 67 + /// The round time. 68 + /// </summary> 40 69 [SerializeField] 41 70 private float roundTime; 71 + 42 72 private float roundTimeRemaining; 73 + /// <summary> 74 + /// Gets the remaining round time. 75 + /// </summary> 76 + /// <value>The remaining round time.</value> 43 77 public float RemainingRoundTime { 44 78 get { 45 79 return roundTimeRemaining; 46 80 } 47 81 } 48 82 83 + /// <summary> 84 + /// The guardian. 85 + /// </summary> 49 86 [SerializeField] 50 87 public GameObject guardian; 51 88 52 89 private bool guardianSummoned; 53 90 91 + /// <summary> 92 + /// Awake this instance. 93 + /// </summary> 54 94 void Awake() { 55 95 Physics2D.raycastsHitTriggers = true; 56 96 if(player1.Field != null && player2.Field != null) { ··· 62 102 } 63 103 } 64 104 105 + /// <summary> 106 + /// Fixeds the update. 107 + /// </summary> 65 108 void FixedUpdate() { 66 109 bool reset = false; 67 110 if (player1.Field.LivesRemaining <= 0) { 68 - player1.score++; 111 + player2.score++; 69 112 reset = true; 70 113 } 71 114 if (player2.Field.LivesRemaining <= 0) { 72 - player2.score++; 115 + player1.score++; 73 116 reset = true; 74 117 } 75 118 if(player1.score >= winningScore && player2.score >= winningScore) { ··· 90 133 } 91 134 } 92 135 136 + /// <summary> 137 + /// Starts the round. 138 + /// </summary> 93 139 public void StartRound() { 94 140 roundTimeRemaining = roundTime; 95 141 guardianSummoned = false; 96 142 } 97 143 144 + /// <summary> 145 + /// Reset this instance. 146 + /// </summary> 98 147 public void Reset() { 99 - 148 + player1.Field.Reset (); 149 + player2.Field.Reset (); 100 150 } 101 151 152 + /// <summary> 153 + /// Spawns the enemy. 154 + /// </summary> 155 + /// <param name="prefab">Prefab.</param> 156 + /// <param name="relativeLocations">Relative locations.</param> 102 157 public void SpawnEnemy(GameObject prefab, Vector2 relativeLocations) { 103 158 if(player1.Field != null && player2.Field != null) { 104 159 player1.Field.SpawnEnemy(prefab, relativeLocations);
+3 -9
Assets/Scripts/PlayerControllers/AIAgent.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// AI agent. 6 + /// </summary> 4 7 public class AIAgent : MonoBehaviour { 5 8 6 - // Use this for initialization 7 - void Start () { 8 - 9 - } 10 - 11 - // Update is called once per frame 12 - void Update () { 13 - 14 - } 15 9 }
+13
Assets/Scripts/PlayerControllers/ControlledAgent.cs
··· 2 2 using BaseLib; 3 3 using System.Collections; 4 4 5 + /// <summary> 6 + /// Controlled agent. 7 + /// </summary> 5 8 public class ControlledAgent : PlayerAgent { 6 9 private string horizontalMoveAxis; 7 10 private string verticalMoveAxis; ··· 9 12 private string focusButton; 10 13 private string chargeButton; 11 14 15 + /// <summary> 16 + /// Initialize the specified fieldController, playerAvatar and targetField. 17 + /// </summary> 18 + /// <param name="fieldController">Field controller.</param> 19 + /// <param name="playerAvatar">Player avatar.</param> 20 + /// <param name="targetField">Target field.</param> 12 21 public override void Initialize (PlayerFieldController fieldController, Avatar playerAvatar, PlayerFieldController targetField) { 13 22 base.Initialize (fieldController, playerAvatar, targetField); 14 23 string strPlay = "Player "; ··· 20 29 chargeButton = "Charge " + strPlay + playerNumber; 21 30 } 22 31 32 + /// <summary> 33 + /// Update the specified dt. 34 + /// </summary> 35 + /// <param name="dt">Dt.</param> 23 36 public override void Update (float dt) { 24 37 Vector2 movementVector = Vector2.zero; 25 38 movementVector.x = Util.Sign(Input.GetAxis (horizontalMoveAxis));
+23 -2
Assets/Scripts/PlayerControllers/PlayerAgent.cs
··· 2 2 using System; 3 3 using System.Collections; 4 4 5 + /// <summary> 6 + /// Player agent. 7 + /// </summary> 5 8 [Serializable] 6 - public abstract class PlayerAgent 7 - { 9 + public abstract class PlayerAgent { 10 + 8 11 private Avatar playerAvatar; 9 12 private PlayerFieldController fieldController; 10 13 14 + /// <summary> 15 + /// Gets the player avatar. 16 + /// </summary> 17 + /// <value>The player avatar.</value> 11 18 public Avatar PlayerAvatar { 12 19 get { 13 20 return playerAvatar; 14 21 } 15 22 } 16 23 24 + /// <summary> 25 + /// Gets the field controller. 26 + /// </summary> 27 + /// <value>The field controller.</value> 17 28 public PlayerFieldController FieldController { 18 29 get { 19 30 return fieldController; 20 31 } 21 32 } 22 33 34 + /// <summary> 35 + /// Initialize the specified fieldController, playerAvatar and targetField. 36 + /// </summary> 37 + /// <param name="fieldController">Field controller.</param> 38 + /// <param name="playerAvatar">Player avatar.</param> 39 + /// <param name="targetField">Target field.</param> 23 40 public virtual void Initialize(PlayerFieldController fieldController, Avatar playerAvatar, PlayerFieldController targetField) { 24 41 this.fieldController = fieldController; 25 42 this.playerAvatar = playerAvatar; 26 43 playerAvatar.Initialize (fieldController, targetField); 27 44 } 28 45 46 + /// <summary> 47 + /// Update the specified dt. 48 + /// </summary> 49 + /// <param name="dt">Dt.</param> 29 50 public abstract void Update(float dt); 30 51 }
+143
Assets/Scripts/PlayerFieldController.cs
··· 3 3 using System.Collections; 4 4 using System.Collections.Generic; 5 5 6 + /// <summary> 7 + /// Player field controller. 8 + /// </summary> 6 9 public class PlayerFieldController : BaseLib.CachedObject { 10 + 7 11 public enum CoordinateSystem { Screen, FieldRelative, AbsoluteWorld } 8 12 13 + /// <summary> 14 + /// The player spawn location. 15 + /// </summary> 9 16 public Vector2 playerSpawnLocation; 10 17 11 18 private int playerNumber = 1; 19 + /// <summary> 20 + /// Gets or sets the player number. 21 + /// </summary> 22 + /// <value>The player number.</value> 12 23 public int PlayerNumber { 13 24 get { 14 25 return playerNumber; ··· 18 29 } 19 30 } 20 31 32 + /// <summary> 33 + /// The game plane distance. 34 + /// </summary> 21 35 [SerializeField] 22 36 private float gamePlaneDistance; 37 + 38 + /// <summary> 39 + /// The field camera. 40 + /// </summary> 23 41 [SerializeField] 24 42 private Camera fieldCamera; 25 43 26 44 private Transform cameraTransform; 45 + /// <summary> 46 + /// Gets or sets the camera transform. 47 + /// </summary> 48 + /// <value>The camera transform.</value> 27 49 public Transform CameraTransform { 28 50 get { 29 51 return cameraTransform; ··· 34 56 } 35 57 36 58 private PlayerAgent playerController; 59 + /// <summary> 60 + /// Gets or sets the player controller. 61 + /// </summary> 62 + /// <value>The player controller.</value> 37 63 public PlayerAgent PlayerController { 38 64 get { 39 65 return playerController; ··· 44 70 } 45 71 46 72 private PlayerFieldController targetField; 73 + /// <summary> 74 + /// Sets the target field. 75 + /// </summary> 76 + /// <value>The target field.</value> 47 77 public PlayerFieldController TargetField { 48 78 set { 49 79 targetField = value; 50 80 } 51 81 } 52 82 83 + /// <summary> 84 + /// Gets the lives remaining. 85 + /// </summary> 86 + /// <value>The lives remaining.</value> 53 87 public int LivesRemaining { 54 88 get { 55 89 if(playerController != null && playerController.PlayerAvatar != null) { ··· 61 95 } 62 96 } 63 97 98 + /// <summary> 99 + /// Gets the player position. 100 + /// </summary> 101 + /// <value>The player position.</value> 64 102 public Vector3 PlayerPosition { 65 103 get { 66 104 if(playerController != null && playerController.PlayerAvatar != null) { ··· 72 110 } 73 111 } 74 112 113 + /// <summary> 114 + /// Angles the toward player. 115 + /// </summary> 116 + /// <returns>The toward player.</returns> 117 + /// <param name="startLocation">Start location.</param> 75 118 public float AngleTowardPlayer(Vector3 startLocation) { 76 119 return Projectile.AngleBetween2D (startLocation, PlayerPosition); 77 120 } 78 121 122 + /// <summary> 123 + /// The death cancel raidus. 124 + /// </summary> 79 125 [SerializeField] 80 126 private float deathCancelRaidus; 81 127 ··· 84 130 private Vector3 zDirection; 85 131 private Vector3 bottomLeft; 86 132 133 + /// <summary> 134 + /// Gets the size of the X. 135 + /// </summary> 136 + /// <value>The size of the X.</value> 87 137 public float XSize { 88 138 get { return xDirection.magnitude; } 89 139 } 140 + 141 + /// <summary> 142 + /// Gets the size of the Y. 143 + /// </summary> 144 + /// <value>The size of the Y.</value> 90 145 public float YSize { 91 146 get { return yDirection.magnitude; } 92 147 } 148 + 149 + /// <summary> 150 + /// Gets the bottom left. 151 + /// </summary> 152 + /// <value>The bottom left.</value> 93 153 public Vector3 BottomLeft { 94 154 get { return WorldPoint (new Vector3(0f, 0f, gamePlaneDistance)); } 95 155 } 156 + 157 + /// <summary> 158 + /// Gets the bottom right. 159 + /// </summary> 160 + /// <value>The bottom right.</value> 96 161 public Vector3 BottomRight { 97 162 get { return WorldPoint (new Vector3(1f, 0f, gamePlaneDistance)); } 98 163 } 164 + 165 + /// <summary> 166 + /// Gets the top left. 167 + /// </summary> 168 + /// <value>The top left.</value> 99 169 public Vector3 TopLeft { 100 170 get { return WorldPoint (new Vector3(0f, 1f, gamePlaneDistance)); } 101 171 } 172 + 173 + /// <summary> 174 + /// Gets the top right. 175 + /// </summary> 176 + /// <value>The top right.</value> 102 177 public Vector3 TopRight { 103 178 get { return WorldPoint (new Vector3(1f, 1f, gamePlaneDistance)); } 104 179 } 180 + 181 + /// <summary> 182 + /// Gets the center. 183 + /// </summary> 184 + /// <value>The center.</value> 105 185 public Vector3 Center { 106 186 get { return WorldPoint (new Vector3(0.5f, 0.5f, gamePlaneDistance)); } 107 187 } 188 + 189 + /// <summary> 190 + /// Gets the top. 191 + /// </summary> 192 + /// <value>The top.</value> 108 193 public Vector3 Top { 109 194 get { return WorldPoint (new Vector3 (0.5f, 1f, gamePlaneDistance)); } 110 195 } 196 + 197 + /// <summary> 198 + /// Gets the bottom. 199 + /// </summary> 200 + /// <value>The bottom.</value> 111 201 public Vector3 Bottom { 112 202 get { return WorldPoint (new Vector3 (0.5f, 0f, gamePlaneDistance));} 113 203 } 204 + 205 + /// <summary> 206 + /// Gets the right. 207 + /// </summary> 208 + /// <value>The right.</value> 114 209 public Vector3 Right { 115 210 get { return WorldPoint (new Vector3 (1f, 0.5f, gamePlaneDistance)); } 116 211 } 212 + 213 + /// <summary> 214 + /// Gets the left. 215 + /// </summary> 216 + /// <value>The left.</value> 117 217 public Vector3 Left { 118 218 get { return WorldPoint (new Vector3 (0f, 0.5f, gamePlaneDistance));} 119 219 } 120 220 221 + /// <summary> 222 + /// The bullet pool. 223 + /// </summary> 121 224 [SerializeField] 122 225 private ProjectilePool bulletPool; 123 226 227 + /// <summary> 228 + /// Start this instance. 229 + /// </summary> 124 230 void Start() { 125 231 fieldCamera.orthographic = true; 126 232 cameraTransform = fieldCamera.transform; 127 233 RecomputeWorldPoints (); 128 234 } 129 235 236 + /// <summary> 237 + /// Fixeds the update. 238 + /// </summary> 130 239 void FixedUpdate () { 131 240 if(playerController != null) { 132 241 playerController.Update(Time.fixedDeltaTime); 133 242 } 134 243 } 135 244 245 + /// <summary> 246 + /// Worlds the point. 247 + /// </summary> 248 + /// <returns>The point.</returns> 249 + /// <param name="fieldPoint">Field point.</param> 136 250 public Vector3 WorldPoint(Vector3 fieldPoint) { 137 251 return bottomLeft + Relative2Absolute (fieldPoint); 138 252 } 139 253 254 + /// <summary> 255 + /// Fields the point. 256 + /// </summary> 257 + /// <returns>The point.</returns> 258 + /// <param name="worldPoint">World point.</param> 140 259 public Vector3 FieldPoint(Vector3 worldPoint) { 141 260 Vector3 offset = worldPoint - bottomLeft; 142 261 return new Vector3 (Vector3.Project (offset, xDirection).magnitude, Vector3.Project (offset, yDirection).magnitude, Vector3.Project (offset, zDirection).magnitude); 143 262 } 144 263 264 + /// <summary> 265 + /// Relative2s the absolute. 266 + /// </summary> 267 + /// <returns>The absolute.</returns> 268 + /// <param name="relativeVector">Relative vector.</param> 145 269 public Vector3 Relative2Absolute(Vector3 relativeVector) { 146 270 return relativeVector.x * xDirection + relativeVector.y * yDirection + relativeVector.z * zDirection; 271 + } 272 + 273 + /// <summary> 274 + /// Reset this instance. 275 + /// </summary> 276 + public void Reset() { 277 + playerController.PlayerAvatar.Reset (5); 147 278 } 148 279 149 280 /// <summary> ··· 202 333 return projectile; 203 334 } 204 335 336 + /// <summary> 337 + /// Spawns the enemy. 338 + /// </summary> 339 + /// <param name="prefab">Prefab.</param> 340 + /// <param name="fieldLocation">Field location.</param> 205 341 public void SpawnEnemy(GameObject prefab, Vector2 fieldLocation) { 206 342 FieldMovementPattern enemy = ((GameObject)Instantiate (prefab)).GetComponent<FieldMovementPattern> (); 207 343 enemy.Transform.position = WorldPoint (Util.To3D (fieldLocation, gamePlaneDistance)); 208 344 } 209 345 346 + /// <summary> 347 + /// Gets all bullets. 348 + /// </summary> 349 + /// <returns>The all bullets.</returns> 350 + /// <param name="position">Position.</param> 351 + /// <param name="radius">Radius.</param> 352 + /// <param name="layerMask">Layer mask.</param> 210 353 public Projectile[] GetAllBullets(Vector3 position, float radius, int layerMask = 1 << 14) { 211 354 Collider2D[] hits = Physics2D.OverlapCircleAll (position, radius, layerMask); 212 355 List<Projectile> projectiles = new List<Projectile> ();
+22 -8
Assets/Scripts/PlayerMovementLimit.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Player movement limit. 6 + /// </summary> 4 7 [RequireComponent(typeof(ScreenBoundary))] 5 - public class PlayerMovementLimit : MonoBehaviour 6 - { 8 + public class PlayerMovementLimit : MonoBehaviour { 9 + 10 + /// <summary> 11 + /// The tag check. 12 + /// </summary> 7 13 [SerializeField] 8 14 private string tagCheck; 9 15 16 + /// <summary> 17 + /// The locked movement vector. 18 + /// </summary> 10 19 [SerializeField] 11 20 private Vector2 lockedMovementVector; 12 21 13 - void OnTriggerEnter2D(Collider2D other) 14 - { 15 - if(other.CompareTag(tagCheck)) 16 - { 22 + /// <summary> 23 + /// Raises the trigger enter2 d event. 24 + /// </summary> 25 + /// <param name="other">Other.</param> 26 + void OnTriggerEnter2D(Collider2D other) { 27 + if(other.CompareTag(tagCheck)) { 17 28 Avatar player = other.gameObject.GetComponent<Avatar> (); 18 - if(player != null) 19 - { 29 + if(player != null) { 20 30 player.ForbidMovement(lockedMovementVector); 21 31 } 22 32 } 23 33 } 24 34 35 + /// <summary> 36 + /// Raises the trigger exit2 d event. 37 + /// </summary> 38 + /// <param name="other">Other.</param> 25 39 void OnTriggerExit2D(Collider2D other) 26 40 { 27 41 if(other.CompareTag(tagCheck))
+1 -1
Assets/Scripts/Projectile Controllers.meta Assets/Scripts/AttackPatterns/Projectile Controllers.meta
··· 1 1 fileFormatVersion: 2 2 - guid: 748877e7ba7dc9944b1a1db416d9bd49 2 + guid: 0ce12263703185443a36703c425d2fbb 3 3 folderAsset: yes 4 4 DefaultImporter: 5 5 userData:
+129 -23
Assets/Scripts/Projectile Controllers/Projectile.cs Assets/Scripts/AttackPatterns/Projectile Controllers/Projectile.cs
··· 3 3 using System.Collections.Generic; 4 4 using System.Collections; 5 5 6 - //[RequireComponent(typeof(BoxCollider2D))] 7 - //[RequireComponent(typeof(CircleCollider2D))] 6 + /// <summary> 7 + /// Projectile. 8 + /// </summary> 8 9 [RequireComponent(typeof(SpriteRenderer))] 9 10 public class Projectile : PooledObject<ProjectilePrefab> { 11 + /// <summary> 12 + /// The player death mask. 13 + /// </summary> 14 + private static int playerDeathMask = 1 << 8; 10 15 11 - private static int playerDeathMask = 1 << 8; 16 + /// <summary> 17 + /// The enemy damage mask. 18 + /// </summary> 12 19 private static int enemyDamageMask = 1 << 13; 20 + 21 + /// <summary> 22 + /// The combo mask. 23 + /// </summary> 13 24 private static int comboMask = playerDeathMask | enemyDamageMask; 14 25 26 + /// <summary> 27 + /// Angles the between 2d. 28 + /// </summary> 29 + /// <returns>The between2 d.</returns> 30 + /// <param name="v1">V1.</param> 31 + /// <param name="v2">V2.</param> 15 32 public static float AngleBetween2D(Vector2 v1, Vector2 v2) { 16 33 Vector2 diff = v2 - v1; 17 34 return Mathf.Atan2 (diff.y, diff.x) * 180f / Mathf.PI - 90f; 18 35 } 19 36 37 + /// <summary> 38 + /// Rotations the between2 d. 39 + /// </summary> 40 + /// <returns>The between2 d.</returns> 41 + /// <param name="v1">V1.</param> 42 + /// <param name="v2">V2.</param> 20 43 public static Quaternion RotationBetween2D(Vector2 v1, Vector2 v2) { 21 44 return Quaternion.Euler (0f, 0f, AngleBetween2D (v1, v2)); 22 45 } 23 46 24 - private float damage; 25 - public float Damage { 47 + /// <summary> 48 + /// The damage. 49 + /// </summary> 50 + private int damage; 51 + public int Damage { 26 52 get { 27 53 return damage; 28 54 } ··· 31 57 } 32 58 } 33 59 60 + /// <summary> 61 + /// The linear velocity. 62 + /// </summary> 34 63 private float linearVelocity = 0f; 35 - public float Velocity 36 - { 64 + public float Velocity { 37 65 get { 38 66 return linearVelocity; 39 67 } ··· 42 70 } 43 71 } 44 72 73 + /// <summary> 74 + /// The angular velocity. 75 + /// </summary> 45 76 private Quaternion angularVelocity = Quaternion.identity; 46 - public float AngularVelocity 47 - { 77 + public float AngularVelocity { 48 78 get { 49 79 return angularVelocity.eulerAngles.z; 50 80 } ··· 53 83 } 54 84 } 55 85 86 + /// <summary> 87 + /// Gets or sets the angular velocity radians. 88 + /// </summary> 89 + /// <value>The angular velocity radians.</value> 56 90 public float AngularVelocityRadians 57 91 { 58 92 get { ··· 63 97 } 64 98 } 65 99 100 + /// <summary> 101 + /// The controllers. 102 + /// </summary> 66 103 private List<ProjectileController> controllers; 67 - private Dictionary<string, object> properties; 68 104 69 - // [SerializeField] 70 - // private CircleCollider2D circleCollider; 71 - // [SerializeField] 72 - // private BoxCollider2D boxCollider; 105 + /// <summary> 106 + /// The properties. 107 + /// </summary> 108 + private Dictionary<string, object> properties; 73 109 110 + /// <summary> 111 + /// The circle check. 112 + /// </summary> 74 113 private bool circleCheck = false; 114 + 115 + /// <summary> 116 + /// The box check. 117 + /// </summary> 75 118 private bool boxCheck = false; 119 + 120 + /// <summary> 121 + /// The circle center. 122 + /// </summary> 76 123 private Vector2 circleCenter = Vector2.zero; 124 + 125 + /// <summary> 126 + /// The circle raidus. 127 + /// </summary> 77 128 private float circleRaidus = 1f; 129 + 130 + /// <summary> 131 + /// The box center. 132 + /// </summary> 78 133 private Vector2 boxCenter = Vector2.zero; 134 + 135 + /// <summary> 136 + /// The size of the box. 137 + /// </summary> 79 138 private Vector2 boxSize = Vector2.one; 80 139 140 + /// <summary> 141 + /// The sprite renderer. 142 + /// </summary> 81 143 [SerializeField] 82 144 private SpriteRenderer spriteRenderer; 83 145 146 + /// <summary> 147 + /// Awake this instance. 148 + /// </summary> 84 149 public override void Awake() { 85 150 properties = new Dictionary<string, object> (); 86 151 controllers = new List<ProjectileController> (); 87 - //if(boxCollider == null) 88 - // boxCollider = GetComponent<BoxCollider2D> (); 89 - //if(circleCollider == null) 90 - // circleCollider = GetComponent<CircleCollider2D> (); 91 152 if(spriteRenderer == null) 92 153 spriteRenderer = GetComponent<SpriteRenderer> (); 93 154 } 94 155 156 + /// <summary> 157 + /// Fixeds the update. 158 + /// </summary> 95 159 void FixedUpdate() { 96 160 float dt = Time.fixedDeltaTime; 97 161 ··· 102 166 103 167 RaycastHit2D hit = default(RaycastHit2D); 104 168 if (circleCheck) {//circleCollider.enabled) { 169 + Vector2 offset = Util.ComponentProduct2(Transform.lossyScale, circleCenter); 105 170 float radius = circleRaidus * Util.MaxComponent2(Util.To2D(Transform.lossyScale)); 106 - hit = Physics2D.CircleCast(Transform.position, radius, movementVector, movementDistance, comboMask); 171 + hit = Physics2D.CircleCast(Transform.position + Util.To3D(offset), 172 + radius, 173 + movementVector, 174 + movementDistance, 175 + comboMask); 107 176 } 108 177 if (boxCheck) {//boxCollider.enabled) { 109 178 Vector2 offset = Util.ComponentProduct2(Transform.lossyScale, boxCenter); 110 - hit = Physics2D.BoxCast(Transform.position, 179 + hit = Physics2D.BoxCast(Transform.position + Util.To3D(offset), 111 180 Util.ComponentProduct2(boxSize, Util.To2D(Transform.lossyScale)), 112 181 Transform.rotation.eulerAngles.z, 113 182 movementVector, ··· 143 212 controllers[i].UpdateBullet(this, dt); 144 213 } 145 214 215 + /// <summary> 216 + /// Transfer the specified currentController and targetField. 217 + /// </summary> 218 + /// <param name="currentController">Current controller.</param> 219 + /// <param name="targetField">Target field.</param> 146 220 public void Transfer(PlayerFieldController currentController, PlayerFieldController targetField) { 147 221 Vector2 relativePos = currentController.FieldPoint (Transform.position); 148 222 Transform.position = targetField.WorldPoint (relativePos); 149 223 } 150 224 225 + /// <summary> 226 + /// Matchs the prefab. 227 + /// </summary> 228 + /// <param name="prefab">Prefab.</param> 151 229 public override void MatchPrefab(ProjectilePrefab prefab) { 152 230 BoxCollider2D bc = prefab.BoxCollider; 153 231 CircleCollider2D cc = prefab.CircleCollider; ··· 182 260 } 183 261 } 184 262 263 + /// <summary> 264 + /// Determines whether this instance has property the specified key. 265 + /// </summary> 266 + /// <returns><c>true</c> if this instance has property the specified key; otherwise, <c>false</c>.</returns> 267 + /// <param name="key">Key.</param> 268 + /// <typeparam name="T">The 1st type parameter.</typeparam> 185 269 public bool HasProperty<T>(string key) { 186 270 return (properties.ContainsKey(key)) && (properties[key] is T); 187 271 } 188 - 272 + 273 + /// <summary> 274 + /// Gets the property. 275 + /// </summary> 276 + /// <returns>The property.</returns> 277 + /// <param name="key">Key.</param> 278 + /// <typeparam name="T">The 1st type parameter.</typeparam> 189 279 public T GetProperty<T>(string key) { 190 280 if(properties.ContainsKey(key)) 191 281 return (T)properties[key]; 192 282 else 193 283 return default(T); 194 284 } 195 - 285 + /// <summary> 286 + /// Sets the property. 287 + /// </summary> 288 + /// <param name="key">Key.</param> 289 + /// <param name="value">Value.</param> 290 + /// <typeparam name="T">The 1st type parameter.</typeparam> 196 291 public void SetProperty<T>(string key, T value) { 197 292 properties [key] = value; 198 293 } 199 294 295 + /// <summary> 296 + /// Adds the controller. 297 + /// </summary> 298 + /// <param name="controller">Controller.</param> 200 299 public void AddController(ProjectileController controller) { 201 300 controllers.Add (controller); 202 301 controller.OnControllerAdd (this); 203 302 } 204 303 304 + /// <summary> 305 + /// Removes the controller. 306 + /// </summary> 307 + /// <param name="controller">Controller.</param> 205 308 public void RemoveController (ProjectileController controller) { 206 309 if(controllers.Remove(controller)) 207 310 controller.OnControllerRemove(this); 208 311 } 209 312 313 + /// <summary> 314 + /// Deactivate this instance. 315 + /// </summary> 210 316 protected override void Deactivate() { 211 317 properties.Clear (); 212 318 controllers.Clear (); 213 319 linearVelocity = 0f; 214 - damage = 0f; 320 + damage = 0; 215 321 angularVelocity = Quaternion.identity; 216 322 } 217 323 }
+1 -1
Assets/Scripts/Projectile Controllers/Projectile.cs.meta Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectilePool.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: b3667caebb9c5b541b241e0139966b24 2 + guid: dabb15c3274b0454a8207ff9f283c403 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
Assets/Scripts/Projectile Controllers/ProjectileController.cs Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectileController.cs
+1 -1
Assets/Scripts/Projectile Controllers/ProjectileController.cs.meta Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectilePrefab.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: aff53f28969350f46a44b81b9009182d 2 + guid: b21fb6d643cdeac479decda6fc79ad9f 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
-166
Assets/Scripts/Projectile Controllers/ProjectileData.cs
··· 1 - using UnityEngine; 2 - using System.Collections; 3 - using BaseLib; 4 - 5 - public class ProjectileData { 6 - private static Mesh quadMesh; 7 - private ProjectileGroup group; 8 - private Vector3 position = Vector3.zero; 9 - private Quaternion rotation = Quaternion.identity; 10 - private Vector3 scale = Vector3.zero; 11 - private float velocity = 0f; 12 - private Quaternion angularVelocity = Quaternion.identity; 13 - private ProjectileCollisionHandler collisionHandler; 14 - 15 - public static Mesh ProjectileMesh 16 - { 17 - get { 18 - if(quadMesh == null) { 19 - //Magic numbers woooooo! 20 - quadMesh = new Mesh(); 21 - Vector3[] verts = new Vector3[]{ 22 - new Vector3( 1, 0, 1), 23 - new Vector3( 1, 0, -1), 24 - new Vector3(-1, 0, 1), 25 - new Vector3(-1, 0, -1), 26 - }; 27 - Vector2[] uv = new Vector2[] { 28 - new Vector2(1, 1), 29 - new Vector2(1, 0), 30 - new Vector2(0, 1), 31 - new Vector2(0, 0), 32 - }; 33 - int[] tris = new int[]{0, 1, 2, 2, 1, 3}; 34 - quadMesh.vertices = verts; 35 - quadMesh.uv = uv; 36 - quadMesh.triangles = tris; 37 - } 38 - return quadMesh; 39 - } 40 - } 41 - 42 - public Vector3 Position { 43 - get { 44 - return position; 45 - } 46 - set { 47 - position = value; 48 - } 49 - } 50 - 51 - public Quaternion Rotation { 52 - get { 53 - return rotation; 54 - } 55 - set { 56 - rotation = value; 57 - } 58 - } 59 - 60 - public Vector3 Scale { 61 - get { 62 - return position; 63 - } 64 - set { 65 - position = value; 66 - } 67 - } 68 - 69 - public float Velocity { 70 - get { 71 - return velocity; 72 - } 73 - set { 74 - velocity = value; 75 - } 76 - } 77 - 78 - public Quaternion AngularVelocity { 79 - get { 80 - return angularVelocity; 81 - } 82 - set { 83 - angularVelocity = value; 84 - } 85 - } 86 - 87 - public ProjectileCollisionHandler CollisionHandler { 88 - get { 89 - return collisionHandler; 90 - } 91 - set { 92 - collisionHandler = value; 93 - } 94 - } 95 - 96 - public ProjectileGroup Group { 97 - get { 98 - return group; 99 - } 100 - set { 101 - group = value; 102 - } 103 - } 104 - 105 - public void Draw() 106 - { 107 - Graphics.DrawMesh (ProjectileMesh, Matrix4x4.TRS (position, rotation, scale), group.ProjectileMaterial, group.Layer, group.TargetCamera); 108 - } 109 - 110 - public void Update(float dt) 111 - { 112 - Quaternion newRotation = Quaternion.Slerp (rotation, rotation * angularVelocity, dt); 113 - Vector3 movementVector = velocity * dt * (newRotation * Vector3.up); 114 - 115 - //TODO: add support for ProjectileControllers here 116 - 117 - RaycastHit2D[] hits = collisionHandler.CheckCollision (this, movementVector); 118 - 119 - rotation = newRotation; 120 - position += movementVector; 121 - } 122 - } 123 - 124 - public abstract class ProjectileCollisionHandler { 125 - public abstract RaycastHit2D[] CheckCollision(ProjectileData projectile, Vector3 movementVector); 126 - } 127 - 128 - public class BoxProjectileCollisionHandler : ProjectileCollisionHandler { 129 - private Vector2 boxOffset; 130 - private Vector2 boxSize; 131 - 132 - public BoxProjectileCollisionHandler(Vector2 offset, Vector2 size) { 133 - boxOffset = offset; 134 - boxSize = size; 135 - } 136 - 137 - public override RaycastHit2D[] CheckCollision (ProjectileData projectile, Vector3 movementVector) { 138 - Vector2 origin = Util.To2D (projectile.Position) + Util.ComponentProduct2 (projectile.Scale, boxOffset); 139 - Vector2 size = Util.ComponentProduct2 (projectile.Scale, boxSize); 140 - return Physics2D.BoxCastAll (origin, size, projectile.Rotation.eulerAngles.z, movementVector, movementVector.magnitude); 141 - } 142 - } 143 - 144 - public class CircleProjectileCollisionHandler : ProjectileCollisionHandler { 145 - private Vector2 circleOffset; 146 - private float circleRadius; 147 - 148 - public CircleProjectileCollisionHandler(Vector2 offset, float radius) { 149 - circleOffset = offset; 150 - circleRadius = radius; 151 - } 152 - 153 - private float MinAbsScale(params float[] values) { 154 - float min = float.MaxValue; 155 - for(int i = 0; i < values.Length; i++) 156 - if(values[i] < min) 157 - min = Mathf.Abs(values[i]); 158 - return min; 159 - } 160 - 161 - public override RaycastHit2D[] CheckCollision (ProjectileData projectile, Vector3 movementVector) { 162 - Vector2 origin = Util.To2D (projectile.Position) + Util.ComponentProduct2 (projectile.Scale, circleOffset); 163 - float size = circleRadius * MinAbsScale (projectile.Scale.x, projectile.Scale.y, projectile.Scale.z); 164 - return Physics2D.CircleCastAll(origin, size, movementVector, movementVector.magnitude, projectile.Group.Layer); 165 - } 166 - }
+1 -1
Assets/Scripts/Projectile Controllers/ProjectileData.cs.meta Assets/Editor/FindMissingScripts.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: 5d35cc0f823f9e645b5131a2e949f071 2 + guid: db10a0a41309f56479ad68c5b0528932 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
Assets/Scripts/Projectile Controllers/ProjectileGroup.cs Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectileGroup.cs
+1 -1
Assets/Scripts/Projectile Controllers/ProjectileGroup.cs.meta Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectileController.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: 4165dc805af8f4847a6978fb8d1a6f56 2 + guid: b8312495ebf40354b9744dccae1585b2 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
Assets/Scripts/Projectile Controllers/ProjectilePool.cs Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectilePool.cs
+1 -1
Assets/Scripts/Projectile Controllers/ProjectilePool.cs.meta Assets/Scripts/AttackPatterns/BasicCircularBurst.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: 7f9433190e8cd464a84f5bc085fad49d 2 + guid: 87e16c388915f4c46b83ba556cc01a32 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
Assets/Scripts/Projectile Controllers/ProjectilePrefab.cs Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectilePrefab.cs
+1 -1
Assets/Scripts/Projectile Controllers/ProjectilePrefab.cs.meta Assets/Scripts/AttackPatterns/Projectile Controllers/ProjectileGroup.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: aa80ca343bbf59249b0420e69f7012b9 2 + guid: 83b777663d2cc4244a101ba6c5c83c80 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
+19 -10
Assets/Scripts/ProjectileBoundary.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Projectile boundary. 6 + /// </summary> 4 7 [RequireComponent(typeof(Collider2D))] 5 - public class ProjectileBoundary : MonoBehaviour 6 - { 8 + public class ProjectileBoundary : MonoBehaviour { 9 + 10 + /// <summary> 11 + /// The tag filter. 12 + /// </summary> 7 13 [SerializeField] 8 14 private string tagFilter; 9 15 10 - void Awake() 11 - { 16 + /// <summary> 17 + /// Awake this instance. 18 + /// </summary> 19 + void Awake() { 12 20 if(tagFilter == null) 13 21 tagFilter = ""; 14 22 } 15 23 16 - void OnTriggerEnter2D(Collider2D other) 17 - { 24 + /// <summary> 25 + /// Raises the trigger enter2 d event. 26 + /// </summary> 27 + /// <param name="other">Other.</param> 28 + void OnTriggerEnter2D(Collider2D other) { 18 29 //Debug.Log ("Entered"); 19 - if(other.CompareTag(tagFilter)) 20 - { 30 + if(other.CompareTag(tagFilter)) { 21 31 Projectile proj = other.GetComponent<Projectile>(); 22 - if(proj != null) 23 - { 32 + if(proj != null) { 24 33 proj.Active = false; 25 34 } 26 35 }
-28
Assets/Scripts/Test/TestPlayerAttackPattern.cs
··· 1 - using UnityEngine; 2 - using System.Collections; 3 - 4 - public class TestPlayerAttackPattern : AttackPattern { 5 - 6 - public ProjectilePrefab prefab; 7 - public Vector2 spawnLocation; 8 - public int number; 9 - public float velocity; 10 - public float angV; 11 - 12 - 13 - protected override void MainLoop (float dt) { 14 - /*time -= dt; 15 - if(time < 0f) 16 - {*/ 17 - 18 - for(int i = 0; i < number; i++) 19 - { 20 - Projectile bullet = TargetField.SpawnProjectile(prefab, spawnLocation, 360f / (float) number * (float)i); 21 - bullet.Velocity = velocity; 22 - bullet.AngularVelocity = angV; 23 - } 24 - Deactivate (); 25 - /* time = timer; 26 - }*/ 27 - } 28 - }
+1 -1
Assets/Scripts/Test/TestPlayerAttackPattern.cs.meta Assets/Scripts/AttackPatterns/Projectile Controllers/Projectile.cs.meta
··· 1 1 fileFormatVersion: 2 2 - guid: 4d6f59c604b93914ba987211f1cacada 2 + guid: de908e234dd4c854e9a4d8a0177248e0 3 3 MonoImporter: 4 4 serializedVersion: 2 5 5 defaultReferences: []
+3
Assets/Scripts/Test/TestSpawnPlayer.cs
··· 1 1 using UnityEngine; 2 2 using System.Collections; 3 3 4 + /// <summary> 5 + /// Test spawn player. 6 + /// </summary> 4 7 [RequireComponent(typeof(GameController))] 5 8 public class TestSpawnPlayer : TestScript 6 9 {
+56
Dogfight.sublime-project
··· 1 + { 2 + "folders": 3 + [ 4 + { 5 + "follow_symlinks": true, 6 + "path": "Assets/Scripts", 7 + "file_exclude_patterns": 8 + [ 9 + "*.dll", 10 + "*.meta" 11 + ] 12 + } 13 + ], 14 + "settings": { 15 + 16 + // Uncomment the next line for OS X/Linux, if "mono" does not launch Mono in the Terminal. 17 + //"completesharp_mono_path": "/Applications/Unity/MonoDevelop.app/Contents/MacOS/bin/MonoDevelop", 18 + 19 + // Possible default directory paths for Unity: 20 + // Windows: C:\Program Files\Unity\Editor\Data\ 21 + // Windows 64-bit: C:\Program Files (x86)\Unity\Editor\Data\ 22 + // Mac OS X: /Applications/Unity/Unity.app/Contents/Frameworks/ 23 + 24 + "completesharp_assemblies": [ 25 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Managed\\UnityEngine.dll", 26 + 27 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Managed\\UnityEditor.dll", 28 + 29 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\lib\\mono\\unity\\UnityScript.dll", 30 + 31 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\lib\\mono\\unity\\System.Core.dll", 32 + 33 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\lib\\mono\\unity\\System.dll", 34 + 35 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Managed\\nunit.framework.dll", 36 + 37 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\lib\\mono\\unity\\mscorlib.dll", 38 + 39 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\lib\\mono\\unity\\System.Core.dll", 40 + 41 + "C:\\Program Files (x86)\\Unity\\Editor\\Data\\Mono\\lib\\mono\\unity\\System.dll", 42 + 43 + "${project_path:Library}\\ScriptAssemblies\\Assembly-CSharp.dll", 44 + 45 + "${project_path:Library}\\ScriptAssemblies\\Assembly-CSharp-Editor.dll", 46 + 47 + "${project_path:Library}\\ScriptAssemblies\\Assembly-UnityScript-Editor.dll", 48 + 49 + "${project_path:Library}\\ScriptAssemblies\\Assembly-CSharp-firstpass.dll" 50 + ], 51 + 52 + "completioncommon_inhibit_sublime_completions": true, 53 + 54 + "completioncommon_shorten_names": true 55 + } 56 + }