示例#1
0
        internal override void SetSteeringWheel(float yaw, float pitch)
        {
            base.SetSteeringWheel(yaw, pitch);

            ShipSide useShipSide = yaw > 0 ? ShipSide.Port : ShipSide.Starboard;

            yaw = Mathf.Abs(yaw);
            if (yaw > .1f && yaw >= previousAbsYaw)
            {
                subTurnHandlers?.ForEach(turnHandler => turnHandler.OnSubTurn(useShipSide));
            }

            previousAbsYaw = yaw;
        }
    public void AddHealth(int health, ShipSide shipSide)
    {
        switch (shipSide)
        {
        case ShipSide.Left:
            LeftSideHealth += health;
            if (LeftSideHealth < 0)
            {
                LeftSideHealth = 0;
            }

            if (LeftSideHealth > MaxSideHealth)
            {
                LeftSideHealth = MaxSideHealth;
            }
            break;

        case ShipSide.Right:
            RightSideHealth += health;
            if (RightSideHealth < 0)
            {
                RightSideHealth = 0;
            }

            if (RightSideHealth > MaxSideHealth)
            {
                RightSideHealth = MaxSideHealth;
            }
            break;
        }

        currentHealth += health;
        if (currentHealth < 0)
        {
            currentHealth = 0;
        }

        if (currentHealth > 100)
        {
            currentHealth = 100;
        }
    }
示例#3
0
    public void Shoot(ShipSide pSide)
    {
        if (!CanShoot(pSide))
        {
            return;
        }

        var cannonSpawnPoints = pSide == ShipSide.Left ? LeftCannonsBulletSpawn : RightCannonsBulletSpawn;

        gameObject.GetComponent <AudioSource>().PlayOneShot(CannonSFX);
        foreach (GameObject spawnPoint in cannonSpawnPoints)
        {
            var cannonBall = Instantiate(CannonBallPrefab, spawnPoint.transform.position, spawnPoint.transform.rotation);
            var rigidbody  = cannonBall.GetComponent <Rigidbody>();
            var particle   = Instantiate(BlastParticles, spawnPoint.transform.position, spawnPoint.transform.rotation, spawnPoint.transform);
            rigidbody.AddRelativeForce(new Vector3(0, 0, BulletStartVelocity), ForceMode.VelocityChange);

            Destroy(particle, 2);
        }
    }
示例#4
0
 private bool CanShoot(ShipSide pSide)
 {
     if (pSide == ShipSide.Left)
     {
         if (LeftCooldown > CooldownTime)
         {
             LeftCooldown = 0;
             return(true);
         }
         return(false);
     }
     if (pSide == ShipSide.Right)
     {
         if (RightCooldown > CooldownTime)
         {
             RightCooldown = 0;
             return(true);
         }
         return(false);
     }
     return(false);
 }