//update for an indirect attack public bool OnIndirectAttackUpdate() { if (sourceStepTimer > 0) { sourceStepTimer -= Time.deltaTime; } else { source.InvokeAttackPerformedEvent(); //not an area attack: CustomEvents.OnAttackPerformed(source, source.Target, source.GetTargetPosition()); sources[sourceStep].Launch(gameMgr.EffectPool, source); if (launchType == LaunchTypes.inOrder) //if the attack is supposed to go through attack objects in order and launch them { sourceStep++; //increment the source step } if (sourceStep >= sources.Length || launchType == LaunchTypes.random) //if we reached the last attack object or the launch type is set to random { sourceStep = 0; //end of attack source.OnAttackComplete(); } else //move to next attack object { sourceStepTimer = sources[sourceStep].GetDelay(); } return(true); //return whenever an attack object is launched } return(false); }
//a method that launches the attack object towards the target public void Launch(EffectObjPool effectPool, AttackEntity source) { AttackObject newAttackObject = effectPool.SpawnEffectObj(attackObject, launchPosition.position, Quaternion.identity).GetComponent <AttackObject>(); Vector3 targetPosition = source.GetTargetPosition(); if (GameManager.MultiplayerGame == false) //if this is a singleplayer game, we can play with accuracy: { targetPosition += new Vector3(Random.Range(-accuracyModifier.x, accuracyModifier.x), Random.Range(-accuracyModifier.y, accuracyModifier.y), Random.Range(-accuracyModifier.z, accuracyModifier.z)); } newAttackObject.Enable(source, targetPosition, (createInDelay == true) ? delayTime : 0.0f, damageInDelay, delayParentObject, source.CanEngageFriendly()); }