Created
July 2, 2020 19:53
-
-
Save kurtkaiser/d56c206a9331a22eb933894a3811e480 to your computer and use it in GitHub Desktop.
RPG battle system, this game was built for a YouTube tutorial.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System.Collections; | |
using System.Collections.Generic; | |
using UnityEngine; | |
using UnityEngine.UI; | |
public class FighterAction : MonoBehaviour | |
{ | |
private GameObject hero; | |
private GameObject enemy; | |
[SerializeField] | |
private GameObject meleePrefab; | |
[SerializeField] | |
private GameObject rangePrefab; | |
[SerializeField] | |
private Sprite faceIcon; | |
private GameObject currentAttack; | |
void Awake() | |
{ | |
hero = GameObject.FindGameObjectWithTag("Hero"); | |
enemy = GameObject.FindGameObjectWithTag("Enemy"); | |
} | |
public void SelectAttack(string btn) | |
{ | |
GameObject victim = hero; | |
if (tag == "Hero") | |
{ | |
victim = enemy; | |
} | |
if (btn.CompareTo("melee") == 0) | |
{ | |
meleePrefab.GetComponent<AttackScript>().Attack(victim); | |
} else if (btn.CompareTo("range") == 0) | |
{ | |
rangePrefab.GetComponent<AttackScript>().Attack(victim); | |
} else | |
{ | |
Debug.Log("Run"); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment