示例#1
0
    private void ChangeColorState()
    {
        float mouseWheel = Input.GetAxis("Mouse ScrollWheel");

        //  scroll up
        if (mouseWheel > 0f)
        {
            colorSelected++;
        }

        // scroll down
        if (mouseWheel < 0f)
        {
            colorSelected--;
        }

        if (colorSelected % colorStateSize == 0)
        {
            colorSelected = 0;
        }

        if (colorSelected < 0)
        {
            colorSelected = colorStateSize + colorSelected;
        }

        currentColorState = (ColorState)colorSelected;

        gunProperties.SetBulletPrefab(bulletPrefabs[colorSelected]);
    }
示例#2
0
 // Use this for initialization
 void Start()
 {
     gunProperties  = GetComponent <GunProperties>();
     gunFire        = gunProperties.GetGunFire();
     colorStateSize = System.Enum.GetNames(typeof(ColorState)).Length;
     gunProperties.SetBulletPrefab(bulletPrefabs[colorSelected]);
     uiColorImage = GameObject.FindWithTag("BulletColourUI").GetComponent <Image>();
 }