A special style of blood bar is needed for the project. The description is as follows:
1. Normal color is red. After being hurt, the amount of blood that will be deducted is dark (dark red), and has the effect of falling animation;
2. After the shield effect, add a portion of the amount of blood, the additional part is white, the shield effect disappears after the portion of the blood loss;
3. When the shield effect is damaged, the white blood amount is deducted first. When the white blood quantity is insufficient, the remainder is deducted from the red blood volume;
4. The white blood amount of the deduction effect is turned gray and has a downward animation effect;
4. When the effect of the shield, if the white blood will be added to the total blood bar "Overflow", the new calculation of the percentage of the blood bar;
5. When poisoning, the corresponding amount of blood (according to the priority of injury to the blood, that is, the first deduction of the shield, then deducted from normal) into purple. The purple blood quantity has the decreasing animation;
6. If the poisoning is injured, do not deduct the amount of purple blood (in fact, the portion has been deducted, but there is a buffer time), but the red or white part;
7. If the poison is affected by the shield effect?
When making ordinary blood strips, we usually use UISlider.
But here is the effect of shielding and poisoning, obviously not enough with UISlider. My first thought is to use multiple blood strips superimposed together, to distinguish between normal blood bar, poison blood bar, shield blood bar. But how to solve the blood-losing effect?
If it's just a drop animation, that's a good solution, but it will darken first, which is obviously a slider.
So I brainwave thought: a blood bar, multiple uislider! We can write a custom blood bar that contains the normal amount of blood, the poison value, the shield value, and the corresponding state attribute.
After practice, my idea is true indeed. First look at the following:
Production of Ngui-enhanced blood strips (Healthbar) in Unity3d