Skip to content
Snippets Groups Projects
Commit 5a3f9da0 authored by Gelencsér Ákos's avatar Gelencsér Ákos :alien:
Browse files

Bug fixek es Coin item implementalasa

parent e8f3bedc
No related branches found
No related tags found
1 merge request!15Currency uni 24
%YAML 1.1
%TAG !u! tag:unity3d.com,2011:
--- !u!114 &3462310278958733585
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInstance: {fileID: 0}
m_PrefabAsset: {fileID: 0}
m_GameObject: {fileID: 1861963846499114013}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 6e72592402bcab845a5f56bebff35e93, type: 3}
m_Name:
m_EditorClassIdentifier:
--- !u!1001 &1662937610123576041
PrefabInstance:
m_ObjectHideFlags: 0
serializedVersion: 2
m_Modification:
m_TransformParent: {fileID: 0}
m_Modifications:
- target: {fileID: 1064246659690438388, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_Name
value: Coins
objectReference: {fileID: 0}
- target: {fileID: 2610869581788646341, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: _price
value: 50
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_RootOrder
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalPosition.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalPosition.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalPosition.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalRotation.w
value: 1
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalRotation.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalRotation.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalRotation.z
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalEulerAnglesHint.x
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalEulerAnglesHint.y
value: 0
objectReference: {fileID: 0}
- target: {fileID: 4926020174793385408, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
propertyPath: m_LocalEulerAnglesHint.z
value: 0
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
--- !u!1 &1861963846499114013 stripped
GameObject:
m_CorrespondingSourceObject: {fileID: 1064246659690438388, guid: 12f2636fba4195c47bb2021ed2e58413, type: 3}
m_PrefabInstance: {fileID: 1662937610123576041}
m_PrefabAsset: {fileID: 0}
fileFormatVersion: 2
guid: 39beb763e9e5f7c46b82ad1ee4e30241
PrefabImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
This diff is collapsed.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Coin : BaseItemEffect {
public int coinBonusLowerBound = 50;
public int coinBonusUpperBound = 500;
public override void Effect(GameObject player) {
int value = Random.Range(coinBonusLowerBound, coinBonusUpperBound);
player.GetComponent<PlayerCurrencySystem>().ManageBalance(value);
}
}
fileFormatVersion: 2
guid: 6e72592402bcab845a5f56bebff35e93
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -42,8 +42,8 @@ public class ItemBaseCollision : MonoBehaviour
}
public void OnTriggerEnter2D(Collider2D other) {
// A talpbol megszerezzuk a playert
//PlayerJump playerJump = other.gameObject.GetComponent<PlayerJump>();
if (!other.gameObject.CompareTag("Player"))
return;
// levonjuk a jatekos szamlajarol az item arat
other.gameObject.GetComponent<PlayerCurrencySystem>().ManageBalance(-_price);
// meghivjuk az item effektjet a jatekosra
......
......@@ -13,8 +13,8 @@ public class Player : MonoBehaviour {
[SerializeField] float debug_speed = 100f;
// A kepernyo szelessege
public float offset = 3;
// Reszeg allapotban adott idore le kell tiltani az iranyitast
public bool movementEnabled = true;
// Reszeg allapotban adott idore ennyi x iranyu sebesseget kap
public float drunk_speed_modifier = 0;
void Start() {
// Megmondjuk, hogy azt az rb-t akarjuk hasznalni, ami azon a gameobjecten van, mint ez a script
......@@ -32,18 +32,16 @@ public class Player : MonoBehaviour {
}
private void FixedUpdate() {
if (!movementEnabled)
return;
if (Input.GetKey(KeyCode.A)) {
if (Rb.velocity.x > 0)
Rb.velocity = new Vector2(0, Rb.velocity.y);
Rb.velocity = new Vector2(drunk_speed_modifier, Rb.velocity.y);
Rb.AddForce(new Vector2(-debug_speed, 0) * Time.deltaTime, ForceMode2D.Impulse);
}
if (Input.GetKey(KeyCode.D)) {
if (Rb.velocity.x < 0)
Rb.velocity = new Vector2(0, Rb.velocity.y);
Rb.velocity = new Vector2(drunk_speed_modifier, Rb.velocity.y);
Rb.AddForce(new Vector2(debug_speed, 0) * Time.deltaTime, ForceMode2D.Impulse);
}
}
......@@ -80,19 +78,14 @@ public class Player : MonoBehaviour {
// Mozgassuk a jatekost
transform.Translate(acc * horizontal_speed); */
if (!movementEnabled) {
return;
}
float acc = Input.acceleration.x;
float vAcc = acc * horizontal_speed * Time.deltaTime;
Rb.velocity = new Vector2(vAcc, Rb.velocity.y);
Rb.velocity = new Vector2(drunk_speed_modifier + vAcc, Rb.velocity.y);
}
public void SetMovementAbility(bool newState) {
movementEnabled = newState;
//Debug.Log(movementEnabled);
public void SetDrunkSpeedModifier(float mod) {
drunk_speed_modifier = mod;
}
}
......@@ -13,12 +13,12 @@ public class PlayerJump : MonoBehaviour {
public float jump_boost_force = 16f; // mekkora a nagyobb ugras (az alap ugras sebessege torlodik, ezzel helyettesitodik)
public int drunk_state_duration = 0; // hany ugrasig "reszeg" a karakter
public int drunk_state_disabled_distance = 3; // reszeg allapotban ugras utan mennyit tavolodjon mire kijozanodik
public Player player; // ezzel allitjuk le a jatekos iranyitasat
public Player player;
void Start() {
// Megmondjuk, hogy azt az rb-t akarjuk hasznalni, ami azon a gameobjecten van, mint ez a script
rb = gameObject.GetComponentInParent<Rigidbody2D>();
// Ezzel allitjuk le a jatekos iranyitasat
player = rb.gameObject.GetComponent<Player>();
}
......@@ -28,6 +28,8 @@ public class PlayerJump : MonoBehaviour {
// Mert egyszer a sima PlatformBounce masodszor meg a PlatformBoostPlayer hivja meg ezt a jump fuggvenyt
if (force == jump_force)
UpdateStatusEffects();
// Fix osszeg jutalom minden ugrasert
player.GetComponent<PlayerCurrencySystem>().ManageBalance(); // default parameter a jutalom
}
private void UpdateStatusEffects() {
......@@ -46,18 +48,16 @@ public class PlayerJump : MonoBehaviour {
// Random eldontjuk, hogy balra vagy jobbra mutasson
if (Random.Range(0, 99) % 2 == 0)
velocity = -velocity;
// Megkapja az oldaliranyu erot
rb.velocity = new Vector2(rb.velocity.x + velocity, rb.velocity.y);
// Adott idore lekapcsoljuk az iranyitast ha meg nincs lekapcsolva
StartCoroutine(DisableMovement(player));
StartCoroutine(DisableMovement(player, velocity));
// Csokkentjuk a reszegseg idotartamat
drunk_state_duration--;
}
}
IEnumerator DisableMovement(Player player) {
player.SetMovementAbility(false);
IEnumerator DisableMovement(Player player, float mod) {
player.SetDrunkSpeedModifier(mod);
yield return new WaitForSeconds(0.5f);
player.SetMovementAbility(true);
player.SetDrunkSpeedModifier(0);
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment