// Deals with player being hit by the book public void HitByBook(BookBehavior bookBehavior) { //get which book hit the player BookBehavior.KnowledgeType adding = bookBehavior.Kind; //check if player was already hit by book if (!activeEffects[(int)adding]) { AddEffect(adding); } else { singleSource.PlayOneShot(nullSound); } }
public void GetBook(BookBehavior bookBehavior) { currentBook = bookBehavior; singleSource.PlayOneShot(liftSound); if (repeatShot) { hold = true; } else { hold = false; } // May want to move the book to the hand position, once we get art and know where that is GetComponent <SpriteRenderer>().sprite = playerSprites[(int)player.PlayerColor]; }
public void Throw(Vector3 fromPosition, bool keep, params Vector3[] directions) { BookBehavior newBookBehavior = null; if (keep) { newBookBehavior = Instantiate(gameObject, transform.parent).GetComponent <BookBehavior>(); newBookBehavior.State = BookState.Held; newBookBehavior._heldBy = _heldBy; newBookBehavior.Kind = Kind; } if (directions[0].sqrMagnitude > 0) { transform.parent = null; _throwDirection = directions[0].normalized; State = BookState.Thrown; GetComponent <CircleCollider2D>().enabled = true; SetHeight(ThrowHeight); _verticalVelocity = InitialVerticalVelocity; _heldBy.GetComponent <RigidbodyController>().LoseBook(); for (int i = 1; i < directions.Length; i++) { BookBehavior extraThrownBookBehavior = Instantiate(gameObject).GetComponent <BookBehavior>(); extraThrownBookBehavior._throwDirection = directions[i].normalized; extraThrownBookBehavior.State = BookState.Thrown; extraThrownBookBehavior.GetComponent <CircleCollider2D>().enabled = true; extraThrownBookBehavior.SetHeight(ThrowHeight); extraThrownBookBehavior._heldBy = _heldBy; extraThrownBookBehavior._verticalVelocity = InitialVerticalVelocity; extraThrownBookBehavior.Kind = Kind; } } if (keep) { _heldBy.GetComponent <RigidbodyController>().GetBook(newBookBehavior); } }
public void LoseBook() { currentBook = null; GetComponent <SpriteRenderer>().sprite = playerRestingSprites[(int)player.PlayerColor]; }