Orb of experience(s)
This commit is contained in:
@@ -13,7 +13,9 @@ GameObject:
|
||||
- component: {fileID: 3279790092549852026}
|
||||
- component: {fileID: -6060090594203959720}
|
||||
- component: {fileID: 5629464872527876577}
|
||||
- component: {fileID: 8338184184584571871}
|
||||
- component: {fileID: 3787322971358149925}
|
||||
- component: {fileID: 7397454076540391921}
|
||||
m_Layer: 0
|
||||
m_Name: Player
|
||||
m_TagString: Player
|
||||
@@ -172,15 +174,50 @@ BoxCollider2D:
|
||||
m_SpriteTilingProperty:
|
||||
border: {x: 0, y: 0, z: 0, w: 0}
|
||||
pivot: {x: 0.5, y: 0.5}
|
||||
oldSize: {x: 0.4857143, y: 0.74285716}
|
||||
oldSize: {x: 0.34, y: 0.52}
|
||||
newSize: {x: 0.17, y: 0.26}
|
||||
adaptiveTilingThreshold: 0.5
|
||||
drawMode: 0
|
||||
adaptiveTiling: 0
|
||||
m_AutoTiling: 0
|
||||
serializedVersion: 2
|
||||
m_Size: {x: 0.17, y: 0.26}
|
||||
m_Size: {x: 0.34, y: 0.52}
|
||||
m_EdgeRadius: 0
|
||||
--- !u!58 &8338184184584571871
|
||||
CircleCollider2D:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1784956759114531697}
|
||||
m_Enabled: 1
|
||||
m_Density: 1
|
||||
m_Material: {fileID: 0}
|
||||
m_IncludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_ExcludeLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 0
|
||||
m_LayerOverridePriority: 0
|
||||
m_ForceSendLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ForceReceiveLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_ContactCaptureLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_CallbackLayers:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_IsTrigger: 1
|
||||
m_UsedByEffector: 0
|
||||
m_UsedByComposite: 0
|
||||
m_Offset: {x: 0, y: 0}
|
||||
serializedVersion: 2
|
||||
m_Radius: 0.7
|
||||
--- !u!114 &3787322971358149925
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@@ -193,3 +230,15 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 32f5e7611866dce4ab320c814d279d84, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
--- !u!114 &7397454076540391921
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1784956759114531697}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 76eec47d6b942ad4ab792b7022c07bb1, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
using UnityEngine;
|
||||
|
||||
[RequireComponent(typeof(PlayerManager))]
|
||||
public class PlayerCollisions : MonoBehaviour
|
||||
{
|
||||
private PlayerManager _pm;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
_pm = GetComponent<PlayerManager>();
|
||||
}
|
||||
|
||||
private void OnTriggerStay2D(Collider2D collision)
|
||||
{
|
||||
/** --- Orb Absorber ------------------------------- */
|
||||
if (collision.gameObject.CompareTag("Orb"))
|
||||
{
|
||||
GameObject orb = collision.gameObject;
|
||||
orb.transform.position = Vector3.MoveTowards(orb.transform.position, transform.position, 1f * Time.deltaTime);
|
||||
|
||||
if (orb.transform.position == transform.position)
|
||||
{
|
||||
Destroy(orb);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void OnTriggerExit2D(Collider2D collision)
|
||||
{
|
||||
if (collision.gameObject.CompareTag("Orb"))
|
||||
{
|
||||
GameObject orb = collision.gameObject;
|
||||
|
||||
if (orb.transform.position == transform.position)
|
||||
{
|
||||
_pm.AddExperience((int)orb.GetComponent<OrbStats>().OrbValue);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 76eec47d6b942ad4ab792b7022c07bb1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,22 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class PlayerManager : MonoBehaviour
|
||||
{
|
||||
public float Health = 100f;
|
||||
public float Speed = 10f;
|
||||
public int Exp = 0;
|
||||
public int Level = 1;
|
||||
|
||||
public void AddExperience(int value)
|
||||
{
|
||||
Exp += value;
|
||||
|
||||
if (Exp >= Level * 10)
|
||||
{
|
||||
Exp -= Level * 10;
|
||||
Level++;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d8afe5a349c86994f8ddacd37ce22ae3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
Reference in New Issue
Block a user