Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class AttributeManager : MonoBehaviour
- {
- public static int MAGIC = 16, INTELLIGENCE = 8, CHARISMA = 4, FLY = 2, INVISIBLE = 1;
- public Text attributeDisplay;
- public int attributes = 0;
- private void OnTriggerEnter(Collider other) {
- if(other.gameObject.tag == "MAGIC")
- attributes |= MAGIC;
- if(other.gameObject.tag == "INTELLIGENCE")
- attributes |= INTELLIGENCE;
- if(other.gameObject.tag == "CHARISMA")
- attributes |= CHARISMA;
- if(other.gameObject.tag == "FLY")
- attributes |= FLY;
- if(other.gameObject.tag == "INVISIBLE")
- attributes |= INVISIBLE;
- else if(other.gameObject.tag == "ANTI-MAGIC")
- attributes &= ~(MAGIC);
- if(other.gameObject.tag == "MAGE")
- attributes |= (MAGIC | INTELLIGENCE | CHARISMA);
- if(other.gameObject.tag == "ANTI-MAGE")
- attributes &= ~(INTELLIGENCE | MAGIC);
- }
- void resetAttributes()
- {
- attributes = 0;
- }
- void Update()
- {
- Vector3 screenPoint = Camera.main.WorldToScreenPoint(this.transform.position);
- attributeDisplay.transform.position = screenPoint + new Vector3(0,-50,0);
- attributeDisplay.text = Convert.ToString(attributes, 2).PadLeft(8, '0');
- if(Input.GetKeyDown(KeyCode.Space)){
- resetAttributes();
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement