void Update() { if (!executeLogic) { return; } DrawArrow(); GameObject go = RayReturn(); if (go) { if (go != gameObject) { OutCard card = go.GetComponent <OutCard>(); Hero hero = go.GetComponent <Hero>(); if (card) { executeLogic = false; card.DamageControl(true, damageValue); } else if (hero) { } else { } } } }
void OnMouseUp() { Debug.Log(" ======= OutCard Up ====== "); //Cursor.visible = true; GameData.arrowObj.SetActive(false); getUp = false; Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition); RaycastHit rayhit; if (Physics.Raycast(ray, out rayhit)) { GameObject go = rayhit.collider.gameObject; if (go == gameObject) { ChangeRigBody(true); return; } OutCard card = go.GetComponent <OutCard>(); Hero hero = go.GetComponent <Hero>(); if (card) { FightController.instance.Attack(this, card); } else if (hero) { FightController.instance.Attack(this, hero); } else { ChangeRigBody(true); } } }
public void Attack(OutCard attacker, OutCard victim) { Vector3 oriPos = attacker.transform.localPosition; Tween tweenGo = attacker.transform.DOMove(victim.transform.localPosition, 0.5f, false); tweenGo.OnComplete(() => { attacker.DamageControl(true, victim.attack); victim.DamageControl(true, attacker.attack); attacker.transform.DOMove(oriPos, 0.5f).OnComplete(() => { attacker.ChangeRigBody(true); }); }); }
public void Attack(OutCard attacker, Hero hero) { attacker.defence -= hero.attack; hero.hp -= attacker.attack; }