Commit 733ede15 authored by bogomil's avatar bogomil

Merge remote-tracking branch 'origin/master'

parents b6f3b57e a6717723
using System.Collections;
using System.Collections.Generic;
using DG.Tweening;
using TMPro;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class ShowCountdown : MonoBehaviour
{
public TextMeshProUGUI delayTextField;
private float _timer = 0;
// called zero
void Awake()
{
Debug.Log("Awake");
}
// called first
void OnEnable()
{
Debug.Log("OnEnable called");
SceneManager.sceneLoaded += OnSceneLoaded;
}
//
// called second
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
// Debug.Log("OnSceneLoaded: " + scene.name);
// Debug.Log(mode);
delayTextField.text = "funcs";
_timer = 0;
StartCoroutine(UpdateDelayText());
}
IEnumerator UpdateDelayText() //TODO : Anpassen an Runden Countdown/Zwischen Runden
{
float sec = 1;
float framerate = (sec / Time.unscaledDeltaTime);
int dt = GameManager.instance.data.DelayTime-1;
WaitForSecondsRealtime waiting = new WaitForSecondsRealtime(0.06f);
for (int i = 0; i < GameManager.instance.data.DelayTime; i++)
{
delayTextField.text = dt + "";
for (float frame = 0; frame < 1; frame += 1 / framerate)
{
delayTextField.fontSize -= Mathf.Lerp(0, 1, frame) * 10;
//print(delayTextField.fontSize);
yield return waiting;
}
delayTextField.fontSize = 300;
dt--;
if (dt < 1)
{
delayTextField.text = "Go!";
continue;
}
}
/*int dt = GameManager.instance.data.DelayTime - 1;
for (int i = 0; i < GameManager.instance.data.DelayTime; i++)
{
if(dt-i < 1)
continue;
delayTextField.text = (dt- i) + "";
for (int w = 0; w < 50; w++)
{
delayTextField.fontSize -= 2f;
yield return new WaitForSecondsRealtime(0.01f );
}
delayTextField.fontSize = 300;
}
delayTextField.text = "GO!";*/
}
void LoadDelayTimer()
{
delayTextField.text = "funktioniert";
}
// called third
void Start()
{
Debug.Log("Start");
}
// called when the game is terminated
void OnDisable()
{
Debug.Log("OnDisable");
SceneManager.sceneLoaded -= OnSceneLoaded;
}
}
fileFormatVersion: 2
guid: 6de4aea1d19a51b4da8b810082d30f95
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!1 &4287269793653179316
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 4979490206211125694}
- component: {fileID: 537870465706917231}
- component: {fileID: 3150255801453280764}
- component: {fileID: 2008477302556361684}
m_Layer: 5
m_Name: PlayerTag
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!224 &4979490206211125694
RectTransform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4287269793653179316}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0.5, y: 0.5}
m_AnchorMax: {x: 0.5, y: 0.5}
m_AnchoredPosition: {x: -18.691284, y: -2.4674377}
m_SizeDelta: {x: 200, y: 50}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!222 &537870465706917231
CanvasRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4287269793653179316}
m_CullTransparentMesh: 0
--- !u!114 &3150255801453280764
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4287269793653179316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: f4688fdb7df04437aeb418b961361dc5, type: 3}
m_Name:
m_EditorClassIdentifier:
m_Material: {fileID: 0}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_RaycastTarget: 1
m_OnCullStateChanged:
m_PersistentCalls:
m_Calls: []
m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI,
Version=1.0.0.0, Culture=neutral, PublicKeyToken=null
m_text: New Text
m_isRightToLeft: 0
m_fontAsset: {fileID: 11400000, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_sharedMaterial: {fileID: 2180264, guid: 8f586378b4e144a9851e7b34d9b748ee, type: 2}
m_fontSharedMaterials: []
m_fontMaterial: {fileID: 0}
m_fontMaterials: []
m_fontColor32:
serializedVersion: 2
rgba: 4294967295
m_fontColor: {r: 1, g: 1, b: 1, a: 1}
m_enableVertexGradient: 0
m_colorMode: 3
m_fontColorGradient:
topLeft: {r: 1, g: 1, b: 1, a: 1}
topRight: {r: 1, g: 1, b: 1, a: 1}
bottomLeft: {r: 1, g: 1, b: 1, a: 1}
bottomRight: {r: 1, g: 1, b: 1, a: 1}
m_fontColorGradientPreset: {fileID: 0}
m_spriteAsset: {fileID: 0}
m_tintAllSprites: 0
m_overrideHtmlColors: 0
m_faceColor:
serializedVersion: 2
rgba: 4294967295
m_outlineColor:
serializedVersion: 2
rgba: 4278190080
m_fontSize: 36
m_fontSizeBase: 36
m_fontWeight: 400
m_enableAutoSizing: 0
m_fontSizeMin: 18
m_fontSizeMax: 72
m_fontStyle: 0
m_textAlignment: 257
m_characterSpacing: 0
m_wordSpacing: 0
m_lineSpacing: 0
m_lineSpacingMax: 0
m_paragraphSpacing: 0
m_charWidthMaxAdj: 0
m_enableWordWrapping: 1
m_wordWrappingRatios: 0.4
m_overflowMode: 0
m_firstOverflowCharacterIndex: -1
m_linkedTextComponent: {fileID: 0}
m_isLinkedTextComponent: 0
m_isTextTruncated: 0
m_enableKerning: 1
m_enableExtraPadding: 0
checkPaddingRequired: 0
m_isRichText: 1
m_parseCtrlCharacters: 1
m_isOrthographic: 1
m_isCullingEnabled: 0
m_ignoreRectMaskCulling: 0
m_ignoreCulling: 1
m_horizontalMapping: 0
m_verticalMapping: 0
m_uvLineOffset: 0
m_geometrySortingOrder: 0
m_VertexBufferAutoSizeReduction: 1
m_firstVisibleCharacter: 0
m_useMaxVisibleDescender: 1
m_pageToDisplay: 1
m_margin: {x: 0, y: 0, z: 0, w: 0}
m_textInfo:
textComponent: {fileID: 3150255801453280764}
characterCount: 8
spriteCount: 0
spaceCount: 1
wordCount: 2
linkCount: 0
lineCount: 1
pageCount: 1
materialCount: 1
m_isUsingLegacyAnimationComponent: 0
m_isVolumetricText: 0
m_spriteAnimator: {fileID: 0}
m_hasFontAssetChanged: 0
m_subTextObjects:
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
- {fileID: 0}
m_baseMaterial: {fileID: 0}
m_maskOffset: {x: 0, y: 0, z: 0, w: 0}
--- !u!114 &2008477302556361684
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 4287269793653179316}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6a24ac252658c014ca1ebf474572bc02, type: 3}
m_Name:
m_EditorClassIdentifier:
player: -1
bodyTag:
tag: {fileID: 0}
data: {fileID: 0}
character: {fileID: 0}
offset: {x: 0, y: 1, z: 0}
fileFormatVersion: 2
guid: c7c81494d91977b4ab6e5e21dbb5530e
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
fileFormatVersion: 2
guid: 2d82b416b9dd4b947824ee48c81f7e12
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
This diff is collapsed.
This diff is collapsed.
fileFormatVersion: 2
guid: a069fabbf83995c4f952207a6cb7dc8d
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 9237b512751da1745bd5dfebe51f8e0b
folderAsset: yes
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
using System;
using UnityEngine;
namespace _Game.Scripts.Camera {
public class CameraFollowMovement : MonoBehaviour {
private Transform _head, _body;
private void OnEnable() {
_head = GameObject.FindWithTag("HeadPlayer").transform;
_body = GameObject.FindWithTag("BodyPlayer").transform;
}
private void Update() {
var target = (_head.position + _body.position) / 2;
Debug.DrawLine(transform.position, target);
target = new Vector3(0, target.y, target.z) - transform.position;
var rotation = Quaternion.LookRotation(target, Vector3.up);
transform.rotation = Quaternion.RotateTowards(transform.rotation, rotation.normalized, 5);
}
}
}
fileFormatVersion: 2
guid: d718df83990771b47be6e1ec9df7498b
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -58,6 +58,9 @@ namespace _Game.Scripts.GameManager {
print("Round End");
roundTime.StopCountdown = true;
UpdateScorePoints();
SwitchRolesOfPlayers(); // changes playerX.role in GameData
data.RoundsPlayed++;
print("Rounds Played = " + data.RoundsPlayed);
......@@ -74,13 +77,85 @@ namespace _Game.Scripts.GameManager {
if (data.IsSwitched) {
data.IsSwitched = false;
SceneManager.LoadScene("MainLevel");
SceneManager.LoadScene("InGameUI", LoadSceneMode.Additive);
SceneManager.LoadScene("DelayTimer", LoadSceneMode.Additive);
}
else {
data.IsSwitched = true;
SceneManager.LoadScene("MainLevelSwitched");
SceneManager.LoadScene("InGameUI", LoadSceneMode.Additive);
SceneManager.LoadScene("DelayTimer", LoadSceneMode.Additive);
}
}
private void UpdateScorePoints()
{
Debug.Log("Updated Scores");
if (data.player1.role == GameData.Role.Body)
{
// Punkte = [Punkte von letzter Runde] + ( [MaxRundenzeit] - [Noch Übrige Zeit] );
data.player1.UpdateScore(data.player1.scoreLastRound + data.roundTime - roundTime.CurrentTime);
}
else if (data.player1.role == GameData.Role.Head)
{
// Punkte = [Punkte von letzter Runde] + ( Rundenzeit ) - ( [ Rundenzeit ] - [ noch übrige Zeit ] ) )
data.player1.UpdateScore(data.player1.scoreLastRound +
((data.roundTime) - (data.roundTime - roundTime.CurrentTime)));
}
else
{
throw new UnityException(
"Can't update score of player 1 because he didn't does not have a role (Head or Body)");
}
if (data.player2.role == GameData.Role.Body)
{
// Punkte = [Punkte von letzter Runde] + ( [MaxRundenzeit] - [Noch Übrige Zeit] );
data.player2.UpdateScore(data.player2.scoreLastRound + data.roundTime - roundTime.CurrentTime);
}
else if (data.player2.role == GameData.Role.Head)
{
// Punkte = [Punkte von letzter Runde] + ( Rundenzeit ) - ( [ Rundenzeit ] - [ noch übrige Zeit ] ) )
data.player2.UpdateScore(data.player2.scoreLastRound +
((data.roundTime) - (data.roundTime - roundTime.CurrentTime)));
}
else
{
throw new UnityException(
"Can't update score of player 2 because he didn't does not have a role (Head or Body)");
}
}
void SwitchRolesOfPlayers()
{
Debug.Log("Switching Roles of Players");
switch (data.player1.role)
{
case GameData.Role.Body:
data.player1.role = GameData.Role.Head;
break;
case GameData.Role.Head:
data.player1.role = GameData.Role.Body;
break;
default:
throw new UnityException(
"Can't update roles of player 1 because he didn't does not have a role (Head or Body)");
break;
}
switch (data.player2.role)
{
case GameData.Role.Body:
data.player2.role = GameData.Role.Head;
break;
case GameData.Role.Head:
data.player2.role = GameData.Role.Body;
break;
default:
throw new UnityException(
"Can't update roles of player 2 because he didn't does not have a role (Head or Body)");
break;
}
}
}
}
......@@ -7,21 +7,41 @@ using UnityEngine.Serialization;
namespace _Game.Scripts.Input {
public class SwitchPlayerManager : MonoBehaviour {
[SerializeField] private string characterTag;
[SerializeField] private MovementBase movement;
[SerializeField] private UseMutation mutation;
public void OnMovement(InputValue value) {
if (movement == null) return;
public MovementBase Movement{
get
{
if (movement == null || !movement.gameObject.tag.Equals(characterTag)) {
movement = GameObject.FindWithTag(characterTag).GetComponent<MovementBase>();
}
return movement;
}
}
public UseMutation Mutation {
get {
if (mutation == null || !mutation.gameObject.tag.Equals(characterTag)) {
mutation = GameObject.FindWithTag(characterTag).GetComponent<UseMutation>();
}
movement.OnMovement(value);
return mutation;
}
}
public void OnMovement(InputValue value) {
Movement.OnMovement(value);
}
public void OnAbility1() {
mutation.OnAbility1();
Mutation.OnAbility1();
}
public void OnAbility2() {
mutation.OnAbility2();
Mutation.OnAbility2();
}
}
}
......@@ -23,7 +23,6 @@ namespace _Game.Scripts.Observer {
public virtual IEnumerator StartCountdown() {
_isCounting = false;
if (!_isCounting) {
//_onStart.Invoke();
_isCounting = true;
_countdownTime = 0;
while (_countdownTime <= 1) {
......
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlayerCenterCam : MonoBehaviour
{
[SerializeField] private Transform head, body;
private void Update()
{
PlayerCenterView();
}
public void PlayerCenterView()
{
transform.position = new Vector3(0,80,50);
transform.LookAt((head.position + body.position)/2);
transform.rotation= Quaternion.Euler(60,0,0);
}
}
fileFormatVersion: 2
guid: a253c5d838e09234a99dff802cd465c8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -7,9 +7,8 @@ using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class CharacterCustomization : MonoBehaviour
{
public GameData data;
public class CharacterCustomization : MonoBehaviour {
[SerializeField] private GameData data;
public TMP_InputField player1InputField;
public TMP_InputField player2InputField;
public Button greenButtonP1;
......@@ -21,32 +20,26 @@ public class CharacterCustomization : MonoBehaviour
public Button yellowButtonP2;
public Button redButtonP2;
public Button blueButtonP2;
public Button greyButtonP2;
// Start is called before the first frame update
public Button greyButtonP2;
// Start is called before the first frame update
// called first
void OnEnable()
{
void OnEnable() {
SceneManager.sceneLoaded += OnSceneLoaded;
}
void OnDisable()
{
void OnDisable() {
Debug.Log("OnDisable");
SceneManager.sceneLoaded -= OnSceneLoaded;
}
//
// called second
void OnSceneLoaded(Scene scene, LoadSceneMode mode)
{
void OnSceneLoaded(Scene scene, LoadSceneMode mode) {
player1InputField.text = data.player1.name;
player2InputField.text = data.player2.name;
}
......@@ -58,24 +51,23 @@ public class CharacterCustomization : MonoBehaviour
data.player1.Reset(player1InputField.text, GameData.Role.Head);
data.player2.Reset(player2InputField.text, GameData.Role.Body);
SceneManager.LoadScene("MainLevel");
SceneManager.LoadScene("InGameUI", LoadSceneMode.Additive);
SceneManager.LoadScene("DelayTimer", LoadSceneMode.Additive);
}
public void ChangeColorPlayer1(int colors)
{
switch (colors)
{
public void ChangeColorPlayer1(int colors) {