/// <summary> /// Overrides the lightning towers's update function to use to attack the targeted base /// </summary> /// <param name="lightningTower">stores a reference of the TowerStateMachine in tower</param> /// <returns>>It returns back into itself until the current enemy is destroyed</returns> public override LightningTowerState Update(LightningTowerStateMachine lightningTower) { if (lightningTower.attackTarget != null) // if the attackTarget isn't null { lightningTower.timeUntilNextShot -= Time.deltaTime; // then start attack timer if (lightningTower.timeUntilNextShot <= 0) // if atack timer reaches zero { lightningTower.enemy.TakeDamage(lightningTower.attackDamage); // attack lightningTower.timeUntilNextShot = lightningTower.timeBetweenShots; // reset timer } } return(null); // return back into itself }
/// <summary> /// Handles when a tower is selected, doesn't work anymore /// </summary> private void ClickToSelectTower() { if (Input.GetButtonDown("Fire1") && Input.GetButton("Jump")) // on left click + spacebar { Ray ray = cam.ScreenPointToRay(Input.mousePosition); // create a ray from the camera, through scene to the mouse if (Physics.Raycast(ray, out RaycastHit hit, 50, clickableObjects)) { // shoot ray into scene, detect where it hit TowerStateMachine tower = hit.collider.GetComponent <TowerStateMachine>(); if (tower != null && isTowerOne) { currentlySelectedTower = tower; } LightningTowerStateMachine lightningTower = hit.collider.GetComponent <LightningTowerStateMachine>(); if (tower != null && isTowerTwo) { currentlySelectedLightningTower = lightningTower; } } else { currentlySelectedTower = null; // deselect currentlySelectedLightningTower = null; } }
public virtual void OnStart(LightningTowerStateMachine lightningTower) { } // a start function that can be taken over by other classes public virtual void OnEnd(LightningTowerStateMachine lightningTower) { } // a end function that can be taken over by other classes
public abstract LightningTowerState Update(LightningTowerStateMachine lightningTower); // creates a special update that can be taken over by other classes
/// <summary> /// Overrides the lightning tower update to use in this current state /// </summary> /// <param name="lightningTower">stores a reference of the LightningTowerStateMachine in lightningTower</param> /// <returns>It returns back into itself until the current enemy is destroyed or out of range</returns> public override LightningTowerState Update(LightningTowerStateMachine lightningTower) { return null;// stay in current state } // end update