protected bool Compare(float valueToCheck, TypeOfComparison type) { switch (type) { case TypeOfComparison.equals: if (valueToCheck == value) { return(true); } break; case TypeOfComparison.greater: Debug.Log("greater : value to check: " + valueToCheck + ", value + " + value); if (valueToCheck > value) { return(true); } break; case TypeOfComparison.less: if (valueToCheck < value) { return(true); } break; case TypeOfComparison.lessOrEqual: if (valueToCheck <= value) { return(true); } break; case TypeOfComparison.moreOrEqual: if (valueToCheck >= value) { return(true); } break; case TypeOfComparison.notEqual: if (valueToCheck != value) { return(true); } break; default: return(false); } return(false); }
public T Comparison(TypeOfComparison typeOfComparison, T firstTank, T secondTank) { switch (typeOfComparison) { case TypeOfComparison.Armor: { if (firstTank.armor.health > secondTank.armor.health) { return(firstTank); } else { return(secondTank); } } case TypeOfComparison.Engine: { if (firstTank.engine.health > secondTank.engine.health) { return(firstTank); } else { return(secondTank); } } case TypeOfComparison.Gun: { if (firstTank.gun.health > secondTank.gun.health) { return(firstTank); } else { return(secondTank); } } default: { return(firstTank); } } }