diff --git a/Assets/Prefabs/BG.prefab b/Assets/Prefabs/BG.prefab new file mode 100644 index 0000000..708edd1 Binary files /dev/null and b/Assets/Prefabs/BG.prefab differ diff --git a/Assets/Prefabs/BG.prefab.meta b/Assets/Prefabs/BG.prefab.meta new file mode 100644 index 0000000..b2bf818 --- /dev/null +++ b/Assets/Prefabs/BG.prefab.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 7a4a5609f0bed9a47ab313b518b6be11 +timeCreated: 1477316349 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Bird.prefab b/Assets/Prefabs/Bird.prefab index 73b8a03..58a3023 100644 Binary files a/Assets/Prefabs/Bird.prefab and b/Assets/Prefabs/Bird.prefab differ diff --git a/Assets/Prefabs/Cloud.prefab b/Assets/Prefabs/Cloud.prefab index 7a764e6..d235977 100644 Binary files a/Assets/Prefabs/Cloud.prefab and b/Assets/Prefabs/Cloud.prefab differ diff --git a/Assets/Scenes/Main.unity b/Assets/Scenes/Main.unity index abb1b2e..cdddca4 100644 Binary files a/Assets/Scenes/Main.unity and b/Assets/Scenes/Main.unity differ diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 7686fb3..23548c7 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -5,8 +5,12 @@ namespace Assets.Scripts public class Player : MonoBehaviour { private Transform _pos; + private float _blinkTimer = 0f; + private int _blinkCount = 0; public int Score = 0; + public int Battery = 100; + public bool IsBlinking = false; void Start() { @@ -19,6 +23,31 @@ namespace Assets.Scripts newPos.z = -1; _pos.position = Vector3.Lerp(_pos.position, newPos, 10 * Time.deltaTime); + if (IsBlinking) + Blink(); + } + + public void Blink() + { + _blinkTimer += Time.deltaTime; + + if (_blinkTimer > .16f) + { + GetComponent().enabled = !GetComponent().enabled; + _blinkCount++; + _blinkTimer = 0f; + } + + if (_blinkCount != 7) return; + _blinkCount = 0; + _blinkTimer = 0f; + IsBlinking = false; + } + + public void SetBlinking() + { + GetComponent().enabled = false; + IsBlinking = true; } } } \ No newline at end of file diff --git a/Assets/Scripts/SimpleEnnemy.cs b/Assets/Scripts/SimpleEnnemy.cs index 7dcc0cf..1eeeb9b 100644 --- a/Assets/Scripts/SimpleEnnemy.cs +++ b/Assets/Scripts/SimpleEnnemy.cs @@ -31,6 +31,7 @@ public class SimpleEnnemy : MonoBehaviour { gameObject.SetActive(false); + _player.GetComponent().Battery -= 4; //GetScores(); TODO: Successfully get scores from API } diff --git a/Assets/Scripts/StaticEnemy.cs b/Assets/Scripts/StaticEnemy.cs new file mode 100644 index 0000000..0d3a616 --- /dev/null +++ b/Assets/Scripts/StaticEnemy.cs @@ -0,0 +1,30 @@ +using UnityEngine; +using System.Collections; +using Assets.Scripts; + +public class StaticEnemy : MonoBehaviour +{ + private GameObject _player; + private Transform _position; + + void Start () + { + _player = GameObject.FindWithTag("Player"); + _position = GetComponent(); + } + + void Update () + { + if (_position.position.x < Camera.main.ScreenToWorldPoint(new Vector3(0, 0, 0)).x) + { + gameObject.SetActive(false); + } + } + + void OnTriggerEnter2D(Collider2D other) + { + gameObject.SetActive(false); + _player.GetComponent().SetBlinking(); + _player.GetComponent().Battery -= 4; + } +} diff --git a/Assets/Scripts/StaticEnemy.cs.meta b/Assets/Scripts/StaticEnemy.cs.meta new file mode 100644 index 0000000..12d3b3c --- /dev/null +++ b/Assets/Scripts/StaticEnemy.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: ffacec83647a7c2418808191c004e5fc +timeCreated: 1477319175 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: