예제 #1
0
        public void Validate(UnitCell attacker, HexCell target, int damage, Action onCompletionCallback)
        {
            if (this.attacker != attacker)
            {
                Debug.LogError("Invalid attacker!");
                return;
            }

            if (this.target != target)
            {
                Debug.LogError("Invalid target!");
                isActioned = true;
                attacker.AttackComplete();
                return;
            }

            if (this.damage != damage)
            {
                Debug.LogError($"Damage mismatch. Expected {this.damage} got {damage}");
                this.damage = damage;
            }

            this.damage = damage;
            this.onCompletionCallback = onCompletionCallback;

            isValidated = true;

            CompleteAttackIfSynced();
        }
예제 #2
0
        private void CompleteAttackIfSynced()
        {
            if (isActioned)
            {
                return;
            }

            if (isAnimationComplete && isValidated)
            {
                isActioned = true;
                target.RemoveHealth(damage);
                onCompletionCallback?.Invoke();
                attacker.AttackComplete();
            }
        }