Untitled
using UnityEngine; public class PlayerController : MonoBehaviour { public float moveSpeed = 5f; // Movement speed public float jumpHeight = 5f; // Jump height public Camera playerCamera; public GameObject bulletPrefab; public Transform bulletSpawnPoint; private CharacterController characterController; void Start() { characterController = GetComponent<CharacterController>(); } void Update() { MovePlayer(); Shoot(); } void MovePlayer() { float horizontal = Input.GetAxis("Horizontal"); float vertical = Input.GetAxis("Vertical"); Vector3 moveDirection = new Vector3(horizontal, 0, vertical).normalized; if (moveDirection.magnitude >= 0.1f) { characterController.Move(moveDirection * moveSpeed * Time.deltaTime); } } void Shoot() { if (Input.GetButtonDown("Fire1")) // Left mouse button { FireBullet(); } } void FireBullet() { Instantiate(bulletPrefab, bulletSpawnPoint.position, bulletSpawnPoint.rotation); } } public class CharacterAbilities : MonoBehaviour { public string characterName; public int level; public float speedBoost = 1.0f; void Start() { // Check for specific character and assign abilities if (characterName == "Ronaldo") { speedBoost = 1.5f; // Ronaldo has a speed boost } else if (characterName == "Dhoni") { speedBoost = 1.2f; // Dhoni has agility } // Adjust the character's speed GetComponent<PlayerController>().moveSpeed *= speedBoost; } } public class LevelingSystem : MonoBehaviour { public int currentXP = 0; public int currentLevel = 1; public int xpToNextLevel = 100; public GameObject[] availableGuns; // Different guns available at each level public GameObject[] availableClothes; // Different clothes/skins available at each level void Update() { if (currentXP >= xpToNextLevel) { LevelUp(); } } void LevelUp() { currentLevel++; currentXP = 0; // Reset XP xpToNextLevel *= 2; // Increase XP needed for next level // Give rewards based on the level EquipRewards(); } void EquipRewards() { // Equip a new gun or clothes based on the player's level if (currentLevel == 5) { // Give a new gun at level 5 EquipGun(availableGuns[1]); } else if (currentLevel == 10) { // Give new clothes at level 10 EquipClothes(availableClothes[1]); } } void EquipGun(GameObject gun) { // Equip the new gun to the player Instantiate(gun, transform.position, Quaternion.identity); } void EquipClothes(GameObject clothes) { // Equip the new clothes to the player Instantiate(clothes, transform.position, Quaternion.identity); } } using Photon.Pun; using UnityEngine; public class MultiplayerController : MonoBehaviourPunCallbacks { public GameObject playerPrefab; void Start() { if (PhotonNetwork.IsConnected) { PhotonNetwork.Instantiate(playerPrefab.name, Vector3.zero, Quaternion.identity); } else { PhotonNetwork.ConnectUsingSettings(); } } public override void OnConnectedToMaster() { Debug.Log("Connected to master"); PhotonNetwork.JoinRandomRoom(); } public override void OnJoinRandomFailed(short returnCode, string message) { PhotonNetwork.CreateRoom(null, new Photon.Realtime.RoomOptions { MaxPlayers = 10 }); } }
Leave a Comment