I read some script and seem to be complicated to understand. Hope someone can explain why The first:
public static bool ContainsDestroyWholeRowColumn(BonusType bt)
{
return (bt & BonusType.DestroyWholeRowColumn)
== BonusType.DestroyWholeRowColumn;
}
Why don't write bt.Equal(BonusType.DestroyWholeRowColumn)
or bt == BonusType.DestroyWhoeRowColumn
?
The Second:
public bool IsSameType(Shape otherShape)
{
if (otherShape == null || !(otherShape is Shape))// check otherShape is not null and it is Shape
throw new ArgumentException("otherShape");
return string.Compare(this.Type, (otherShape as Shape).Type) == 0;
}
if input method is not the right Type. I think It will be alert immediately, why they also need to check the type of object The last:
//if we are in the middle of the calculations/loops
//and we have less than 3 matches, return a random one
if(row >= Constants.Rows / 2 && matches.Count > 0 && matches.Count <=2)
return matches[UnityEngine.Random.Range(0, matches.Count - 1)];
I thought these code always return 0; What happened? The writer was wrong or I missed some basic knowledge. Please help me if you know. Thanks