/// <summary> /// Creates the specified object for the player attached to this object /// </summary> /// <param name="prefab">The prefab to instantiate</param> /// <param name="position">The location at which to spawn the item</param> /// <param name="characterIndex">The index of the selected character</param> /// <param name="playerName">The index of the selected character</param> /// <param name="id">ID of the profile</param> public override Transform Spawn(Transform prefab, Vector3 position, int characterIndex, string playerName, int playerIndex, Guid id) { base.Spawn(prefab, position, characterIndex, playerName, playerIndex, id); // create the player display var spawned = Instantiate(prefab, position, Quaternion.identity); // get the movement script attached to the visual player _movement = spawned.GetComponent <PlayerMovement>(); _movement.SetJumpModifier(0.82f); _movement.AddMovementCallbacks(PlatformLanded, PlatformLeft); _movement.AddTriggerCallbacks(TriggerEnter, null); _movement.SetMasking(SpriteMaskInteraction.VisibleOutsideMask); // set the height of the object SetHeight(spawned, characterIndex); // use the correct animation controller SetAnimation(spawned, characterIndex); // sets the player name _movement.SetPlayerName(true, playerName); return(spawned); }
/// <summary> /// Creates the specified object for the player attached to this object /// </summary> /// <param name="prefab">The prefab to instantiate</param> /// <param name="position">The location at which to spawn the item</param> /// <param name="characterIndex">The index of the selected character</param> /// <param name="playerIndex">The index of the player</param> /// <param name="id">ID of the profile</param> public override Transform Spawn(Transform prefab, Vector3 position, int characterIndex, string playerName, int playerIndex, Guid id) { base.Spawn(prefab, position, characterIndex, playerName, playerIndex, id); // create the player display var spawned = Instantiate(prefab, position, Quaternion.identity); // get the movement script attached to the visual player _movement = spawned.GetComponent <PlayerMovement>(); // assign callbacks for when the item interacts with triggers and colliders _movement.AddTriggerCallbacks(TriggerEnter, TriggerExit); _movement.AddMovementCallbacks(CollisionEnter, null); // get the collider for the player _collider = _movement.GetComponentInChildren <Collider2D>(); // set the height of the object SetHeight(spawned, characterIndex); // use the correct animation controller SetAnimation(spawned, characterIndex); // sets the player name _movement.SetPlayerName(true, playerName); return(spawned); }
/// <summary> /// Creates the specified object for the player attached to this object /// </summary> /// <param name="prefab">The prefab to instantiate</param> /// <param name="position">The location at which to spawn the item</param> /// <param name="characterIndex">The index of the selected character</param> /// <param name="playerIndex">The index of the player</param> /// <param name="id">ID of the profile</param> public override Transform Spawn(Transform prefab, Vector3 position, int characterIndex, string playerName, int playerIndex, Guid id) { base.Spawn(prefab, position, characterIndex, playerName, playerIndex, id); // create the player display var spawned = Instantiate(prefab, position, Quaternion.identity); // get the movement script attached to the visual player _movement = spawned.GetComponent <PlayerMovement>(); // dampen jump force slightly _movement.SetJumpModifier(0.85f); // assign callbacks for when the item interacts with triggers _movement.AddTriggerCallbacks(TriggerEntered_, TriggerExited_); // set collision callbacks (to check landing for spawning trolls) _movement.AddMovementCallbacks(ColliderHit_, null); // set the height of the object SetHeight(spawned, characterIndex); // use the correct animation controller SetAnimation(spawned, characterIndex); _followers = STARTING_FOLLOWERS; // follower _followerSound = (AudioSource)gameObject.AddComponent(typeof(AudioSource)); _followerSound.clip = FollowBackController.Instance.FollowerSound; _followerSound.volume = 0.35f; // selfie _selfieSound = (AudioSource)gameObject.AddComponent(typeof(AudioSource)); _selfieSound.clip = FollowBackController.Instance.SelfieSound; _selfieSound.volume = 0.5f; return(spawned); }