Пример #1
0
	public void createPoolObjs(BulletType type, int count)
	{
		i=0;
		if(type==BulletType.GUN_SMALL_BULLET)
		{
			for(i=0;i<count;i++)
			{
				tmp=(GameObject) GameObject.Instantiate(Resources.Load("prefab/bullets/smallGunBullet"),bulletStartPosition,Quaternion.identity);
				bringToBack(type,tmp.GetComponent<BulletContainer>());
			}
		}
		else if(type==BulletType.GUN_MID_BULLET)
		{
			for(i=0;i<count;i++)
			{
				tmp=(GameObject) GameObject.Instantiate(Resources.Load("prefab/bullets/midGunBullet"),bulletStartPosition,Quaternion.identity);
				bringToBack(type,tmp.GetComponent<BulletContainer>());
			}
		}
		else if(type==BulletType.GUN_LARGE_BULLET)
		{
			for(i=0;i<count;i++)
			{
				tmp=(GameObject) GameObject.Instantiate(Resources.Load("prefab/bullets/largeGunBullet"),bulletStartPosition,Quaternion.identity);
				bringToBack(type,tmp.GetComponent<BulletContainer>());
			}
		}
	}
Пример #2
0
 public TurretLevel(
     int level,
     int buyPrice,
     int sellPrice,
     float range,
     double fireRate,
     int nbCanons,
     double buildingTime,
     BulletType bullet,
     string canonImageName,
     string baseImageName,
     float bulletHitPoints,
     float bulletSpeed,
     string movingSfx,
     string firingSfx)
 {
     Level = level;
     BuyPrice = buyPrice;
     SellPrice = sellPrice;
     Range = range;
     FireRate = fireRate;
     NbCanons = nbCanons;
     BuildingTime = buildingTime;
     Bullet = bullet;
     CanonImageName = canonImageName;
     BaseImageName = baseImageName;
     BulletHitPoints = bulletHitPoints;
     BulletSpeed = bulletSpeed;
     MovingSfx = movingSfx;
     FiringSfx = firingSfx;
 }
Пример #3
0
        public static void pushBullet(BulletType type, float x, float y, GameTime currentTime, float direction)
        {
            if (Math.Sqrt(Math.Pow(y - LevelState.levelCamera.getFocusPosition().Y, 2) + Math.Pow(x - LevelState.levelCamera.getFocusPosition().X, 2)) > 1000)
            {
                return;
            }

            bool full = true;

            for (int i = 0; i < pool.Length; i++)
            {
                if (pool[i].InUse)
                {
                    continue;
                }
                else
                {
                    full = false;
                    pool[i].add(x, y, type, currentTime, direction);
                    break;
                }
            }

            if (full)
            {
                Console.WriteLine("full");
            }
        }
Пример #4
0
        // Method that creates a bullet and shoots it in any direction
        public Bullet FireBullet(float rotation, float velocity, Color newColor, BulletType type = BulletType.Circle, bool overridemanicmode = false)
        {
            if (AsteroidRebuttal.ManicMode && !overridemanicmode)
                velocity *= 2;

            return new Bullet(Parent, Center, rotation, velocity, newColor, type);
        }
Пример #5
0
        // Simple method that creates a bullet and shoots it in the direction the emitter is facing
        public Bullet FireBullet(float velocity, Color newColor, BulletType type = BulletType.Circle)
        {
            if (AsteroidRebuttal.ManicMode)
                velocity *= 2;

            return new Bullet(Parent, Center, Rotation, velocity, newColor, type);
        }
Пример #6
0
 // Use this for initialization
 void Start () {
     firerate = basicFirerate;
     fireRateTimer = firerate;
     setFirerateUpgrades(startupFirerateCounter);
     bulletType = BulletType.CLASSICBULLET;
     player = GameObject.FindGameObjectWithTag("Player");
 }
Пример #7
0
        public Bullet Get(BulletType type)
        {
            Bullet b = null;

            switch (type)
            {
                case BulletType.Base: b = ((Pool<BasicBullet>) BulletsPools[type]).Get(); break;
                case BulletType.Gunner: b = ((Pool<GunnerBullet>) BulletsPools[type]).Get(); break;
                case BulletType.LaserMultiple: b = ((Pool<MultipleLasersBullet>) BulletsPools[type]).Get(); break;
                case BulletType.LaserSimple: b = ((Pool<LaserBullet>) BulletsPools[type]).Get(); break;
                case BulletType.Missile: b = ((Pool<MissileBullet>) BulletsPools[type]).Get(); break;
                case BulletType.Nanobots: b = ((Pool<NanobotsBullet>) BulletsPools[type]).Get(); break;
                case BulletType.RailGun: b = ((Pool<RailGunBullet>) BulletsPools[type]).Get(); break;
                case BulletType.SlowMotion: b = ((Pool<SlowMotionBullet>) BulletsPools[type]).Get(); break;
                case BulletType.Shield: b = ((Pool<ShieldBullet>) BulletsPools[type]).Get(); break;
                case BulletType.Pulse: b = ((Pool<PulseBullet>) BulletsPools[type]).Get(); break;
                case BulletType.Mine: b = ((Pool<MineBullet>) BulletsPools[type]).Get(); break;
            }

            b.Scene = Simulator.Scene;
            b.Type = type;

            if (!b.AssetsLoaded)
                b.LoadAssets();

            return b;
        }
	public void createBullet(float angle, float speed = 10.0f, BulletType type = BulletType.Basic){//int bulletType = 0) {
		GameObject bullet = null;
		Rigidbody2D bulletRB;
		angle += movementManager.currentShotAngle();
		if(type == BulletType.Basic){//bulletType == 0) {
			bullet = ((GameObject)Instantiate (basicBulletPrefab, transform.position, 
				Quaternion.Euler (0.0f, 0.0f, 0.0f)));
		} else if(type == BulletType.Stray){//bulletType == 1) {
			bullet = ((GameObject)Instantiate (strayBulletPrefab, transform.position, 
				Quaternion.Euler (0.0f, 0.0f, 0.0f)));
		} else if(type == BulletType.Block){//2) {
			bullet = ((GameObject)Instantiate (squareBulletPrefab, transform.position, 
				Quaternion.Euler (0.0f, 0.0f, 0.0f)));
		} else if(type == BulletType.Roundabout){//bulletType == 4) {
			bullet = ((GameObject)Instantiate (circleBulletPrefab, transform.position, 
				Quaternion.Euler (0.0f, 0.0f, 0.0f)));
		} else if(type == BulletType.Point){//bulletType == 5) {
			bullet = ((GameObject)Instantiate (triangleBulletPrefab, transform.position, 
				Quaternion.Euler (0.0f, 0.0f, 0.0f)));
		}
		bulletRB = bullet.GetComponent<Rigidbody2D> ();

		bulletRB.rotation = angle - 90f;

		bulletRB.velocity = new Vector2(Mathf.Cos(angle * Mathf.Deg2Rad), Mathf.Sin(angle * Mathf.Deg2Rad)) * speed;

		OwnerScript script = bullet.GetComponent<OwnerScript>();
		Player player = gameObject.GetComponent<Player>();
		script.Initialize(type, gameObject, gameObject.GetComponent<PlayerHealth>().opponent, player.number); 
		BulletManager.Instance.AddBullet(bullet);
	}
Пример #9
0
	void GetBulletType(int newType)
	{
		if(newType==-1) // Example
			myBulletType = new ANewBulletType();
		else if(newType>=0)
			myBulletType = new BasicBullet();
		myBulletType.script = this;
	}
Пример #10
0
 public override void onShoot(int energy_, params object[] args)
 {
     energy = energy_;
     type = (BulletType)args[0];
     // Because a bullet updates twice, effective speed is 12
     speedx = anglex * 6.0;
     speedy = angley * 6.0;
 }
Пример #11
0
 public Bullet getBullet(BulletType type)
 {
     if (type == BulletType.STANDARD)
         return getStandardBullet ();
     else if (type == BulletType.PIERCING)
         return getPiercingBullet ();
     else
         return getGranadeBullet ();
 }
Пример #12
0
 // Use this for initialization
 void Start() {
     firerate = basicFirerate;
     fireRateTimer = firerate;
     setUpgrades(startupUpgradeCounter);
     bulletType = BulletType.ROCKET;
     player = GameObject.FindGameObjectWithTag("Player");
     damage = basicDamage;
     explosionSize = basicExplosionSize;
 }
Пример #13
0
 public override Element factory(BulletType type, int x, int y,Direction dir)
 {
     switch (type)
     {
         case BulletType.PlayerBullet: return new PlayerBullet(x, y, dir);
         case BulletType.AnamyBullet: return new EnemyBullet(x, y, dir);
     }
     return null;
 }
Пример #14
0
    // Use this for initialization
    void Start () {
        laserPower = initialLaserPower;
        setLaserUpgrades(startupLaserPowerCounter);
        bulletType = BulletType.LASER;
        player = GameObject.FindGameObjectWithTag("Player");
        lr = GetComponent<LineRenderer>();
        lr.sortingLayerName = "player";
        lr.enabled = false;

    }
Пример #15
0
    /**
     *
     * Returns force backwards that can be used for e.g. player recoil
     **/
    public Vector3 shoot(Vector3 direction, float angle, BulletType bulletType)
    {
        // Assign bullet properties
        CreateBullet(bulletType);

        Vector3 velocityChange = Quaternion.Euler(0.0F, 0.0F, angle) * (BulletSpeed * direction);
        this.rb.velocity = velocityChange;

        return -velocityChange * Mass * RecoilCoefficient;
    }
Пример #16
0
	public void Shoot(BulletType type, Vector2 pos, float rot, Vector2 vel, int pID)
	{
		//Shoot bullet on server
		string s = BulletDir.toString(pos, rot, vel, pID);
		s += ":"+type;

        PhotonView pun = GetComponent<PhotonView>();
		pun.RPC("ShootServer",PhotonTargets.All,s);
		//ShootClient(type,pos,rot,vel); //Shoot bullet on client

	}
Пример #17
0
        /// <summary>
        /// Constructs bullet entity.
        /// </summary>
        /// <param name="bulletColour">Colour of bullet.</param>
        /// <param name="bulletType">Type of bullet.</param>
        /// <param name="owner">Owner of bullet.</param>
        /// <param name="position">Spawn position of bullet.</param>
        /// <param name="trajectory">Trajectory of bullet.</param>
        public BulletEntity(BulletColour bulletColour, BulletType bulletType, Entity owner, Point position, Vector trajectory)
            : base(bulletType.ToString() + bulletColour.ToString(), InitBounding(bulletType, position, trajectory), 1)
        {
            _bulletColour = bulletColour;
            _bulletType = bulletType;
            _owner = owner;
            _trajectory = trajectory;
            _grazed = false;

            _movement = new Linear(trajectory);
        }
Пример #18
0
 public void SetBulletType(int index, BulletType type)
 {
     if(type == BulletType.Empty)
     {
         BulletSlots[index].renderer.enabled = false;
     }
     else
     {
         BulletSlots[index].renderer.enabled = true;
     }
 }
Пример #19
0
	void ShootClient(BulletType type, Vector2 pos, float rot, Vector2 vel)
	{
		foreach(var v in BulletOptions)
		{
			if(v.type == type)
			{
				GameObject NewBullet = (GameObject)Instantiate(v.Prefab, pos, Quaternion.identity);
                //GameObject NewBullet = PhotonNetwork.Instantiate(bulletName, pos, Quaternion.identity);
				NewBullet.transform.eulerAngles = new Vector3(0,0,rot);
				NewBullet.GetComponent<BulletSpawn>().Init(vel, false, PhotonNetwork.player.ID);
			}
		}
	}
Пример #20
0
 /// <summary>
 /// Instanciates a new bullet.
 /// </summary>
 /// <param name="outX">The x position the bullet was fired from.</param>
 /// <param name="outY">The y position the bullet was fired from.</param>
 /// <param name="bulletPower">The power of the bullet.</param>
 /// <param name="bulletSpeed">The speed of the bullet.</param>
 /// <param name="bulletType">The type of the bullet.</param>
 /// <param name="direction">The direction of the bullet.</param>
 public Bullet(int outX, int outY, int bulletPower, double bulletSpeed, BulletType bulletType, MoveDirection direction)
 {
     this.speed = bulletSpeed;
     this.x = outX;
     this.y = outY;
     this.BulletPower = bulletPower;
     this.bulletType = bulletType;
     this.spriteSize.Width = 32;
     this.spriteSize.Height = 32;
     this.Direction = direction;
     this.collitionRectangle = new Rectangle(x, y, spriteSize.Width, spriteSize.Height);
     SetBulletSpesific();
 }
Пример #21
0
 public int getShotCount(BulletType type)
 {
     switch (type)
     {
         case BulletType.HeavyShot:
             return heavyShot;
         case BulletType.ScatterShot:
             return scatterShot;
         case BulletType.MissileDrop:
             return missileDropShot;
         default:
             return 999;
     }
 }
Пример #22
0
    /// <summary>
    /// This function creates the Object Pool for bullet Game Objects
    /// </summary>
    /// <param name="playerBulletType"></param>
    /// <param name="enemyBulletType"></param>
    private void _BuildBulletPool(BulletType playerBulletType, BulletType enemyBulletType)
    {
        // create empty Queue structure
        m_playerBulletPool = new Queue <GameObject>();
        m_enemyBulletPool  = new Queue <GameObject>();

        for (int count = 0; count < MaxBullets; count++)
        {
            var tempPlayerBullet = BulletFactory.Instance().createBullet(playerBulletType);
            m_playerBulletPool.Enqueue(tempPlayerBullet);

            var tempEnemyBullet = BulletFactory.Instance().createBullet(enemyBulletType);
            m_enemyBulletPool.Enqueue(tempEnemyBullet);
        }
    }
Пример #23
0
        // Stores the script manager that belongs to the parent if it exists
        public Bullet(GameObject newParent, Vector2 newPosition, float newRotation, float newVelocity, Color newColor, BulletType type = BulletType.CircleSmall)
        {
            parent = newParent;

            // Because the Origin does not exist yet, set Position here and update it later once Origin exists.
            Position = newPosition;

            Rotation = newRotation;
            Velocity = newVelocity;

            Color = newColor;
            bulletType = type;

            Initialize();
        }
Пример #24
0
    public void StartSpecialBehavior(BulletType BehaviorType)
    {
        StopAllCoroutines();

        switch(BehaviorType){
        case BulletType.Normal:
            break;
        case BulletType.SpiralIn:
            StartCoroutine(SpiralIn());
            break;
        default:
            print("Please write special behavior code for " + BehaviorType.ToString() + ".");
            break;
        }
    }
Пример #25
0
    public Bullet GetBullet(BulletType bulletType)
    {
        var data = GetBulletData(bulletType);

        foreach (var bullet in data.bulletList)
        {
            if (!bullet.gameObject.activeSelf)
            {
                bullet.gameObject.SetActive(true);
                return(bullet);
            }
        }

        return(InstantiateBullet(data.bulletPrefab, data.bulletList, true));
    }
Пример #26
0
    public new void Start()
    {
        Collider col = GetComponent <Collider>();

        if (!col)
        {
            return;
        }
        GetComponent <Collider>().isTrigger = true;

        Rigidbody rig = GetComponent <Rigidbody>();

        if (!rig)
        {
            rig = gameObject.AddComponent <Rigidbody>();
        }
        rig.useGravity = false;

        if (parent == null)
        {
            parent = transform.parent.GetComponent <Bullet>();
        }

        bulletType = parent.bulletType;

        //AttackArea用の初期設定
        gameObject.tag = Tags.Magic;
        aligment       = aligment.player;
        character      = parent.parent;

        //爆弾として生成された場合の処理
        if (isBomb)
        {
            //持続ダメージの発生はビームの処理を流用中
            bulletType = BulletType.beam;
            Damage     = parent.BombDamage;
        }
        else
        {
            Damage = parent.damage;
        }
        bombDamage = parent.BombDamage;

        base.Start();

        _pos = _nowPos = transform.position;
        //transform.localEulerAngles = Vector3.zero;
    }
Пример #27
0
        public void shoot(float power)
        {
            if (type != BulletType.BasicBullet)
            {
                if (inventory.getShotCount(type) <= 0)
                {
                    type = inventory.findNextShotType();
                }

                switch (type)
                {
                case BulletType.HeavyShot:
                    bullet = new HeavyShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                    break;

                case BulletType.ScatterShot:
                    bullet = new ScatterShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                    break;

                case BulletType.TeleportShot:
                    bullet = new TeleportShot(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                    break;

                case BulletType.MissileDrop:
                    bullet = new MissileDrop(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
                    break;
                }

                inventory.decrementShot(type);
            }
            else
            {
                bullet = new Bullet(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8));
            }

            bullet.speed = turretDirection * new Vector2(power, -power);
            ((TankGame)Game).soundManager.shoot.Play();
            Game.Components.Add(bullet);
            recoil       = true;
            shotPosition = tankPosition.X;

            shotPuff = new Puff(game, new Vector2(turretPosition.X + turretPic.Width / 2, turretPosition.Y - turretPic.Height / 8), turretDirection, power);
            shotPuff.AutoInitialize(game.GraphicsDevice, game.Content, TankGame.spriteBatch);

            shotPuff.UpdateOrder = 100;
            shotPuff.DrawOrder   = 100;
            shotPuff.Visible     = true;
        }
Пример #28
0
        public static void SpawnBullet(Vector2 position, bool right, BulletType type)
        {
            if (numberofBullets < 100)
            {
                switch (type)
                {
                case BulletType.revolver:
                    bullets[numberofBullets]            = new RevolverBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.kanone:
                    bullets[numberofBullets]            = new KanoneBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.seestern:
                    bullets[numberofBullets]            = new SeesternBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.knife:
                    bullets[numberofBullets]            = new MesserBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.cthullu:
                    bullets[numberofBullets]            = new CthulluBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.seifenblase:
                    bullets[numberofBullets]            = new SeifenblaseBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.regenbogen:
                    bullets[numberofBullets]            = new RegenbogenBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;

                case BulletType.spitzspitz:
                    bullets[numberofBullets]            = new SpitzspitzBullet(right);
                    bullets[numberofBullets++].position = position;
                    break;
                }
            }
        }
Пример #29
0
    //在死亡池中查找
    public BulletMove takebullet(BulletType Type)
    {
        var temp = diepool.First;

        for (int i = 0; i < diepool.Count; ++i)
        {
            if (temp.Value.type == Type)
            {
                lifepool.AddLast(temp.Value);
                diepool.Remove(temp.Value);
                return(temp.Value);
            }
            temp = temp.Next;
        }
        return(null);
    }
Пример #30
0
    public void Fire(float angle, float delta, int count, BulletType proto, int alterIndex)
    {
        Vector3 beg = new Vector3(0f, angle, 0f);

        if (space == Space.Self)
        {
            beg += transform.eulerAngles;
        }
        for (int i = 0; i < count; i++)
        {
            Vector3    euler = beg + new Vector3(0f, delta * i, 0f);
            BulletType type  = i == alterIndex?AlterType(proto) : proto;

            EnemyBulletManager.instance.SetBullet(type, transform.position, euler);
        }
    }
Пример #31
0
    private void PreinstantiateBullets(BulletType bulletType, int numberOfBulletsToPreinstantiate)
    {
        Queue <Bullet> bullets = Instance.bulletsAvailable[bulletType];

        for (int index = 0; index < numberOfBulletsToPreinstantiate; index++)
        {
            Bullet bullet = InstantiateBullet(bulletType);
            if (bullet == null)
            {
                Debug.LogError(string.Format("Failed to instantiate {0} bullets.", numberOfBulletsToPreinstantiate));
                break;
            }

            bullets.Enqueue(bullet);
        }
    }
Пример #32
0
        public ShotgunSystem(Texture2D texture, Vector2 position, Texture2D bulletTexture, int pellets, float spreadPercent) : base(texture, position, bulletTexture)
        {
            //float spreadPercent = 0.5f;

            float MaxSpreadWidth = 2 * spreadPercent;
            float calculation    = MaxSpreadWidth / (pellets - 1);

            for (int i = 0; i < pellets; i++)
            {
                directions.Add(new Vector2(spreadPercent - (i * calculation), -1));
            }


            RunTimerSetup(WeaponStatistics.SHOTGUN_FIREDELAY, WeaponStatistics.RESTOCKTIMER);
            bulletType = new BulletType(BulletType.bulletType.Normal);
        }
Пример #33
0
    public void RemoveBloodCell(BulletType cellType, int amount = 1)
    {
        if (!whiteBloodCells.ContainsKey(cellType))
        {
            return;
        }

        if (whiteBloodCells[cellType] - amount < 0)
        {
            whiteBloodCells[cellType] = 0;
        }
        else
        {
            whiteBloodCells[cellType] = whiteBloodCells[cellType] - amount;
        }
    }
Пример #34
0
    public void elementEffect(BulletType bulletType)
    {
        switch (bulletType)
        {
        case BulletType.fireBullet:
            StartCoroutine(Burn());
            break;

        case BulletType.iceBullet:
            StartCoroutine(Freeze());
            break;

        case BulletType.none:
            return;
        }
    }
Пример #35
0
    public void Init(Vector3 direction, BulletType bulletType)
    {
        SetBulletType(bulletType);

        if (bulletType == BulletType.AoE)
        {
            for (int i = 0; i < m_ExplosionHits.Length; i++)
            {
                m_ExplosionHits[i] = null;
            }
        }

        m_Direction       = direction;
        m_CurrentLifeTime = m_CurrentScriptableBullet.BulletLifeTime;
        GenerateEffects();
    }
Пример #36
0
    /// <summary>
    /// 创建一个新的子弹
    /// </summary>
    private BaseBulletController CreateBulletUtil(BulletType type, Transform parent, Vector3 pos, int power)
    {
        //根据子弹类型 生成数据
        BaseBulletInfo data = BulletInfo.Instance.GetBulletData(type, power);

        GameObject bulletGo = ResourcesLoadManager.LoadBulletResources <GameObject>(data.bulletResName);
        GameObject bullet   = GameObject.Instantiate <GameObject>(bulletGo);

        bullet.transform.SetParent(GameController.Instance.BulletGroup);

        BaseBulletController bulletController = bullet.AddComponent <BaseBulletController>();

        bulletController.InitBulletData(parent, bullet.transform, pos, data);

        return(bulletController);
    }
Пример #37
0
    /// <summary>
    /// 死亡池寻找
    /// </summary>
    /// <param name="type"> 子弹种类</param>
    /// <returns></returns>
    public EnemyBullet FindInDeathPool(BulletType type)
    {
        EnemyBullet eBullet = null;

        foreach (EnemyBullet item in deatehBulletPool)
        {
            if (item.typeOfBullet == type)
            {
                eBullet = item;
                deatehBulletPool.Remove(eBullet);
                eBullet.gameObject.SetActive(true);
                break;
            }
        }
        return(eBullet);
    }
Пример #38
0
    private void DropWeapon()
    {
        GameObject         test       = Instantiate(playerData.weapon, transform.position + transform.up * canonOut * 2, transform.rotation);
        WeaponDropedscript weaponData = test.GetComponent <WeaponDropedscript>();

        weaponData.owner        = this.gameObject;
        weaponData.myBulletType = this.bulletType;
        weaponData.myWeaponType = this.weaponType;
        weaponData.ammoInside   = this.ammo;
        weaponData.maxAmmo      = this.maxAmmo;

        bulletType = BulletType.None;
        weaponType = WeaponType.None;
        ammo       = 0;
        maxAmmo    = 0;
    }
Пример #39
0
 public void NoDamageShield(BulletType type)
 {
     if (data.baseStats.bulletType[currentType].Equals(type))
     {
         Debug.Log("No Damage");
         HealthPlayer player = FindObjectOfType <HealthPlayer>();
         player.Damage(0);
     }
     else
     {
         Debug.Log("Damage");
         HealthPlayer player = FindObjectOfType <HealthPlayer>();
         Bullet       bullet = FindObjectOfType <Bullet>();
         player.Damage(bullet.damage);
     }
 }
Пример #40
0
        /***** 弾を出す処理 ****************************************************/
        // 指定された角度で弾を撃つ
        protected void ShotBullet(
            BulletType type,
            float deg,
            float?speed = null, float?accel = null, float?size = null, Color?color = null)
        {
            // 発射位置と向き
            Vector3 genPos = this.transform.position;
            Vector3 genRot = this.transform.eulerAngles;

            bulletGenerator.ShotBullet(
                genPos, genRot, type, deg,
                moveSpeed: speed,
                accel: accel,
                size: size,
                color: color);
        }
Пример #41
0
    private static Type getBulletByType(BulletType type)
    {
        Type t = null;

        switch (type)
        {
        case BulletType.normal:
            t = typeof(BulletNormal);
            break;

        default:
            t = typeof(BulletNormal);
            break;
        }
        return(t);
    }
Пример #42
0
        public void Initialize(BulletType type, Vector3 Position, Vector3 direction, float speed, float option)
        {
            _bulletType = type;
            _Pinit      = Position;

            _Vinit = Vector3.Normalize(direction);

            if (type == BulletType.Random)
            {
                float theta = Random.Range(0, Mathf.PI * 2);
                _Vinit = new Vector3(Mathf.Cos(theta), Mathf.Sin(theta), 0);
            }

            _speed  = speed;
            _option = option;
        }
Пример #43
0
        /// <summary>
        /// 获取弹型配置
        /// </summary>
        /// <param name="styleId"></param>
        /// <returns></returns>
        public LaserStyleCfg GetLaserStyleCfg(BulletType type, int styleId)
        {
            int len = _styleCfgList.Count;

            for (int i = 0; i < len; i++)
            {
                if (_styleCfgList[i].type == type && _styleCfgList[i].styleId == styleId)
                {
                    return(_styleCfgList[i]);
                }
            }
            return(new LaserStyleCfg
            {
                type = BulletType.Undefined
            });
        }
Пример #44
0
        /// <summary>
        /// 获取激光的配置
        /// </summary>
        /// <returns></returns>
        public List <LaserStyleCfg> GetLaserStyleCfgsByType(BulletType type)
        {
            List <LaserStyleCfg> cfgs = new List <LaserStyleCfg>();
            LaserStyleCfg        cfg;
            int len = _styleCfgList.Count;

            for (int i = 0; i < len; i++)
            {
                cfg = _styleCfgList[i];
                if (cfg.type == type)
                {
                    cfgs.Add(cfg);
                }
            }
            return(cfgs);
        }
Пример #45
0
 /// <summary>
 /// 根据子弹类型以及id获取子弹原型的名称
 /// </summary>
 /// <param name="type"></param>
 /// <param name="bulletId"></param>
 /// <returns></returns>
 private string GetProtoTypeNameByBulletTypeAndId(BulletType type, string bulletId)
 {
     if (type == BulletType.Enemy_Laser)
     {
         return("EnemyLaser" + bulletId);
     }
     if (type == BulletType.Enemy_LinearLaser)
     {
         return("EnemyLinearLaser" + bulletId);
     }
     if (type == BulletType.Enemy_CurveLaser)
     {
         return("EnemyCurveLaser" + bulletId);
     }
     return(bulletId);
 }
Пример #46
0
        public Bullet(GameObject gameObject, BulletType type, float dirRotation) : base(gameObject)
        {
            canRelease = true;

            switch (type)
            {
            case BulletType.BasicBullet:
                this.movementSpeed = Constant.basicBulletMovementSpeed;
                this.lifeSpan      = Constant.basicBulletLifeSpan;
                this.bulletDmg     = Constant.basicBulletDmg;
                break;

            case BulletType.BiggerBullet:
                this.movementSpeed = Constant.biggerBulletMovementSpeed;
                this.lifeSpan      = Constant.biggerBulletLifeSpan;
                this.bulletDmg     = Constant.biggerBulletDmg;
                break;

            case BulletType.ShotgunPellet:
                this.movementSpeed = Constant.shotgunPelletMovementSpeed;
                this.lifeSpan      = Constant.shotgunPelletLifeSpan;
                this.bulletDmg     = Constant.shotgunPelletDmg;
                break;

            case BulletType.SniperBullet:
                this.movementSpeed = Constant.sniperBulletMovementSpeed;
                this.lifeSpan      = Constant.sniperBulletLifeSpan;
                this.bulletDmg     = Constant.sniperBulletBulletDmg;
                break;

            case BulletType.SpitterBullet:
                this.movementSpeed = Constant.spitterBulletMovementSpeed;
                this.lifeSpan      = Constant.spitterBulletLifeSpan;
                this.bulletDmg     = Constant.spitterBulletDmg;
                break;

            default:
                break;
            }
            this.bulletType  = type;
            this.dirRotation = dirRotation;

            shouldDie              = false;
            this.timeStamp         = GameWorld.Instance.TotalGameTime;
            spriteRenderer         = (SpriteRenderer)GameObject.GetComponent("SpriteRenderer");
            spriteRenderer.UseRect = true;
        }
Пример #47
0
        private static void AddConcreteBulletComponent(GameObject bulletObject, BulletType bulletType)
        {
            switch (bulletType)
            {
            case BulletType.Projectile:
                bulletObject.AddComponent <ProjectileBullet>();
                break;

            case BulletType.Hitscan:
                bulletObject.AddComponent <HitscanBullet>();
                break;

            default:
                Debug.LogError("Couldn't find matching bullet component for bullet type.");
                break;
            }
        }
Пример #48
0
        public Bullet(Layer bulletLayer, BulletType bulletType)
        {
            this.Collidable = true;
            this.BulletType = bulletType;

            ParticleEffect effect = GameManager.Content.Load<ParticleEffect>(@"ParticleEffects/smoke1");
            this.ParticleEngine = new ParticleEngine(effect);
            bulletLayer.AddChild(this.ParticleEngine);

            ParticleEffect effect2 = GameManager.Content.Load<ParticleEffect>(@"ParticleEffects/smokePuff");
            this.ExplosionParticles = new ParticleEngine(effect2);
            bulletLayer.AddChild(this.ExplosionParticles);

            this.LoadTexture(this.BulletType.TextureName);
            this.AddCollisionGroup("bullet");
            this.Deactivate();
        }
Пример #49
0
        public void CreateHeldBullet(BulletType _type, Vector3 _pos)
        {
            switch (_type)
            {
            case BulletType.Normal:
                this.factory.CreateHeldNormalBullet(this.playerNumber, GetFreeActor(), "right", _pos);
                this.factory.CreateHeldNormalBullet(this.playerNumber, GetFreeActor(), "left", _pos);
                break;

            case BulletType.Special:
                break;

            case BulletType.Skill:

                break;
            }
        }
Пример #50
0
        public void SetInfo(Transform _target, BulletType _type, float _delay, float _speed1, float _duringTime, float _speed2, float _missileTime, float _missileTurnSpeed)
        {
            target = _target;
            type   = _type;

            waitTime1 = Time.time + _delay;
            speed1    = _speed1;
            waitTime2 = waitTime1 + _duringTime;
            speed2    = _speed2;

            duringTime = _duringTime;
            speed      = speed1;

            missileTime      = _missileTime;
            waitMissleTime   = waitTime1 + _missileTime;
            missileTurnSpeed = _missileTurnSpeed;
        }
Пример #51
0
    public Sprite GetSprite(BulletType type)
    {
        switch (type)
        {
        case BulletType.EVEN:
            return(spEven);

        case BulletType.DIVISIBLE_3:
            return(spDiv3);

        case BulletType.PRIME:
            return(spPrime);

        default:
            return(null);
        }
    }
Пример #52
0
        public Bullet(Texture2D sprite, Vector2 direction, float speed, float time, Colour colour, bool[] hostileToPlayer, BulletType type, float scale, Player p)
            : base(sprite)
        {
            this.velocity = direction * speed;
            this.rotation = GetRotation(direction);
            this.position = direction;
            this.Colour = colour;
            this.HostileToPlayer = hostileToPlayer;
            this.scale = new Vector2(scale);
            this.type = type;
            this.player = p;
            this.lifeTime = time;

            dir = direction;

            start = position;
        }
Пример #53
0
        public BulletBuilder(string name, BulletType type) : base(name)
        {
            switch (type)
            {
            case BulletType.BulletWithFireStrategy:
                TagPrefab = UnityPaths.TagPlayerMainCannon;
                break;

            case BulletType.AdditionalBullet:
                TagPrefab       = UnityPaths.TagPlayerAdditionalBullets;
                DirDestination += UnityPaths.DirSuffixAdditional;
                break;

            default:
                throw new ArgumentException($"UNKNOWN BULLET {type}");
            }
        }
Пример #54
0
 public void incrementShot(BulletType type)
 {
     switch (type)
     {
         case BulletType.HeavyShot:
             heavyShot++;
             break;
         case BulletType.ScatterShot:
             scatterShot++;
             break;
         case BulletType.MissileDrop:
             missileDropShot++;
             break;
         default:
             break;
     }
 }
Пример #55
0
    /// <summary>
    /// 将子弹Go添加到对应层级上
    /// </summary>
    /// <param name="type"></param>
    /// <param name="prefab"></param>
    private void AddBulletGoToLayer(BulletType type, GameObject prefab)
    {
        switch (type)
        {
        case BulletType.Enemy_Simple:
        case BulletType.Enemy_Laser:
        case BulletType.Enemy_LinearLaser:
        case BulletType.Enemy_CurveLaser:
            UIManager.GetInstance().AddGoToLayer(prefab, LayerId.EnemyBarrage);
            break;

        case BulletType.Player_Simple:
        case BulletType.Player_Laser:
            UIManager.GetInstance().AddGoToLayer(prefab, LayerId.PlayerBarage);
            break;
        }
    }
Пример #56
0
    /// ----------------------------------------------------------------------------------------------
    /// ---------------------------------- PRIVATE FUNCTIONS -----------------------------------------
    /// ----------------------------------------------------------------------------------------------

    // Activate the inactive bullet.
    void ActivateBullet(BulletType bulletType)
    {
        Transform trans = null;

        if (bulletType == BulletType.PRIMARY)
        {
            trans = BulletManager.sSingleton.GetPlayerBullet();
        }
        else
        {
            trans = BulletManager.sSingleton.GetPlayerRocket();
        }

        trans.position = transform.position + transform.up * (mPlayerSize.y / 2);
        trans.rotation = transform.rotation;
        trans.gameObject.SetActive(true);
    }
Пример #57
0
        // Method that creates a cluster of bullets in a random spread and at variable velocity.
        public Bullet[] FireBulletCluster(float rotation, int numberOfBullets, float spread, float baseVelocity, float randomVelocity, Color newColor, BulletType type = BulletType.Circle)
        {
            if (AsteroidRebuttal.ManicMode)
                baseVelocity *= 2;

            List<Bullet> bullets = new List<Bullet>();
            spread = VectorMathHelper.DegreesToRadians(spread);
            float launchRotation;
            float velocity;

            for (int i = 0; i < numberOfBullets; i++)
            {
                velocity = baseVelocity + ((float)rand.NextDouble() * randomVelocity);
                launchRotation = rotation + ((((float)rand.NextDouble() * 2) - 1) * (spread / 2));
                bullets.Add(FireBullet(launchRotation, velocity, newColor, type));
            }

            return bullets.ToArray();
        }
Пример #58
0
 public TurretLevel()
 {
     Level = 1;
     BuyPrice = 0;
     SellPrice = 0;
     Range = 1;
     FireRate = 1;
     NbCanons = 1;
     BuildingTime = 1;
     Bullet = BulletType.None;
     CanonImageName = "";
     BaseImageName = "";
     BulletHitPoints = 0;
     BulletExplosionRange = 1;
     BulletSpeed = 0;
     MovingSfx = "";
     FiringSfx = "";
     BulletExplosionSfx = "";
 }
Пример #59
0
    // Feel free to add your own type of bullet. Remember to define it in BulletType.cs
    private void CreateBullet(BulletType bulletType)
    {
        float damage, recoilCoefficent, bulletSpeed, mass;
        switch (bulletType)
        {
            // SHOTGUN
            case BulletType.MINOR:
                damage = 0.08F;
                recoilCoefficent = 20.0F;
                bulletSpeed = 80.0F;
                mass = 2.0F;
                lifeSpan = 0.4F;
                break;
            // MACHINEGUN
            case BulletType.HEAVY:
                damage = 0.05F;
                recoilCoefficent = 2.0F;
                bulletSpeed = 80.0F;
                mass = 4.0F;
                lifeSpan = 2.0F;
                break;
            case BulletType.EXPLOSIVE:
                damage = 0.1F;
                recoilCoefficent = 15.0F;
                bulletSpeed = 10.0F;
                mass = 4.0F;
                lifeSpan = 2.0F;
                break;
            default:
                damage = 0.1F;
                recoilCoefficent = 10.0F;
                bulletSpeed = 30.0F;
                mass = 2.0F;
                lifeSpan = 2.0F;
                break;
        }

        this.Damage = damage;
        this.RecoilCoefficient = recoilCoefficent;
        this.BulletSpeed = bulletSpeed;
        this.Mass = mass;
    }
Пример #60
0
 /// <summary>
 /// This method instanciates a new enemey.
 /// </summary>
 /// <param name="x">The x start positon.</param>
 /// <param name="startPosition">The start position on the level map.</param>
 /// <param name="speed">The speed of the enemey</param>
 /// <param name="movePattern">Which move pattern the enemy uses.</param>
 /// <param name="enemyType">Which type of enemey this is.</param>
 /// <param name="bulletType">Which type of bullets the enemy fires.</param>
 /// <param name="bulletPower">How powerfull the enemy bullets are.</param>
 /// <param name="bulletSpeed">How fast the enemey bullets are.</param>
 /// <param name="bulletReloadTime">How long it takes for the plane to reload.</param>
 /// <param name="shieldThicknes">How thick the shiled of the enemy is.</param>
 /// <param name="score">The score the player recives by killing this enemey.</param>
 public Enemy(int x, int startPosition, double speed, MovePattern movePattern, EnemyType enemyType, BulletType bulletType, int bulletPower, double bulletSpeed, double bulletReloadTime, int power, int score)
 {
     this.x = x;
     this.y = -32;
     this.tempY = this.y;
     this.speed = speed;
     this.score = score;
     this.startPosition = startPosition;
     this.movePattern = movePattern;
     this.enemyType = enemyType;
     this.bulletType = bulletType;
     this.bulletPower = bulletPower;
     this.bulletSpeed = bulletSpeed;
     this.bulletReloadTime = bulletReloadTime;
     this.bulletTick = (int)(bulletReloadTime - (bulletReloadTime / 4)); //Making the plane able to fire the first bullet after one fourth of the bullet reload time.
     this.power = power;
     this.spriteTick = 0;
     this.collitionRectangle = new Rectangle(x, y, spriteSize.Width, spriteSize.Height);
     this.Status = EnemyStatus.Idle;
     SetEnemySpesific();
 }