Example #1
0
 /// <summary>
 /// Called by colliding with a Token (from Token's OnTriggerEnter)
 /// </summary>
 /// <param name="token">Token that was collected</param>
 public override void CollectToken(Token token)
 {
     // Handle what type of token was collected
     if (token.GetType().Equals(typeof(ArrowToken)))
     {
         // Find the running timer associated with the token
         TokenTimer t = timers.Find(i => i.ID.Equals(((ArrowToken)token).Type.ToString()));
         // If the token has not been collected yet
         if (t == null)
         {
             // Add a new Token Timer and initialize it
             TokenTimer tt = gameObject.AddComponent <TokenTimer>();
             tt.Initialize(TokenTimer.TOKEN_INTERVAL, ((ArrowToken)token).Type.ToString());
             // Make sure that the token is removed from the component when the timer times out
             tt.TimeOut += new TokenTimer.TimerEvent(RemoveToken);
             types       = Bitwise.SetBit(types, (int)tt.TokenType);
             timers.Add(tt);
         }
         else
         {
             // Token has already been collected so we just need to reset the timer
             t.Reset();
         }
     }
 }
Example #2
0
        public void RemoveArrowType(Enums.Arrows type)
        {
            // Clear the appropriate token bit and remove the timer from the list of running timers
            types = Bitwise.ClearBit(types, (int)type);
            TokenTimer t = timers.Find(i => i.ID.Equals(type.ToString()));

            timers.Remove(t);
        }
Example #3
0
        // Removes the token from the types the player has collected
        private void RemoveToken(TokenTimer tt)
        {
            // Clear the appropriate token bit and remove the timer from the list of running timers
            types = Bitwise.ClearBit(types, (int)tt.TokenType);
            TokenTimer t = timers.Find(i => i.ID.Equals(tt.TokenType.ToString()));

            timers.Remove(t);
        }
Example #4
0
 public void AddArrowType(Enums.Arrows type)
 {
     if (type > 0 && type < Enums.Arrows.NumTypes)
     {
         // Find the running timer associated with the type
         TokenTimer t = timers.Find(i => i.ID.Equals(type.ToString()));
         // If the type has not been added yet
         if (t == null)
         {
             // Add a new Token Timer and initialize it
             TokenTimer tt = gameObject.AddComponent <TokenTimer>();
             tt.Initialize(TokenTimer.TOKEN_INTERVAL, type.ToString());
             // Make sure that the type is removed from the component when the timer times out
             tt.TimeOut += new TokenTimer.TimerEvent(RemoveToken);
             types       = Bitwise.SetBit(types, (int)type);
             timers.Add(tt);
         }
         else
         {
             // Type has already been added so we just need to reset the timer
             t.Reset();
         }
     }
 }
Example #5
0
 // Removes the token from the types the player has collected
 private void RemoveToken(TokenTimer tt)
 {
     RemoveArrowType(tt.TokenType);
 }