public async Task <IActionResult> PlaceShip(Guid gameId, uint playerPosition, string type, char row, uint column, char heading, int gameVersion)
        {
            var game = await _aggRepo.GetById <Game>(gameId);

            var location = new Location(row, column);

            // See if user inputs are valid
            if (!game.ValidLocation(location, playerPosition))
            {
                return(new BadRequestResult());
            }

            var shipToAdd = new ShipDetails
            {
                BowAt     = location,
                Heading   = ConvertToHeading(heading),
                ClassSize = 3,
                ClassName = "Destroyer",
                Status    = ShipStatus.Active
            };

            // see if ship can be placed here
            var goodLocation = game.CanAddShip(shipToAdd, playerPosition);

            if (!goodLocation)
            {
                return(new BadRequestResult());
            }
            var newCommandId = Guid.NewGuid();
            await _bus.Send(new AddShip(newCommandId, gameVersion, gameId, playerPosition, shipToAdd));

            return(new RedirectToActionResult("Get", "Games", new { gameId }));
        }
 public AddShip(Guid commandId, int currentAggregateVersion, Guid gameId, uint playerIndex, ShipDetails shipDetails)
     : base(commandId, currentAggregateVersion)
 {
     GameId      = gameId;
     PlayerIndex = playerIndex;
     ShipDetails = shipDetails;
 }
 public ShipAdded(Guid gameId, uint playerIndex, ShipDetails ship)
 {
     Id          = Guid.NewGuid();
     GameId      = gameId;
     PlayerIndex = playerIndex;
     ShipToAdd   = ship;
 }
Example #4
0
        public void ABoardWillAllowIndicateThatTwoShipThatOverlapAreBad()
        {
            var sut = new Board {
                Dimensions = 8
            };

            var shipOne = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('a', 1),
                Heading   = Direction.N
            };

            sut.AddShip(shipOne);
            Assert.Equal(1, sut.Ships.Sum(s => 1));

            var shipTwo = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('c', 1),
                Heading   = Direction.N
            };

            Assert.False(sut.ShipFitsOnBoard(shipTwo));

            sut.AddShip(shipTwo);
            Assert.Equal(1, sut.Ships.Sum(s => 1));
        }
Example #5
0
        public void BoardShouldReportActiveBoatsIfAtLeastOneBoatIsActive()
        {
            var sut = new Board {
                Dimensions = 8
            };
            var shipOne = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('a', 1),
                Heading   = Direction.N,
                Status    = ShipStatus.Sunk
            };

            sut.AddShip(shipOne);
            Assert.Equal(1, sut.Ships.Sum(s => 1));
            var shipTwo = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('g', 4),
                Heading   = Direction.E,
                Status    = ShipStatus.Active
            };

            sut.AddShip(shipTwo);
            Assert.Equal(2, sut.Ships.Sum(s => 1));
            Assert.True(sut.HasActiveShips);
        }
Example #6
0
 // Use this for initialization
 void Start()
 {
     shipDetails  = FindObjectOfType <ShipDetails>();
     displayModel = transform.parent.GetComponent <DisplayModel>();
     meshRenderer = GetComponent <Renderer>();
     ogMaterial   = meshRenderer.material;
     ring         = transform.parent.Find("Ring");
 }
    //Ship31 Secondary
    public void Ship31Secondary()
    {
        List <Transform> bulletSpecialSpawnPoints = new List <Transform>();
        int i = 0;

        foreach (Transform child in transform)
        {
            if (child.CompareTag("BulletSpawn") && child.name.Contains("BulletSpawnPointSecondary"))
            {
                bulletSpecialSpawnPoints.Add(child.transform);
                i++;
            }
        }

        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;


        if (shipHandling.currentBattery >= shipDetails.Secondary.BatteryCharge)
        {
            List <Transform> usedSpawnPoints = new List <Transform>();

            usedSpawnPoints = bulletSpecialSpawnPoints;



            foreach (Transform currBulletSpawnPoint in usedSpawnPoints)
            {
                GameObject bullet = (GameObject)Instantiate(
                    shipDetails.Secondary.SecondaryPrefab,
                    currBulletSpawnPoint.position,
                    currBulletSpawnPoint.rotation);
                bullet.GetComponent <BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
                Transform transform = bullet.GetComponentInChildren <Transform>();
                transform.localScale = new Vector3(shipDetails.Secondary.Scale, shipDetails.Secondary.Scale, shipDetails.Secondary.Scale);
                bullet.GetComponent <BulletCollision>().bulletHitPoints = shipDetails.Secondary.HitPoints;
                bullet.gameObject.tag = "Bullet";

                // Add velocity to the bullet
                bullet.GetComponent <Rigidbody>().velocity = bullet.transform.forward * shipDetails.Secondary.Speed;

                BulletCollision bulletCol = bullet.GetComponentInChildren <BulletCollision>();

                bulletCol.setDamage(shipDetails.Secondary.Damage);

                createdBullets.Add(bullet);

                // Destroy the bullet after X seconds
                Destroy(bullet, shipDetails.Secondary.TimeToLive);

                CheckForMaxInstances();
            }


            shipHandling.currentBattery    = shipHandling.currentBattery - shipDetails.Secondary.BatteryCharge;
            shipHandling.lastSecondaryUsed = Time.time;
        }
    }
Example #8
0
 public bool AddShip(ShipDetails ship, uint playerIndex)
 {
     // Ensure current ship fits within board dimensions
     if (_innerDetails.Players[playerIndex].Board.ShipFitsOnBoard(ship))
     {
         ApplyChange(new ShipAdded(Id, playerIndex, ship));
         return(true);
     }
     return(false);
 }
    public void Ship63Secondary()
    {
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;

        if (shipHandling.currentBattery >= shipDetails.Secondary.BatteryCharge)
        {
            DeployMine();
        }
    }
        public void ShipShouldNotHaveLocationsWithoutHeadingPropertySet()
        {
            var sut = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                Heading   = Direction.None
            };

            Assert.Equal(0, sut.Locations.Sum(l => 1));
        }
        public void ShipShouldNotHaveLocationsWithoutBowAtPropertySet()
        {
            var sut = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('a', 1)
            };

            Assert.Equal(0, sut.Locations.Sum(l => 1));
        }
    private void EquipComponent()
    {
        if (GetCurrentHandGripRelease())
        {
            if (compatibleComponent != null)
            {
                if (equippedPart != null)
                {
                    Destroy(equippedPart);
                }
                equippedPart = (GameObject)Instantiate(compatibleComponent, transform.position, transform.rotation, transform);//Instantiate(compatibleComponent, transform);
                equippedPart.GetComponent <DroneComponent>().rotSpeed = Vector3.zero;
                equippedPart.GetComponent <DroneComponent>().onStand  = false;
                equippedPart.GetComponent <Collider>().enabled        = false;
                equippedPart.transform.localScale = Vector3.one;
            }
            equippedPart.tag = socketType;
            Renderer eqPartRenderer = equippedPart.GetComponent <Renderer>();
            for (int i = 0; i < eqPartRenderer.materials.Length; i++)
            {
                eqPartRenderer.materials[i].shader = Shader.Find("Standard");
            }
            partEquipped = true;
            if (equipSFXCooldown <= 0)
            {
                AudioSource.PlayClipAtPoint(equipSFX, transform.position);
                equipSFXCooldown = 2;
            }
            ShipDetails shipDetails = transform.parent.GetComponent <ShipDetails>();
            switch (socketType)
            {
            case "Fuselage":
                SocketPositions holoSocketPositions = transform.parent.GetComponent <SocketPositions>();
                holoSocketPositions.SetSocketPositions(equippedPart);
                shipDetails.fuselage = equippedPart;
                break;

            case "Engine":
                shipDetails.engine = equippedPart;
                break;

            case "Nose":
                shipDetails.nose = equippedPart;
                break;

            case "Wing":
                shipDetails.wing = equippedPart;
                break;
            }
            transform.parent.GetComponent <ShipDetails>().RefreshStats();
            compatibleComponentInVicinity = false;
        }
    }
Example #13
0
    private void GenericPrimaryShoot()
    {
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;
        float        usedFireRate = shipDetails.Primary.FireRate;


        if (Time.time > usedFireRate + shipHandling.lastShot)
        {
            if (shipHandling.currentBattery >= shipDetails.Primary.BatteryCharge)
            {
                List <Transform> usedSpawnPoints = new List <Transform>();

                usedSpawnPoints = bulletSpawnPoints;

                foreach (Transform currBulletSpawnPoint in usedSpawnPoints)
                {
                    GameObject bullet = (GameObject)Instantiate(
                        shipDetails.Primary.bulletPrefab,
                        currBulletSpawnPoint.position,
                        currBulletSpawnPoint.rotation);
                    bullet.transform.parent = gameObject.transform;
                    bullet.GetComponent <BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
                    bullet.GetComponent <BulletCollision>().bulletHitPoints         = shipDetails.Primary.HitPoints;
                    bullet.gameObject.tag = "Bullet";

                    Transform transform = bullet.GetComponentInChildren <Transform>();
                    transform.localScale = new Vector3(shipDetails.Primary.Scale, shipDetails.Primary.Scale, shipDetails.Primary.Scale);


                    // Add velocity to the bullet
                    bullet.GetComponent <Rigidbody>().velocity = bullet.transform.forward * shipDetails.Primary.Speed;

                    BulletCollision bulletCol = bullet.GetComponentInChildren <BulletCollision>(); //transform.Find("BulletCollision");
                                                                                                   //ScriptB other = (ScriptB)go.GetComponent(typeof(ScriptB));
                    bulletCol.setDamage(shipDetails.Primary.Damage);

                    createdBullets.Add(bullet);

                    // Destroy the bullet after X seconds
                    Destroy(bullet, shipDetails.Primary.TimeToLive);

                    CheckForMaxInstances();
                }

                shipHandling.currentBattery = shipHandling.currentBattery - shipDetails.Primary.BatteryCharge;
                shipHandling.lastShot       = Time.time;
            }
        }
    }
Example #14
0
    private void CheckForMaxInstances()
    {
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;

        if (createdBullets.Count > shipDetails.Primary.MaxInstances)
        {
            for (int i = (createdBullets.Count - shipDetails.Primary.MaxInstances); i > 0; i--)
            {
                GameObject oldestBullet = createdBullets[0];
                Destroy(oldestBullet);
                createdBullets.RemoveAt(0);
            }
        }
    }
        public void ShipShouldHaveLocationsWhenBowAtAndHeadingAreSet()
        {
            var sut = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('a', 1),
                Heading   = Direction.N
            };

            Assert.NotNull(sut.Locations);
            Assert.True(sut.LocationSet.Contains(sut.BowAt.GetHashCode()));
            Assert.True(sut.LocationSet.Contains(new Location('b', 1).GetHashCode()));
            Assert.True(sut.LocationSet.Contains(new Location('c', 1).GetHashCode()));
        }
Example #16
0
        public void ABoardWillIndicateIfAShipIsInAnInvalidPosition(Location bowAt, Direction heading)
        {
            var shipToPlace = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = bowAt,
                Heading   = heading
            };

            var sut = new Board {
                Dimensions = 8
            };

            Assert.False(sut.ShipFitsOnBoard(shipToPlace));
        }
        public void ShipShouldHaveProperLocations(Location bowAt, Direction heading, HashSet <int> correctLocations)
        {
            var sut = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = bowAt,
                Heading   = heading
            };

            Assert.NotNull(sut.Locations);
            var intersection            = sut.LocationSet.Intersect(correctLocations);
            var locationsInIntersection = intersection.Count();

            Assert.Equal(3, locationsInIntersection);
        }
    public void DeployMine()
    {
        List <Transform> bulletSpecialSpawnPoints = new List <Transform>();
        int i = 0;

        foreach (Transform child in transform)
        {
            if (child.CompareTag("BulletSpawn") && child.name.Contains("BulletSpawnPointSecondary"))
            {
                bulletSpecialSpawnPoints.Add(child.transform);
                i++;
            }
        }

        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;


        foreach (Transform currBulletSpawnPoint in bulletSpecialSpawnPoints)
        {
            GameObject bullet = (GameObject)Instantiate(
                shipDetails.Secondary.SecondaryPrefab,
                currBulletSpawnPoint.position,
                currBulletSpawnPoint.rotation);
            bullet.GetComponent <BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
            Transform transform = bullet.GetComponentInChildren <Transform>();
            transform.localScale = new Vector3(shipDetails.Secondary.Scale, shipDetails.Secondary.Scale, shipDetails.Secondary.Scale);
            bullet.GetComponent <BulletCollision>().bulletHitPoints = shipDetails.Secondary.HitPoints;
            bullet.gameObject.tag = "Bullet";
            bullet.GetComponent <BulletCollision>().isMine = true;
            bullet.transform.SetPositionAndRotation(currBulletSpawnPoint.position, Quaternion.identity);

            BulletCollision bulletCol = bullet.GetComponentInChildren <BulletCollision>();

            bulletCol.setDamage(shipDetails.Secondary.Damage);
            createdBullets.Add(bullet);

            Destroy(bullet, shipDetails.Secondary.TimeToLive);

            CheckForMaxInstances();
        }

        shipHandling.currentBattery    = shipHandling.currentBattery - shipDetails.Secondary.BatteryCharge;
        shipHandling.lastSecondaryUsed = Time.time;
    }
Example #19
0
    public void Ship17Primary()
    {
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;
        float        usedFireRate = shipDetails.Primary.FireRate;

        if (Time.time > usedFireRate + shipHandling.lastShot)
        {
            if (shipHandling.currentBattery >= shipDetails.Primary.BatteryCharge)
            {
                Ship17LaserActive = true;
                // The laser drawing is done in Update...
                Ship17LaserDurationLeft     = Ship17LaserDuration;
                shipHandling.currentBattery = shipHandling.currentBattery - shipDetails.Primary.BatteryCharge;
                shipHandling.lastShot       = Time.time;
            }
        }
    }
Example #20
0
        public ActionResult CheckOut(Cart car, ShipDetails ShipDetails)
        {
            if (car.GetAllCart.Count() == 0)
            {
                ModelState.AddModelError("", "Sorry Your Cart Is Empty");
            }

            if (ModelState.IsValid)
            {
                _order.OrderProduct(car, ShipDetails);
                car.ClearList();
                return(View("Complated"));
            }
            else
            {
                return(View(ShipDetails));
            }
        }
Example #21
0
        private static void AddShips()
        {
            for (uint playerIndex = 0; playerIndex < 2; playerIndex++)
            {
                ShipDetails shipToAdd       = null;
                var         needToPlaceShip = true;
                do
                {
                    WriteInstruction(
                        "You are about to place a Destroyer (3 spaces) on your board. We will pick a spot on the board to place the bow (front)");
                    WriteInstruction("and then we will pick the direction that your boat is heading.");
                    var row      = GetRowValue(playerIndex, "Please enter the row for the bow of your ship");
                    var col      = GetColumnValue(playerIndex, "Please enter the column for the bow of your ship");
                    var heading  = GetHeadingValue(playerIndex);
                    var location = new Location(row, col);

                    // See if user inputs are valid
                    if (!GetGameAggregate(_currentGame.Id).ValidLocation(location, playerIndex))
                    {
                        continue;
                    }

                    shipToAdd = new ShipDetails
                    {
                        BowAt     = location,
                        Heading   = ConvertToHeading(heading),
                        ClassSize = 3,
                        ClassName = "Destroyer",
                        Status    = ShipStatus.Active
                    };
                    // see if ship can be placed here
                    needToPlaceShip = !GetGameAggregate(_currentGame.Id).CanAddShip(shipToAdd, playerIndex);
                } while (needToPlaceShip);

                // send command to add the ship
                var newCommandId = Guid.NewGuid();
                _commandBus.Send(new AddShip(newCommandId, _currentGame.Version, _currentGame.Id, playerIndex,
                                             shipToAdd));

                // refresh current view of the game
                _currentGame = _read.Get <GameDetails>(_currentGame.Id).Result;
                DrawPlayersBoard(_currentGame.Players[playerIndex].Board.Representation);
            }
        }
Example #22
0
        public void BoardShouldReportNoActiveBoatsIfNoBoatsAreActive()
        {
            var sut = new Board {
                Dimensions = 8
            };

            var shipOne = new ShipDetails
            {
                ClassName = "Destroyer",
                ClassSize = 3,
                BowAt     = new Location('a', 1),
                Heading   = Direction.N,
                Status    = ShipStatus.Sunk
            };

            sut.AddShip(shipOne);
            Assert.Equal(1, sut.Ships.Sum(s => 1));
            Assert.False(sut.HasActiveShips);
        }
            private static int SetShipAddress(ShipDetails shipDetails, SqlConnection con)
            {
                using (SqlCommand cmd = new SqlCommand("INSERT INTO shipDetails OUTPUT INSERTED.ship_id VALUES( @shipAddress, @shipCity, @shipCountry, @phone )", con))
                {
                    cmd.Parameters.AddWithValue("@shipAddress", shipDetails.shipAddress);
                    cmd.Parameters.AddWithValue("@shipCity", shipDetails.shipCity);
                    cmd.Parameters.AddWithValue("@shipCountry", shipDetails.shipCountry);
                    cmd.Parameters.AddWithValue("@phone", shipDetails.phone);

                    using (SqlDataReader rd = cmd.ExecuteReader())
                    {
                        if (rd.Read())
                        {
                            return(rd.IsDBNull(0) ? 0 : rd.GetInt32(0));
                        }
                        return(0);
                    }
                }
            }
    public void Ship47Secondary()
    {
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;



        if (shipHandling.currentBattery >= shipDetails.Secondary.BatteryCharge && Ship47SecondaryActive == false)
        {
            Ship47SecondaryActive        = true;
            shipHandling.currentBattery -= shipDetails.Secondary.BatteryCharge;

            AudioClip Woosh = shipDetails.Secondary.SecondarySound;
            //Debug.Log("Woosh is " + Woosh.ToString());
            //Debug.Log("source47 is " + source47.ToString());

            source47.PlayOneShot(Woosh);
        }
    }
Example #25
0
        private void setShipDetailsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ShipDetails form = new ShipDetails();

            form.JumpRange      = jumpRange;
            form.TankSize       = tankSize;
            form.CurrentCargo   = currentCargo;
            form.UnladenMass    = unladenMass;
            form.LinearConstant = linearConstant;
            form.PowerConstant  = powerConstant;
            form.OptimalMass    = optimalMass;
            form.maxFuelPerJump = maxFuelPerJump;
            form.FSDDrive       = "5A";
            form.tankWarning    = tankWarning;

            if (form.ShowDialog(this.FindForm()) == DialogResult.OK)
            {
                jumpRange      = form.JumpRange;
                tankSize       = form.TankSize;
                currentCargo   = form.CurrentCargo;
                unladenMass    = form.UnladenMass;
                powerConstant  = form.PowerConstant;
                optimalMass    = form.OptimalMass;
                maxFuelPerJump = form.maxFuelPerJump;
                fsdDrive       = form.FSDDrive;
                linearConstant = form.LinearConstant;
                tankWarning    = form.tankWarning;

                SQLiteDBClass.PutSettingDouble(DbSave + "JumpRange", jumpRange);
                SQLiteDBClass.PutSettingDouble(DbSave + "TankSize", tankSize);
                SQLiteDBClass.PutSettingDouble(DbSave + "currentCargo", currentCargo);
                SQLiteDBClass.PutSettingDouble(DbSave + "unladenMass", unladenMass);
                SQLiteDBClass.PutSettingDouble(DbSave + "linearConstant", linearConstant);
                SQLiteDBClass.PutSettingDouble(DbSave + "powerConstant", powerConstant);
                SQLiteDBClass.PutSettingDouble(DbSave + "optimalMass", optimalMass);
                SQLiteDBClass.PutSettingDouble(DbSave + "maxFuelPerJump", maxFuelPerJump);
                SQLiteDBClass.PutSettingDouble(DbSave + "TankWarning", tankWarning);
                SQLiteDBClass.PutSettingString(DbSave + "fsdDrive", fsdDrive);

                displayLastFSDOrScoop(lastHE);
            }
        }
Example #26
0
    // Reset ship data
    public void ResetShipLevelData()
    {
        BinaryFormatter bf   = new BinaryFormatter();
        FileStream      file = File.Open(Application.persistentDataPath + "/ShipData.dat", FileMode.OpenOrCreate);

        ShipDetails shipDetails = new ShipDetails();

        shipDetails.MainCannonLevel = 70;
        shipDetails.RocketLevel     = 60;
        shipDetails.WingCannonLevel = 50;
        shipDetails.LaserLevel      = 50;
        shipDetails.MagnetLevel     = 50;
        shipDetails.ShieldLevel     = 50;


        shipDetails.CoinsAmount  = 999999;
        shipDetails.LaserAmount  = 100;
        shipDetails.ShieldAmount = 100;

        bf.Serialize(file, shipDetails);
        file.Close();
    }
Example #27
0
        public ActionResult CreateShip(ShipDetails shipDetails)
        {
            AddShipViewModel asvm = new AddShipViewModel
            {
                Location = _context.Location
                           .DistinctBy(l => l.Origin)
                           .ToList()
            };

            if (!ModelState.IsValid)
            {
                ViewBag.IsSuccess = false;
                ViewBag.Message   = "Ship Create Failed.";

                return(View("AddShip", asvm));
            }
            shipDetails.RemainingBaySize = shipDetails.BaySize;
            shipDetails.Availability     = true;


            _context.ShipDetails.Add(shipDetails);

            try
            {
                _context.SaveChanges();

                ViewBag.IsSuccess = true;
                ViewBag.Message   = "Ship added successfully. Thanks for using our service";
                ModelState.Clear();
            }
            catch (Exception ex)
            {
                ViewBag.IsSuccess = false;
                ViewBag.Message   = "Error in adding ship! \nError: " + ex.Message;
            }


            return(View("AddShip", asvm));
        }
Example #28
0
    // Loading Saved Ship Detail from desk;
    public void LoadShipData()
    {
        if (File.Exists(Application.persistentDataPath + "/ShipData.dat"))
        {
            BinaryFormatter bf          = new BinaryFormatter();
            FileStream      file        = File.Open(Application.persistentDataPath + "/ShipData.dat", FileMode.Open);
            ShipDetails     shipDetails = new ShipDetails();
            shipDetails = (ShipDetails)bf.Deserialize(file);

            MainCannonLevel = shipDetails.MainCannonLevel;
            WingCannonLevel = shipDetails.WingCannonLevel;
            RocketLevel     = shipDetails.RocketLevel;
            LaserLevel      = shipDetails.LaserLevel;
            MagnetLevel     = shipDetails.MagnetLevel;
            ShieldLevel     = shipDetails.ShieldLevel;

            CoinsAmount  = shipDetails.CoinsAmount;
            LaserAmount  = shipDetails.LaserAmount;
            ShieldAmount = shipDetails.ShieldAmount;

            file.Close();
        }
        else
        {
            // I've bumped up all the values for this demo while the default values are commented
            Debug.Log("HELLo");
            MainCannonLevel = 70;   // == 0
            WingCannonLevel = 60;   // == 0
            RocketLevel     = 50;   // == 0;
            LaserLevel      = 50;   // == 0;
            MagnetLevel     = 50;   // == 0;
            ShieldLevel     = 50;   // == 0;

            CoinsAmount  = 9999999; // == 0;
            LaserAmount  = 100;     // == 0;
            ShieldAmount = 100;     // == 0;
        }
    }
Example #29
0
 public bool CanAddShip(ShipDetails ship, uint playerIndex) => _innerDetails?.Players[playerIndex].Board.ShipFitsOnBoard(ship) ?? false;
    //Ship17 Secondary
    public void Ship17Secondary()
    {
        // Give speed boost to ship
        ShipHandling shipHandling = this.GetComponentInParent <ShipHandling>();
        ShipDetails  shipDetails  = shipHandling.shipDetails;
        Rigidbody    rb           = GetComponent <Rigidbody>();

        if (shipHandling.currentBattery >= shipDetails.Secondary.BatteryCharge)
        {
            rb.AddForce((transform.right * 1000));

            shipHandling.currentBattery    = shipHandling.currentBattery - shipDetails.Secondary.BatteryCharge;
            shipHandling.lastSecondaryUsed = Time.time;
        }

        /*
         * List<Transform> bulletSpecialSpawnPoints = new List<Transform>();
         * int i = 0;
         * foreach (Transform child in transform)
         * {
         *  if (child.CompareTag("BulletSpawn") && child.name.Contains("BulletSpawnPointSecondary"))
         *  {
         *      bulletSpecialSpawnPoints.Add(child.transform);
         *      i++;
         *  }
         * }
         *
         * ShipHandling shipHandling = this.GetComponentInParent<ShipHandling>();
         * ShipDetails shipDetails = shipHandling.shipDetails;
         *
         *
         * if (shipHandling.currentBattery >= shipDetails.Secondary.BatteryCharge)
         * {
         *  List<Transform> usedSpawnPoints = new List<Transform>();
         *
         *  usedSpawnPoints = bulletSpecialSpawnPoints;
         *
         *
         *
         *  foreach (Transform currBulletSpawnPoint in usedSpawnPoints)
         *  {
         *      GameObject bullet = (GameObject)Instantiate(
         *      shipDetails.Secondary.SecondaryPrefab,
         *      currBulletSpawnPoint.position,
         *      currBulletSpawnPoint.rotation);
         *      bullet.GetComponent<BulletCollision>().bulletOwnerPlayerNumber = shipHandling.playerNumber;
         *      Transform transform = bullet.GetComponentInChildren<Transform>();
         *      transform.localScale = new Vector3(shipDetails.Secondary.Scale, shipDetails.Secondary.Scale, shipDetails.Secondary.Scale);
         *      bullet.GetComponent<BulletCollision>().bulletHitPoints = shipDetails.Secondary.HitPoints;
         *      bullet.gameObject.tag = "Bullet";
         *
         *      // Add velocity to the bullet
         *      bullet.GetComponent<Rigidbody>().velocity = bullet.transform.forward * shipDetails.Secondary.Speed;
         *
         *      BulletCollision bulletCol = bullet.GetComponentInChildren<BulletCollision>();
         *
         *      bulletCol.setDamage(shipDetails.Secondary.Damage);
         *
         *      createdBullets.Add(bullet);
         *
         *      // Destroy the bullet after X seconds
         *      Destroy(bullet, shipDetails.Secondary.TimeToLive);
         *
         *      CheckForMaxInstances();
         *  }
         *
         *
         *  shipHandling.currentBattery = shipHandling.currentBattery - shipDetails.Secondary.BatteryCharge;
         *
         *
         *
         *  shipHandling.lastSecondaryUsed = Time.time;
         * }
         *
         */
    }