public override void Destroy() { base.Destroy(); BulletFactory.Destroy(); EnemyFactory.Destroy(); BulletList.MakeOneWay(); EnemyList.MakeOneWay(); if (BackgroundInstance != null) { BackgroundInstance.Destroy(); BackgroundInstance.Detach(); } if (PlayerInstance != null) { PlayerInstance.Destroy(); PlayerInstance.Detach(); } for (int i = BulletList.Count - 1; i > -1; i--) { BulletList[i].Destroy(); } for (int i = EnemyList.Count - 1; i > -1; i--) { EnemyList[i].Destroy(); } if (ScoreboardInstance != null) { ScoreboardInstance.Destroy(); ScoreboardInstance.Detach(); } BulletList.MakeTwoWay(); EnemyList.MakeTwoWay(); CustomDestroy(); }
public FinalBossRandomBullets(Vector2 newPosition, ContentManager gameContent, int directionModifier) : base(null, newPosition, Vector2.Zero, true, null) { Random random = new Random(); Content = gameContent; bullets = new List <Bullets>(); factory = new BulletFactory(gameContent); Vector2 pos = new Vector2(random.Next(0, 1000), random.Next(0, 40)); int randDir = random.Next(0, 3); BulletMovements moves = new BulletMovements(); Movement mov = new MoveDownLeft(7.0); if (randDir == 0) { moves.addMovement(new MoveDown(7.0)); } else if (randDir == 1) { moves.addMovement(new MoveDownLeft(7.0)); } else if (randDir == 2) { moves.addMovement(new MoveDownRight(7.0)); } bullets.Add(factory.bulletFactory("bullet", pos, new Vector2(1, (2 * directionModifier)), true, 1, moves)); }
private void FireBlueBullet() { //蓝色子弹 if (ShootIdx % BlueBulletFrame == 0) { Master.PlayShootSound(EShootSound.Tan00); //6发换角度 for (int i = 0; i < BlueBulletCount; i++) { var f1 = Quaternion.Euler(0, 0, _blueBulletAngel + i * 10) * Master.transform.up; var data = MoveData.New(Master.transform.position, f1, BlueBulletSpeed); BulletFactory.CreateBulletAndShoot(BlueBulletId, Master.transform, Layers.EnemyBullet, data); } _blueShootIndex++; Master.PlayShootEffect(EColor.BlueLight, 2f); if (_blueShootIndex % Random.Range(4, 6) == 0) { _blueBulletAngel += Random.Range(90, 110); } else { _blueBulletAngel += Random.Range(25, 35); } if (_blueBulletAngel > 360) { _blueBulletAngel -= 360; } } }
KeyboardState pastKey; //2nd most recent key command public Player(ContentManager gameContent) { Content = gameContent; isGod = false; bullets = new List <Bullets>(); factory = new BulletFactory(gameContent); }
private void FireBlueBullet() { //蓝色子弹 if (ShootIdx % BlueBulletFrame == 0) { Master.PlayShootSound(EShootSound.Tan00); for (int i = 0; i < BlueBulletCount; i++) { for (int j = 0; j < 3; j++) { var f1 = Quaternion.Euler(0, 0, _blueBulletAngel + i * -12 + j * 120) * Master.transform.up; var data = MoveData.New(Master.transform.position, f1, BlueBulletSpeed + i * 0.05f, -0.5f, BlueBulletSpeed - 2f); BulletFactory.CreateBulletAndShoot(BlueBulletId, Master.transform, Layers.EnemyBullet, data); } } Master.PlayShootEffect(EColor.BlueLight, 2f); _blueBulletAngel += 15; if (_blueBulletAngel > 360) { _blueBulletAngel -= 360; } } }
public void FixUpdateShoot(bool isSlow, int layer, bool inShoot) { var shootFrame = isSlow ? Deploy.slowFrame : Deploy.fastFrame; var bulletId = isSlow ? Deploy.slowBulletId : Deploy.fastBulletId; var atk = isSlow ? Deploy.slowAtk : Deploy.fastAtk; var bulletSpeed = isSlow ? Deploy.slowSpeed : Deploy.fastSpeed; if (_prevInSlow != isSlow) { _prevInSlow = isSlow; if (_currBullet != null) { BulletFactory.DestroyBullet(_currBullet); _currBullet = null; } _prevInLoopShoot = false; NextShootFrame = GameSystem.FixedFrameCount + shootFrame; } _slowEffect?.SetActiveSafe(inShoot && isSlow); _fastEffect?.SetActiveSafe(inShoot && !isSlow); if (shootFrame > 0) { //正常类型,持续射击 if (inShoot) { if (GameSystem.FixedFrameCount > NextShootFrame) { NextShootFrame = GameSystem.FixedFrameCount + shootFrame; BulletFactory.CreateBullet(bulletId, transform, layer, bullet => { var data = MoveData.New(transform.position, MathUtility.SwapYZ(transform.forward), bulletSpeed); bullet.Shoot(data, atk: atk); }); } } } else { //射击间隔为0的,表示激光类型,射击状态下持续显示,非射击销毁 if (!_prevInLoopShoot && inShoot) { BulletFactory.CreateBullet(bulletId, transform, layer, bullet => { _currBullet = bullet; bullet.Shoot(MoveData.New(transform.position, transform.up, bulletSpeed), atk: atk); }); } if (_prevInLoopShoot && !inShoot) { if (_currBullet != null) { BulletFactory.DestroyBullet(_currBullet); _currBullet = null; } } _prevInLoopShoot = inShoot; } }
protected override void Attack() { if (bowAngel != 0) { Vector3 characterPos = character.position; Vector3 arrowPos = arrow.position; Vector3 direction = FlipX ? arrow.right : -arrow.right; // ВЫСЧИТЫВАЕМ V(СИЛУ) float x = characterPos.x - arrowPos.x; if (x < 0) { x = x * -1; bowAngel = 180 - bowAngel; } float y = 0; float h = arrowPos.y - characterPos.y; // ВОЗМОЖНО БАГ float alpha = Methods.GradToRad(bowAngel); // ВОЗМОЖНО БАГ float velocity = Mathf.Sqrt(-Physics2D.gravity.magnitude * Mathf.Pow(x, 2) / ((y - Mathf.Tan(alpha) * x - h) * 2 * Mathf.Pow(Mathf.Cos(alpha), 2))); velocity = Mathf.Clamp(velocity, 0, maxVelocity); direction *= velocity; BulletFactory.CreateArrow(arrow, damage, direction, tag); } }
public void Start() { debugInput.Initialize(); testStage = new TestStage(levelData); bulletFactory = new BulletFactory(originalBullet, levelData); // プレイヤー playerModel = new PlayerModel(testStage.LevelData, testStage); playerPresenter.Initialize(playerModel, debugInput, testStage); playerModel.OnAttackObservable.Subscribe(attacker => { // 弾生成 if (playerBullet == null) { playerBullet = bulletFactory.CreateBullet(attacker); playerBullet.OnDestroy.Subscribe(_ => { playerBullet = null; }).AddTo(this); } }).AddTo(this); // 敵 enemyArmy = new EnemyArmy(testStage); }
private void SpawnPlayer(BulletFactory bulletFactory) { var spaceshipTexture = Content.Load <Texture2D>("playerShip1_blue"); var spaceshipRegion = new TextureRegion2D(spaceshipTexture); _player = _entityManager.AddEntity(new Spaceship(spaceshipRegion, bulletFactory)); }
//protected override void Initialize() //{ // base.Initialize(); // _graphicsDeviceManager.IsFullScreen = true; // _graphicsDeviceManager.PreferredBackBufferWidth = GraphicsDevice.DisplayMode.Width; // _graphicsDeviceManager.PreferredBackBufferHeight = GraphicsDevice.DisplayMode.Height; // _graphicsDeviceManager.ApplyChanges(); //} protected override void LoadContent() { _viewportAdapter = new BoxingViewportAdapter(Window, GraphicsDevice, 800, 480); _font = Content.Load <BitmapFont>("Fonts/courier-new-32"); _camera = new Camera2D(_viewportAdapter); _explosionAnimations = Content.Load <SpriteSheetAnimationGroup>("explosion-animations"); _spriteBatch = new SpriteBatch(GraphicsDevice); _backgroundTexture = Content.Load <Texture2D>("black"); var bulletTexture = Content.Load <Texture2D>("laserBlue03"); var bulletRegion = new TextureRegion2D(bulletTexture); _bulletFactory = new BulletFactory(_entityManager, bulletRegion); SpawnPlayer(_bulletFactory); _meteorFactory = new MeteorFactory(_entityManager, Content); for (var i = 0; i < 13; i++) { _meteorFactory.SpawnNewMeteor(_player.Position); } }
public FinalBossBullets(Vector2 newPosition, ContentManager gameContent, int directionModifier) : base(null, newPosition, Vector2.Zero, true, null) { Vector2 midShotPos = new Vector2(position.X + 94, position.Y + 63); Vector2 leftShotPot = new Vector2(position.X + 40, position.Y + 75); Vector2 rightShotPos = new Vector2(position.X + 148, position.Y + 75); Content = gameContent; bullets = new List <Bullets>(); factory = new BulletFactory(gameContent); BulletMovements down = new BulletMovements(); BulletMovements downLeft = new BulletMovements(); BulletMovements downRight = new BulletMovements(); down.addMovement(new MoveDown(7.0)); downLeft.addMovement(new MoveDownLeft(7.0)); downRight.addMovement(new MoveDownRight(7.0)); bullets.Add(factory.bulletFactory("bullet", midShotPos, new Vector2(0, (10 * directionModifier)), true, 1, down)); bullets.Add(factory.bulletFactory("bullet", midShotPos, new Vector2(-5, (10 * directionModifier)), true, 1, downLeft)); bullets.Add(factory.bulletFactory("bullet", midShotPos, new Vector2(-10, (10 * directionModifier)), true, 1, downLeft)); bullets.Add(factory.bulletFactory("bullet", midShotPos, new Vector2(-5, (10 * directionModifier)), true, 1, downRight)); bullets.Add(factory.bulletFactory("bullet", midShotPos, new Vector2(-10, (10 * directionModifier)), true, 1, downRight)); bullets.Add(factory.bulletFactory("bullet", leftShotPot, new Vector2(-1, (10 * directionModifier)), true, 1, down)); bullets.Add(factory.bulletFactory("bullet", rightShotPos, new Vector2(-1, (10 * directionModifier)), true, 1, down)); }
//子弹爆炸,销毁子弹 protected virtual void DoBulletBomb() { if (InCache) { return; } //播放爆炸特效 if (Deploy.bombEffectId > 0) { var pos = Renderer.transform.position; var forward = MoveData.Forward; var speed = Deploy.bombEffectSpeed; TextureEffectFactroy.CreateEffect(Deploy.bombEffectId, SortingOrder.EnemyBullet, effect => { effect.transform.position = pos; effect.AutoDestroy(); if (speed > 0) { effect.SetAutoMove(forward, speed); } }); } //销毁子弹 BulletFactory.DestroyBullet(this); }
public BulletController(BulletModel model, Transform spawnPoint, EnemyController target, int turretLevel) { _model = model; _view = BulletFactory.InstantiateView(spawnPoint, _model.PrefabName, this); _target = target; _model.Level = turretLevel; _target.AddObserver(this); }
public Gun(Gun g) { this.bulletTexture = g.bulletTexture; this.tickFireDelay = g.tickFireDelay; this.fireShape = g.fireShape; this.team = g.team; this.fireAngleOffset = g.fireAngleOffset; }
public Gun(float delay, Texture2D texture, BulletFactory factory, TEAM team, double fireAngleOffset = Math.PI / 2) { this.bulletTexture = texture; this.tickFireDelay = (long)(delay * 1000); this.fireShape = factory; this.team = team; this.fireAngleOffset = fireAngleOffset; }
// Use this for initialization void Start() { this.CoolDown = 0.0f; this.BulletF = BulletFactory.GetInstance(); this.bullets = new List <Bullet>(); this.energy = maxEnergy; this.timer = Time.deltaTime; }
public static BulletFactory getInstance() { if (_instance == null) { _instance = new BulletFactory(); } return(_instance); }
private void Awake() { if (Instance != null) { Debug.LogError("There is multiple instance of singleton BulletsFactory"); return; } Instance = this; }
public BattleObjectFactory(Vector <BattleObject> map, Engine.BattleEngine battleEngine) { _map = map; _buildingFactory = new BuildingFactory(this, battleEngine); _unitFactory = new UnitFactory(this, battleEngine); _bulletFactory = new BulletFactory(this, battleEngine); _spellFactory = new SpellFactory(this, battleEngine); _damageFactory = new DamageFactory(this, battleEngine); }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); } instance = this; }
/// <summary> /// Creates a turret model used by turret controllers. /// </summary> /// <param name="salvoReloadTime">The fire rate of the turret in shoot/second</param> /// <param name="accuracy">The accuracy of the turret. Must be bettwen 1 and 100</param> /// <param name="range">What is the turret's max firing range?</param> /// <param name="bulletType">What type of bullet does the turret fire?</param> public Turret(float salvoReloadTime, int accuracy, float range, int shotsPerSalvo, float shotReloadTime, BulletType bulletType) { this.salvoReloadTime = salvoReloadTime; this.accuracy = accuracy; this.range = range; this.shotsPerSalvo = shotsPerSalvo; this.shotReloadTime = shotReloadTime; bullet = BulletFactory.getInstance().CreateBullet(bulletType); }
//--------------------------------------------------------------------------- public void Spawn() { TransformComponent transform = GetComponent <TransformComponent>(); if (transform != null) { BulletFactory.Create(transform.AbsoluteLocation, transform.Orientation, Description); } }
private void FireBigStar() { for (int i = 0; i < 6; i++) { var shootForward = Quaternion.Euler(0, 0, _starAngel + i * 60) * Master.transform.up; var moveData = MoveData.New(Master.transform.position, shootForward, StarSpeed - 2f); BulletFactory.CreateBulletAndShoot(BigStarId, Master.transform, Layers.EnemyBullet, moveData); } }
public static BulletFactory GetInstance() { if (instance == null) { instance = new BulletFactory(); } return(instance); }
public void SetUp(BulletFactory bulletFactory, PlayerState playerState, FightState state, IPlayerInputController playerInputController) { _playerInputController = playerInputController; _bulletFactory = bulletFactory; _playerState = playerState; _playerState.SetPosition(transform.position); _state = state; }
// step 3. make a pubic static creational method for class access public static BulletFactory Instance() { if (m_instance == null) { m_instance = new BulletFactory(); } return(m_instance); }
void RemoveLastProjectiles() { while (m_lastProjectiles.Count > 0) { BulletFactory.DestroyBullet(m_lastProjectiles[0]); //Destroy(m_lastProjectiles[0]); m_lastProjectiles.RemoveAt(0); } }
/* * TODO: IMPLEMEMENT GUN TO FOLLOW SPECIFIC SHAPE/PATTERN EQUATION */ public BossGun(Vector2 startingLoc, int delay, BulletFactory factory, float direction, ILocationEquation shape, Texture2D texture, TEAM team) : base(delay, texture, factory, team) { Location = startingLoc; this.delay = delay; this.bfactory = factory; this.direction = direction; base.fireAngleOffset = Math.PI / 2; path = (SpiralLocationEquation)shape; }
// Use this for initialization void Start() { sceneController = SceneController.GetInstance(); actionManager = ActionManager.GetInstance(); ufoFactory = UFOFactory.getInstance(); actionManager = ActionManager.GetInstance(); ufoFactory = UFOFactory.getInstance(); bulletFactory = BulletFactory.getInstance(); }
protected bool CheckBulletOutSide(Vector3 bulletCenter) { //超出边界销毁 if (bulletCenter.x < -15f || bulletCenter.x > 5f || bulletCenter.y < -12f || bulletCenter.y > 12f) { BulletFactory.DestroyBullet(this); return(true); } return(false); }
// Use this for initialization void Start() { pBulletFactory = FindObjectOfType <BulletFactory>(); Damage dmg = GetComponent <Damage>(); dmg.SetDamage(rawDamage); Invoke("StartFire", shotOffset); }