public void OnClick(OneMapObjectWeapon who)
        {
            int  id   = who.id;
            bool find = false;

            //find
            for (int i = 0; i < MAX_WEAPON_NUM_CAN_SELECT; i++)
            {
                if (_weapon_ids[i] == id && _weapon_ids[i] != -1)
                {// current index is click and has exist weapon then  cancel it
                    who.SetNumber(0);
                    _weapon_ids[i] = -1;
                    find           = true;
                }
            }
            if (find)
            {
                return;
            }
            //not find ,select a empty to place this id
            for (int i = 0; i < MAX_WEAPON_NUM_CAN_SELECT; i++)
            {
                if (_weapon_ids[i] == -1)
                {// current index is empty
                    _weapon_ids[i] = id;
                    who.SetNumber(i + 1);
                    break;
                }
            }
        }
Esempio n. 2
0
 public void OnCellWeaponClick(OneMapObjectWeapon who)
 {
     if (currentWeapon != null && root != null && root.CurrentStep == MapEditorStep.WeaponSpawn)
     {
         currentWeapon.OnClick(who);
     }
     else
     {
         if (UITips.ins != null)
         {
             UITips.ins.ShowTips("请先选择一个武器出生点!");
         }
     }
 }