示例#1
0
 private int CompareMapItemsByTime(MapItem t1, MapItem t2)
 {
     if (t1.AppearTime > t2.AppearTime)
         return -1;
     else if (t1.AppearTime == t2.AppearTime)
         return 0;
     else
         return 1;
 }
示例#2
0
        private Boolean GetMapItemAcceptance(MapItem tempMapItem, List<MapItem> conflictTestItems)
        {
            Boolean pass = true;

            for (int j = 0; j < /*i*/conflictTestItems.Count; j++)
            {
                if (tempMapItem.Position.Equals(conflictTestItems[j].Position))
                {

                    Boolean tempInDanger = false;

                    if ((tempMapItem.AppearTime >= conflictTestItems[j].AppearTime) & (tempMapItem.AppearTime <= conflictTestItems[j].DisappearTime)) //Temp CoinPile appears after the old CoinPile appears and before the old CoinPile disappears
                    {
                        tempInDanger = true;
                    }
                    else if ((conflictTestItems[j].AppearTime >= tempMapItem.AppearTime) & (conflictTestItems[j].AppearTime <= tempMapItem.DisappearTime))//Old CoinPile appears after the temp CoinPile appears and before the temp CoinPile disappears
                    {
                        tempInDanger = true;
                    }
                    else if ((tempMapItem.AppearTime >= conflictTestItems[j].AppearTime) & (tempMapItem.DisappearTime <= conflictTestItems[j].DisappearTime))//Temp CoinPile appears after the old CoinPile appears and disappears before the old CoinPile does
                    {
                        tempInDanger = true;
                    }
                    else if ((conflictTestItems[j].AppearTime >= tempMapItem.AppearTime) & (conflictTestItems[j].DisappearTime <= tempMapItem.DisappearTime))//Old CoinPile appears after the temp CoinPile appears and disappears before the temp CoinPile does
                    {
                        tempInDanger = true;
                    }

                    if (tempInDanger)
                    {
                        tempMapItem.AppearTime = tempMapItem.AppearTime + 2000;
                        tempMapItem.DisappearTime = tempMapItem.DisappearTime + 2000;
                        if (tempMapItem.DisappearTime <= Constant.LIFE_TIME)
                        {
                            j = 0; //Cheak the compatibility all over again
                        }
                        else
                        {
                            pass = false;//do not add it
                            break;
                        }
                    }
                }
            }

            return (pass);
        }