Commit b33d8e90 by Naliwe GS

Switching

parent f33f917f
fileFormatVersion: 2
guid: 7a4a5609f0bed9a47ab313b518b6be11
timeCreated: 1477316349
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
No preview for this file type
...@@ -5,8 +5,12 @@ namespace Assets.Scripts ...@@ -5,8 +5,12 @@ namespace Assets.Scripts
public class Player : MonoBehaviour public class Player : MonoBehaviour
{ {
private Transform _pos; private Transform _pos;
private float _blinkTimer = 0f;
private int _blinkCount = 0;
public int Score = 0; public int Score = 0;
public int Battery = 100;
public bool IsBlinking = false;
void Start() void Start()
{ {
...@@ -19,6 +23,31 @@ namespace Assets.Scripts ...@@ -19,6 +23,31 @@ namespace Assets.Scripts
newPos.z = -1; newPos.z = -1;
_pos.position = Vector3.Lerp(_pos.position, newPos, 10 * Time.deltaTime); _pos.position = Vector3.Lerp(_pos.position, newPos, 10 * Time.deltaTime);
if (IsBlinking)
Blink();
}
public void Blink()
{
_blinkTimer += Time.deltaTime;
if (_blinkTimer > .16f)
{
GetComponent<SpriteRenderer>().enabled = !GetComponent<SpriteRenderer>().enabled;
_blinkCount++;
_blinkTimer = 0f;
}
if (_blinkCount != 7) return;
_blinkCount = 0;
_blinkTimer = 0f;
IsBlinking = false;
}
public void SetBlinking()
{
GetComponent<SpriteRenderer>().enabled = false;
IsBlinking = true;
} }
} }
} }
\ No newline at end of file
...@@ -31,6 +31,7 @@ public class SimpleEnnemy : MonoBehaviour ...@@ -31,6 +31,7 @@ public class SimpleEnnemy : MonoBehaviour
{ {
gameObject.SetActive(false); gameObject.SetActive(false);
_player.GetComponent<Player>().Battery -= 4;
//GetScores(); TODO: Successfully get scores from API //GetScores(); TODO: Successfully get scores from API
} }
......
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<Transform>();
}
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<Player>().SetBlinking();
_player.GetComponent<Player>().Battery -= 4;
}
}
fileFormatVersion: 2
guid: ffacec83647a7c2418808191c004e5fc
timeCreated: 1477319175
licenseType: Free
MonoImporter:
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment