コード例 #1
0
ファイル: BulletManager.cs プロジェクト: nhhoang/shooting
	public void SetCurrentBulletType(Bullet.Type type, int numBullet = 100) {
		currentType = type;
		switch (currentType) {
			case Bullet.Type.NORMAL:
				reloadTime = 0.5f;
			break;
		}
		
		GameScreenUI.Instance.AddBullet(type, numBullet);
	}
コード例 #2
0
ファイル: BulletUI.cs プロジェクト: nhhoang/shooting
	public void Init(Bullet.Type type, int quantity) {
		bulletType = type;
		this.quantity += quantity;
		lblQuantity.text = this.quantity.ToString();
		
		switch (bulletType) {
			case Bullet.Type.NORMAL:
				sprite.spriteName = "circles_11";
				secondsToReload = 0.5f;
			break;
		}
	}
コード例 #3
0
    private void Fire(Bullet.Type BulletType)
    {
        //Fire may be denied by tutorial
        if (FireAllowed)
        {
            int ShotBullet = mPlayerCharacter.Fire(BulletType);

            //If an ice bullet was shot, freeze the game
            if (ShotBullet == (int)Bullet.Type.Ice)
            {
                //GameFrozen = true;
                mCurrentDifficulty.Freeze();
            }
        }
    }
コード例 #4
0
    public bool Fire(Vector3 position, Bullet.Type type)
    {
        // If the gun is not charging, fire the first bullet in the available list
        if (mInactive.Count > 0 && mCharging <= 0.0f)
        {
            mInactive[0].Fire(type, position);
            mActive.Add(mInactive[0]);
            mInactive.RemoveAt(0);

            //Reset charging time
            mCharging = RechargeTime;

            //Confirm that bullet has been shot
            return(true);
        }

        return(false);
    }
コード例 #5
0
    public int Fire(Bullet.Type BulletType)
    {
        if (mGun != null)
        {           //Decision
            //Inventory is based on the Powerups enum, which is incompatible with the Bullet enum
            //A math expression could be used, but it would be difficult to understand and would break if anything changed about either of the 2 objects
            int invIndex = -1;
            switch (BulletType)
            {
            case Bullet.Type.Ice:
                invIndex = (int)PowerupFactory.Type.Ice;
                break;

            case Bullet.Type.Golden:
                invIndex = (int)PowerupFactory.Type.Golden;
                break;

            case Bullet.Type.Explosive:
                invIndex = (int)PowerupFactory.Type.Explosive;
                break;
            }

            //If a bullet that exists in finite supply has been chosen, check there is enough of it
            if (invIndex >= 0 && Inventory[invIndex] <= 0)
            {
                return(-1);
            }

            //Action
            Vector3 position = transform.position;
            position.y += FireOffset;

            //Only decrease inventory if the bullet was actually fired
            if (mGun.Fire(position, BulletType) && invIndex >= 0)
            {
                Inventory[invIndex]--;
            }
            return((int)BulletType);
        }
        return(-1);
    }
コード例 #6
0
ファイル: Controller.cs プロジェクト: Issung/JuggleNaut
    /// <summary>
    /// Needs work, needs to dequeue the needed type of bullet, Queue might need to be turned into a list.
    /// </summary>
    public static Bullet GetBullet(Bullet.Type type)
    {
        List <Bullet> bulletsOfType = bulletPool.Where(t => t.type == type).ToList();

        if (bulletsOfType.Count < 1)
        {
            GameObject bullet = Instantiate(bulletPrefab);

            if (type == Bullet.Type.Direction)
            {
                bullet.AddComponent(typeof(DirectionBullet));
            }

            return(bullet.GetComponent <Bullet>());
        }
        else
        {
            Bullet bullet = bulletsOfType[0];
            bulletPool.Remove(bullet);
            return(bullet);
        }
    }
コード例 #7
0
ファイル: Game.cs プロジェクト: cacticouncil/ConsoleGames
        public void FireBullet(Bullet.Type type, int x, int y)
        {
            Bullet b = new Bullet(type, x, y);

            mBullets.Add(b);
        }
コード例 #8
0
ファイル: BulletManager.cs プロジェクト: nhhoang/shooting
	public BulletInventory(Bullet.Type type, int total) {
		this.type = type;
		this.total = total;
	}
コード例 #9
0
ファイル: BulletManager.cs プロジェクト: nhhoang/shooting
	void Awake() {
		trans = transform;
		currentType = Bullet.Type.NORMAL;
		Physics.gravity = new Vector3(0, -9.0f, 0);
	}