3D Workspace
Home
Assets
Affiliate Program
Sign up/Log in
?
Upgrade
DCC Bridge
3D Creation Made Simple
Text & Image to 3D Model in seconds
One-Click Texturing & Smart Detail Editing
Free Credits Monthly
Start Free
Anonymous1768841564
02-10 15:45
Model Name
computer monitor 3d model
Tags
props
rendering
realistic
Prompt
```csharp using UnityEngine; using UnityEngine.Purchasing; using Photon.Pun; using System.Collections.Generic; //================ CORE =================// public class GameCore : MonoBehaviour { public static GameCore Instance; public int curseEnergy = 2000; public int level = 1; public bool noAds = true; void Awake() { if (Instance == null) Instance = this; DontDestroyOnLoad(gameObject); } } //================ LEVEL =================// public class LevelSystem : MonoBehaviour { public int level = 1; public int xp = 0; public int xpNeed = 100; public void AddXP(int amount) { xp += amount; while (xp >= xpNeed) { xp -= xpNeed; level++; xpNeed += 50; GameCore.Instance.curseEnergy += 100; } } } //================ STORY =================// public enum StoryAct { Awakening, World, Tournament, SpecialGrade, Domain, End } public class StoryManager : MonoBehaviour { public static StoryManager Instance; public StoryAct act = StoryAct.Awakening; public int progress; void Awake() { if (Instance == null) Instance = this; DontDestroyOnLoad(gameObject); } public void Advance() { progress++; if (progress >= 5) { act++; progress = 0; GameCore.Instance.curseEnergy += 1000; } } } //================ PLAYER =================// public class PlayerController : MonoBehaviourPunCallbacks { public float speed = 6f; Rigidbody rb; void Start() { rb = GetComponent<Rigidbody>(); if (!photonView.IsMine) enabled = false; } void Update() { float h = Input.GetAxis("Horizontal"); float v = Input.GetAxis("Vertical"); rb.velocity = new Vector3(h * speed, rb.velocity.y, v * speed); } } //================ HEALTH =================// public class HealthSystem : MonoBehaviour { public int hp = 100; public void Damage(int d) { hp -= d; if (hp <= 0) Destroy(gameObject); } } //================ ENERGY =================// public class EnergySystem : MonoBehaviour { public float max = 100; float current; void Start() { current = max; } public bool Use(float cost) { if (current < cost) return false; current -= cost; return true; } } //================ ABILITIES =================// public abstract class AbilityBase : MonoBehaviour { public float cost = 20; EnergySystem energy; void Awake() { energy = GetComponentInParent<EnergySystem>(); } public void Activate() { if (energy.Use(cost)) Execute(); } protected abstract void Execute(); } public class SlashAbility : AbilityBase { public GameObject slash; protected override void Execute() { Instantiate(slash, transform.position + transform.forward, transform.rotation); } } public class DomainAbility : AbilityBase { public GameObject domain; protected override void Execute() { Destroy(Instantiate(domain, transform.position, Quaternion.identity), 15f); } } //================ ABILITY INVENTORY =================// [CreateAssetMenu(menuName = "Ability")] public class AbilityData : ScriptableObject { public string abilityName; public int price; public GameObject prefab; } public class AbilityInventory : MonoBehaviour { public Transform holder; public List<AbilityData> owned = new(); public void Buy(AbilityData a) { if (!owned.Contains(a) && GameCore.Instance.curseEnergy >= a.price) { GameCore.Instance.curseEnergy -= a.price; owned.Add(a); Instantiate(a.prefab, holder); } } public void Activate(int i) { if (i < holder.childCount) holder.GetChild(i).GetComponent<AbilityBase>().Activate(); } } //================ CHARACTERS =================// [CreateAssetMenu(menuName = "Character")] public class CharacterData : ScriptableObject { public string charName; public GameObject prefab; public int price; } public class CharacterInventory : MonoBehaviour { public List<CharacterData> owned = new(); public CharacterData active; public void Buy(CharacterData c) { if (!owned.Contains(c) && GameCore.Instance.curseEnergy >= c.price) { GameCore.Instance.curseEnergy -= c.price; owned.Add(c); active = c; } } } //================ CHARACTER SPIN =================// public class CharacterSpin : MonoBehaviour { public List<CharacterData> all; bool free = true; public void Spin(CharacterInventory inv) { if (free) { free = false; inv.owned.Add(all[Random.Range(0, all.Count)]); } else if (GameCore.Instance.curseEnergy >= 500) { GameCore.Instance.curseEnergy -= 500; inv.owned.Add(all[Random.Range(0, all.Count)]); } } } //================ QUEST =================// [CreateAssetMenu(menuName = "Quest")] public class QuestData : ScriptableObject { public string questName; public int target; public int xp; public int energy; } public class QuestManager : MonoBehaviour { public LevelSystem level; public List<QuestData> active = new(); Dictionary<string, int> progress = new(); public void Accept(QuestData q) { active.Add(q); progress[q.questName] = 0; } public void UpdateQuest(string name) { if (!progress.ContainsKey(name)) return; progress[name]++; QuestData q = active.Find(x => x.questName == name); if (progress[name] >= q.target) { level.AddXP(q.xp); GameCore.Instance.curseEnergy += q.energy; StoryManager.Instance.Advance(); } } } //================ ONLINE =================// public class OnlineManager : MonoBehaviourPunCallbacks { public void Friends() { PhotonNetwork.JoinOrCreateRoom("Friends", new Photon.Realtime.RoomOptions { MaxPlayers = 5 }, null); } public void Squad5v5() { PhotonNetwork.JoinOrCreateRoom("5v5", new Photon.Realtime.RoomOptions { MaxPlayers = 10 }, null); } } //================ CUSTOM PVP ARENA =================// public class PVPArenaManager : MonoBehaviourPunCallbacks { public Transform[] spawnPoints; public float matchTime = 300f; float timer; bool matchActive; Dictionary<int, int> scores = new(); void Start() { if (PhotonNetwork.IsMasterClient) StartMatch(); } void Update() { if (!matchActive) return; timer -= Time.deltaTime; if (timer <= 0) EndMatch(); } void StartMatch() { timer = matchTime; matchActive = true; foreach (var p in PhotonNetwork.PlayerList) photonView.RPC(nameof(SpawnPlayer), p, p.ActorNumber); } [PunRPC] void SpawnPlayer(int actor) { int i = actor % spawnPoints.Length; PhotonNetwork.Instantiate("Player", spawnPoints[i].position, spawnPoints[i].rotation); } public void AddScore(int actor, int value) { if (!scores.ContainsKey(actor)) scores[actor] = 0; scores[actor] += value; } void EndMatch() { matchActive = false; GameCore.Instance.curseEnergy += 500; } } //================ IAP CURSE ENERGY =================// public class IAPManager : MonoBehaviour, IStoreListener { public static IAPManager Instance; IStoreController controller; void Awake() { if (Instance == null) { Instance = this; DontDestroyOnLoad(gameObject); Init(); } } void Init() { var b = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); b.AddProduct("curse_1000", ProductType.Consumable); UnityPurchasing.Initialize(this, b); } public void BuyEnergy() { controller.InitiatePurchase("curse_1000"); } public void OnInitialized(IStoreController c, IExtensionProvider e) { controller = c; } public void OnInitializeFailed(InitializationFailureReason e) { } public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs a) { GameCore.Instance.curseEnergy += 1000; return PurchaseProcessingResult.Complete; } public void OnPurchaseFailed(Product p, PurchaseFailureReason r) { } } //================ SPECIAL CHARACTER IAP =================// public class SpecialCharacterIAP : MonoBehaviour, IStoreListener { public CharacterData special; public CharacterInventory inv; IStoreController controller; void Start() { var b = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance()); b.AddProduct("special_char", ProductType.NonConsumable); UnityPurchasing.Initialize(this, b); } public void BuySpecial() { controller.InitiatePurchase("special_char"); } public void OnInitialized(IStoreController c, IExtensionProvider e) { controller = c; } public void OnInitializeFailed(InitializationFailureReason e) { } public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs a) { inv.owned.Add(special); inv.active = special; return PurchaseProcessingResult.Complete; } public void OnPurchaseFailed(Product p, PurchaseFailureReason r) { } } ``` \
Detailed Info
Related Models
Enter invite code
Enter invite code to get credits!