예제 #1
0
        public void Attack(Unit.Unit originUnit, Unit.Unit opponentUnit)
        {
            if (UnitStateManager.currentState == State.Attack)
            {
                OriginUnitFaceTowardsToOpponent(originUnit, opponentUnit);
                var unitMotion = originUnit.GetComponentInChildren <UnitMotion>();
                unitMotion.AttackMotion();

                StartCoroutine(OpponentUnitImpact(originUnit, opponentUnit,
                                                  unitMotion.GetLengthOfCurrentClip()));
            }
        }
예제 #2
0
        // This is a temporary solution because if i use unity animation event, it has issue with the go reference
        // I have no damn idea :((
        private IEnumerator OpponentUnitImpact(Unit.Unit originUnit, Unit.Unit opponentUnit, float time)
        {
            yield return(new WaitForSeconds(time));

            // The magic number is temporary, will implement skillset if there's enough time
            opponentUnit.GetComponent <Health.Health>().GetDamaged(1);
            opponentUnit.GetComponentInChildren <UnitMotion>().GetDamageMotion();

            if (!hasOpponentInitiatedCounter)
            {
                hasOpponentInitiatedCounter = true;
                yield return(new WaitForSeconds(time));

                Attack(opponentUnit, originUnit);
            }
            else
            {
                UnitStateManager.currentState = State.Done;
                hasOpponentInitiatedCounter   = false;
            }
        }