Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Clean Code #1

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
Empty file.
Binary file not shown.
Binary file not shown.
Binary file not shown.
15 changes: 15 additions & 0 deletions Color Switch Replica/Assets/ColorsType.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ColorSwitchReplica
{
public enum ColorsType
{
Cyan = 0,
Yellow = 1,
Magenta = 2,
Pink = 3
}
}
13 changes: 13 additions & 0 deletions Color Switch Replica/Assets/ColorsType.cs.meta

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

Binary file modified Color Switch Replica/Assets/Main.unity
Binary file not shown.
119 changes: 59 additions & 60 deletions Color Switch Replica/Assets/Player.cs
Original file line number Diff line number Diff line change
@@ -1,71 +1,70 @@
using UnityEngine;
using UnityEngine.SceneManagement;

public class Player : MonoBehaviour {
namespace ColorSwitchReplica {

public float jumpForce = 10f;
public class Player : MonoBehaviour {

public Rigidbody2D rb;
public SpriteRenderer sr;
public float jumpForce = 10f;
public Rigidbody2D rigidBody2D;
public SpriteRenderer spriteRenderer;
public string currentColorInTheCircle;
public Color colorPink, colorAzul;

public string currentColor;

public Color colorCyan;
public Color colorYellow;
public Color colorMagenta;
public Color colorPink;

void Start ()
{
SetRandomColor();
}
void Start ()
{
SetRandomColor();
}

// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Jump") || Input.GetMouseButtonDown(0))
{
rb.velocity = Vector2.up * jumpForce;
}
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Jump") || Input.GetMouseButtonDown(0))
{
rigidBody2D.velocity = Vector2.up * jumpForce;
}
}

void OnTriggerEnter2D (Collider2D col)
{
if (col.tag == "ColorChanger")
{
SetRandomColor();
Destroy(col.gameObject);
return;
}
void OnTriggerEnter2D (Collider2D collider2D)
{
if (collider2D.tag == "ColorChanger")
{
SetRandomColor();
Destroy(collider2D.gameObject);
return;
}

if (col.tag != currentColor)
{
Debug.Log("GAME OVER!");
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}
if (collider2D.tag != currentColorInTheCircle)
{
Debug.Log("GAME OVER!");
SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);
}
}

void SetRandomColor ()
{
int index = Random.Range(0, 4);
void SetRandomColor ()
{
int colorsType = Random.Range(0, 4);

switch (index)
{
case 0:
currentColor = "Cyan";
sr.color = colorCyan;
break;
case 1:
currentColor = "Yellow";
sr.color = colorYellow;
break;
case 2:
currentColor = "Magenta";
sr.color = colorMagenta;
break;
case 3:
currentColor = "Pink";
sr.color = colorPink;
break;
}
}
}
switch (colorsType)
{
case 0:
currentColorInTheCircle = "Cyan";
spriteRenderer.color = Color.cyan;
break;
case 1:
currentColorInTheCircle = "Yellow";
spriteRenderer.color = Color.yellow;
break;
case 2:
currentColorInTheCircle = "Magenta";
spriteRenderer.color = Color.magenta;
break;
case 3:
currentColorInTheCircle = "Pink";
spriteRenderer.color = colorPink;
break;
default:
throw new System.NotImplementedException();
}
}
}
}
11 changes: 11 additions & 0 deletions Color Switch Replica/Assets/SetRotation.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
using UnityEngine;

public class SetRotation : MonoBehaviour {

public float speedRotation = 100f;

// Update is called once per frame
void Update () {
transform.Rotate(0f, 0f, speedRotation * Time.deltaTime);
}
}
12 changes: 12 additions & 0 deletions Color Switch Replica/Assets/SetRotation.cs.meta

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

2 changes: 1 addition & 1 deletion Color Switch Replica/ProjectSettings/ProjectVersion.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
m_EditorVersion: 5.6.0f3
m_EditorVersion: 2017.2.1f1
4 changes: 4 additions & 0 deletions Color Switch Replica/UnityPackageManager/manifest.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"dependencies": {
}
}