-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Agora joias são spawnadas (ou não) nos blocos. - Agora todos os blocos são destruídos com apenas um toque. Ficará assim? Não sei. - Adicionado primeiro obstáculo móvel, o Pintor-de-vento. Ele está muito rápido e não muito bonito, precisa de ajustes. - Velocidade da Fase aumentada.
- Loading branch information
1 parent
eb6a314
commit cbcb978
Showing
51 changed files
with
648 additions
and
8 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class Gem : MonoBehaviour, IItem { | ||
[SerializeField] private SOGem gemData; | ||
|
||
public void Effect(){ | ||
return; | ||
} | ||
public IEnumerator CatchAnimation(){ | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
public void Destroy(){ | ||
//GameObject.Destroy(this.gameObject); | ||
transform.position = Vector3.zero; | ||
transform.parent = null; | ||
} | ||
public int GetValue(){ | ||
return gemData.value; | ||
} | ||
public string GetDescription(){ | ||
return gemData.description; | ||
} | ||
public IEnumerator OnTouch(){ | ||
int frameDuration = 5; | ||
float rotationAngle = 30; | ||
|
||
for(int i = 0; i < frameDuration; i++){ | ||
transform.Rotate(0,0,Time.deltaTime*rotationAngle); | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
for(int i = 0; i < frameDuration; i++){ | ||
transform.Rotate(0,0,-Time.deltaTime*rotationAngle); | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
} | ||
public IEnumerator OnFall(){ | ||
Rigidbody2D temp = gameObject.AddComponent<Rigidbody2D>(); | ||
temp.gravityScale = 5; | ||
temp.AddForceAtPosition(new Vector2(Random.Range(-3f,3f),Random.Range(-3f,3f))*50, | ||
(Vector2)transform.position + Vector2.up, | ||
ForceMode2D.Force); | ||
transform.parent = null; | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
using System.Collections; | ||
|
||
public interface IItem { | ||
void Effect(); | ||
void Destroy(); | ||
int GetValue(); | ||
string GetDescription(); | ||
IEnumerator CatchAnimation(); | ||
IEnumerator OnTouch(); | ||
IEnumerator OnFall(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class ItemCatcher : MonoBehaviour { | ||
LevelManager lManager; | ||
|
||
private void Start(){ | ||
lManager = GameObject.Find("Player").GetComponent<LevelManager>(); | ||
} | ||
private void OnTriggerEnter2D(Collider2D other){ | ||
if(other.CompareTag("Gem")){ | ||
NewGem(other.gameObject); | ||
} | ||
} | ||
private void PlayAnimation(IItem item){ | ||
Debug.Log("Play_Animation"); | ||
StartCoroutine( item.CatchAnimation() ); | ||
} | ||
private void NewGem(GameObject gem){ | ||
IItem item = gem.GetComponent<IItem>(); | ||
item.Destroy(); | ||
lManager.collectedItems.Add(gem.gameObject); | ||
lManager.totalMoney += item.GetValue(); | ||
StartCoroutine ( lManager.UpdateMoneyText() ); | ||
} | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,5 +2,4 @@ | |
|
||
bool OnClick(); | ||
float MoveTo(); | ||
void Restart(); | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
#if UNITY_EDITOR | ||
using UnityEditor; | ||
#endif | ||
|
||
public class Pintor : MonoBehaviour,IHook { | ||
|
||
[Header("Movement Properties")] | ||
[Range(0,1)] | ||
[SerializeField] private float velocity; | ||
private Vector3 targetPosition; | ||
|
||
[Header("Smoke Properties")] | ||
[SerializeField] private GameObject smokePrefab; | ||
[SerializeField] private float duration; | ||
[SerializeField] private bool RandomColor; | ||
[SerializeField] private Color initialColor; | ||
[SerializeField] private Color finalColor; | ||
[SerializeField] private Color actualColor; | ||
|
||
[Header("Resistance")] | ||
[SerializeField] private int resistance; | ||
|
||
private GameObject cameraInScene; | ||
private float cameraHeight; | ||
private float cameraWidth; | ||
|
||
private void Start(){ | ||
actualColor = initialColor; | ||
GetCamera(); | ||
GetTargetPosition(); | ||
StartCoroutine( Movement() ); | ||
} | ||
private void GetCamera(){ | ||
cameraInScene = GameObject.Find("Main Camera"); | ||
cameraHeight = cameraInScene.GetComponent<Camera>().orthographicSize*2; | ||
cameraWidth = cameraInScene.GetComponent<Camera>().aspect*cameraHeight; | ||
|
||
Debug.Log(cameraHeight+"/"+cameraWidth); | ||
} | ||
private void NewSmoke(){ | ||
GameObject go = Instantiate(smokePrefab,transform.position + Vector3.right*2,Quaternion.identity); | ||
actualColor = Vector4.Lerp(actualColor,finalColor,0.25f); | ||
go.GetComponent<SpriteRenderer>().color = actualColor; | ||
} | ||
private IEnumerator Movement(){ | ||
float x,y,a,b; | ||
x = transform.position.x; y = transform.position.y; | ||
a = targetPosition.x; b = targetPosition.y; | ||
StartCoroutine( SmokeHandler() ); | ||
while(a != b || y != b){ | ||
x = Mathf.Lerp(x, a, velocity); | ||
y = Mathf.Lerp(y, b, velocity); | ||
transform.position = new Vector3(x,y,0); | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
} | ||
private IEnumerator SmokeHandler(){ | ||
GameObject player = GameObject.Find("Player"); | ||
while(player.transform.position.x < this.transform.position.x){ | ||
yield return new WaitForSeconds(duration); | ||
NewSmoke(); | ||
} | ||
} | ||
private void GetTargetPosition(){ | ||
Vector3 rand = new Vector3(Random.Range(-60f,-30f),Random.Range(-5f,5f),0); | ||
targetPosition = transform.position + rand; | ||
} | ||
public float MoveTo(){ | ||
return transform.position.y; | ||
} | ||
private void OnMouseDown(){ | ||
if( OnClick() ){ | ||
GameObject.Find("Player").GetComponent<Muquirana>().ChangePosition( MoveTo() ); | ||
} | ||
} | ||
public bool OnClick(){ | ||
resistance--; | ||
StartCoroutine( Damage() ); | ||
if(resistance <= 0){ | ||
Fall(); | ||
return true; | ||
} | ||
return false; | ||
} | ||
private IEnumerator Damage(){ | ||
for(int i = 0;i < 5;i++){ | ||
transform.localScale = transform.localScale*1.05f; | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
for(int i = 0;i < 5;i++){ | ||
transform.localScale = transform.localScale/1.05f; | ||
yield return new WaitForEndOfFrame(); | ||
} | ||
} | ||
private void Fall(){ | ||
StopAllCoroutines(); | ||
GetComponent<BoxCollider2D>().enabled = false; | ||
Rigidbody2D myRB = gameObject.AddComponent<Rigidbody2D>(); | ||
myRB.gravityScale = 5; | ||
} | ||
|
||
} |
Oops, something went wrong.