Skip to content

Instantly share code, notes, and snippets.

@markdekuijer
Last active November 8, 2018 21:34
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save markdekuijer/0cffbec3938fa9045873c6c14caa9e5b to your computer and use it in GitHub Desktop.
Save markdekuijer/0cffbec3938fa9045873c6c14caa9e5b to your computer and use it in GitHub Desktop.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class DroppedItem : MonoBehaviour
{
[Header("OnStartWeapon")]
[SerializeField] private Text DmgText;
[SerializeField] private Text CurrentDmgText;
[SerializeField] private Text levelText;
[SerializeField] private Text weaponNameText;
[SerializeField] private Image rarityImage;
[SerializeField] private Image classTypeImage;
[Header("OnStartArmore")]
[SerializeField] private Text armorNameText;
[Header("Stats")]
public MeshFilter meshRenderer;
public int level;
public string setName;
public float damage;
public CharacterType classType;
public Rarity rarity;
private GameObject UIWeaponObject;
private GameObject UIArmoreObject;
//TODO @self-reminder: clean this section up if you continue this project;
[Header("MeshTypes")]
[SerializeField] private Mesh bowMesh;
[SerializeField] private GameObject swordMesh;
[SerializeField] private GameObject offhandMesh;
[SerializeField] private GameObject chestMesh;
[SerializeField] private GameObject helmetMesh;
[SerializeField] private GameObject bootMesh;
private ArmoreStats armoreStats;
private WeaponStats weaponStats;
//Gets called right after it gets picked out of the pool
//and reset/set all values to the new drop
public void Init(Drops d)
{
if(d is WeaponStats)
{
weaponStats = (WeaponStats)d;
meshRenderer.mesh = bowMesh;
level = weaponStats.levelRequirment;
setName = weaponStats.setName;
damage = weaponStats.damage;
classType = weaponStats.Class;
rarity = weaponStats.rarity;
}
else if(d is ArmoreStats)
{
armoreStats = (ArmoreStats)d;
}
}
public void OnMouseEnter()
{
if (weaponStats != null)
{
DmgText.text = CharacterBehaviour.currentWeaponStats.damage.ToString();
UIWeaponObject.SetActive(true);
}
else if (armoreStats != null)
{
//armorePoints = CharacterBehaviour.currentArmoreStats.defence.ToString(); rework needed for armor system
UIArmoreObject.SetActive(true);
}
}
public void OnMouseExit()
{
UIWeaponObject.SetActive(false);
UIArmoreObject.SetActive(false);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment