Beispiel #1
0
        public override void Initialize()
        {
            // create and add any components that belong to this scene
            this.AddComponent(new Background(Game));

            this.AddComponent(new Score(Game, "fonts\\hudFont", HudLocation.TopRight));

            this.AddComponent(new AnimalsDead(Game, "fonts\\hudFont", HudLocation.TopLeft));


            AnimalManager animalManager = new AnimalManager(Game);

            this.AddComponent(animalManager);
            Game.Services.AddService <AnimalManager>(animalManager);

            TrashManager trashManager = new TrashManager(Game);

            this.AddComponent(trashManager);
            Game.Services.AddService <TrashManager>(trashManager);

            Hunter hunter = new Hunter(Game);

            this.AddComponent(hunter);
            Game.Services.AddService <Hunter>(hunter);

            base.Initialize();
        }
Beispiel #2
0
        public override void ProcessPacket(TrashSystemNewTrashCreatedPacket packet, NebulaConnection conn)
        {
            bool valid = true;

            if (IsHost)
            {
                Player player = playerManager.GetPlayer(conn);
                if (player != null)
                {
                    playerManager.SendPacketToOtherPlayers(packet, player);
                }
                else
                {
                    valid = false;
                }
            }

            if (valid)
            {
                int myId = SimulatedWorld.GenerateTrashOnPlayer(packet);

                //Check if myID is same as the ID from the host
                if (myId != packet.TrashId)
                {
                    TrashManager.SwitchTrashWithIds(myId, packet.TrashId);
                }
            }
        }
Beispiel #3
0
    //public SoundManager Sound;



    // Use this for initialization
    void Start()
    {
        //Identify other managers by name
        findMatches  = FindObjectOfType <FindMatches>();
        levelManager = FindObjectOfType <LevelManager>();
        trashManager = FindObjectOfType <TrashManager>();
        //burnScript = FindObjectOfType<BurnScript>();

        //Sound = FindObjectOfType<SoundManager>();


        allDots = new GameObject[width, height];

        //TODO : get current level
        levelManager.Load(level);

        SetUp();
        // TODO : add real trashes
        int[] canIdList = { 0, 1, 2, 3, 4 };
        trashManager.Init(canIdList);

        toCompost    = new GameObject[30];
        toRecycle    = new GameObject[30];
        toGlass      = new GameObject[30];
        toElectronic = new GameObject[30];
        toWaste      = new GameObject[30];
        // hello = GameObject.FindGameObjectWithTag("UUUIII");
    }
Beispiel #4
0
        /// <summary>
        /// Checks for collision between trash and animal
        /// </summary>
        private void CheckForCollision(GameTime gameTime)
        {
            AnimalsDead  animalsDead = Game.Services.GetService <AnimalsDead>();
            TrashManager trashManger = Game.Services.GetService <TrashManager>();

            foreach (Trash trash in trashManger.TrashList)
            {
                if (AnimalBounds.Intersects(trash.trashBoundry))
                {
                    hit = true;
                    secondsSinceLastHit += gameTime.ElapsedGameTime.TotalSeconds;
                    if (secondsSinceLastHit >= 2.5)
                    {
                        health--;
                        secondsSinceLastHit = 0.0;
                    }
                    if (health == 0)
                    {
                        Game.Components.Remove(this);
                        animalsDead.AddDeadAnimal();
                        if (animalsDead.Dead >= 10)
                        {
                            animalsDead.GameOver = true;
                            ((Game1)Game).HideAllScenes();
                            Game.Services.GetService <GameOver>().Show();
                        }
                    }
                }
            }
        }
    //Expand this region to see the methods related to collision events
    #region CollisionEvents

    private void OnTriggerEnter2D(Collider2D other)
    {
        switch (other.gameObject.tag)
        {
        case "Dust":
            if (isCleaning)
            {
                GameObject newTrash = Instantiate(trashBall, trashBallOffset.transform.position, Quaternion.identity);
                levelManager.AddToTrashToDestroy(newTrash);
                newTrash.GetComponent <Rigidbody2D>().mass = other.GetComponent <TrashManager>().trashValue;
                TrashManager trashScript = other.GetComponent <TrashManager>();
                trashScript.PlayTrashClip();
//                    Destroy(other.gameObject);
            }
            break;

        case "Souvenir":
            Destroy(other.gameObject);
            levelManager.PickUpSouvenir();
            break;

        default:
            break;
        }
    }
Beispiel #6
0
 public void ProcessPacket(TrashSystemCorrectionIdPacket packet, NebulaConnection conn)
 {
     if (packet.OriginalId != packet.NewId)
     {
         //Server sent correction packet for the trashId
         //Switch item on position NewId, with item on position OriginalId
         TrashManager.SwitchTrashWithIds(packet.OriginalId, packet.NewId);
     }
 }
Beispiel #7
0
    public void SetTrashManager(TrashManager trashManager)
    {
        this.trashManager = trashManager;

        if (this.trashManager != null && this.Model != null)
        {
            this.trashManager.OnTriggerEnterAction += this.Model.OnTriggerEnterAction;
        }
    }
Beispiel #8
0
    private void OnCollisionEnter2D(Collision2D collision)
    {
        Trash trash = collision.gameObject.GetComponent <Trash>();

        if (trash != null && addTrash())
        {
            collision.gameObject.SetActive(false);
            TrashManager.collectGarbage(collision.transform.GetSiblingIndex());
        }
    }
Beispiel #9
0
        public void ProcessPacket(TrashSystemNewTrashCreatedPacket packet, NebulaConnection conn)
        {
            int myId = SimulatedWorld.GenerateTrashOnPlayer(packet);

            //Check if myID is same as the ID from the host
            if (myId != packet.TrashId)
            {
                TrashManager.SwitchTrashWithIds(myId, packet.TrashId);
            }
        }
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();
        GUILayout.FlexibleSpace();
        TrashManager trashManager = (TrashManager)target;

        if (GUILayout.Button("Clear Trash"))
        {
            trashManager.ClearTrash();
        }
    }
Beispiel #11
0
    private void Awake()
    {
        main = this;

        trashList             = new List <Trash>();
        selectedTrash         = new List <Trash>();
        waitingTrash          = new List <Trash>();
        trashSiteList         = new List <Waypoint>();
        trashCapacities       = new Dictionary <Waypoint, float>();
        trashWaitingWaypoints = new Dictionary <Trash, Waypoint>();
    }
Beispiel #12
0
    private void Start()
    {
        roomResultManager = GetComponent <RoomResultsManager>();
        currentTime       = UnityEngine.Random.Range(TimeFilmingMin, TimeFilmingMax);

        objectDetect.objectDetected.AddListener(EventObjectIn);
        objectDetect.onLeaveRoom.AddListener(OnLeaveRoom);

        trashManager = GetComponent <TrashManager>();
        trashManager.trashClean.AddListener(EventClean);
    }
Beispiel #13
0
        /// <summary>
        /// Checks For collision between the hunter and trash
        /// </summary>
        private void CheckForCollision()
        {
            trashBoundry          = trash.Bounds;
            trashBoundry.Location = trashPosition.ToPoint();

            Hunter       hunter      = Game.Services.GetService <Hunter>();
            TrashManager trashManger = Game.Services.GetService <TrashManager>();

            if (trashBoundry.Intersects(hunter.HunterBounds))
            {
                Game.Services.GetService <Score>().AddScore(10);
                pickup.Play();
                Game.Components.Remove(this);
                trashManger.TrashList.Remove(this);
                this.Enabled = false;
            }
        }
    private void OnTriggerEnter2D(Collider2D other)
    {
        switch (other.tag)
        {
        case "Dust":
            TrashManager trash      = other.GetComponent <TrashManager>();
            int          trashValue = trash.trashValue;
            GrowTrashBall(other.gameObject, trashValue);
//                levelManager.SetNumberOfTrashCollected();
            break;

        case "Souvenir":
            Destroy(other.gameObject);
            break;

        default:
            break;
        }
    }
Beispiel #15
0
    public void ChangeScene()
    {
        if (resetProgress)
        {
#if UNITY_EDITOR
            Debug.LogWarning("RESETTING PROGRESS");
#endif
            Player.ResetProgress();
            TrashManager.reset();
            EventTracker.GetInstance().RegisterEndEvent();
        }

        if (startGame)
        {
            EventTracker.GetInstance().RegisterStartEvent();
        }

        Cursor.visible = true;
        SceneManager.LoadScene(sceneName);
    }
    private void GrowTrashBall(GameObject toDestroy, int massScaleAmount)
    {
        float scaleF = massScaleAmount / 100f;

        transform.localScale += new Vector3(scaleF, scaleF, scaleF);
        rb.mass += massScaleAmount;
        if (toDestroy.CompareTag("Dust"))
        {
            TrashManager trashScript = toDestroy.GetComponent <TrashManager>();
            trashScript.PlayTrashClip();
//            Destroy(toDestroy.gameObject);
        }
        else
        {
            GetComponent <EatAndBeingEaten>().EatABall(toDestroy);
        }
        if (rb.mass >= 10)
        {
            transform.GetChild(0).gameObject.SetActive(true);
            massText.text = rb.mass + "kg";
        }
    }
Beispiel #17
0
        public override void Update(GameTime gameTime)
        {
            trashPosition  += Speed;
            trashPosition.Y = MathHelper.Clamp(trashPosition.Y, 0, GraphicsDevice.Viewport.Height - YCLAMP);

            if (trashPosition.Y == GraphicsDevice.Viewport.Height - 40 && playEffect == true)
            {
                soundEffects.Play();
                playEffect = false;
            }
            AnimalsDead animalsDead = Game.Services.GetService <AnimalsDead>();

            if (animalsDead.Dead > 9)
            {
                TrashManager trashManger = Game.Services.GetService <TrashManager>();
                trashManger.SpawnTimer = 5;
                Game.Components.Remove(this);
                trashManger.TrashList.Remove(this);
                animalsDead.GameOver = false;
            }
            CheckForCollision();

            base.Update(gameTime);
        }