Inheritance: MonoBehaviour
Beispiel #1
0
        public new void Start()
        {
            _ship = new Ship(GameRef.Game.Content.Load<Texture2D>("ship"), GameRef.Game.Content.Load<Texture2D>("bullet"), this);
            AddEntity(_ship);

            _enemyship = new EnemyShip(GameRef.Game.Content.Load<Texture2D>("enemyship"), GameRef.Game.Content.Load<Texture2D>("bullet"), this);
            AddEntity(_enemyship);

            _ship.Collision.AddPartner(_enemyship);
            _enemyship.Collision.AddPartner(_ship);

            for (var i = 0; i < 10; i++)
            {
                var a = new Asteroid(GameRef.Game.Content.Load<Texture2D>("asteroid"), this);

                while (a.Collision.TestCollision(_ship))
                {
                    a = new Asteroid(GameRef.Game.Content.Load<Texture2D>("asteroid"), this);
                }
                _ship.Collision.AddPartner(a);
                a.Collision.AddPartner(_ship);

                AddEntity(a);
            }

            _font = GameRef.Game.Content.Load<SpriteFont>("font");
        }
Beispiel #2
0
	Vector2 Plot (Vector2 from, Vector2 to, Ship target = null) {
		Vector2 relPos = to-from;
		
		RaycastHit2D firstRay = Physics2D.CircleCast (from, cRadius, relPos, Mathf.Infinity, layerMask);
		
		if (!firstRay) {
			return to;
		}

		if (target && firstRay.transform.gameObject.Equals(target.gameObject)) {
			return to;
		}

		Vector2 silly = new Vector2 (relPos.y, -relPos.x);
		silly.Normalize ();
		
		Vector2 newPos = firstRay.centroid;
		float distance = relPos.magnitude / 2;
		
		for (int i = 1; i < maxIterations; i++) {
			newPos = newPos+silly*Mathf.Pow (-1, i)*i*7;
			RaycastHit2D iterRay = Physics2D.CircleCast (from, cRadius, newPos-from, distance, layerMask);
			
			if (!iterRay.collider || target && iterRay.transform.gameObject.Equals (target.gameObject)) {
				return from+(newPos-from).normalized*distance;
			}
		}
		
		return from + firstRay.normal*30;
	}
Beispiel #3
0
    public Battlefield()
    {
        _instance = this;
		//InitBattleField(new MapObject(){ w = 3, h = 3 });
		su = new Submarine();
		sh = new Ship();
    }
Beispiel #4
0
    public static void LoadRaidMapScene(WorldMapHexagonTileData tileData, Ship ship)
    {
        SelectedTileData = tileData;
        SelectedShip = ship;

        Application.LoadLevel("RaidMap");
    }
Beispiel #5
0
	// Use this for initialization
	void Start () {
		currentTimeTilChangePosition = 0;

		if(ship == null) {
			ship = gameObject.GetComponent<Ship>();
		}
	}
Beispiel #6
0
 public void TestCrazyAllStop()
 {
     var ship = new Ship(4000);
     Assert.AreEqual(0, ship.Velocity.Magnitude(), "new ship wasn't stopped");
     ship.ImpulsePercentage = 100;
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreNotEqual(0, ship.Velocity.Magnitude(), "ship wasn't moving, after turning on impulse");
     ship.DesiredOrientation = Math.PI / 2;
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreNotEqual(0, ship.Velocity.Magnitude(), "ship wasn't moving before telling it to stop");
     ship.TargetSpeedMetersPerSecond = 0; // all stop
     ship.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreNotEqual(0, ship.Velocity.Magnitude(), "ship wasn't moving, just after all stop");
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25)); // strictly speaking the previous one was really close to zero, so it should work, but one more actually makes it zero.
     Assert.AreEqual(0, ship.Velocity.Magnitude(), "ship should be stopped by now?");
 }
		internal void Update(Ship[] s)
		{
			this.ships = s;

			if (this.ships.Length == 0)
			{
				this.RejuvenateTime = null;
				return;
			}

			var condition = this.ships.Min(x => x.Condition);
			if (condition != this.minCondition)
			{
				this.minCondition = condition;

				var rejuvnate = DateTimeOffset.Now; // 回復完了予測時刻

				while (condition < KanColleClient.Current.Settings.ReSortieCondition)
				{
					rejuvnate = rejuvnate.AddMinutes(3);
					condition += 3;
					if (condition > 49) condition = 49;
				}

				this.RejuvenateTime = rejuvnate <= DateTimeOffset.Now
					? (DateTimeOffset?)null
					: rejuvnate;
			}
		}
Beispiel #8
0
    public static Fleet Create(Ship leader)
    {
        var fleet = CreateInstance<Fleet>();
        fleet.leader = leader;

        return fleet;
    }
Beispiel #9
0
 public void TestAllStop0Radians()
 {
     var ship = new Ship(4000);
     Assert.AreEqual(0, ship.Velocity.Magnitude(), "new ship wasn't stopped");
     Assert.AreEqual(0, ship.Orientation, "ship wasn't oriented 0");
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.ImpulsePercentage = 100;
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreEqual(0, ship.Orientation, "ship turned during acceleration");
     ship.TargetSpeedMetersPerSecond = 0;
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     ship.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreNotEqual(Vector3.Zero, ship.Velocity, "Ship couldn't have been stopped by now.");
     Assert.IsTrue(Utility.ApproximatelyEqual(0, ship.Orientation), "ship turned during all stop");
     ship.Update(TimeSpan.FromSeconds(0.25));
     Assert.AreEqual(Vector3.Zero, ship.Velocity, "velocity wasn't stopped long after all stop message sent");
 }
 protected override bool validTarget(Ship ship)
 {
     if (!base.validTarget(ship))
         return false;
     Vector2 targetDirection = ship.transform.position - this.transform.position;
     return targetDirection.magnitude < range && Mathf.Abs(Vector3.Angle(transform.TransformVector(direction), targetDirection)) < arc;
 }
Beispiel #11
0
	// Use this for initialization
	void Start ()
	{
		ship = GetComponent<Ship> ();

		currentCooldown = cooldownTime;
	
	}
 public void Activate(Ship activator, int slot)
 {
     if (Cooldown <= Mathf.Epsilon) //cd check
     {
         behaviour.Activate(activator, slot);
     }
 }
 public void UpdateBehaviour(Ship owner)
 {
     if (behaviour)
     {
         behaviour.UpdateForOwner(owner);
     }
 }
        protected override void ApplyPowerup(Ship ship)
        {
            PlayerShip applyShip;
            EnemyPlayerShip applyAIShip;

            if (ship == Player.Ship)
            {
                if (Config.SoundFXOn)
                    GameStateManagementGame.Instance.soundManager.PlaySound("FX1", 0.7f);  
 
                applyShip = ship.GetRoot() as PlayerShip;

                if (applyShip.Shield.Health < Config.ShieldHealth)
                {
                    if (Config.ship1Active)
                        applyShip.Shield.ShieldRegen(Config.ShieldsPowerupValue + 5);
                    else
                        applyShip.Shield.ShieldRegen(Config.ShieldsPowerupValue);
                }
            }

            if (ship == Player.EnemyPlayer)
            {
                applyAIShip = ship.GetRoot() as EnemyPlayerShip;

                if (applyAIShip.Shield.Health < Config.ShieldHealth)
                    applyAIShip.Shield.ShieldRegen(Config.ShieldsPowerupValue);
            }
        }
 // Use this for initialization
 void Start ()
 {
     m_Ship = GetComponent<Ship>();
     m_IsDashReady = true;
     m_StickDelay = 0.5f;
     m_DashCoolDown = 7;
 }
Beispiel #16
0
 void OnTriggerEnter(Collider other)
 {
     if(other.tag =="Player"){
         s = other.gameObject.GetComponent<Ship>();
         s.AddPowerUp(this);
     }
 }
	public DamageMessage (float dmg, Vector3 dir, float dmgFrce, Weapon.DamageBias bs, Weapon.WeaponType tp, Ship own)
	{
		damage = dmg;
		damageDirection = dir;
		damageForce = dmgFrce;
		bias = bs;
		type = tp;
		
		if (own != null)
			owner = own.gameObject;
		else
			return;
		
		hasShip = true;
		try
		{
			viewID = own.GetComponent<PhotonView>().viewID;
		}
		catch
		{
			Debug.Log(owner.name  + " does not have a photon View ID");
		}
		
		if (own is AiShip)
			player = false;
		else
			player = true;
	}
    // Use this for initialization
    void Start()
    {
        texture = new Texture2D(128, 128,TextureFormat.RGB24,false);
        style = new GUIStyle();

        texture2 = new Texture2D(128, 128,TextureFormat.RGB24,false);
        style = new GUIStyle();

        weapon = GetComponent<Weapon>();
        ship = GetComponent<Ship>();
        maxHealth = ship.GetHealth();
        curHealth = maxHealth;
        maxCool = weapon.GetcdTime();
        curCool = maxCool;
        for (int y = 0; y < texture.height; ++y)
        {
            for (int x = 0; x < texture.width; ++x)
            {
                Color color = new Color(238, 0, 238);
                texture.SetPixel(x, y, color);
            }
        }
        texture.Apply();

        for (int y = 0; y < texture2.height; ++y)
        {
            for (int x = 0; x < texture2.width; ++x)
            {
                Color color = new Color(255, 0, 0);
                texture2.SetPixel(x, y, color);
            }
        }
        texture2.Apply();
    }
Beispiel #19
0
        public void RunOutOfEnergy()
        {
            var game = new Game();
            var system = new StarSystem();
            system.RandomlySpawnEnemies = false;
            game.Add(system);
            var ship = new Ship();
            system.AddEntity(ship);
            ship.ShieldsEngaged = false;
            ship.ImpulsePercentage = 100;
            Assert.IsTrue(ship.Energy > 0, "Ship didn't have any energy");
            var oldVelocity = ship.Velocity;
            Assert.AreEqual(0, ship.Velocity.Magnitude(), "Ship should be at rest at first");

            for (int i = 0; i < 200; i++)
            {
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                game.Update(TimeSpan.FromSeconds(0.25));
                Assert.IsTrue(oldVelocity.Magnitude() < ship.Velocity.Magnitude(), "The ship didn't increase in speed");
                oldVelocity = ship.Velocity;
            }
            Assert.AreEqual(0, ship.Energy, "The ship didn't run out of energy");
            ship.Update(TimeSpan.FromSeconds(1));
            Assert.AreEqual(oldVelocity, ship.Velocity, "The ship should not have been able to increase it's velocity without energy.");
        }
 public override void NotifyDeath(Ship ship, Ship killer)
 {
     if (ship.name == "Ghost Ship")
     {
         failed = true;
     }
 }
    public static void createShipMesh(Player player, Ship ship)
    {
        float tileWidth = .5501f;
        float tileThickness = .0501f;

        doCreateShipMesh(player, ship, tileWidth, tileThickness);
    }
        protected override void ApplyPowerup(Ship ship)
        {
            //new EffectNode(Config.LightningSpriteSheet, this.Position);
            PlayerShip applyShip;
            applyShip = ship.GetRoot() as PlayerShip;

            //for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
            //{
            //    ProjectileBulletGreenBeam.FireBullet(Vector2.Normalize(Enemy.Enemies[i].Position - applyShip.Position), applyShip.Position);
            //}
            //for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
            //{
            //    ProjectileBulletGreenBeam.FireBullet(Vector2.Normalize(Enemy.Enemies[i].Position - applyShip.Position), applyShip.Position);
            //}
            //for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
            //{
            //    ProjectileBulletGreenBeam.FireBullet(Vector2.Normalize(Enemy.Enemies[i].Position - applyShip.Position), applyShip.Position);
            //}
            //for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
            //{
            //    ProjectileBulletGreenBeam.FireBullet(Vector2.Normalize(Enemy.Enemies[i].Position - applyShip.Position), applyShip.Position);
            //}
            //for (int i = Enemy.Enemies.Count - 1; i >= 0; i--)
            //{
            //    ProjectileBulletGreenBeam.FireBullet(Vector2.Normalize(Enemy.Enemies[i].Position - applyShip.Position), applyShip.Position);
            //}

            //AoEWeaponBurstWave tempWeapon = new AoEWeaponBurstWave(applyShip, 0, 200, 50f);
            AoEWeaponBurstWave tempWeapon = new AoEWeaponBurstWave(applyShip, 0, 100, 50f);
            tempWeapon.StartFire();
        }
Beispiel #23
0
 protected override bool Equals(Ship other)
 {
     //doesn't check direction
     return ShipPosition.X == other.ShipPosition.X &&
         ShipPosition.Y == other.ShipPosition.Y &&
         Length == other.Length;
 }
    public override void Activate(Ship activator)
    {
        var moorable = activator.Moorable;
        Debug.Assert(moorable);

        moorable.BeginAutoDocking(this);
    }
 public WeaponAuto(Ship ship, double fireInterval)
     : base(ship)
 {
     this.FireInterval = fireInterval;
     this.timer = new Timer();
     this.timer.Fire += new NotifyHandler(timer_Fire);
 }
Beispiel #26
0
 public override List<string> ExecuteOrder(Ship ship)
 {
     List<string> result = new List<string>();
     result.Add(moveShip(ship));
     this.IsCompleted = true;
     return result;
 }
 // Use this for initialization
 public Regroup(Ship inShip)
 {
     ship = inShip;
     target = ship.fleetLeader.transform;
     if(ship.photonView.isMine)
         ship.photonView.RPC("RegroupRPC", PhotonTargets.Others, null);
 }
Beispiel #28
0
 public void Start()
 {
     if(null == ship) {
         ship = GameObject.Find("Ship").GetComponent<Ship>();
     }
     ExhaustTrail.transform.parent = gameObject.transform;
 }
Beispiel #29
0
 public MoveToShipAtRange(Ship targetShip, int range, LocationCollection locations)
 {
     this.OrderValues = new object[3];
     this.OrderValues[0] = targetShip;
     this.OrderValues[1] = range;
     this.OrderValues[2] = locations;
 }
        public static void AddDrones(Ship ship)
        {
            const int DRONE_BANDWIDTH_ID = 1271;
            var bandwidth = ship.GetAttributeById(DRONE_BANDWIDTH_ID)
                .Value;

            if (bandwidth <= 25)
            {
                AddDrones(ship, _hobgoblin, (int) bandwidth / 5);
                return;
            }

            if (bandwidth <= 50)
            {
                AddDrones(ship, _hammerhead, (int) bandwidth / 10);
                AddDrones(ship, _hobgoblin, ((int) bandwidth / 10) / 5);
                return;
            }
            //TODO verteilunug fuer <= 100 sieht normalerweise anders aus
            AddDrones(ship, _ogre, (int) bandwidth / 25);

            var rest = (int) bandwidth % 25;
            AddDrones(ship, _hammerhead, rest / 10);

            var restMed = rest % 10;
            AddDrones(ship, _hobgoblin, restMed / 5);
        }
Beispiel #31
0
 public Shipping(Pirate pirate, Ship ship)
 {
     _pirate = pirate;
     _ship   = ship;
 }
Beispiel #32
0
 protected override void ExecuteCommand(Ship targetShip)
 {
     targetShip.Status();
 }
 public ArrivalEvent(DateTime occured, Ship ship, Port port, Port prev) : base(occured, ship, port, prev)
 {
 }
Beispiel #34
0
 void MoveShip(Ship ship)
 {
 }
 void Start()
 {
     ship = GetComponent <Ship>();
 }
Beispiel #36
0
 public ThrustMove(Ship ship, int angleDeg, int thrust)
     : base(MoveType.Thrust, ship)
 {
     this.thrust   = thrust;
     this.angleDeg = angleDeg;
 }
Beispiel #37
0
        /// <summary>
        /// 登陆
        /// </summary>
        /// <param name="user"></param>
        /// <returns></returns>
        public IActionResult UserLogin(string name, string password)
        {
            if (string.IsNullOrEmpty(ManagerHelp.Cid))
            {
                return(new JsonResult(new { code = 1, msg = "组件还在自动注册中,请稍等" }));
            }
            var usersModel = _context.User.FirstOrDefault(u => u.Name == name && u.Password == MD5Help.MD5Encrypt(password));

            if (usersModel == null)
            {
                return(new JsonResult(new { code = 1, msg = "用户名或密码不正确" }));
            }
            else
            {
                //保存登陆的用户ID
                HttpContext.Session.Set("uid", Encoding.UTF8.GetBytes(usersModel.Id));
                //保存用户可操作的权限 admin 最高权限
                ManagerHelp.IsShowAlarm = usersModel.Id.ToLower() == "admin" ? true : usersModel.Enablequery;
                bool   flag     = ManagerHelp.IsShipPort;//判断是否是船舶端
                string shipName = "";
                string shipId   = "";
                if (ManagerHelp.IsShipPort)
                {
                    var ship = _context.Ship.FirstOrDefault();
                    if (ship != null)
                    {
                        shipName = ship.Name;
                        shipId   = ship.Id;
                    }
                    else
                    {
                        ship = new Ship()
                        {
                            Coordinate = "",
                            CrewNum    = 0,
                            Flag       = false,
                            Id         = Guid.NewGuid().ToString(),
                            Name       = "Boat",
                            type       = Ship.Type.AUTO
                        };
                        shipId = ship.Id;
                        _context.Ship.Add(ship);
                        _context.SaveChanges();
                    }
                }

                //缓存用户数据
                UserToken ut = new UserToken()
                {
                    Id              = usersModel.Id,
                    Name            = usersModel.Name,
                    EnableConfigure = usersModel.EnableConfigure,
                    Enablequery     = usersModel.Enablequery,
                    ShipName        = shipName,
                    ShipId          = shipId,
                    IsLandHome      = ManagerHelp.IsShipPort ? false : true
                };
                string userStr      = JsonConvert.SerializeObject(ut);
                string browsertoken = HttpContext.Request.Cookies["token"];
                if (browsertoken == null)
                {
                    //生成token
                    string token = Guid.NewGuid().ToString();
                    //将请求的url注册
                    HttpContext.Session.SetString(token, userStr);
                    //写入浏览器token
                    HttpContext.Response.Cookies.Append("token", token);
                }
                else
                {
                    //将请求的url注册
                    HttpContext.Session.SetString(browsertoken, userStr);
                    //写入浏览器token
                    HttpContext.Response.Cookies.Append("token", browsertoken);
                }
                return(new JsonResult(new { code = 0, flag = flag }));
            }
        }
Beispiel #38
0
 public void onCollision(Ship ship)
 {
     ship.Health -= Damage;
 }
Beispiel #39
0
	private Ship hideShip(Ship s) {
		s.x = -30;
		s.y = 400;
		return s;
	}
Beispiel #40
0
 public ShipController(Ship owner) => Owner = owner;
Beispiel #41
0
	private List<Debri> stepDebri(float t, Ship ship, List<Debri> debri) {
		return addDebri(ship, debri).Select(debris => debris.stepObj(t) as Debri).ToList();
	}
Beispiel #42
0
	private Ship autoShip(Tunnel t, Ship s) {
		s.x = towards(t.x, s.x);
		return s;
	}
Beispiel #43
0
 public void SetShip(GameObject ship)
 {
     m_MyShip     = ship;
     m_ShipScript = ship.GetComponent <Ship> ();
 }
Beispiel #44
0
	private bool inside(Ship ship, Piece piece) {
		return withinN(piece.width / 2, piece.x, ship.x);
	}
Beispiel #45
0
    private void Update()
    {
        float   deltaX     = Input.GetAxis("Mouse X");
        float   deltaY     = Input.GetAxis("Mouse Y");
        Vector3 mouseDelta = new Vector3(deltaX, deltaY, 0.0f);

        mouseMovement += mouseDelta;
        player.transform.Rotate((yUpIsUp ? mouseDelta.y : -mouseDelta.y) * mouseSensitivity, mouseDelta.x * mouseSensitivity, 0.0f, Space.Self);

        mouseMovement.y = Mathf.Clamp(mouseMovement.y, -90.0f, 90.0f);

        HandleTilt();

        // look for target

        // cull outside view
        List <Transform> candidates = new List <Transform>();

        foreach (Enemy iEnemy in gameManager.enemies)
        {
            if (iEnemy && iEnemy.ship && ContainsPoint(Camera.main.WorldToScreenPoint(iEnemy.ship.transform.position)))
            {
                candidates.Add(iEnemy.ship.transform);
            }
        }

        List <Transform> finalCandidates = new List <Transform>();

        // cull which are visible
        foreach (Transform iCandidate in candidates)
        {
            Vector3    directionToCandidate = (iCandidate.position - transform.position).normalized;
            RaycastHit hit;
            if (Physics.Raycast(transform.position + directionToCandidate * 5.0f, directionToCandidate, out hit, Camera.main.farClipPlane))
            {
                if (hit.collider.transform.parent != null)
                {
                    Ship hitShip = hit.collider.transform.parent.GetComponent <Ship>();
                    if (hitShip)
                    {
                        finalCandidates.Add(iCandidate);
                    }
                }
            }
        }

        // find closest one to screen center and lock on
        Transform closestTarget   = null;
        float     closestDistance = 99999.0f;

        foreach (Transform iCandidate in finalCandidates)
        {
            Vector3 screenPoint = Camera.main.WorldToScreenPoint(iCandidate.position);
            screenPoint.x -= Screen.width * 0.5f;
            screenPoint.y -= Screen.height * 0.5f;
            screenPoint.z  = 0.0f;
            if (screenPoint.magnitude < closestDistance)
            {
                closestDistance = screenPoint.magnitude;
                closestTarget   = iCandidate;
            }
        }

        if (closestTarget)
        {
            target = closestTarget;
            reticule.SetActive(true);
            reticule.transform.position = Camera.main.WorldToScreenPoint(closestTarget.position);
        }
        else
        {
            target = null;
            reticule.SetActive(false);
        }
    }
Beispiel #46
0
 void Start()
 {
     S      = GameObject.FindWithTag("Ship").GetComponent <Ship>();
     Player = GameObject.FindWithTag("Player");
 }
Beispiel #47
0
    private void PlaceSingleShipOnMap(Ship ship)
    {
        List <GridTile> allCandidateTiles = new List <GridTile>();
        List <GridTile> finalCandidates   = new List <GridTile>();
        int             minShipHeat       = int.MaxValue;

        foreach (var tile in GridCoords.CurrentGridInfo.gameGridTiles)
        {
            if (tile.tileType == 0)
            {
                allCandidateTiles.Add(tile);
                if (tile.ShipStartHeat < minShipHeat)
                {
                    minShipHeat = tile.ShipStartHeat;
                }
            }
        }

        foreach (var sh in shipInventory)
        {
            if (sh == ship)
            {
                continue;
            }

            TileCoordinates shipPos = GridCoords.FromWorldToTilePosition(sh.transform.position);
            if (!GridCoords.IsInGrid(shipPos.tileX, shipPos.tileY))
            {
                continue;
            }

            GridTile tileToRemove = GridCoords.CurrentGridInfo.gameGridTiles[shipPos.tileX, shipPos.tileY];
            allCandidateTiles.Remove(tileToRemove);
        }

        int count = 0;

        foreach (var tile in allCandidateTiles)
        {
            if (tile.ShipStartHeat <= minShipHeat + 2)
            {
                finalCandidates.Add(tile);
                count++;
            }
        }
        int             randomIndex  = UnityEngine.Random.Range(0, count);
        Vector2         shipPosition = finalCandidates[randomIndex].TileCenter;
        TileCoordinates shipCoords   = finalCandidates[randomIndex].TileCoordinates;

        ship.transform.position = shipPosition;

        // Add heat, one circle cast per heat distance
        for (int j = 1; j <= shipHeatDistance; j++)
        {
            float heatCastRadius = GridCoords.CurrentGridInfo.TileWidth * j;

            Collider2D[] allHits = Physics2D.OverlapCircleAll(shipPosition, heatCastRadius, tileLayerMask);
            foreach (var hit in allHits)
            {
                GridTile candidate = hit.GetComponent <GridTile>();
                if (hit != null)
                {
                    candidate.AddShipHeat(1);
                }
            }
        }

        foreach (var tile in allCandidateTiles)
        {
            // If same X
            if (tile.tileX == shipCoords.tileX)
            {
                // If not exact same tile
                if (tile.tileY != shipCoords.tileY)
                {
                    // If neighbour
                    if (tile.tileY == shipCoords.tileY - 1 || tile.tileY == shipCoords.tileY + 1)
                    {
                        tile.AddShipHeat(2);
                    }
                    // If other
                    else
                    {
                        tile.AddShipHeat(2);
                    }
                }
            }

            if (tile.tileY == shipCoords.tileY)
            {
                // If not exact same tile
                if (tile.tileX != shipCoords.tileX)
                {
                    // If neighbour
                    if (tile.tileX == shipCoords.tileX - 1 || tile.tileX == shipCoords.tileX + 1)
                    {
                        tile.AddShipHeat(2);
                    }
                    // If other
                    else
                    {
                        tile.AddShipHeat(2);
                    }
                }
            }
        }
    }
Beispiel #48
0
 // '' <summary>
 // '' Set the _Value to the PossibleAttack value, and the _Ship to the ship
 // '' </summary>
 // '' <param name="value">either hit, miss, destroyed, shotalready</param>
 // '' <param name="ship">the ship information</param>
 public AttackResult(ResultOfAttack value, Ship ship, string text, int row, int column) : this(value, text, row, column)
 {
     _ship = ship;
 }
Beispiel #49
0
 // Enlever un ship de l'inventaire
 private void OnShipDestroyed(Ship ship)
 {
     _activeShipsCount--;
     UpdateShipInventoryUI();
 }
Beispiel #50
0
    private void Generate()
    {
        if (m_b_IsInit)
        {
            return;
        }

        m_b_IsInit = true;

        initColor();

        GameObject shipPrefab = (GameObject)Resources.Load("prefabs/ShipPattern");
        GameObject shipTemp   = Instantiate(shipPrefab, this.transform);

        this.ship = shipTemp.GetComponent <Ship>();
        // - - - - - - - - - - - - - - - - -  Color1 - - - - - - - - - - - - - -
        int lenghtActu = 0; // * * * * Mettre + 24 * * * * (commence à 24)
        int tempInt    = Convert.ToInt32(codeGen.Substring(lenghtActu, 5), 2);

        lenghtActu += 5;

        brightColor = brightColorsList[tempInt % brightColorsList.Length];

        // - - - - - - - - - - - - - - - - -  Color2 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 5), 2);
        lenghtActu += 5;

        darkColor = darkColorsList[tempInt % darkColorsList.Length];

        // - - - - - - - - - - - - - - - - - lightColor - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 5), 2);
        lenghtActu += 5;
        lightColor  = lightColorsList[tempInt % lightColorsList.Length];

        this.ship.SetColorGlobal(this.brightColor, this.darkColor, this.lightColor);

        // - - - - - - - - - - - - - - - - -  Cockpit - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 8), 2);
        lenghtActu += 8;
        cockpit     = tempInt;

        this.ship.SetCockpit(0, this.cockpit);

        // - - - - - - - - - - - - - - - - - base 1 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 8), 2);
        lenghtActu += 8;
        base1       = tempInt;

        this.ship.SetBases(0, base1);
        // - - - - - - - - - - - - - - - - - base 2 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 8), 2);
        lenghtActu += 8;
        base2       = tempInt;

        this.ship.SetBases(1, base2);
        // - - - - - - - - - - - - - - - - - base 3 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 8), 2);
        lenghtActu += 8;
        base3       = tempInt;

        this.ship.SetBases(2, base3);
        // - - - - - - - - - - - - - - - - - Wings 1 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 5), 2);
        lenghtActu += 5;
        wings1      = tempInt;

        this.ship.SetWings(0, wings1);
        // - - - - - - - - - - - - - - - - - Wings 2 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 5), 2);
        lenghtActu += 5;
        wings2      = tempInt;

        this.ship.SetWings(1, wings2);
        // - - - - - - - - - - - - - - - - - Wings 3 - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 5), 2);
        lenghtActu += 5;
        wings3      = tempInt;

        this.ship.SetWings(2, wings3);
        // - - - - - - - - - - - - - - - - - Placement - - - - - - - - - - - - - -
        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, 2), 2);
        lenghtActu += 2;
        placement   = tempInt;

        // - - - - - - - - - - - - - - - - - - GAME PLAY - - - - - - - - - - - - - - - - - - - - - - - - - -
        // - - - - - - - - - - - - - - - - - type 1 - - - - - - - - - - - - - -
        tempInt = Convert.ToInt32(codeGen.Substring(lenghtActu + 7, 1), 2);
        type1   = tempInt;

        // - - - - - - - - - - - - - - - - - Design 1 - - - - - - - - - - - - - -
        int tempLenght = 5;

        if (type1 == 1)
        {
            tempLenght = 4;
        }

        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, tempLenght), 2);
        lenghtActu += tempLenght;
        design1     = tempInt;

        // - - - - - - - - - - - - - - - - - orientation 1 => CANON - - - - - - - - - - - -
        // - - - - - - -  - - - - -  - - - - subtype => SUBTYPE - - - - - - - - - - - - - -
        tempInt               = Convert.ToInt32(codeGen.Substring(lenghtActu, 7 - tempLenght), 2);
        lenghtActu           += 7 - tempLenght + 1;
        orientationOrSubType1 = tempInt;

        // - - - - - - - - - - - - - - - - - type 2 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        tempInt = Convert.ToInt32(codeGen.Substring(lenghtActu + 7, 1), 2);
        type2   = tempInt;

        // - - - - - - - - - - - - - - - - - Design 2 - - - - - - - - - - - - - -
        tempLenght = 5;
        if (type2 == 1)
        {
            tempLenght = 4;
        }

        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, tempLenght), 2);
        lenghtActu += tempLenght;
        design2     = tempInt;

        // - - - - - - - - - - - - - - - - - orientation 2 => CANON - - - - - - - - - - - -
        // - - - - - - -  - - - - -  - - - - subtype => SUBTYPE - - - - - - - - - - - - - -
        tempInt               = Convert.ToInt32(codeGen.Substring(lenghtActu, 7 - tempLenght), 2);
        lenghtActu           += 7 - tempLenght + 1;
        orientationOrSubType2 = tempInt;

        // - - - - - - - - - - - - - - - - - type 3 - - - - - - - - - - - - - - - - - - - - - - - - - - - -
        tempInt = Convert.ToInt32(codeGen.Substring(lenghtActu + 7, 1), 2);
        type3   = tempInt;

        // - - - - - - - - - - - - - - - - - Design 3 - - - - - - - - - - - - - -
        tempLenght = 5;
        if (type3 == 1)
        {
            tempLenght = 4;
        }

        tempInt     = Convert.ToInt32(codeGen.Substring(lenghtActu, tempLenght), 2);
        lenghtActu += tempLenght;
        design3     = tempInt;

        // - - - - - - - - - - - - - - - - - orientation 3 => CANON - - - - - - - - - - - -
        // - - - - - - -  - - - - -  - - - - subtype => SUBTYPE - - - - - - - - - - - - - -
        tempInt               = Convert.ToInt32(codeGen.Substring(lenghtActu, 7 - tempLenght), 2);
        lenghtActu           += 7 - tempLenght + 1;
        orientationOrSubType3 = tempInt;

        // Init Game play - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -  - - - - - - - - - - - -
        initGamePlay(type1, 0, design1, orientationOrSubType1);
        initGamePlay(type2, 1, design2, orientationOrSubType2);
        initGamePlay(type3, 2, design3, orientationOrSubType3);
    }
Beispiel #51
0
 public ShipLaserWeapon(StrategyGame game, Color laserColor, float laserWidth, int fireTicks, int refireTicks, float range, float damage, Ship shooter, PointF offset)
     : base(game, fireTicks, refireTicks, range, damage, shooter, offset)
 {
     LaserPen = new Pen(laserColor, laserWidth);
 }
Beispiel #52
0
 // Fonction qui se trigger lorsqu'un vaisseau change d'état
 // Pour l'instant, ne sert qu'à notifier le ShipUI
 private void OnShipStateChange(Ship ship)
 {
     UpdateShipInventoryUI();
 }
        private void handleCargoInventoryEvent(CargoInventoryEvent @event)
        {
            Ship ship = GetCurrentShip();

            ship.cargo = @event.inventory;
        }
Beispiel #54
0
    public string GetDefaultCallsign(Ship newShip, int defaultNumber)
    {
        string number = defaultNumber.ToString("00");

        string candidateCallsign = newShip.shipClass[0] + number;

        bool valid = true;

        for (int i = 0; i < shipInventory.Count; i++)
        {
            if (shipInventory[i].shipCallsign == candidateCallsign)
            {
                valid = false;
                break;
            }
        }

        if (!valid)
        {
            valid             = true;
            candidateCallsign = "X" + number;
            for (int i = 0; i < shipInventory.Count; i++)
            {
                if (shipInventory[i].shipCallsign == candidateCallsign)
                {
                    valid = false;
                    break;
                }
            }
        }

        if (!valid)
        {
            while (!valid)
            {
                char currentChar = 'A';
                candidateCallsign = currentChar + number;

                valid = true;
                for (int i = 0; i < shipInventory.Count; i++)
                {
                    if (shipInventory[i].shipCallsign == candidateCallsign)
                    {
                        valid = false;
                        break;
                    }
                }
                if (!valid)
                {
                    currentChar++;
                    if (currentChar > 'Z')
                    {
                        break;
                    }
                }
            }
        }

        if (!valid)
        {
            return("$$$");
        }
        return(candidateCallsign);
    }
        private void handleShipLoadoutEvent(ShipLoadoutEvent @event)
        {
            // Obtain the ship to which this loadout refers
            Ship ship = GetShip(@event.shipid);

            if (ship == null)
            {
                // The ship is unknown - create it
                ship         = ShipDefinitions.FromEDModel(@event.ship);
                ship.LocalId = (int)@event.shipid;
                ship.role    = Role.MultiPurpose;
                AddShip(ship);
            }

            // Update name and ident if required
            setShipName(ship, @event.shipname);
            setShipIdent(ship, @event.shipident);

            ship.paintjob = @event.paintjob;

            // Augment the ship info if required
            if (ship.model == null)
            {
                ship.model = @event.ship;
                ship.Augment();
            }

            // Set the standard modules
            Compartment compartment = @event.compartments.FirstOrDefault(c => c.name == "Armour");

            if (compartment != null)
            {
                ship.bulkheads = compartment.module;
                // We take ship overall health from here
                ship.health = compartment.module.health;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "ShipCockpit");
            if (compartment != null)
            {
                ship.canopy = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "PowerPlant");
            if (compartment != null)
            {
                ship.powerplant = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "MainEngines");
            if (compartment != null)
            {
                ship.thrusters = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "PowerDistributor");
            if (compartment != null)
            {
                ship.powerdistributor = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "FrameShiftDrive");
            if (compartment != null)
            {
                ship.frameshiftdrive = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "LifeSupport");
            if (compartment != null)
            {
                ship.lifesupport = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "Radar");
            if (compartment != null)
            {
                ship.sensors = compartment.module;
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "FuelTank");
            if (compartment != null)
            {
                ship.fueltank = compartment.module;
            }
            if (ship.fueltank != null)
            {
                ship.fueltankcapacity = (decimal)Math.Pow(2, ship.fueltank.@class);
            }

            compartment = @event.compartments.FirstOrDefault(c => c.name == "CargoHatch");
            if (compartment != null)
            {
                ship.cargohatch = compartment.module;
            }

            // Internal + restricted modules
            ship.compartments = @event.compartments.Where(c => c.name.StartsWith("Slot") || c.name.StartsWith("Military")).ToList();

            // Hardpoints
            ship.hardpoints = @event.hardpoints;

            // total fuel tank capacity
            ship.fueltanktotalcapacity = ship.fueltankcapacity + (int)ship.compartments.Where(c => c.module != null && c.module.name.EndsWith("Fuel Tank")).Sum(c => Math.Pow(2, c.module.@class));

            // Cargo capacity
            ship.cargocapacity = (int)ship.compartments.Where(c => c.module != null && c.module.name.EndsWith("Cargo Rack")).Sum(c => Math.Pow(2, c.module.@class));

            writeShips();
        }
        public void HandleProfile(JObject profile)
        {
            // Obtain the current ship from the profile
            Ship profileCurrentShip = FrontierApi.ShipFromJson((JObject)profile["ship"]);

            // Obtain the shipyard from the profile
            List <Ship> profileShipyard = FrontierApi.ShipyardFromJson(profileCurrentShip, profile);

            // Information from the Frontier API can be out-of-date so we only use it to set our ship if we don't know what it already is
            if (currentShipId == null)
            {
                // This means that we don't have any info so far; set our active ship
                if (profileCurrentShip != null)
                {
                    SetCurrentShip(profileCurrentShip.LocalId, profileCurrentShip.model);
                }
            }

            // Add the raw JSON for each known ship provided in the profile
            // TODO Rationalise companion API data - munge the JSON according to the compartment information, removing anything that is out-of-sync
            if (profileCurrentShip != null)
            {
                Ship ship = GetShip(profileCurrentShip.LocalId);
                if (ship == null)
                {
                    // This means that we haven't seen the ship in the profile before.  Add it to the shipyard
                    ship = profileCurrentShip;
                    AddShip(ship);
                }
                if (ship.model == null)
                {
                    // We don't know this ship's model but can fill it from the info we have
                    ship.model = profileCurrentShip.model;
                    ship.Augment();
                }
                // Obtain items that we can't obtain from the journal
                ship.value = profileCurrentShip.value;
                if (ship.cargohatch != null)
                {
                    // Engineering info for each module isn't in the journal, but we only use this to pass on to Coriolis so don't
                    // need to splice it in to our model.  We do, however, have cargo hatch information from the journal that we
                    // want to make avaialable to Coriolis so need to parse the raw data and add cargo hatch info as appropriate
                    JObject cargoHatchModule = new JObject
                    {
                        { "on", ship.cargohatch.enabled },
                        { "priority", ship.cargohatch.priority },
                        { "value", ship.cargohatch.price },
                        { "health", ship.cargohatch.health },
                        { "name", "ModularCargoBayDoor" }
                    };
                    JObject cargoHatchSlot = new JObject
                    {
                        { "module", cargoHatchModule }
                    };
                    JObject parsedRaw = JObject.Parse(profileCurrentShip.raw);
                    parsedRaw["modules"]["CargoHatch"] = cargoHatchSlot;
                    ship.raw = parsedRaw.ToString(Formatting.None);
                }
            }

            // As of 2.3.0 Frontier no longer supplies module information for ships other than the active ship, so we
            // keep around the oldest information that we have available
            //foreach (Ship profileShip in profileShipyard)
            //{
            //    Ship ship = GetShip(profileShip.LocalId);
            //    if (ship != null)
            //    {
            //        ship.raw = profileShip.raw;
            //        if (ship.model == null)
            //        {
            //            // We don't know this ship's model but can fill it from the info we have
            //            ship.model = profileShip.model;
            //            ship.Augment();
            //        }
            //        // Obtain items that we can't obtain from the journal
            //        ship.value = profileShip.value;
            //    }
            //}

            writeShips();
        }
Beispiel #57
0
    public override void _Ready()
    {
        base._Ready();

        _ship = GetParent <Ship>();
    }
        private void handleShipRebootedEvent(ShipRebootedEvent @event)
        {
            Ship ship = GetCurrentShip();

            if (ship == null)
            {
                return;
            }
            foreach (string modulename in @event.modules)
            {
                // Find the matching module and set health to 1%
                if (modulename == "ShipCockpit" && ship.canopy != null)
                {
                    ship.canopy.health = 1;
                }
                else if (modulename == "PowerPlant" && ship.powerplant != null)
                {
                    ship.powerplant.health = 1;
                }
                else if (modulename == "MainEngines" && ship.thrusters != null)
                {
                    ship.thrusters.health = 1;
                }
                else if (modulename == "PowerDistributor" && ship.powerdistributor != null)
                {
                    ship.powerdistributor.health = 1;
                }
                else if (modulename == "FrameShiftDrive" && ship.frameshiftdrive != null)
                {
                    ship.frameshiftdrive.health = 1;
                }
                else if (modulename == "LifeSupport" && ship.lifesupport != null)
                {
                    ship.lifesupport.health = 1;
                }
                else if (modulename == "Radar" && ship.sensors != null)
                {
                    ship.sensors.health = 1;
                }
                else if (modulename == "CargoHatch" && ship.cargohatch != null)
                {
                    ship.cargohatch.health = 1;
                }
                else if (modulename == "DataLinkScanner" && ship.datalinkscanner != null)
                {
                    ship.datalinkscanner.health = 1;
                }
                else if (modulename.Contains("Hardpoint"))
                {
                    foreach (Hardpoint hardpoint in ship.hardpoints)
                    {
                        if (hardpoint.name == modulename && hardpoint.module != null)
                        {
                            hardpoint.module.health = 1;
                            break;
                        }
                    }
                }
                else
                {
                    foreach (Compartment compartment in ship.compartments)
                    {
                        if (compartment.name == modulename && compartment.module != null)
                        {
                            compartment.module.health = 1;
                            break;
                        }
                    }
                }
            }
        }
Beispiel #59
0
        /// <summary>
        /// Allows the game to run logic such as updating the world,
        /// checking for collisions, gathering input, and playing audio.
        /// </summary>
        /// <param name="gameTime">Provides a snapshot of timing values.</param>
        protected override void Update(GameTime gameTime)
        {
            // Allows the game to exit
            if (GamePad.GetState(PlayerIndex.One).Buttons.Back == ButtonState.Pressed ||
                Keyboard.GetState().IsKeyDown(Keys.Q))
            {
                this.Exit();
            }

            if (Keyboard.GetState().IsKeyDown(Keys.M))
            {
                warsContent.AddExplosion(1);
                warsContent.PlayExplosionSound();
            }

            /*
             * Keys[] keys = Keyboard.GetState().GetPressedKeys();
             * foreach(Keys key in keys)
             * {
             *  Console.WriteLine("Key pressed: {0}", key);
             * }
             */

            // The time since Update was called last.
            float elapsed = (float)gameTime.ElapsedGameTime.TotalSeconds;

            addShipCounter -= elapsed;
            if (Keyboard.GetState().IsKeyDown(Keys.Y) && addShipCounter <= 0)
            {
                addShipCounter = 0.3f;
                warsContent.AddShip(random.Next(4));
            }

            counter -= elapsed;
            if (counter <= 0)
            {
                counter = 3f;
                //Console.WriteLine("elapsed game time: {0}, elapsed real time: {1}", elapsed, (float)gameTime.ElapsedRealTime.TotalSeconds);
                if (warsContent.ships.Count == 1)
                {
                    warsContent.AddShip(random.Next(4));
                }

                //warsContent.AddShip();
                //Console.WriteLine("Angle: {0}", MathHelper.ToDegrees(((Ship)warsContent.ships[0]).RotationAngle));
            }


            // Joystick
            try
            {
                // poll the joystick
                joystickDevice.Poll();
                // update the joystick state field
                joystickState = joystickDevice.CurrentJoystickState;
            }
            catch (Exception err)
            {
                // we probably lost connection to the joystick
                // was it unplugged or locked by another application?
                Console.WriteLine(err.Message);
            }


            // TODO: Add your update logic here
            foreach (Cat cat in warsContent.cats)
            {
                cat.RedShotSpacingCounter -= elapsed;
            }
            bool playerAbove1throttle = false;

            for (int player = 1; player <= warsContent.ships.Count; player++)
            {
                //Ship ship = (Ship)warsContent.ships[player];
                Ship ship = warsContent.getPlayersShip(player);

                Commands com = warsControl.GetPlayerCommands(player, ref warsContent, ref joystickState);
                if (com.left)
                {
                    ship.RotationAngle += 4 * elapsed;
                    //Console.WriteLine("RotationAngle: {0}", MathHelper.ToDegrees(ship.RotationAngle));
                }
                if (com.right)
                {
                    ship.RotationAngle -= 4 * elapsed;
                    //Console.WriteLine("RotationAngle: {0}", MathHelper.ToDegrees(ship.RotationAngle));
                }
                if (com.throttle)
                {
                    // Sound
                    if (player == 1)
                    {
                        warsContent.PlayEngineSound(player);
                    }
                    ship.Throttle = elapsed * ship.ThrottlePower; // NOTE NOTE NOTE TODO: Make dependent on time (elapsed)
                    //Console.WriteLine("Ship speed: {0}", ship.Speed.ToString());
                    warsContent.AddFume(player);
                    if (player > 1)
                    {
                        playerAbove1throttle = true;
                    }
                }
                else
                {
                    if (player == 1)
                    {
                        warsContent.PauseEngineSound(player);
                    }
                    ship.Throttle = 0;
                }

                ship.RedShotSpacingCounter -= elapsed;
                if (com.fire == 1)
                {
                    if (ship.RedShotSpacingCounter <= 0)
                    {
                        ship.RedShotSpacingCounter = ship.RedShotSpacing;
                        //Console.WriteLine("Shot!");
                        warsContent.AddShot(player);
                    }
                    if (player == 1)
                    {
                        foreach (Cat cat in warsContent.cats)
                        {
                            if (cat.RedShotSpacingCounter <= 0)
                            {
                                cat.RedShotSpacingCounter = cat.RedShotSpacing;
                                warsContent.AddCatShot(player, cat);
                            }
                        }
                    }
                }
            }

            if (playerAbove1throttle)
            {
                warsContent.PlayEngineSound(2);
            }
            else
            {
                warsContent.PauseEngineSound(2);
            }

            //            if(Keyboard.GetState().IsKeyDown(Keys.S)) {
            //                ship.Throttle -= 4 * elapsed;
            //            }

            foreach (Cat cat in warsContent.cats)
            {
                cat.RotationAngle    += 4 * elapsed;
                cat.PosRotationAngle -= 4 * elapsed;
                cat.Pos = warsContent.getPlayersShip(cat.Owner).Pos;
                //Vector2 goal = warsContent.getPlayersShip(cat.Owner).Pos + cat.PosRotationVector * cat.ShipDistance;
                cat.Pos += cat.PosRotationVector * cat.ShipDistance;
                //cat.Speed = goal;
                //cat.move();
            }

            foreach (Ship ship in warsContent.ships)
            {
                ship.updateSpeed();
            }
            for (int playerMinus1 = 0; playerMinus1 < warsContent.ships.Count; playerMinus1++)
            {
                if (playerMinus1 != 0)
                {
                    warsContent.getPlayersShip(playerMinus1 + 1).move();
                    warsContent.getPlayersShip(playerMinus1 + 1).Pos -= warsContent.getPlayersShip(1).Speed;
                }
            }

            foreach (WarsObject obj in warsContent.planetObjects)
            {
                obj.Speed = -warsContent.getPlayersShip(1).Speed;
                obj.move();
            }

            foreach (WarsObject obj in warsContent.bgObjects)
            {
                //obj.Speed = new Vector2(-ship.Speed.X, ship.Speed.Y);
                //obj.Speed = -((Ship)warsContent.ships[1]).Speed;
                obj.Speed = -warsContent.getPlayersShip(1).Speed;

                obj.move();
                Vector2 newPos = obj.Pos;
                newPos.X = newPos.X % Constants.RESOLUTION_WIDTH;
                newPos.Y = newPos.Y % Constants.RESOLUTION_HEIGHT;
                if (newPos.X < 0)
                {
                    newPos.X += Constants.RESOLUTION_WIDTH;
                }
                if (newPos.Y < 0)
                {
                    newPos.Y += Constants.RESOLUTION_HEIGHT;
                }
                obj.Pos = newPos;
            }

            foreach (WarsObject obj in warsContent.fumeObjects)
            {
                obj.move();
                //obj.Pos += new Vector2(-ship.Speed.X / Constants.FUME_SPEED_AFFECT_FACTOR, ship.Speed.Y / Constants.FUME_SPEED_AFFECT_FACTOR);
                //obj.Pos += new Vector2(-ship.Speed.X, ship.Speed.Y);
                //obj.Pos -= ((Ship)warsContent.ships[1]).Speed;
                obj.Pos -= warsContent.getPlayersShip(1).Speed;
            }
            for (int i = 0; i < warsContent.fumeObjects.Count; i++)
            {
                WarsObject obj = (WarsObject)warsContent.fumeObjects[i];
                //newPos.X = newPos.X % Constants.RESOLUTION_WIDTH;
                //newPos.Y = newPos.Y % Constants.RESOLUTION_HEIGHT;
                if (obj.updateTTL(elapsed))
                {
                    warsContent.fumeObjects.RemoveAt(i);
                }
                else
                {
                    if (obj.Pos.X < 0)
                    {
                        warsContent.fumeObjects.RemoveAt(i);
                    }
                    else if (obj.Pos.Y < 0)
                    {
                        warsContent.fumeObjects.RemoveAt(i);
                    }
                }
            }


            // Shots
            foreach (WarsObject obj in warsContent.shotObjects)
            {
                obj.move();
                //obj.Pos += new Vector2(-ship.Speed.X, ship.Speed.Y);
                //obj.Pos -= ((Ship)warsContent.ships[1]).Speed;
                obj.Pos -= warsContent.getPlayersShip(1).Speed;
            }
            for (int i = 0; i < warsContent.shotObjects.Count; i++)
            {
                WarsObject obj = (WarsObject)warsContent.shotObjects[i];
                if (obj.updateTTL(elapsed))
                {
                    warsContent.shotObjects.RemoveAt(i);
                }
            }
            // Collision detection (player 1 shoots others)
            for (int playerIndexMinus1 = 1; playerIndexMinus1 < warsContent.ships.Count; playerIndexMinus1++)
            {
                Ship           ship       = warsContent.getPlayersShip(playerIndexMinus1 + 1);
                BoundingSphere shipSphere = new BoundingSphere(new Vector3(ship.Pos, 0), (float)ship.Texture.Width / 2f);
                for (int i = 0; i < warsContent.shotObjects.Count; i++)
                {
                    WarsObject     obj        = (WarsObject)warsContent.shotObjects[i];
                    BoundingSphere shotSphere = new BoundingSphere(new Vector3(obj.Pos, 0), (float)warsContent.redShot.Height / 2f);
                    if (shotSphere.Intersects(shipSphere))
                    {
                        if (obj.Owner != playerIndexMinus1 + 1)
                        {
                            warsContent.AddExplosion(playerIndexMinus1 + 1);
                            warsContent.PlayExplosionSound();
                            warsContent.shotObjects.RemoveAt(i);
                            warsContent.ships.RemoveAt(playerIndexMinus1);
                            whiteFlash = true;
                            break;
                        }
                    }
                }
            }
            // Collision detection (player 1 gets shot)
            Ship           ship1       = warsContent.getPlayersShip(1);
            BoundingSphere ship1Sphere = new BoundingSphere(new Vector3(ship1.Pos, 0), (float)ship1.Texture.Width / 2f);

            for (int i = 0; i < warsContent.shotObjects.Count; i++)
            {
                WarsObject     obj        = (WarsObject)warsContent.shotObjects[i];
                BoundingSphere shotSphere = new BoundingSphere(new Vector3(obj.Pos, 0), (float)warsContent.redShot.Height / 2f);
                if (shotSphere.Intersects(ship1Sphere))
                {
                    if (obj.Owner != 1)
                    {
                        //                        warsContent.AddExplosion(1);
                        //                        warsContent.PlayExplosionSound();
                        warsContent.shotObjects.RemoveAt(i);
                        //                        warsContent.ships.RemoveAt(playerIndexMinus1);
                        warsContent.PlayImHit();
                        break;
                    }
                }
            }


            base.Update(gameTime);
        }
        public void GetNameShip()
        {
            Ship ship = new Ship(0, "John");

            Assert.AreEqual("John", ship.GetName());
        }