Ejemplo n.º 1
0
        private void AddShip(int shipID, Ship tempShip)
        {
            if (!_shipList.ContainsKey(shipID))
            {
                _shipList.Add(shipID, tempShip);
                if (_simulateNPCs && tempShip.IsLocalSim)
                {
                    _positionUpdateList.Add(tempShip);
                }


                //This stuff will probably be removed in the future.
                _targetManager.RegisterObject(tempShip);
                _teamManager.RegisterObject(tempShip);
            }
            else
            {
                throw new InvalidOperationException("Error: ship already exists in shipList!");
            }
        }
Ejemplo n.º 2
0
        public void CreateMissile(ProjectileTypes projectileType,
                                  Vector2 position, Vector2 velocityOffset, float rotation,
                                  int projectileID, ICanFire firingObj, bool isLocalSim, byte firingWeaponSlot)
        {
            IMissile proj = null;


            if (firingObj is Turret)
            {
                ConsoleManager.WriteLine("ERROR: Missiles not implemented for turrets in ProjectileManager.CreateMissile().", ConsoleMessageType.Error);
            }
            else
            {
                switch (projectileType)
                {
                case ProjectileTypes.AmbassadorMissile:
                {
                    proj = new Missile <AmbassadorProjectileStats>(_collisionManager, _world, projectileID, firingObj, isLocalSim, _particleManager, firingWeaponSlot);
                    _simulationManager.StartSimulating(proj);
                    _targetingManager.RegisterObject(proj);
                    break;
                }


                case ProjectileTypes.HellHoundMissile:
                {
                    proj = new Missile <HellhoundProjectileStats>(_collisionManager, _world, projectileID, firingObj, isLocalSim, _particleManager, firingWeaponSlot);
                    _simulationManager.StartSimulating(proj);
                    _targetingManager.RegisterObject(proj);
                    break;
                }

                case ProjectileTypes.MissileType1:
                {
                    proj = new Missile <MissileType1ProjectileStats>(_collisionManager, _world, projectileID, firingObj, isLocalSim, _particleManager, firingWeaponSlot);
                    _simulationManager.StartSimulating(proj);
                    _targetingManager.RegisterObject(proj);
                    break;
                }

                case ProjectileTypes.MissileType2:
                {
                    proj = new Missile <MissileType2ProjectileStats>(_collisionManager, _world, projectileID, firingObj, isLocalSim, _particleManager, firingWeaponSlot);
                    _simulationManager.StartSimulating(proj);
                    _targetingManager.RegisterObject(proj);
                    break;
                }

                case ProjectileTypes.MissileType3:
                {
                    proj = new Missile <MissileType3ProjectileStats>(_collisionManager, _world, projectileID, firingObj, isLocalSim, _particleManager, firingWeaponSlot);
                    _simulationManager.StartSimulating(proj);
                    _targetingManager.RegisterObject(proj);
                    break;
                }

                case ProjectileTypes.MissileType4:
                {
                    proj = new Missile <MissileType4ProjectileStats>(_collisionManager, _world, projectileID, firingObj, isLocalSim, _particleManager, firingWeaponSlot);
                    _simulationManager.StartSimulating(proj);
                    _targetingManager.RegisterObject(proj);
                    break;
                }

                default:
                    ConsoleManager.WriteLine("ERROR: ProjectileType " + projectileType + " not implemented in ProjectileManager.CreateProjectile().", ConsoleMessageType.Error);
                    break;
                }
                velocityOffset = new Vector2(velocityOffset.X / 1000f + (float)(Math.Sin(rotation)) * _flyweights[projectileType].BaseSpeed / 1000f,
                                             velocityOffset.Y / 1000f - (float)(Math.Cos(rotation)) * _flyweights[projectileType].BaseSpeed / 1000f);

                //Proj could be null here, but it should be an easy catch if we forget to add a switch case and it breaks
                proj.BodyData = new ProjectileBodyDataObject(BodyTypes.Projectile, projectileID, firingObj, proj);
            }



            proj.LinearVelocity    = velocityOffset;
            proj.Rotation          = rotation;
            proj.Position          = position;
            ((IProjectile)proj).Id = projectileID;
            _projectileList.Add(proj);
        }