/// <summary> /// Spawns a token /// </summary> /// <param name="tokenPrefab">The token to be spawned</param> private void SpawnToken(GameObject tokenPrefab) { tokenPrefab.transform.position = transform.position; // Turn on token since pooling tokenPrefab.SetActive(true); spawnItem = tokenPrefab.GetComponent<Token>(); }
/// <summary> /// Overriding the collect token method from player controller object /// </summary> /// <param name="token">The token that was collected</param> public override void CollectToken(Token token) { // Handle what type of token was collected if (token.GetType().Equals(typeof(HealthToken))) { // Add health back to the player ModifyHealth(((HealthToken)token).Health); } }
/// <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))) { AddArrowType(((ArrowToken)token).Type); } }
/// <summary> /// Overriding the collect token method from player controller object /// </summary> /// <param name="token">The token that was collected</param> public override void CollectToken(Token token) { }
/// <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(); } } }
// Virtual method for collecting battle tokens public abstract void CollectToken(Token token);