public void TryFire(CastleShip castleShip, string actionKey) { if (inUse) { return; } this.StartCoroutine(TargetManagement_Coroutine(castleShip, actionKey)); }
public void TryFire(CastleShip castleShip, string actionID) { if (cooldownTimer <= 0) { Fire(castleShip, actionID); cooldownTimer = 1 / shotsPerSecond; } }
void Fire(CastleShip castleShip, string actionID) { CatapultBall catapultBall = GameObject.Instantiate(this.catapultBall); catapultBall.transform.position = this.shootPoint.position; catapultBall.transform.rotation = this.shootPoint.rotation; //catapultBall.transform.position += this.controllable.RigidbodyRef.velocity * 0.2f; catapultBall.transform.Rotate(Random.Range(-angleSpread, angleSpread), Random.Range(-angleSpread, angleSpread), 0, Space.Self); catapultBall.Shoot(shotStrength, castleShip); }
void Fire(CastleShip castleShip) { BallistaArrow missile = GameObject.Instantiate(ballistaArrow); missile.transform.position = this.shootPoint.position; missile.transform.rotation = this.shootPoint.rotation; missile.transform.eulerAngles = new Vector3(0, missile.transform.eulerAngles.y, missile.transform.eulerAngles.z); missile.transform.Rotate(0, Random.Range(-angleSpread, angleSpread), 0, Space.Self); missile.Shoot(shotStrength, castleShip); }
public void Shoot(float strength, CastleShip castleShip) { this.castleShipRef = castleShip; Rigidbody shipRigidbody = castleShip.RigidbodyRef; Vector2 forcePos = this.transform.position; forcePos.y = shipRigidbody.centerOfMass.y; shipRigidbody.AddForce(-shipRigidbody.transform.forward * strength / 2, ForceMode.Impulse); this.rigidBody.AddForce(this.transform.forward * strength, ForceMode.Impulse); }
private void AddShip(CastleShip.CastleShipType castleShipType, bool ai = false) { if (CastleShip != null) { RemoveShip(); } castleShip = battleManagerRef.SpawnShip(castleShipType, this.BoundPlayerID, this.spawnPosition, ai); CastleShip.OnGoldChanged += AddGold; CastleShip.OnKill += AddKill; CastleShip.SetColourMaterial(this.playerColour); playerUIManager.ConnectToCastleShip(CastleShip); CastleShip.DamageableRef.OnDeath.AddListener(OnShipDie); }
IEnumerator TargetManagement_Coroutine(CastleShip castleShip, string actionKey) { inUse = true; Player playerRef = ReInput.players.GetPlayer(castleShip.GetComponent <PlayerControlled>().PlayerID); TrebuchetTargetedArea trebuchetTargetedArea = Instantiate(this.trebuchetTargetedArea); float distance = 0; Vector3 endPosition = Vector3.zero; float timeHeld = 0; while (playerRef.GetButton(actionKey)) { timeHeld += Time.deltaTime; distance += Time.deltaTime * 3; distance = Mathf.Clamp(distance, 0, 10); endPosition = startPoint.position + castleShip.transform.forward * distance; trebuchetTargetedArea.UpdatePosition(endPosition, originPoint.transform.position); yield return(null); } Destroy(trebuchetTargetedArea.gameObject); inUse = false; if (timeHeld <= 0.3f) { yield break; } for (int i = 0; i < catapultBallsToSpawn; i++) { CatapultBall spawnedBall = GameObject.Instantiate(catapultBall); spawnedBall.castleShipRef = castleShip; Vector3 randomXZ = Random.insideUnitCircle * 1.5f; float randomY = Random.Range(0f, 3f); spawnedBall.transform.position = new Vector3(endPosition.x + randomXZ.x, endPosition.y + 10 + randomY, endPosition.z + randomXZ.y); } }
private void OnShipSelectionChanged(CastleShip ship) { this.shipImage.sprite = ship.Image; this.shipName.text = ship.ShipName; }
public void DisconnectCastleShip(CastleShip castleShip) { castleShip.DamageableRef.onHpChanged -= OnHPChanged; }
public void ConnectToCastleShip(CastleShip castleShip) { castleShip.DamageableRef.onHpChanged += OnHPChanged; }
public virtual void ActivateModifier(CastleShip castleShipRef) { ; }
public void Shoot(float strength, CastleShip castleShip) { this.rigidBody.AddRelativeForce(this.transform.forward * strength, ForceMode.Impulse); this.castleShip = castleShip; }
public override void ActivateModifier(CastleShip castleShipRef) { Debug.Log("Activate modifier"); base.ActivateModifier(castleShipRef); castleShipRef.SetCurrentThrustModifier(2.0f); }
public override void DeactivateModifier(CastleShip castleShipRef) { base.DeactivateModifier(castleShipRef); castleShipRef.SetCurrentThrustModifier(1.0f); }