Ejemplo n.º 1
0
        private void SwitchGun(GunSwitchSide side)
        {
            foreach (var i in _tank)
            {
                ref var guns = ref _tank.Get2(i).weapons;
                _tank.Get2(i).currentWeapon.prefab.SetActive(false);
                int index     = guns.IndexOf(_tank.Get2(i).currentWeapon);
                int lastIndex = guns.Count - 1;

                switch (side)
                {
                case GunSwitchSide.Plus:
                    if (index < lastIndex)
                    {
                        index += 1;
                    }
                    else
                    {
                        index = 0;
                    }
                    break;

                case GunSwitchSide.Minus:
                    if (index > 0)
                    {
                        index -= 1;
                    }
                    else
                    {
                        index = lastIndex;
                    }
                    break;
                }

                _tank.Get2(i).currentWeapon = guns[index];
                _tank.Get2(i).currentWeapon.prefab.SetActive(true);
            }
Ejemplo n.º 2
0
 private void gunSwitchEvent(GunSwitchSide side)
 {
     _world.NewEntity().Get <GunSwitchEvent>().switchSide = side;
 }