//is only called after establishing this object should be hit
    IEnumerable <WaitForSeconds> GiveDamage(GameObject toAttack, Action onFinished)
    {
        bool hasTarget = true;
        ActiveObjectController  activeControllerTarget  = toAttack.GetComponent <ActiveObjectController>();
        PassiveObjectController passiveControllerTarget = toAttack.GetComponent <PassiveObjectController>();

        while (hasTarget)
        {
            if (activeControllerTarget)
            {
                activeControllerTarget.Hit(activeObjectModell.attackDamage);
                if (!activeControllerTarget.IsAlive())
                {
                    hasTarget = false;
                    activeObjectModell.ResetTargetToNull();
                }
                else
                {
                    yield return(new WaitForSeconds(activeObjectModell.attackEveryXSecond));
                }
            }
            else if (passiveControllerTarget)
            {
                passiveControllerTarget.Hit(activeObjectModell.attackDamage);
                if (!passiveControllerTarget.IsAlive())
                {
                    hasTarget = false;
                    activeObjectModell.ResetTargetToNull();
                }
                else
                {
                    yield return(new WaitForSeconds(activeObjectModell.attackEveryXSecond));
                }
            }
        }

        // activeObjectModell.ResetTargetToNull();
        //  Debug.Log("ACTIVE OBJECT MODEL: reset target to null");
        onFinished();
        SearchForTarget();
    }
Exemplo n.º 2
0
 public void ExecuteCommand(Command command, PassiveObjectController obj)
 {
     command.Execute(obj);
     _commandHistory.Push(command);
 }
Exemplo n.º 3
0
 // Start is called before the first frame update
 public abstract void  Execute(PassiveObjectController obj);
Exemplo n.º 4
0
 public override void Execute(PassiveObjectController obj)
 {
     obj.RotateForward();
 }
Exemplo n.º 5
0
 public override void Execute(PassiveObjectController obj)
 {
     obj.RotateRight();
 }
Exemplo n.º 6
0
 public override void Execute(PassiveObjectController obj)
 {
     // obj.Translate(Vector3.right * 100 * Time.deltaTime * -1);
     obj.RotateLeft();
 }