// Use this for initialization void Start() { Cursor.visible = false; //hides the mouse from the user Cursor.lockState = CursorLockMode.Locked; //you cannot use the cursor scriptInstance = ScriptableObject.CreateInstance("CardRetrievalFromDeck"); //so you can use the script holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //access to script changePlayer = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //to change players cameraHolder = GameObject.Find("Main Camera"); //sets the object to just the main camera if (GameManager.Instance.round == 1) //only happens in the first round { for (int i = 0; i < 5; i++) { holder.drawCP1Deck(); //adds the cards to the computers hand //draws a card and puts it into the hand cardParent = GameManager.Instance.cp1AI; holder.cardNameHolder = "back_of_card"; generateCardObject(); holder.setSpriteCP1(sr); //generating the card object to be placed into the panel } } StartCoroutine("computerPerforms"); //goes through the function needed for the AI }
//Made this its own class so that we could use a for loop to draw 5 cards public void DrawCard() { //looping through each deck in play foreach (Deck deck in GameManager.Instance.Decks) { //finding the correct deck to be used if (deck.DeckId == GameManager.Instance.deckPicked) { //checking to make sure there are cards left in the deck if (deck.Cards.Count != 0) { //retrieving the object created in the form of the "instance" earlier holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //calling the object's CardDrawRandomizer function, which selects a random card from the deck holder.CardDrawRandomizer(); //calling this script's generateCardObject function, which creates an object to represent the card generateCardObject(); //calling the script object's setSprite function, which passes in the SpriteRenderer, and sets it's sprite to the corresponding card chosen in CardDrawRandomizer holder.setSprite(sr); if (deck.Cards.Count == 0) { //calling this script's changeDeck function, which replaces the deck with an out of cards image changeDeck(); } } else { } } } }
void Start() { var env = GameObject.FindGameObjectWithTag("AgentEnvironment"); if (!env) { return; } var agentEnvironment = env.GetComponent <AgentEnvironment>(); if (agentEnvironment) { m_environment = agentEnvironment; } m_simulationData = ScriptableObject.FindObjectOfType <SimulationData>(); simulationDataText.text += "\n" + $"Density : {m_simulationData.populationDensity.ToString()} \n " + $"Infectivity : {m_simulationData.infectivity.ToString()} \n " + $"Launch Sick nb : {m_simulationData.launchSickNumber.ToString()} \n " + $"Launch Immuned nb : {m_simulationData.launchImmunedNumber.ToString()} \n " + $"Disease duration : {m_simulationData.diseaseDuration.ToString()} \n " + $"Death statistic : {m_simulationData.deathStatistic.ToString()} \n " + $"Disease transmission distance : {m_simulationData.diseaseTransmissionDistance.ToString()} \n "; m_bastCitizensStatText = currentCitizensStatText.text; m_bastMayorStatText = currentMayorStatText.text; }
private static DynamicUnitManager GetInstance() { if (s_Instance == null) { #if UNITY_EDITOR // If there's no instance, load or create one DynamicUnitManager asset = null; string assetPathAndName = GeneratePath(); // Check the asset database for an existing instance of the asset asset = AssetDatabase.LoadAssetAtPath(assetPathAndName, typeof(ScriptableObject)) as DynamicUnitManager; // If the asset doesn't exist, create it if (asset == null) { asset = ScriptableObject.CreateInstance <DynamicUnitManager>(); asset.Units = new List <UnitItem>(); AssetDatabase.CreateAsset(asset, assetPathAndName); AssetDatabase.SaveAssets(); } s_Instance = asset; #else s_Instance = ScriptableObject.FindObjectOfType(typeof(DynamicUnitManager)) as DynamicUnitManager; #endif } return(s_Instance); }
// Use this for initialization void Start() { scriptInstance = ScriptableObject.CreateInstance("CardRetrievalFromDeck"); //so you can use the script holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //access to script changePlayer = GameObject.Find("Main Camera").GetComponent <HideShowBoards>(); //to change players cameraHolder = GameObject.Find("Main Camera"); // to access the scripts of the main camera if (GameManager.Instance.round == 1) //will only happen in the first round { for (int i = 0; i < 5; i++) { holder.drawCP3Deck(); //adds the cards to the computers hand //draws a card and puts it into the hand cardParent = GameObject.Find("Computer Three Board/CP3Hand").transform; holder.cardNameHolder = "back_of_card"; generateCardObject(); holder.setSpriteCP1(sr); //generating the card object to be placed into the panel } } round = 0; //starts at 1, goes to 10 sort = 5; //starts at 5 StartCoroutine("computerPerforms"); }
//-----START/UPDATE-----// public void Start() { if (hasAuthority && !isServer) { this.LocalPlayer = FindObjectsOfType <PlayerScript>().First(x => x.isLocalPlayer); LocalPlayer.PlayerUnits.Add(this); } else if (isServer) { var playerList = FindObjectsOfType <PlayerScript>(); foreach (var pl in playerList) { if (pl.PlayerUnits.Any(x => x == this)) { LocalPlayer = pl; } } } this.gridscr = ScriptableObject.FindObjectOfType <GridScript>(); this.IsDisplayingMovement = false; this.isMoving = false; this.isDisplayingRotations = false; this.isFacingRight = true; this.HasInitialized = true; //GameManager waits for this to be true on all units before proceeding with initialization. }
/* * @name Draw(int pAmount) extends from parent * @purpose gets the card from the deck and calls generate card object and */ public override void Draw(int pAmount) { //gets parent info base.Draw(pAmount); //makes sure you can opnly draw once basically if (CanDraw == true) { //checking to make sure there are cards left in the deck if (Deck.Cards.Count != 0) { //determins how many cards to draw for (int i = 0; i < pAmount; i++) { //retrieving the object created in the form of the "instance" earlier Holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //sets the parent CardParent = GameObject.Find(HandGameObject).transform; //calling the object's CardDrawRandomizer function, which selects a random card from the deck Holder.CardDrawRandomizer(CurrentPlayer); //calling this script's generateCardObject function, which creates an object to represent the card GenerateCardObject(); //calling the script object's setSprite function, which passes in the SpriteRenderer, and sets it's sprite to the corresponding card chosen in CardDrawRandomizer Holder.setSprite(Sr); } } else { //calling this script's changeDeck function, which replaces the deck with an out of cards image ChangeDeck(); } } }
// Use this for initialization void Start() { threeCard = GameManager.Instance.threeCardBurst; holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //gets access to the script playerDraw = ScriptableObject.FindObjectOfType <DebugDealer>(); //gets access to the script cardParent = GameObject.Find("Game Board Container/Player Board/Board/Player/Hand").transform; }
public T GetAsset <T>(string name = "") where T : UnityEngine.Object { if (typeof(ScriptableObject).IsAssignableFrom(typeof(T))) { return(ScriptableObject.FindObjectOfType <T>() as T); } return(((GameObject)_prefabsCollectionObject.prefabsDictionary[name]).GetComponent <T>()); }
public static Type Get <Type>(bool create = true) where Type : ScriptableObject { if (ProxyEditor.IsSwitching()) { return(null); } var name = typeof(Type).Name; return(Locate.GetAsset <Type>(name + ".asset") ?? ScriptableObject.FindObjectOfType <Type>() ?? create?Singleton.Create <Type>(name + ".asset") : null); }
static public MessageLog Create() { var messageLog = ScriptableObject.FindObjectOfType <MessageLog>(); if (messageLog == null) { messageLog = ScriptableObject.CreateInstance <MessageLog>(); } return(messageLog); }
public static UnityApiEvents GetOrCreate() { var loggerAsset = ScriptableObject.FindObjectOfType <UnityApiEvents>(); if (loggerAsset == null) { loggerAsset = ScriptableObject.CreateInstance <UnityApiEvents>(); } return(loggerAsset); }
void explosion() { explosed = true; for (int i = 0; i < 15; i++) { GameObject deb = Instantiate((GameObject)Resources.Load("debris"), transform.position + (Random.insideUnitSphere * 0.5f), Quaternion.identity); ScriptableObject.FindObjectOfType <ExplosionSystem>().debris.Add(deb); deb.GetComponent <Rigidbody>().AddExplosionForce(50, transform.position, 0); } Destroy(gameObject.GetComponent <MeshRenderer>()); Invoke("Dest", 1); }
public static T GetScriptableObjectInstance <T>() where T : ScriptableObject { Type type = typeof(T); T instance = ScriptableObject.FindObjectOfType(type) as T; if (instance == null) { instance = ScriptableObject.CreateInstance(type) as T; } return(instance); }
public static HFTHappyFunTimesSettings GetInstance() { if (s_instance == null) { s_instance = ScriptableObject.FindObjectOfType <HFTHappyFunTimesSettings>(); if (s_instance == null) { s_instance = ScriptableObject.CreateInstance <HFTHappyFunTimesSettings>(); s_instance.name = "HappyFunTimes Settings"; } } return(s_instance); }
/* * @name StartTurn() * @purpose deals the player 5 cards if its round one then starts the players turn */ public virtual void StartTurn() { //assigns deck info and color //CreateDeckInfo(); //Updates the round to current ChangeRound(); //updates the score board ChangeAllScore(); //creating an "instance" of the CardRetrievalFromDeck script, allows it to be retrieved as an object ScriptInstance = ScriptableObject.CreateInstance("CardRetrievalFromDeck"); //so you can use the script Holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //access to script //CameraHolder = GameObject.Find("Main Camera"); //sets the object to just the main camera }
static public UberLoggerEditor Create() { var editorDebug = ScriptableObject.FindObjectOfType <UberLoggerEditor>(); if (editorDebug == null) { editorDebug = ScriptableObject.CreateInstance <UberLoggerEditor>(); } editorDebug.NoErrors = 0; editorDebug.NoWarnings = 0; editorDebug.NoMessages = 0; return(editorDebug); }
static public XLoggerEditor Ctor() { XLoggerEditor xLoggerEditor = ScriptableObject.FindObjectOfType <XLoggerEditor>(); if (xLoggerEditor == null) { xLoggerEditor = ScriptableObject.CreateInstance <XLoggerEditor>(); } xLoggerEditor.Errors = 0; xLoggerEditor.Warnings = 0; xLoggerEditor.Messages = 0; xLoggerEditor.ErrorPause = false; xLoggerEditor.ClearOnPlay = false; xLoggerEditor.Playing = false; return(xLoggerEditor); }
static MazeCreationWorkflowBackEnd FindOrCreateBackend() { var existingInstance = ScriptableObject.FindObjectOfType <MazeCreationWorkflowBackEnd>(); if (existingInstance != null) { log("Using existing backend instance"); return(existingInstance); } log("Create bew Backend instance"); var newInstance = CreateInstance <MazeCreationWorkflowBackEnd>(); newInstance.OnEditorModeChange += m => log("Change to Mode: " + m.Name); return(newInstance); }
static void CreateGrid() { CubeGridSingletonObject sing = GameObject.FindObjectOfType <CubeGridSingletonObject>(); if (sing == null) { GameObject EmptyObject = new GameObject("Empty_Singleton"); sing = EmptyObject.AddComponent <CubeGridSingletonObject>(); } m_Instance = ScriptableObject.FindObjectOfType <CubeGrid>(); if (!m_Instance) { m_Instance = ScriptableObject.CreateInstance <CubeGrid>(); } sing.Grid = m_Instance; Selection.activeObject = m_Instance; }
public void Update() { //// spawn a lizard or snake every 500 frames //if (count == 500) //{ // SpawnNewLizard(); //} //if (count == 1000) //{ // SpawnNewSnake(); // count = 0; //} count++; // initialize game on I key press if (Input.GetKeyDown(KeyCode.I)) { GameManager.Instance.InitializeGame(); } if (Input.GetKeyDown(KeyCode.J)) { // applying default critter behavior to critters //m_Snake.setIdleBehavior(); } if (Input.GetKeyDown(KeyCode.S)) { // applying default critter behavior to critters Critter lizards = ScriptableObject.FindObjectOfType <Lizard>(); //lizards.setShakingBehavior(); } if (Input.GetKeyDown(KeyCode.P)) { // applying sprinting behavior to critters Critter snakes = ScriptableObject.FindObjectOfType <Snake>(); Critter lizards = ScriptableObject.FindObjectOfType <Lizard>(); lizards.setSprintingBehavior(); snakes.setSprintingBehavior(); } }
/* * @name Draw(int pAmount) extends from parent * @purpose gets the card from the deck and calls generate card object and */ public override void Draw(int pAmount) { //gets parent frunction base.Draw(pAmount); //checking to make sure there are cards left in the deck if (Deck.Cards.Count != 0) { //determins how many cards to draw for (int i = 0; i < pAmount; i++) { //retrieving the object created in the form of the "instance" earlier Holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); CardParent = GameObject.Find(HandGameObject).transform; //calling the object's CardDrawRandomizer function, which selects a random card from the deck Holder.CardDrawRandomizer(CurrentPlayer); //changes the sprite so the player cant see the cards in the computers hand Holder.CardNameHolder = "back_of_card"; GenerateCardObject(); Holder.setSprite(Sr); //generating the card object to be placed into the panel } } else { //retrieving the object created in the form of the "instance" earlier Holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //sets the parent CardParent = GameObject.Find(HandGameObject).transform; //calling the object's CardDrawRandomizer function, which selects a random card from the deck Holder.CardDrawRandomizer(CurrentPlayer); //changes the sprite so the player cant see the cards in the computers hand Holder.CardNameHolder = "back_of_card"; //calling this script's generateCardObject function, which creates an object to represent the card GenerateCardObject(); //calling the script object's setSprite function, which passes in the SpriteRenderer, and sets it's sprite to the corresponding card chosen in CardDrawRandomizer Holder.setSprite(Sr); } }
private void Start() { var env = GameObject.FindGameObjectWithTag("AgentEnvironment"); if (!env) { return; } var agentEnvironment = env.GetComponent <AgentEnvironment>(); if (agentEnvironment) { m_environment = agentEnvironment; } m_simulationData = ScriptableObject.FindObjectOfType <SimulationData>(); var map = GameObject.FindGameObjectWithTag("Map"); uint height = 0, width = 0; if (map.GetComponent <Renderer>() != null) { var size = map.GetComponent <Renderer>().bounds.size; width = (uint)size.x; height = (uint)size.z; } var mapPosition = map.transform.position; m_environment.Coordinates = new AgentEnvironment.MapCoordinates(mapPosition, width, height); // Instantiate House prefab for (uint i = 0; i < m_simulationData.populationDensity; i++) { var position = new Vector3(mapPosition.x + Random.Range(-(float)width / 2, (float)width / 2), mapPosition.y, mapPosition.z + Random.Range(-(float)height / 2, (float)height / 2)); var house = Instantiate(housePrefab, position, Quaternion.identity); house.transform.parent = map.transform; var citizen = Instantiate(citizenPrefab, new Vector3(position.x, position.y + 0.5f, position.z), Quaternion.identity); citizen.transform.parent = map.transform; if (citizen.TryGetComponent <CitizenBody>(out var citizenBody)) { citizenBody.InitProximityColliderSize(new Vector3( m_simulationData.diseaseTransmissionDistance, 1, m_simulationData.diseaseTransmissionDistance)); } } m_environment.UpdateAgentList(); var mayor = Instantiate(mayorPrefab); }
public static Type GetSingleton <Type>(bool create = true) where Type : ScriptableObject { var name = typeof(Type).Name; return(FileManager.GetAsset <Type>(name + ".asset", false) ?? ScriptableObject.FindObjectOfType <Type>() ?? create?Utility.CreateSingleton("Assets/Settings/" + name).As <Type>() : null); }
// Use this for initialization void Start() { showBoard = GameObject.Find("Main Camera").GetComponent <CheckDeckAndDiscardPlayer>(); //sets object holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //gets access to the script playerDraw = ScriptableObject.FindObjectOfType <DebugDealer>(); //gets access to the script }
//code that executes on the script load public void Start() { holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //gets access to the script playerDraw = ScriptableObject.FindObjectOfType <DebugDealer>(); //gets access to the script }
// Use this for initialization void Start() { holder = ScriptableObject.FindObjectOfType <CardRetrievalFromDeck>(); //gets access to the script }
void Awake() { bgmManager = ScriptableObject.FindObjectOfType <BgmManager>(); sfxManager = ScriptableObject.FindObjectOfType <SfxManager>(); }