Esempio n. 1
0
    public virtual void OnBulletCreated( WeaponBase _weapon, BulletBase _bullet )
    {
        SmartBullet smartBullet = _bullet as SmartBullet;
        if ( smartBullet != null )
        {
            smartBullet.health.Owner = this.health.Owner;
        }

        SeekingBullet seekingScript = _bullet as SeekingBullet;
        if ( seekingScript != null
        && ( !_weapon.weaponDesc.requiresWeaponLock || _weapon.IsLockedOntoTarget() ) )
        {
            seekingScript.target = this.currentTarget;
        }
    }
Esempio n. 2
0
 protected virtual void OnBulletCreate(BulletBase bullet)
 {
 }
Esempio n. 3
0
 //Functions to remove from collection
 public void RemoveBulletInRoom(BulletBase bullet)
 {
     activeBulletsInRoom.Remove(bullet);
 }
Esempio n. 4
0
 public void Initialize(BulletBase bullet)
 {
     Bullet = bullet;
 }
Esempio n. 5
0
 public void Shoot(BulletBase _bullet, Vector3 _shootPosition, Vector3 _direction, IShooter _shootable)
 {
     instance.TakeBullet(_bullet).Shoot(_shootPosition, _direction, _shootable);
 }
Esempio n. 6
0
 public BulletRunningStatus(BulletBase owner, Animator animator) : base(owner, animator)
 {
 }
 private void HandleBulletDisable(BulletBase bullet)
 {
     m_activeBullet.Remove(bullet);
     bullet.gameObject.SetActive(false);
     m_cacheBullet.Add(bullet);
 }
Esempio n. 8
0
        public BulletBase ShootBullet(int templateID, UnitBase shooter, UnitBase target, bool isAttack)
        {
            var        config = ConfigManager.Bullet.getRow(templateID);
            BulletBase bullet = null;

            switch (config.BulletType)
            {
            case BulletType.kCoordBullet:
                bullet = new CoordBullet(shooter, target.position);
                break;

            case BulletType.kLineBullet:
                if (config.FixRange > 0)
                {
                    var offset = (target.position - shooter.position).normalized * config.FixRange;
                    bullet = new LineBullet(shooter, shooter.position + offset);
                }
                else
                {
                    bullet = new LineBullet(shooter, target.position);
                }
                break;

            case BulletType.kPenteralBullet:
                if (config.FixRange > 0)
                {
                    var offset = (target.position - shooter.position).normalized * config.FixRange;
                    bullet = new PenetraBullet(shooter, config.DecayScale, shooter.position + offset);
                }
                else
                {
                    bullet = new PenetraBullet(shooter, config.DecayScale, target.position);
                }
                break;

            case BulletType.kReturnBullet:
                if (config.FixRange > 0)
                {
                    var offset = (target.position - shooter.position).normalized * config.FixRange;
                    bullet = new ReturnBullet(shooter, config.DecayScale, shooter.position + offset);
                }
                else
                {
                    bullet = new ReturnBullet(shooter, config.DecayScale, target.position);
                }
                break;

            case BulletType.kTrackBullet:
                bullet = new TrackBullet(shooter, target);
                break;

            default:
                throw new NotImplementedException("not implemented type " + config.BulletType.ToString());
            }
            bullet.radius       = config.Radius;
            bullet.speed        = config.Speed;
            bullet.acceleration = config.Acceleration;
            if (isAttack)
            {
                bullet.InitDamage((int)shooter.ATK.value, config.DamageType, isAttack);
            }
            else if (config.Damage > 0)
            {
                bullet.InitDamage(config.Damage, config.DamageType, isAttack);
            }
            if (config.AoeRadius > 0)
            {
                List <SkillModule.BuffEmitter> emitters = new List <SkillModule.BuffEmitter>(config.BuffEmitter.Length);
                for (int i = 0; i < config.BuffEmitter.Length; ++i)
                {
                    var emitter        = new SkillModule.BuffEmitter();
                    var emitter_config = ConfigManager.BuffEmitter.getRow(config.BuffEmitter[i]);
                    emitter.buffs = new int[emitter_config.Buffs.Length];
                    for (int n = 0; n < emitter_config.Buffs.Length; ++n)
                    {
                        emitter.buffs[n] = emitter_config.Buffs[n];
                    }
                    emitter.Caster = shooter;
                    emitter.filter = emitter_config.AoeFilter;
                    emitters[i]    = emitter;
                }
                bullet.InitAoeFile(config.AoeRadius, config.AoeDuration, config.AoeInterval, emitters);
            }
            if (config.Buffs != null && config.Buffs.Length > 0)
            {
                int[] buffs = new int[config.Buffs.Length];
                for (int n = 0; n < config.Buffs.Length; ++n)
                {
                    buffs[n] = config.Buffs[n];
                }
                bullet.InitBuff(buffs);
            }
            bullet.position = shooter.position;
            AddBullet(bullet);
            return(bullet);
        }
Esempio n. 9
0
 /// <summary>
 /// 弾丸プレハブ更新
 /// </summary>
 public void RefleshBulletPrefab()
 {
     this.bulletPrefab = AssetManager.FindHandle <BulletBase>(SharkDefine.GetBulletPrefabPath(this.bulletKey)).asset as BulletBase;
 }
Esempio n. 10
0
 public virtual void Initialize(BulletBase bullet)
 {
     Bullet = bullet;
     Bullet.RotatorContainer.CreateRotatedRectangle();
 }
Esempio n. 11
0
 private void HandleBulletCreated(BulletBase obj)
 {
     AddChild(obj);
 }
Esempio n. 12
0
    public bool action;     //可行动

    virtual public void BeHit(BulletBase bulletBase)
    {
    }                                                      //被击中
 void SetCoordinatesForBullet(BulletBase bullet, Vector2f centerCoordinatesOfMainObject, float r, float angle)
 {
     bullet.CenterCoordinates = centerCoordinatesOfMainObject + new PolarVector(r, angle).PolarToCartesianCoordinateDegrees();
 }
Esempio n. 14
0
    public void DestroyLocalBullet( BulletBase _bullet )
    {
        if ( _bullet.desc.smartBullet == true )
        {
        #if UNITY_EDITOR
            if ( Network.peerType == NetworkPeerType.Disconnected )
            {
                if ( _bullet.desc.fadeOut > 0.0f )
                {
                    _bullet.OnFadeBegin();
                }
                else
                {
                    GameObject.Destroy( _bullet.gameObject );
                }

                TargetManager.instance.RemoveTarget( _bullet.GetComponent<BaseHealth>() );
                this.debugSmartBulletMap.Remove( ((SmartBullet)_bullet).debugID );
            }
            else
        #endif
            {
                if ( _bullet.GetComponent<NetworkView>().isMine == false )
                {
                    Debug.LogWarning( "You cannot destroy a seeking bullet you don't own!", _bullet );
                    return;
                }
                this.smartBulletMap.Remove( _bullet.GetComponent<NetworkView>().viewID );

                TargetManager.instance.RemoveTarget( _bullet.GetComponent<BaseHealth>() );
                GameNetworkManager.instance.SendDestroySmartBulletMessage( _bullet.GetComponent<NetworkView>().viewID );

                // If it fades, fade it out and let its own script destroy it
                if ( _bullet.desc.fadeOut > 0.0f )
                {
                    _bullet.OnFadeBegin();
                }
                else
                {
                    Network.Destroy( _bullet.gameObject );
                }

            }
        }
        else //Dumb bullet
        {
            if ( _bullet.state == BulletBase.BULLET_STATE.INACTIVE
              || _bullet.gameObject.activeSelf == false )
            {
                DebugConsole.Warning( "No point disabling a currently inactive bullet (" + _bullet.gameObject.name, _bullet );
                return;
            }

            if ( _bullet.desc.fadeOut > 0.0f )
            {
                _bullet.OnFadeBegin();
            }
            else
            {
                _bullet.gameObject.SetActive( false );
                _bullet.state = BulletBase.BULLET_STATE.INACTIVE;
            }

            if ( Network.peerType != NetworkPeerType.Disconnected )
            {
                GameNetworkManager.instance.SendDestroyDumbBulletMessage( _bullet.weaponType, _bullet.index, _bullet.transform.position );
            }
        }
    }
Esempio n. 15
0
        public override void Update(MainLoop mainLoop)
        {
            if (Input.IsKeyPressed(Keys.Escape))
            {
                if (enemy.getAlive() == true && player.getAlive() == true)
                {
                    pauseMenu.ToggleActive();
                }
            }

            if (pauseMenu.GetActive() == false)
            {
                if (Input.IsKeyPressed(Keys.Z))
                {
                    canShoot = true;
                }

                shootInterval--;

                if (enemy.getAlive() == false || player.getAlive() == false)
                {
                    endTimer--;
                    if (player.getAlive() == false)
                    {
                        playerBulletList.Clear();
                    }
                    if (enemy.getAlive() == false)
                    {
                        player.resetHit();
                    }
                }
                //UPDATES
                if (enemy.getAlive() == true)
                {
                    enemy.Update();
                }
                if (player.getAlive() == true)
                {
                    player.Update();
                }
                FXManager.Update();
                CommonData.UpdateData(player.getPosition().X, player.getPosition().Y);
                for (int i = bulletList.Count() - 1; i >= 0; i--)
                {
                    BulletBase bullet = bulletList[i];
                    bullet.Update(player);
                    if (enemy.getAlive() == false)
                    {
                        bullet.setAlive(false);
                    }
                    if (bullet.getAlive() == false)
                    {
                        bulletList.Remove(bullet);
                    }
                }
                for (int i = playerBulletList.Count() - 1; i >= 0; i--)
                {
                    PlayerBullet bullet = playerBulletList[i];
                    bullet.Update();
                    if (bullet.getAlive() == false)
                    {
                        playerBulletList.Remove(bullet);
                    }
                }
                //INPUTS
                if (Input.IsKeyPressed(Keys.X) && bombs > 0 && player.getAlive() == true)
                {
                    ClearBullets();
                    player.resetHit();
                    flashAlpha = 1;
                    bombs--;
                }
                if (Input.IsKeyDown(Keys.Z) && shootInterval <= 0 && canShoot == true && player.getAlive() == true)
                {
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X - 27, player.getPosition().Y - 10)));
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X - 9, player.getPosition().Y - 30)));
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X + 9, player.getPosition().Y - 30)));
                    playerBulletList.Add(new PlayerBullet(new Vector2(player.getPosition().X + 27, player.getPosition().Y - 10)));
                    shootInterval = 5;
                }
                //ENDING
                if (endTimer == 0)
                {
                    if (player.getAlive() == true)
                    {
                        ScoreManager.SetScore(scene, bombs + 1);
                    }
                    pauseMenu.ToggleActive();
                }

                Console.WriteLine(bulletList.Count);
            }
            else
            {
                //PAUSEMENU
                pauseMenu.Update();
            }
            base.Update(mainLoop);
        }
Esempio n. 16
0
        public override void Draw(SpriteBatch sb)
        {
            sb.Draw(Assets.BG, CommonData.drawOffset, Color.White);
            if (flashAlpha > 0)
            {
                flashAlpha -= 0.05f;
                sb.Draw(Assets.enemyExplosion, new Vector2(400, 300), new Rectangle(0, 0, 128, 128), Color.White * flashAlpha, 0, new Vector2(64, 64), 10, SpriteEffects.None, 0);
            }
            player.Draw(sb);
            enemy.Draw(sb);
            FXManager.Draw(sb);
            for (int i = playerBulletList.Count() - 1; i >= 0; i--)
            {
                PlayerBullet bullet = playerBulletList[i];
                bullet.Draw(sb);
            }
            sb.End();

            sb.Begin(SpriteSortMode.Deferred, BlendState.Additive);
            for (int i = bulletList.Count() - 1; i >= 0; i--)
            {
                BulletBase bullet = bulletList[i];
                if (bullet.getAdditive() == true)
                {
                    bullet.Draw(sb);
                }
            }
            sb.End();

            sb.Begin(SpriteSortMode.Deferred, BlendState.AlphaBlend);
            for (int i = bulletList.Count() - 1; i >= 0; i--)
            {
                BulletBase bullet = bulletList[i];
                if (bullet.getAdditive() == false)
                {
                    bullet.Draw(sb);
                }
            }

            if (enemy.getAlive() == true)
            {
                float posX = enemy.getPosition().X - 45f / 2;
                if (posX < 45f / 2)
                {
                    posX = 45f / 2;
                }
                else if (posX > 432 - 45f / 2)
                {
                    posX = 432 - 45f / 2;
                }
                sb.Draw(Assets.menuElements, new Vector2(posX + CommonData.drawOffset.X, CommonData.maxY - 16), new Rectangle(99, 310, 45, 16), Color.White);
                int width = (int)((432 - 20) * enemy.getHealthPercent());
                sb.Draw(Assets.menuElements, new Rectangle(10 + (int)CommonData.drawOffset.X, 5 + (int)CommonData.drawOffset.Y, width, 8), new Rectangle(0, 325, 0, 0), Color.LightGray);
            }
            if (player.getAlive())
            {
                sb.Draw(Assets.menuElements, player.getPosition() + CommonData.drawOffset, new Rectangle(88, 317, 9, 9), Color.White, 0, new Vector2(4.5f, 4.5f), 1, SpriteEffects.None, 0);
            }
            if (pauseMenu.GetActive() == true)
            {
                pauseMenu.Draw(sb);
            }

            sb.Draw(Assets.hud, new Vector2(0, 0), Color.White);
            for (int i = 0; i < bombs; i++)
            {
                sb.Draw(Assets.menuElements, new Vector2(140, 100 + 40 * i), new Rectangle(81, 98, 35, 35), Color.White);
            }


            base.Draw(sb);
        }
Esempio n. 17
0
 public void AddBullet(BulletBase bullet)
 {
     mBullets.Add(bullet);
 }
Esempio n. 18
0
 public override void Initialize(BulletBase bullet)
 {
 }
Esempio n. 19
0
    //public BulletBase CreateBullet(string bulletName) {
    //	//return PoolManager.Get(bulletName).GetComponent<BulletBase>();
    //	//return PoolManager.Get(bulletName);
    //	//return PoolManager.Get(bulletName) as BulletBase;
    //	//return PoolManager.Get(bulletName).gameObject.GetComponent<BulletBase>();
    //	return PoolManager.Get(bulletName);
    //}

    /*
     * public void InitBullet(BulletBase bullet) {
     *      //bullet.transform.position = transform.position;
     *      bullet.transform.position = muzzleTf.position;
     *      //bullet.direction =
     *      //	lastMovement == Vector2.zero ? new Vector2(1, 0) : lastMovement;
     *      //bullet.direction = aimDirection;
     *      //bullet.transform.rotation =
     *      //	Quaternion.FromToRotation(new Vector3(1, 0, 0), bullet.direction);
     *
     *      //bullet.direction = shootAngle;
     *      float angle = shootAngle;
     *      //Debug.Log(angle);
     *      //bullet.direction = new Vector2(Mathf.Cos(angle), Mathf.Sin(angle));
     *      // ?Mathf.Cos, Mathf,Sin 传入的是弧度制角度 ...
     *      bullet.direction = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad));
     *      //bullet.transform.rotation =
     *      //	Quaternion.FromToRotation(new Vector3(1, 0, 0), bullet.direction);
     *      bullet.transform.eulerAngles = new Vector3(0, 0, angle);
     *
     *      bullet.isStop = false;
     *
     *      //BulletBase.temp1 = null;
     *
     *      //bullet.speed *= Random.Range(0.8f, 1.2f);
     * }
     */
    // ?TODO : 把子弹的初始化放进子弹的方法 ...
    // ?改 在调用处实现初始化子弹 为 调用子弹的初始化方法传入初始化参数 ...
    public void InitBullet(BulletBase bullet)
    {
        bullet.Init(muzzleTf.position, shootAngle);
    }
Esempio n. 20
0
 public ObjectLink(BulletBase b)
 {
     me   = b;
     back = null;
 }
Esempio n. 21
0
 private void HandleBulletEnable(BulletBase bullet)
 {
     m_activeBullet.Add(bullet);
 }
Esempio n. 22
0
 protected override void OnBulletCreate(BulletBase bullet)
 {
 }
Esempio n. 23
0
 public BulletEndStatus(BulletBase owner, Animator animator) : base(owner, animator)
 {
 }
Esempio n. 24
0
    /// <summary>
    /// Doubles the size of the bullet contained, creating new bullets to fill out the gap
    /// </summary>
    /// <returns><c>true</c>, if bucket size was increased, <c>false</c> otherwise.</returns>
    private bool DoubleBucketSize()
    {
        int oldLength = this.bulletList.Length;
        // Attempting to double an empty list ain't gonna work so well
        if ( oldLength == 0 )
        {
            DebugConsole.Error( "Cannot double the size of an empty list" );
            return false;
        }
        int newLength = oldLength * 2;
        BulletBase[] newList = new BulletBase[ newLength ];
        this.bulletList.CopyTo( newList, 0 );

        for ( int i = oldLength; i < newLength; ++i )
        {
            BulletBase bulletScript = this.CreateNewBullet( i );
            newList[i] = bulletScript;
        }
        this.bulletList = newList;
        this.currentIndex = oldLength;
        return true;
    }
Esempio n. 25
0
 public void SetType(BulletBase _type)
 {
     bulletType = _type;
     this.gameObject.GetComponent <Renderer>().material.color = bulletType.GetColor();
 }
Esempio n. 26
0
 public override void Initialize(BulletBase bullet)
 {
     base.Initialize(bullet);
     _directionOfMovementInAbsenceOfObjects.Initialize(Bullet);
     _directionOfMovementInAbsenceOfObjects.SpeedFactor = SpeedFactor;
 }
Esempio n. 27
0
 /// <summary>
 /// 命中回调
 /// </summary>
 /// <param name="hitPoint"></param>
 public void OnHit(BulletBase bullet, Vector3 hitPoint, Vector3 normal)
 {
     _onHit?.Invoke(bullet, hitPoint, normal);
 }
Esempio n. 28
0
 public void OnDestroyBullet(BulletBase bulletBase)
 {
     bulletBase.gameObject.SetActive(false);
 }
Esempio n. 29
0
 public void AddBulletInRoom(BulletBase bullet)
 {
     activeBulletsInRoom.Add(bullet);
 }
Esempio n. 30
0
    public virtual void CollisionCheck(BulletBase bullet)
    {
//		Debug.Log("PlayerColl");
        bullet.ColliseionActive(this);
    }
Esempio n. 31
0
 public void AddBulletInActiveRoom(BulletBase bullet)
 {
     m_activeRoom.AddBulletInRoom(bullet);
 }
Esempio n. 32
0
 protected void setDrowStage(Transform bullect, BulletBase copyBullet, BulletBase.objectPosition obPoint, bool stopTimeLine, bool NonDestroyChack)
 {
     _currentPenetrate = _destroyOption._penetrateCount;
     _destroyOption._collistionControl.setDrowStage(bullect, copyBullet, obPoint, stopTimeLine, NonDestroyChack);
 }