Skip to content

Commit

Permalink
1. 滚动的游戏背景;
Browse files Browse the repository at this point in the history
2. 增加不同类型的障碍物;
3. 增加具有简单 AI 的敌人。
  • Loading branch information
Caizc committed Mar 12, 2017
1 parent 274ff12 commit 1780870
Show file tree
Hide file tree
Showing 37 changed files with 343 additions and 8 deletions.
36 changes: 36 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
{
"version": "0.2.0",
"configurations": [
{
"name": "Unity Editor",
"type": "unity",
"request": "launch"
},
{
"name": "Windows Player",
"type": "unity",
"request": "launch"
},
{
"name": "OSX Player",
"type": "unity",
"request": "launch"
},
{
"name": "Linux Player",
"type": "unity",
"request": "launch"
},
{
"name": "iOS Player",
"type": "unity",
"request": "launch"
},
{
"name": "Android Player",
"type": "unity",
"request": "launch"

}
]
}
56 changes: 56 additions & 0 deletions .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
{
"files.exclude":
{
"**/.DS_Store":true,
"**/.git":true,
"**/.gitignore":true,
"**/.gitmodules":true,
"**/*.booproj":true,
"**/*.pidb":true,
"**/*.suo":true,
"**/*.user":true,
"**/*.userprefs":true,
"**/*.unityproj":true,
"**/*.dll":true,
"**/*.exe":true,
"**/*.pdf":true,
"**/*.mid":true,
"**/*.midi":true,
"**/*.wav":true,
"**/*.gif":true,
"**/*.ico":true,
"**/*.jpg":true,
"**/*.jpeg":true,
"**/*.png":true,
"**/*.psd":true,
"**/*.tga":true,
"**/*.tif":true,
"**/*.tiff":true,
"**/*.3ds":true,
"**/*.3DS":true,
"**/*.fbx":true,
"**/*.FBX":true,
"**/*.lxo":true,
"**/*.LXO":true,
"**/*.ma":true,
"**/*.MA":true,
"**/*.obj":true,
"**/*.OBJ":true,
"**/*.asset":true,
"**/*.cubemap":true,
"**/*.flare":true,
"**/*.mat":true,
"**/*.meta":true,
"**/*.prefab":true,
"**/*.unity":true,
"build/":true,
"Build/":true,
"Library/":true,
"library/":true,
"obj/":true,
"Obj/":true,
"ProjectSettings/":true,
"temp/":true,
"Temp/":true
}
}
Binary file added Assets/Materials/fx_bolt_syan.mat
Binary file not shown.

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

Binary file modified Assets/Materials/prop_asteroid_01_mat.mat
Binary file not shown.
Binary file modified Assets/Materials/prop_asteroid_02_mat.mat
Binary file not shown.
Binary file modified Assets/Materials/prop_asteroid_03_mat.mat
Binary file not shown.
Binary file modified Assets/Materials/vehicle_enemyShip_metal_mat.mat
Binary file not shown.
12 changes: 9 additions & 3 deletions Assets/Plugins/Editor/VSCode.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* Seamless support for Microsoft Visual Studio Code in Unity
*
* Version:
* 2.7
* 2.8
*
* Authors:
* Matthew Davey <[email protected]>
Expand All @@ -23,7 +23,7 @@ public static class VSCode
/// <summary>
/// Current Version Number
/// </summary>
public const float Version = 2.7f;
public const float Version = 2.8f;

/// <summary>
/// Current Version Code
Expand All @@ -33,7 +33,7 @@ public static class VSCode
/// <summary>
/// Additional File Extensions
/// </summary>
public const string FileExtensions = ".ts, .bjs, .javascript, .json, .html";
public const string FileExtensions = ".ts, .bjs, .javascript, .json, .html, .shader, .template";

/// <summary>
/// Download URL for Unity Debbuger
Expand Down Expand Up @@ -1275,6 +1275,10 @@ static void WriteWorkspaceSettings()
"\t\t\"**/.gitmodules\":true,\n" +
"\t\t\"**/.svn\":true,\n" +

// Compressed Files
"\t\t\"**/*.zip\":true,\n" +
"\t\t\"**/*.gz\":true,\n" +
"\t\t\"**/*.7z\":true,\n" +

// Project Files
"\t\t\"**/*.booproj\":true,\n" +
Expand Down Expand Up @@ -1332,6 +1336,8 @@ static void WriteWorkspaceSettings()
"\t\t\"**/*.meta\":true,\n" +
"\t\t\"**/*.prefab\":true,\n" +
"\t\t\"**/*.unity\":true,\n" +
"\t\t\"**/*.anim\":true,\n" +
"\t\t\"**/*.controller\":true,\n" +

// Folders
"\t\t\"build/\":true,\n" +
Expand Down
9 changes: 9 additions & 0 deletions Assets/Prefabs/Asteroids.meta

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

Binary file added Assets/Prefabs/Asteroids/Asteroid01.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Prefabs/Asteroids/Asteroid01.prefab.meta

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

Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Prefabs/Asteroids/Asteroid02.prefab.meta

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

Binary file added Assets/Prefabs/Asteroids/Asteroid03.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Prefabs/Asteroids/Asteroid03.prefab.meta

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

9 changes: 9 additions & 0 deletions Assets/Prefabs/Bolts.meta

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

Binary file added Assets/Prefabs/Bolts/Bolt Enemy.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Prefabs/Bolts/Bolt Enemy.prefab.meta

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

File renamed without changes.
File renamed without changes.
Binary file added Assets/Prefabs/Enemy.prefab
Binary file not shown.
8 changes: 8 additions & 0 deletions Assets/Prefabs/Enemy.prefab.meta

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

Binary file modified Assets/Prefabs/VFX/Engines/engines_player.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/VFX/Explosions/explosion_enemy.prefab
Binary file not shown.
Binary file modified Assets/Prefabs/VFX/Starfield/StarField.prefab
Binary file not shown.
23 changes: 23 additions & 0 deletions Assets/Scripts/BGScroller.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
using UnityEngine;

public class BGScroller : MonoBehaviour
{

[SerializeField]
private float scrollSpeed;
[SerializeField]
private float tileSizeZ;

private Vector3 startPosition;

void Start()
{
startPosition = transform.position;
}

void Update()
{
float newPosition = Mathf.Repeat(Time.time * scrollSpeed, tileSizeZ);
transform.position = startPosition + Vector3.forward * newPosition;
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/BGScroller.cs.meta

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

7 changes: 5 additions & 2 deletions Assets/Scripts/DestoryByContact.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,15 @@ void Start()

void OnTriggerEnter(Collider other)
{
if (other.CompareTag("Boundary"))
if (other.CompareTag("Boundary") || other.CompareTag("Enemy"))
{
return;
}

Instantiate(explosion, transform.position, transform.rotation);
if (null != explosion)
{
Instantiate(explosion, transform.position, transform.rotation);
}

if (other.CompareTag("Player"))
{
Expand Down
87 changes: 87 additions & 0 deletions Assets/Scripts/EvasiveManeuver.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
using System.Collections;
using UnityEngine;

public class EvasiveManeuver : MonoBehaviour
{
[SerializeField]
private Boundary boundary;
[SerializeField]
private float tilt;
[SerializeField]
private float dodge;
[SerializeField]
private float smoothing;
[SerializeField]
private float speed;

[SerializeField]
private Vector2 startWait;
[SerializeField]
private Vector2 maneuverTime;
[SerializeField]
private Vector2 maneuverWait;

private float _targetManeuver;
private Rigidbody _rigidbody;
private float _currentSpeed;

private GameObject _player;
private bool _isTracking;

void Start()
{
_rigidbody = GetComponent<Rigidbody>();
_currentSpeed = _rigidbody.velocity.z;

_player = GameObject.FindWithTag("Player");

if (null != _player)
{
_isTracking = (Random.value < 0.5);
}
else
{
_isTracking = false;
}

StartCoroutine(Evade());
}

IEnumerator Evade()
{
yield return new WaitForSeconds(Random.Range(startWait.x, startWait.y));

while (true)
{
_targetManeuver = Random.Range(1.0f, dodge) * -Mathf.Sign(transform.position.x);
yield return new WaitForSeconds(Random.Range(maneuverTime.x, maneuverTime.y));
_targetManeuver = 0.0f;
yield return new WaitForSeconds(Random.Range(maneuverWait.x, maneuverWait.y));
}
}

void FixedUpdate()
{
float newManeuver = Mathf.MoveTowards(_rigidbody.velocity.x, _targetManeuver, Time.deltaTime * smoothing);

float movement;

if (null != _player && _isTracking)
{
movement = Mathf.MoveTowards(_rigidbody.position.x, _player.transform.position.x, Time.deltaTime * speed);
}
else
{
movement = _rigidbody.position.x;
_rigidbody.velocity = new Vector3(newManeuver, 0.0f, _currentSpeed);
}

_rigidbody.position = new Vector3
(
Mathf.Clamp(movement, boundary.xMin, boundary.xMax),
0.0f,
Mathf.Clamp(_rigidbody.position.z, boundary.zMin, boundary.zMax)
);
_rigidbody.rotation = Quaternion.Euler(0.0f, 0.0f, _rigidbody.velocity.x * -tilt);
}
}
12 changes: 12 additions & 0 deletions Assets/Scripts/EvasiveManeuver.cs.meta

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

3 changes: 2 additions & 1 deletion Assets/Scripts/GameController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ public class GameController : MonoBehaviour
{

[SerializeField]
private GameObject hazard;
private GameObject[] hazards;
[SerializeField]
private Vector3 spawnValues;
[SerializeField]
Expand Down Expand Up @@ -65,6 +65,7 @@ private IEnumerator SpawnWaves()
{
Vector3 spawnPosition = new Vector3(Random.Range(-spawnValues.x, spawnValues.x), spawnValues.y, spawnValues.z);
Quaternion spawnRotation = Quaternion.identity;
GameObject hazard = hazards[Random.Range(0, hazards.Length)];

Instantiate(hazard, spawnPosition, spawnRotation);

Expand Down
Loading

0 comments on commit 1780870

Please sign in to comment.