Exemple #1
0
    public void OnObjectSpawn(Vector3Int position, GarbageManager gm)
    {
        this.position   = position;
        garbageManager  = gm;
        lifeTimeCounter = 5f;

        MusicManager.Instance.PlaySingle(noise.clip);
    }
 private void UpdateBins(GarbageManager _garbageManager, bool addBins)
 {
     if (addBins)
     {
         otherGarbageManagers.Add(_garbageManager);
     }
     else
     {
         otherGarbageManagers.Remove(_garbageManager);
     }
 }
Exemple #3
0
 void Awake()
 {
     if (instance == null)
     {
         instance = this;
     }
     levelInit      = GetComponent <LevelInit>();
     garbageManager = new GarbageManager();
     cat            = catPrefab.GetComponent <Cat>();
     mechanism      = mechanismGO.GetComponent <Mechanism>();
     conveyorSR     = conveyor.GetComponent <SpriteRenderer>();
 }
Exemple #4
0
    void Awake()
    {
        Instance = this;

        // Find all the spawners in the scene.
        // TODO: Done once at the start of the scene, but make sure this isn't too slow.  It's probably just more convienent and less error prone than maintaining a list in the editor manually.
        GarbageSpawner[] garbageSpawnersArr = FindObjectsOfType <GarbageSpawner>();
        for (int i = 0; i < garbageSpawnersArr.Length; ++i)
        {
            garbageSpawners.Add(garbageSpawnersArr[i]);
        }
    }
    private void CollectGarbage(Collider collision)
    {
        if (isCollecting && !isDeliveringWaste)
        {
            if (collision.CompareTag("Garbage") && // if the collector runs into the house trigger
                collision.GetComponentInParent <GarbageManager>().garbageNeedsCollecting && // AND the house has Garbage
                isCollecting)    // AND the Collector is in pickup mode...
            {
                // ... tell the house the Collector is here
                collision.GetComponentInParent <GarbageManager>().garbageBeingCollected = true;

                // ... pause the movement
                myNavMeshAgent.isStopped = true;

                // ... get a reference to the house's Garbage Manager
                GarbageManager tempGM = collision.GetComponentInParent <GarbageManager>();

                // temp variable for collecting garbage
                float garbageCollected = (collectionSpeed * Time.deltaTime) * myGameManager.garbageMultipler;

                // ... reduce the garbage in the house at a given speed
                tempGM.garbageLevel -= garbageCollected;

                // ... and add it to the Collector
                garbageInCollector += garbageCollected;

                // if the house has run out of garbage
                if (tempGM.garbageLevel <= 0)
                {
                    tempGM.garbageNeedsCollecting = false;
                    tempGM.garbageBeingCollected  = false;
                    tempGM.garbageLevel           = 0.0f;
                    tempGM.garbageCollected       = true;

                    myAudioManager.GarbageCollectedSFX();
                }
            }
            else if (collision.CompareTag("Garbage") &&
                     !collision.GetComponentInParent <GarbageManager>().garbageNeedsCollecting &&
                     isCollecting)
            {
                // debug
                // Debug.Log("No more garbage at house, Collector not stopping.");

                // reset the bool to look for more garbage
                foundWaste = false;

                // ... resume the movement
                myNavMeshAgent.isStopped = false;
            }
        }
    }
Exemple #6
0
    private void Awake()
    {
        // get realtime references
        myGameManager         = FindObjectOfType <GameManager>();
        myGarbageManager      = GetComponent <GarbageManager>();
        mySatisfactionManager = GetComponentInChildren <SatisfactionManager>();
        if (mySatisfactionManager.GetComponent <SphereCollider>())
        {
            mySatisfactionTrigger = mySatisfactionManager.GetComponent <SphereCollider>();
        }
        myHouseMeshRender = GetComponentInChildren <MeshRenderer>();

        // set some variables
        RandomHouseType();
    }
Exemple #7
0
        private static void Main(string[] args)
        {
            IReader reader = new ConsoleReader();
            IWriter writer = new ConsoleWriter();
            Dictionary <Type, IGarbageDisposalStrategy> strategies = new Dictionary <Type, IGarbageDisposalStrategy>();
            IStrategyHolder   strategyHolder   = new StrategyHolder(strategies);
            IGarbageProcessor garbageProcessor = new GarbageProcessor(strategyHolder);
            IWasteFactory     wasteFactory     = new WasteFactory();

            IGarbageManager garbageManager = new GarbageManager(garbageProcessor, wasteFactory);

            IEngine engine = new Engine(reader, writer, garbageManager);

            engine.Run();
        }
Exemple #8
0
    private void Start()
    {
        if (GameObject.FindGameObjectWithTag("LevelManager").GetComponent <PlayerInfo>() != null)
        {
            playerInfo = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <PlayerInfo>();
        }
        else
        {
            Debug.Log("no playerInfo component found");
        }
        if (GameObject.FindGameObjectWithTag("LevelManager").GetComponent <GarbageManager>() != null)
        {
            garbageManager = GameObject.FindGameObjectWithTag("LevelManager").GetComponent <GarbageManager>();
        }
        else
        {
            Debug.Log("no garbagemanager component found");
        }

        GameObject tempObject = GameObject.Find("EventDisplay");

        if (tempObject != null)
        {
            eventDisplay         = tempObject.GetComponent <Canvas>();
            eventDisplay.enabled = false;
            if (eventDisplay == null)
            {
                Debug.Log("Could not locate Canvas component on " + tempObject.name);
            }
        }

        GameObject tempObject2 = GameObject.Find("EventMessage");

        if (tempObject2 != null)
        {
            eventMessage = tempObject2.GetComponent <Text>();
            if (eventMessage == null)
            {
                Debug.Log("Could not locate Canvas component on " + tempObject2.name);
            }
        }
    }
Exemple #9
0
 void IPooledObject.OnObjectSpawn(Vector3Int position, GarbageManager gm)
 {
     throw new System.NotImplementedException();
 }
Exemple #10
0
 public void SetOnMap(Vector3Int position, GarbageManager gm)
 {
     /*this.position = position;
      * garbageManager = gm;
      * lifeTimeCounter = 2f;*/
 }