Inheritance: MonoBehaviour
Example #1
0
        /// <summary>Tasks performed after the game begins a new day, including when loading a save.</summary>
        private void DayStarted(object sender, EventArgs e)
        {
            if (Context.IsMainPlayer != true)
            {
                return;
            }                                             //if the player using this mod is a multiplayer farmhand, don't do anything; most of this mod's functions should be limited to the host player

            try
            {
                Utility.Config = Helper.Data.ReadJsonFile <FarmConfig>($"data/{Constants.SaveFolderName}.json"); //load the current save's config file ([null] if it doesn't exist)
            }
            catch (Exception ex)                                                                                 //if there's an error while loading the json file, try to explain it in the user's log & then skip any further DayStarted behaviors
            {
                Utility.Monitor.Log($"Warning: Your character's config file could not be parsed correctly. Most of this mod's functions will be disabled. Please edit the file, or delete it and reload your save to generate a new config file. The original error message is displayed below.", LogLevel.Warn);
                Utility.Monitor.Log($"{ex.Message}", LogLevel.Warn);
                return;
            }

            if (Utility.Config == null)                                                             //no config file for this save?
            {
                Utility.Config = new FarmConfig();                                                  //load the default config settings
                Helper.Data.WriteJsonFile($"data/{Constants.SaveFolderName}.json", Utility.Config); //create a config file for the current save
            }

            //run the methods providing the mod's main features
            ObjectSpawner.ForageGeneration();
            ObjectSpawner.LargeObjectGeneration();
            ObjectSpawner.OreGeneration();

            //NOTE: This will reformat any changes the player has made with the default SMAPI formatting
            Helper.Data.WriteJsonFile($"data/{Constants.SaveFolderName}.json", Utility.Config);
        }
Example #2
0
        /// <summary>Tasks performed after the game begins a new day, including when loading a save.</summary>
        private void DayStarted(object sender, EventArgs e)
        {
            //attempt to load the config.json ModConfig file and update its settings
            //NOTE: this already happens in the Entry method, but doing it here allows certain settings to be changed while the game is running
            try
            {
                Utility.MConfig = Helper.ReadConfig <ModConfig>(); //create or load the config.json file

                Helper.WriteConfig <ModConfig>(Utility.MConfig);   //update the config.json file (e.g. to add settings from new versions of the mod)
            }
            catch (Exception ex)                                   //if the config.json file can't be parsed correctly, try to explain it in the user's log & then skip any config-related behaviors
            {
                Utility.Monitor.Log($"Warning: This mod's config.json file could not be parsed correctly. Some related settings will be disabled. Please edit the file, or delete it and reload the game to generate a new config file. The auto-generated error message is displayed below:", LogLevel.Warn);
                Utility.Monitor.Log($"----------", LogLevel.Warn); //visual break to slightly improve clarity, based on user feedback
                Utility.Monitor.Log($"{ex.Message}", LogLevel.Warn);
            }

            if (Context.IsMainPlayer != true)
            {
                return;
            }                                                       //if the player using this mod is a multiplayer farmhand, don't do anything; most of this mod's functions should be limited to the host player

            Utility.LoadFarmData(Helper);                           //load all available data files

            foreach (FarmData data in Utility.FarmDataList)         //for each loaded set of data
            {
                Utility.ReplaceProtectedSpawnsOvernight(data.Save); //protect unexpired spawns listed in the save data
            }

            //run the methods providing the mod's main features
            ObjectSpawner.ForageGeneration();
            ObjectSpawner.LargeObjectGeneration();
            ObjectSpawner.OreGeneration();
        }
Example #3
0
 public void Setup(ForceObjectStartSpawnParameters _forceObjectStartSpawnParameters)
 {
     PlayerMovementManager = new PlayerMovementManager(this.transform);
     ForceObjectsManager   = new ForceObjectsManager(this, _forceObjectStartSpawnParameters);
     OrbitationWheel       = ObjectSpawner.SpawnOrbitationWheel(this.transform.position);
     OrbitationWheel.transform.SetParent(transform);
 }
Example #4
0
 // Use this for initialization
 void Start()
 {
     rig                 = GetComponent <Rigidbody2D>();
     targetrig           = target.GetComponent <Rigidbody2D>();
     rig.angularVelocity = 150;
     gc = GameObject.Find("Game Controller").GetComponent <ObjectSpawner>();
 }
Example #5
0
    public override void SuccessfullyClick()
    {
        if (rb != null && gameObject != null)
        {
            if (!pointsEarned && PowerUpButton.activePowerUps.Count > 0 && Random.Range(0, Random.Range(85, 95)) < 2)
            {
                PowerUp          powerUp = PowerUpButton.DeterminePowerUp();
                ClickForPoints2D spawn   = ObjectSpawner.GetSpawn(powerUp);
                spawn = Instantiate(spawn, null);
                spawn.Reposition(transform.position);
                spawn.transform.parent = null;
                spawn.gameObject.SetActive(true);
            }

            rb.isKinematic = false;
            rb.AddForce(Vector3.down * 200f, ForceMode.Acceleration);

            base.SuccessfullyClick();

            MaterialChanger m = GetComponentInChildren <MaterialChanger>();
            if (m != null)
            {
                m.enabled = true;
            }

            Collider c = GetComponent <Collider>();
            if (c != null)
            {
                Destroy(c);
            }
        }
    }
Example #6
0
    public void loadDatabaseUniqueGameObjectsOnce()
    {
        ObjectSpawner spawner = GetComponent <ObjectSpawner>();

        //.Child("palace")

        FirebaseDatabase.DefaultInstance.GetReference("Users").Child(spawner.palaceUserID).Child("palace").GetValueAsync().ContinueWith(task =>
        {
            if (task.IsFaulted)
            {
                Debug.Log("Fault getting game state from Firebase");
            }
            else if (task.IsCompleted)
            {
                DataSnapshot snapshot = task.Result;
                if (snapshot != null && snapshot.ChildrenCount > 0)
                {
                    Debug.Log("SNAPSHOT" + snapshot.GetRawJsonValue().ToString());
                    foreach (DataSnapshot childSnapshot in snapshot.Children)
                    {
                        loadSnapshotUniqueGameObjects(childSnapshot);
                    }
                }
            }
        });
    }
Example #7
0
    void Update()
    {
        if (landGenerator == null)
        {
            landGenerator = new LandGenerator(config);
        }
        landGenerator.Update();

        if (objectSpawner == null)
        {
            objectSpawner = new ObjectSpawner(config);
        }
        objectSpawner.Update();

        if (playerPhysics == null)
        {
            playerPhysics = new PlayerPhysics(playerObject, config);
        }
        playerPhysics.Update();

        if (cameraFollowPlayer == null)
        {
            cameraFollowPlayer = new CameraFollowPlayer(() => playerObject.transform, () => Camera.main.transform, config);
        }
        cameraFollowPlayer.Update();
    }
Example #8
0
 // Start is called before the first frame update
 void Start()
 {
     gcObjectSpawner = GameObject.Find("GameController").GetComponent <ObjectSpawner>();
     rb = gameObject.GetComponent <Rigidbody>();
     startingEatMagnitude = eatMagnitude;
     startingMass         = rb.mass;
 }
Example #9
0
 protected virtual void Start()
 {
     cam           = Camera.main;
     destination   = GetPositionInWindow();
     curHp         = maxHp;
     pickupSpawner = GameManager.instance.pickupSpawner;
 }
Example #10
0
 void Instantiate()
 {
     if (instance == null)
     {
         instance = this;
     }
 }
Example #11
0
    public void Init()
    {
        line = GetComponent <LineRenderer>();

        line.enabled = false;

        player = PlayerController.Instance;

        endLinePosition = player.transform.position;

        startLinePosition = player.transform.position;

        hitPoint = player.transform.position;

        line.startWidth = line.endWidth = defaultLineWidth;

        objectSpawner = ObjectSpawner.Instance;

        gameplayController = GameplayController.Instance;

        line.startWidth = line.endWidth = 0;

        locktaskpanel = FindObjectOfType <LockTaskPanel>();


        isInit = true;
    }
    void Awake()
    {
        spawner = FindObjectOfType <ObjectSpawner>();
        int randomHouseNumber = Random.Range(0, houses.Length);

        Instantiate(houses[randomHouseNumber], Vector3.zero, Quaternion.identity);
    }
Example #13
0
    // Use this for initialization
    void Start()
    {
        comp_spawner     = GetComponent <ObjectSpawner>();
        comp_gameOver    = GetComponent <GameOverMenu>();
        comp_timeDisplay = GetComponent <TimerDisplay>();

        for (int i = 0; i < obstacles_num; i++)
        {
            comp_spawner.SpawnObjects(1, obstacles_array[Random.Range(0, obstacles_array.Length)]);
        }


        comp_spawner.SpawnObjects(cow_num, cow_obj);
        comp_spawner.SpawnObjects(1, farmer_obj);

        bonus_TimeTarget = (float)bonus_everySecs;
        bonus_Text.gameObject.SetActive(false);


        enabled = false;


        if (GetComponent <Countdown>())
        {
            GetComponent <Countdown>().StartCountdown(delegate {
                StartTheGamePlay();
            });
        }
        else
        {
            StartTheGamePlay();
        }
    }
Example #14
0
    void Awake()
    {
        SP = this;

        spawnInterval = Random.Range(3.5f, 5.5f);
        lastSpawnTime = Time.time + Random.Range(0.0f, 1.5f);
    }
Example #15
0
 private void OnDestroy()
 {
     if (_instance == this)
     {
         _instance = null;
     }
 }
 // 1st method called
 void Awake()
 {
     floor   = GameObject.Find("Track");
     spawner = GameObject.Find("Object Spawner").GetComponent <ObjectSpawner>();
     //// time manager logic (chapter 6)
     timeManager = GetComponent <TimeManager>();
 }
Example #17
0
    void RpcRespawn()
    {
        Vector3 spawnPoint;

        ObjectSpawner.RandomPoint(Vector3.zero, 30.0f, out spawnPoint);
        this.transform.position = spawnPoint;
    }
    void Awake()
    {
        SP = this;

        spawnInterval = Random.Range(3.5f, 5.5f);
        lastSpawnTime = Time.time + Random.Range(0.0f, 1.5f);
    }
Example #19
0
    public GameObject[] pre;              // 프리팹


    private void Start()
    {
        objectToSpawn      = FindObjectOfType <ObjectSpawner>(); // ObjectToSpawn 컴포넌트(스크립트) 활성 비활성에 쓰일 게임오브젝트
        placementIndicator = FindObjectOfType <PlacementIndicator>();
        checkedButton.SetActive(false);
        objectSpawner.GetComponent <ObjectSpawner>().enabled = true;
    }
Example #20
0
    public void Init()
    {
        line = transform.GetChild(0).GetComponent <LineController>();

        objectSpawner = ObjectSpawner.Instance;

        if (currentBase != null)
        {
            currentBase.player = this;
        }


        defaultScale = transform.localScale.x;

        targetLocation = transform.localPosition;

        cameraController = Camera.main.GetComponent <CameraController>();

        renderer = transform.GetChild(2).GetComponent <SpriteRenderer>();

        gameplayController = GameplayController.Instance;

        trailRenderer = GetComponent <TrailRenderer>();

        SetCurrentBase();

        skinSprite = skin.GetComponent <SpriteRenderer>();


        skinSprite.sprite = tether_sprites[GameplayController.LevelIndex];


        isInit = true;
    }
 private void Awake()
 {
     oS  = FindObjectOfType <ObjectSpawner>();
     mM  = FindObjectOfType <MusicManager>();
     eS  = FindObjectOfType <EventSystem>();
     hSM = GetComponent <HighScoreManager>();
 }
    // Use this for initialization
    void Start()
    {
        m_rb = GetComponent <Rigidbody>();
        //Debug.Log("Start()");
        Vector3 spawnPoint;
        Vector3 spawnPt;

        spawnPt = new Vector3(Random.Range(-10f, 10f), 1, Random.Range(-10f, 10f));
        ObjectSpawner.RandomPoint(spawnPt, 10f, out spawnPoint);
        this.transform.position = spawnPoint;

        speed  = GameObject.Find("Speed");
        speed1 = GameObject.Find("Speed1");
        speed2 = GameObject.Find("Speed2");
        speed3 = GameObject.Find("Speed3");

        m_hasFlag = false;

        speedPowerUps = 3;

        TrailRenderer tr = GetComponent <TrailRenderer>();

        tr.enabled = false;

        spedUp     = false;
        speedTimer = 0;

        gameOver = false;

        timerText = GameObject.Find("Time").GetComponent <Text> ();
        scoreText = GameObject.Find("Points").GetComponent <Text> ();
        playAgain = GameObject.Find("PlayAgain").GetComponent <Text> ();
        speedText = GameObject.Find("Speeds").GetComponent <Text> ();
    }
 void Awake()
 {
     spawnedItems     = new List <GameObject>();
     Instance         = this;
     currentSelection = 0;
     spawnPosition    = SpawnPoint.position;
 }
Example #24
0
    private void loadSnapshotUniqueGameObjects(DataSnapshot childSnapshot)
    {
        ObjectSpawner spawner = GetComponent <ObjectSpawner>();

        if (childSnapshot != null)
        {
            string typeName = childSnapshot.Child("typeName").Value.ToString();
            string uid      = childSnapshot.Child("uid").Value.ToString();

            string temp = childSnapshot.Child("position").Child("x").Value.ToString();
            float  x    = float.Parse(temp);
            temp = childSnapshot.Child("position").Child("y").Value.ToString();
            float y = float.Parse(temp);
            temp = childSnapshot.Child("position").Child("z").Value.ToString();
            float z = float.Parse(temp);
            Debug.Log("GETTING FIREBASE VALUES: typeName: " + typeName + " uid: " + uid + " position x: " + x + " y: " + y + " z: " + z);
            Vector3 position = new Vector3(x, y, z);

            temp = childSnapshot.Child("rotation").Child("x").Value.ToString();
            x    = float.Parse(temp);
            temp = childSnapshot.Child("rotation").Child("y").Value.ToString();
            y    = float.Parse(temp);
            temp = childSnapshot.Child("rotation").Child("z").Value.ToString();
            z    = float.Parse(temp);
            Debug.Log("GETTING FIREBASE VALUES position:" + " x: " + x + " y: " + y + " z: " + z);

            Vector3 rotation = new Vector3(x, y, z);
            spawner.loadMnemonic(typeName, uid, position, rotation);
            Debug.Log(spawner.spawnedObjects.Count.ToString());
        }
    }
Example #25
0
    // Start is called before the first frame update
    void Start()
    {
        indicator_Images[0].SetActive(true);
        indicator_Images[1].SetActive(false);
        m_Team_One_Color   = Color.cyan;
        m_Team_Two_Color   = Color.red;
        coolDown_Timer_Max = coolDown_Timer;
        originalRotation   = new Vector3(Controlled_Hazard[Current_Haz_Num].transform.rotation.x,
                                         Controlled_Hazard[Current_Haz_Num].transform.rotation.y,
                                         Controlled_Hazard[Current_Haz_Num].transform.rotation.z);
        m_Move_Platform.y = Controlled_Hazard[Current_Haz_Num].transform.position.y;
        Move_Rotation     = new Vector3(0, 0, 90);
        //get an instance of the object spawner so we can spawn objects
        objectPool           = ObjectSpawner.Instance;
        my_Controller_Player = null;
        for (int i = 0; i < machine_UI.Length; i++)
        {
            machine_UI[i].SetActive(false);
        }
        if (mach == MachineID.SideHazard || mach == MachineID.SpecialPlatform)
        {
            for (int i = 0; i < Controlled_Hazard.Length; i++)
            {
                Hazard_StartPos[i]  = Controlled_Hazard[i].transform.position;
                sideHazardLerpSpeed = 30f;
                sideHazardReady     = true;
                Hazard_StartPos.Add(Hazard_StartPos[i]);
                Hazard_MaxPos[i] = new Vector3(Controlled_Hazard[i].transform.position.x,
                                               Controlled_Hazard[i].transform.position.y + Max_range, Controlled_Hazard[i].transform.position.z);
                Hazard_MaxPos.Add(Hazard_MaxPos[i]);
                Hazard_MinPos[i] = new Vector3(Controlled_Hazard[i].transform.position.x,
                                               Controlled_Hazard[i].transform.position.y - Max_range, Controlled_Hazard[i].transform.position.z);
                Hazard_MinPos.Add(Hazard_MinPos[i]);
            }
        }

        //only do this if this machine is of type "Background Cannon"
        if (mach == MachineID.BackgroundCannon)
        {
            Controlled_Hazard[0].GetComponent <SpriteRenderer>().color = Color.white;
            Controlled_Hazard[0].SetActive(false);
        }

        //set middlePlatform variables
        try
        {
            middlePlatform    = GameObject.Find("MiddlePlatform");
            middlePlatform_rb = middlePlatform.GetComponent <Rigidbody2D>();
            middlePlatform_vacuumBoxCollider = GameObject.Find("MiddlePlatform_Collider_Vacuum").GetComponent <BoxCollider2D>();
            middlePlatform_blowBoxCollider   = GameObject.Find("MiddlePlatform_Collider_Blow").GetComponent <BoxCollider2D>();
        }
        catch
        {
        }


        //setting AudioSource
        machineSoundPlayer = gameObject.GetComponent <AudioSource>();
    }
 void OnEnable()
 {
     targ = target as ObjectSpawner;
     if (targ.prefab != null)
     {
       m_hasAutoMove = (targ.prefab.GetComponent<CustomObject>() as IAutoMove != null);
     }
 }
Example #27
0
 private void Awake()
 {
     if (Instance != null)
     {
         Destroy(Instance.gameObject);
     }
     Instance = this;
 }
 void Awake()
 {
     m_Transform = transform;
     m_SpaceShipBehaviourTransform = FindObjectOfType <SpaceShipBehaviour>().transform;
     m_GameplayManager             = FindObjectOfType <GameplayManager>();
     m_NextChunkPositionZ          = 0;
     m_ObjectSpawner = FindObjectOfType <ObjectSpawner>();
 }
    private void spawn()
    {
        platforms[k].transform.position = new Vector3(0, 0, platforms[k].transform.position.z + (55 * 5));
        ObjectSpawner obj = platforms[k].GetComponent <ObjectSpawner>();

        obj.RandomEnableObjects();
        k = (k + 1) % 5;
    }
Example #30
0
 public override void Initialize()
 {
     RandomParameter();
     enemySpawner  = GetComponent <EnemySpawner>();
     objectSpawner = GetComponent <ObjectSpawner>();
     objectID      = -1;
     MaxStep       = 1000;
 }
Example #31
0
    void Awake()
    {
        _findSpawner = GameObject.Find("Spawner");
        _waveStats = _findSpawner.GetComponent<SpawnSystem>();
        _findObjectSpawner = GameObject.Find("ObjectSpawner");
        _resourcesInfo = _findObjectSpawner.GetComponent<ObjectSpawner>();

    }
Example #32
0
 private void Awake()
 {
     if (_instance != null && _instance != this)
     {
         Destroy(gameObject);
         return;
     }
     _instance = this;
 }
Example #33
0
 void Start()
 {
     bulletPool    = transform.FindChild("Bullets").GetComponent <BulletPool>();
     enemyPool     = transform.FindChild("Enemies").GetComponent <EnemyPool>();
     greenPool     = transform.FindChild("Greens").GetComponent <GreenPool>();
     lootPool      = transform.FindChild("Loot").GetComponent <LootPool>();
     objectSpawner = GetComponent <ObjectSpawner>();
     generateMap(MapType.rockyForest);
 }
Example #34
0
	// Use this for initialization
	void Start () 
	{
		spawner = GameObject.Find ("Object Spawner").GetComponent<ObjectSpawner>();
		spawner.stopSpawning ();
		timeText = GameObject.Find("TimeText").GetComponent<Text>();
		levelText = GameObject.Find ("LevelText");

		endGameView = GameObject.Find ("End Game");
		endGameView.SetActive (false);

		beginLevel ();
	}
	void Awake ()
	{
		objectSpawnRef = GetComponentInParent<ObjectSpawner>();
	}
	void Awake()
	{
		spawner = GetComponent<ObjectSpawner>();
	}
Example #37
0
 void Start()
 {
     cam = GameObject.Find("Main Camera");
     objSpawn = GameObject.Find ("Obj Spawn").GetComponent<ObjectSpawner>();
 }