This repository has been archived by the owner on Apr 10, 2023. It is now read-only.
-
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.
Extract scene management and player interactions and renderer behaviours from Player script to different single scripts
- Loading branch information
Showing
14 changed files
with
268 additions
and
41 deletions.
There are no files selected for viewing
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 |
---|---|---|
@@ -0,0 +1,10 @@ | ||
using UnityEngine; | ||
using UnityEngine.SceneManagement; | ||
|
||
public class GameManager : MonoBehaviour | ||
{ | ||
private void Start() | ||
{ | ||
SceneManager.LoadScene("PremadeLevel", LoadSceneMode.Additive); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
using UnityEngine; | ||
|
||
public class PlayerAIInteractions : MonoBehaviour | ||
{ | ||
[SerializeField] | ||
private Transform raycastPoint; | ||
|
||
public void Interact(bool isSpriteFlipped) | ||
{ | ||
Debug.DrawRay(raycastPoint.position, isSpriteFlipped ? Vector3.left : Vector3.right, Color.red); | ||
RaycastHit2D hit = Physics2D.Raycast(raycastPoint.position, isSpriteFlipped ? Vector3.left : Vector3.right,1); | ||
if(hit.collider != null) | ||
{ | ||
if (hit.collider.GetComponent<NPC_Enemy>()) | ||
{ | ||
hit.collider.GetComponent<NPC_Enemy>().GetHit(); | ||
} | ||
else if (hit.collider.GetComponent<NPC_Friendly>()) | ||
{ | ||
hit.collider.GetComponent<NPC_Friendly>().Talk(); | ||
} | ||
} | ||
} | ||
} |
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,18 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class PlayerAnimations : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
|
||
} | ||
} |
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,18 @@ | ||
using System.Collections; | ||
using System.Collections.Generic; | ||
using UnityEngine; | ||
|
||
public class PlayerInput : MonoBehaviour | ||
{ | ||
// Start is called before the first frame update | ||
void Start() | ||
{ | ||
|
||
} | ||
|
||
// Update is called once per frame | ||
void Update() | ||
{ | ||
|
||
} | ||
} |
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,31 @@ | ||
using System.Collections; | ||
using UnityEngine; | ||
|
||
public class PlayerRenderer : MonoBehaviour | ||
{ | ||
[SerializeField] | ||
private SpriteRenderer playerRenderer; | ||
|
||
public bool IsSpriteFlipped => playerRenderer.flipX; | ||
|
||
public void RenderPlayer(Vector2 movement) | ||
{ | ||
if (Mathf.Abs(movement.x) > 0.1f) | ||
{ | ||
playerRenderer.flipX = Vector3.Dot(transform.right, movement) < 0; | ||
} | ||
} | ||
|
||
public void FlashRed() | ||
{ | ||
StopAllCoroutines(); | ||
StartCoroutine(FlashRedCoroutine()); | ||
} | ||
|
||
private IEnumerator FlashRedCoroutine() | ||
{ | ||
playerRenderer.color = Color.red; | ||
yield return new WaitForSeconds(0.1f); | ||
playerRenderer.color = Color.white; | ||
} | ||
} |
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
File renamed without changes.