init
This commit is contained in:
commit
fca6784fe7
571 changed files with 84105 additions and 0 deletions
89
Assets/Scripts/Combat/AttackSelectorUI.cs
Normal file
89
Assets/Scripts/Combat/AttackSelectorUI.cs
Normal file
|
@ -0,0 +1,89 @@
|
|||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class AttackSelectorUI : MonoBehaviour, IPointerEnterHandler, IPointerExitHandler{
|
||||
|
||||
EnemyController enemy;
|
||||
|
||||
[System.Serializable] enum AttackType { Rock, Paper, Scisors}
|
||||
[SerializeField] AttackType attackType = default;
|
||||
|
||||
AttackManager attack;
|
||||
bool selected;
|
||||
RectTransform rect;
|
||||
|
||||
float velocity;
|
||||
|
||||
[SerializeField] PlayerAttack playerAttack = default;
|
||||
|
||||
void Awake(){
|
||||
attack = GetComponentInParent<AttackManager>();
|
||||
rect = GetComponent<RectTransform>();
|
||||
}
|
||||
|
||||
public void OnPointerEnter(PointerEventData eventData){
|
||||
selected = true;
|
||||
switch (CombatManager.instance.enemyType){
|
||||
case CombatManager.EnemyType.Bear:
|
||||
enemy = CombatManager.instance.bear;
|
||||
break;
|
||||
case CombatManager.EnemyType.Driada:
|
||||
enemy = CombatManager.instance.driada;
|
||||
break;
|
||||
case CombatManager.EnemyType.Loca:
|
||||
enemy = CombatManager.instance.loca;
|
||||
break;
|
||||
case CombatManager.EnemyType.Boss:
|
||||
enemy = CombatManager.instance.boss;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public void OnPointerExit(PointerEventData eventData){
|
||||
selected = false;
|
||||
}
|
||||
|
||||
// Update is called once per frame
|
||||
void Update(){
|
||||
if (selected){
|
||||
if (attackType == AttackType.Paper){
|
||||
if (attack.CanPaperAttack()){
|
||||
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.maxHeight, ref velocity, attack.selectSmoothTime));
|
||||
if (Input.GetMouseButtonUp(0)){
|
||||
playerAttack.open1 = attack.selectedPaper.finger1;
|
||||
playerAttack.open2 = attack.selectedPaper.finger2;
|
||||
playerAttack.open3 = attack.selectedPaper.finger3;
|
||||
playerAttack.open4 = attack.selectedPaper.finger4;
|
||||
playerAttack.open5 = attack.selectedPaper.finger5;
|
||||
enemy.Attack(attack.AttackingWithMeat(false, true), attack.AttackingWithWood(false, true), 2);
|
||||
playerAttack.Attack();
|
||||
}
|
||||
}
|
||||
}else if (attackType == AttackType.Scisors){
|
||||
if (attack.CanScisorAttack()){
|
||||
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.maxHeight, ref velocity, attack.selectSmoothTime));
|
||||
if (Input.GetMouseButtonUp(0)){
|
||||
playerAttack.open1 = attack.selectedScisor.finger1;
|
||||
playerAttack.open2 = attack.selectedScisor.finger2;
|
||||
playerAttack.open3 = attack.selectedScisor.finger3;
|
||||
playerAttack.open4 = attack.selectedScisor.finger4;
|
||||
playerAttack.open5 = attack.selectedScisor.finger5;
|
||||
enemy.Attack(attack.AttackingWithMeat(true, false), attack.AttackingWithWood(true, false), 3);
|
||||
playerAttack.Attack();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.maxHeight, ref velocity, attack.selectSmoothTime));
|
||||
if (Input.GetMouseButtonUp(0)){
|
||||
playerAttack.open1 = playerAttack.open2 = playerAttack.open3 = playerAttack.open4 = playerAttack.open5 = false;
|
||||
enemy.Attack(attack.AttackingWithMeat(false, false), attack.AttackingWithWood(false, false), 1);
|
||||
playerAttack.Attack();
|
||||
}
|
||||
}
|
||||
}else{
|
||||
rect.anchoredPosition = new Vector2(rect.anchoredPosition.x, Mathf.SmoothDamp(rect.anchoredPosition.y, attack.minHeight, ref velocity, attack.selectSmoothTime));
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue