예제 #1
0
    public PlayerData(List<ScreenObject> screens, Color col, List<StaffMember> staff, List<FilmShowing> films, int coins, int day, int popcorn, List<OtherObject> others, bool redCarpet, bool marble, Reputation rep, int boxOffice, FoodArea fa, bool[] poster, Options opt)
    {
        theScreens = screens.ToArray();
        carpetColour = new float[4] { col.r, col.g, col.b, col.a };

        List<SaveableStaff> staffList = new List<SaveableStaff>();

        for (int i = 0; i < staff.Count; i++)
        {
            SaveableStaff s = new SaveableStaff(staff[i]);
            staffList.Add(s);
        }

        staffMembers = staffList.ToArray();
        filmShowings = films.ToArray();
        totalCoins = coins;
        currentDay = day;
        numPopcorn = popcorn;
        otherObjects = others.ToArray();
        hasRedCarpet = redCarpet;
        marbleFloor = marble;
        reputation = rep;
        boxOfficeLevel = boxOffice;
        posters = poster;
        foodArea = fa;
        options = opt;
    }
예제 #2
0
파일: Food.cs 프로젝트: rob1997/MLEcosystem
    void FindFoodArea(Transform parent)
    {
        _foodArea = parent.GetComponentInParent <FoodArea>();

        if (_foodArea == null)
        {
            FindFoodArea(_foodArea.GetComponentInParent <Transform>());
        }
    }
예제 #3
0
    /// <summary>
    /// Calculate how many coins should be returned once an object is sold
    /// </summary>
    /// <returns>How many coins should be returned</returns>
    public static int GetReturnedCoins(string tagSelected, int upgradeLevelSelected, FoodArea fa)
    {
        int paidMoney = 0;

        paidMoney = GetCost(tagSelected);

        int coinsReturned = (int)(Math.Round(0.6f * (float)paidMoney, 0));

        #region Calculate upgrade costs
        int upgradeCosts = 0;

        if (tagSelected.Equals("Screen"))
        {
            switch (upgradeLevelSelected)
            {
                case 2: upgradeCosts = 180; break;
                case 3: upgradeCosts = 720; break;
                case 4: upgradeCosts = 2800; break;
            }
        }
        else if (tagSelected.Equals("Food Area"))
        {
            if (fa.hasHotFood)
            {
                upgradeCosts += 200;
            }
            if (fa.hasIceCream)
            {
                upgradeCosts += 900;
            }
            if (fa.hasPopcorn)
            {
                upgradeCosts += 1500;
            }
            if (fa.tableStatus == 2)
            {
                upgradeCosts += 450;
            }
        }

        coinsReturned += upgradeCosts;
        #endregion

        return coinsReturned;
    }
예제 #4
0
    // Use this for initialization
    void Start()
    {
        options = new Options();

        ConfirmationScript[] sdsdfd = GameObject.FindObjectsOfType<ConfirmationScript>();

        ticketQueue = new CustomerQueue(11, 38.5f, 6.8f, 0);

        #region Find Objects
        theTileManager = GameObject.Find("TileManagement").GetComponent<TileManager>();

        GameObject custStatus = GameObject.Find("Customer Status");
        movementScript.customerStatus = custStatus;
        GameObject[] tmpArray = GameObject.FindGameObjectsWithTag("Floor Tile");
        steps = GameObject.Find("Steps");
        mouseDrag.staffAttributePanel = GameObject.Find("Staff Attributes");
        #endregion

        Customer.tiles = floorTiles;

        #region Hide Objects on Start
        custStatus.SetActive(false);

        shopController.redCarpet.SetActive(false);
        mouseDrag.staffAttributePanel.SetActive(false);
        #endregion

        #region Add Delegate references
        mouseDrag.getStaffJobById += GetStaffJobById;
        mouseDrag.changeStaffJob += UpdateStaffJob;
        movementScript.addToQueueTickets += AddToQueueTickets;
        movementScript.getQueueTicketsSize += GetTicketQueueSize;
        movementScript.addToQueueFood += AddToQueueFood;
        movementScript.getQueueFoodSize += GetFoodQueueSize;
        #endregion

        #region Facebook stuff
        GameObject pnlNoFriends = GameObject.Find("pnlNoFriends");

        try
        {
            string fbUserID = FBScript.current.id;
            if (fbUserID.Length > 0)
            {
                cmdFriends.SetActive(true);
                facebookProfile = new FacebookFriend();
                facebookProfile.name = FBScript.current.firstname + " " + FBScript.current.surname;
                facebookProfile.id = FBScript.current.id;
                facebookProfile.friends = FBScript.current.friendList;

                if (facebookProfile.friends.Count > 0)
                {
                    pnlNoFriends.SetActive(false);
                }
                else
                {
                    pnlNoFriends.SetActive(true);
                }

                for (int i = 0; i < facebookProfile.friends.Count; i++)
                {
                    GameObject go = (GameObject)Instantiate(friendObject.gameObject, new Vector3(0, 0, 0), Quaternion.identity);
                    go.transform.SetParent(popupController.friendList, false);

                    Text[] textComponents = go.GetComponentsInChildren<Text>();
                    textComponents[0].text = facebookProfile.friends[i].name;

                    Button[] buttonComponents = go.GetComponentsInChildren<Button>();
                    string idToSend = facebookProfile.friends[i].id;
                    string nameToSend = facebookProfile.friends[i].name;
                    buttonComponents[0].onClick.AddListener(() => ViewFriendsCinema(idToSend, nameToSend));
                    buttonComponents[1].onClick.AddListener(() => ViewFriendsCinema(idToSend, nameToSend));

                }
            }
            else
            {
                pnlNoFriends.SetActive(true);
                // if the user has not logged into Facebook, hide the facebook friends button
                cmdFriends.SetActive(false);
            }
        }
        catch (Exception) { }
        #endregion

        // this will change depending on starting upgrade levels and other queues etc

        #region Load / New Game

        if (ButtonScript.friendData != null)
        {
            GameObject.Find("Bottom Panel").SetActive(false);
            GameObject.Find("lblOwnerName").GetComponent<Text>().text = ButtonScript.owner + "'s Cinema";
            ButtonScript.dataCopy = ButtonScript.loadGame;
            ButtonScript.loadGame = ButtonScript.friendData;
            ButtonScript.friendData = null;
        }
        else
        {
            GameObject.Find("FriendPanel").SetActive(false);
        }

        // get Player data. If not null, load game
        if (ButtonScript.loadGame == null)
        {
            financeController.Inititalise(45000, 4);

            carpetColour = GetColourFromID(1);

            customerController.reputation = new Reputation();
            customerController.reputation.Initialise();

            OtherObjectScript.CreateStaffSlot(1, new Vector3(37.8f, 12.3f, 0));

            #region Floor Tiles
            floorTiles = new GameObject[40, 80];

            // initialise the floor tiles
            for (int i = 0; i < tmpArray.Length; i++)
            {
                string name = tmpArray[i].name;

                string[] tmp = name.Split('~');
                int x = int.Parse(tmp[1]);
                int y = int.Parse(tmp[2]);

                tmpArray[i].GetComponent<SpriteRenderer>().color = carpetColour;
                tmpArray[i].GetComponent<SpriteRenderer>().sprite = ColourBackground;
                //tmpArray[i].GetComponent<SpriteRenderer>().sprite = profilePicture;   // for funny times, uncomment this line

                floorTiles[x, y] = tmpArray[i];
            }
            #endregion

            for (int i = 0; i < 1; i++)
            {
                Vector3 pos = floorTiles[i * 11, 0].transform.position;
                ShopController.theScreens.Add(new ScreenObject((i + 1), 0));
                ShopController.theScreens[i].SetPosition((int)pos.x, (int)pos.y);
            }
            ShopController.theScreens[0].Upgrade();
            ShopController.theScreens[0].UpgradeComplete();
            // NYAH

            NextDay(false, false);

            // do staff intro thing here
            popupController.ShowPopup(99, "Welcome!!! This is your cinema!\nLets get started by hiring some staff shall we?");

            foodArea = null;

        }
        else
        {
            statusCode = 0;

            PlayerData data = ButtonScript.loadGame;

            carpetColour = new Color(data.carpetColour[0], data.carpetColour[1], data.carpetColour[2]);

            shopController.LoadDecorations(data.hasRedCarpet, data.posters);

            isMarbleFloor = data.marbleFloor;
            customerController.reputation = data.reputation;
            foodArea = data.foodArea;

            options.Load(data.options);

            int boxLevel = data.boxOfficeLevel;
            OtherObjectScript.CreateStaffSlot(1, new Vector3(37.8f, 12.3f, 0));

            for (int i = 0; i < boxLevel - 1; i++)
            {
                OtherObjectScript.UpgradeBoxOffice();
            }

            #region Floor Tiles
            // initialise the floor tiles
            floorTiles = new GameObject[40, 80];

            for (int i = 0; i < tmpArray.Length; i++)
            {
                string name = tmpArray[i].name;

                string[] tmp = name.Split('~');
                int x = int.Parse(tmp[1]);
                int y = int.Parse(tmp[2]);

                tmpArray[i].GetComponent<SpriteRenderer>().color = carpetColour;
                if (!isMarbleFloor)
                {
                    tmpArray[i].GetComponent<SpriteRenderer>().sprite = ColourBackground;
                }
                else
                {
                    tmpArray[i].GetComponent<SpriteRenderer>().sprite = marbleSquares[UnityEngine.Random.Range(0, 3)];
                }

                floorTiles[x, y] = tmpArray[i];
            }
            #endregion

            ShopController.theScreens = new List<ScreenObject>(data.theScreens);

            SaveableStaff[] s = data.staffMembers;

            for (int i = 0; i < s.Length; i++)
            {
                int id = s[i].index;
                string name = s[i].name;
                Transform transform = staffPrefab;
                int dayHired = s[i].dayHired;
                int tID = s[i].transformID;
                int[] attributes = s[i].attributes;
                float[,] cols = s[i].colourArrays;
                int hair = s[i].hairStyleID;
                int extras = s[i].extrasID;

                GameObject go = GameObject.Find("AppearanceController");
                AppearanceScript aS = go.GetComponent<AppearanceScript>();

                Sprite hairSprite = null;
                Sprite extraSprite = null;

                if (hair != 9)
                {
                    hairSprite = aS.hairStyles[hair];
                }
                if (extras != 5)
                {
                    extraSprite = aS.extraImages[extras];
                }
                Color[] c = new Color[3];

                for (int colID = 0; colID < 3; colID++)
                {
                    c[colID] = new Color(cols[colID, 0], cols[colID, 1], cols[colID, 2]);
                }

                StaffMember newStaff = new StaffMember(id, name, transform, dayHired, tID, hairSprite);
                newStaff.SetColours(c, hair, extras);
                newStaff.SetSprites(hairSprite, extraSprite);
                newStaff.SetAttributes(attributes);

                int x = 35 + (2 * (newStaff.GetIndex() % 6)); ;
                int y = 2 * (newStaff.GetIndex() / 6);

                staffMembers.Add(newStaff);
                CreateStaff(newStaff, x, y);
            }

            filmShowings = new List<FilmShowing>(data.filmShowings);
            currDay = data.currentDay;
            numScreens = ShopController.theScreens.Count;
            financeController.Inititalise(data.totalCoins, data.numPopcorn);
            ShopController.otherObjects = new List<OtherObject>(data.otherObjects);

            NextDay(false, false);
            currDay--; // needed for some reason

            // hopefully un-breaks things
            for (int i = 0; i < ShopController.theScreens.Count; i++)
            {
                Vector3 pos = new Vector3(ShopController.theScreens[i].GetX(), ShopController.theScreens[i].GetY(), 0);
                ShopController.theScreens[i].SetPosition((int)pos.x, (int)(pos.y));
            }

            // sort staff appearance
            GameObject[] staffs = GameObject.FindGameObjectsWithTag("Staff");
            for (int i = 0; i < staffs.Length; i++)
            {
                SpriteRenderer[] srs = staffs[i].GetComponentsInChildren<SpriteRenderer>();
                srs[0].color = staffMembers[i].GetColourByIndex(0);
                srs[1].color = staffMembers[i].GetColourByIndex(2);
                srs[2].color = staffMembers[i].GetColourByIndex(2);
                srs[3].color = staffMembers[i].GetColourByIndex(1);
                srs[4].color = staffMembers[i].GetColourByIndex(1);

                srs[3].sprite = staffMembers[i].GetHairStyle();
                srs[4].sprite = staffMembers[i].GetExtras();
            }

            shopController.ShowPosters(0);
            shopController.ShowPosters(1);

            if (popcornSpent > 0)
            {
                financeController.RemovePopcorn(Controller.popcornSpent);
                financeController.popcornLabel.text = financeController.GetNumPopcorn().ToString();
                Controller.popcornSpent = 0;
                DoAutosave();
            }

            string fbID = FBScript.current.id;

            try
            {
                if (isOwned)
                {
                    Gifting g = new Gifting();
                    List<String> gifts = g.GetGifts(fbID);

                    if (gifts.Count > 0)
                    {

                        List<int> counts = new List<int>();
                        List<string> names = new List<string>();

                        // group together - i.e. Susan McDonaldman: 3
                        for (int i = 0; i < gifts.Count; i++)
                        {

                            bool found = false;

                            for (int checkLoop = 0; checkLoop < names.Count; checkLoop++)
                            {
                                if (names[checkLoop].Equals(gifts[i]))
                                {
                                    found = true;
                                    counts[checkLoop]++;
                                    break;
                                }
                            }

                            if (!found)
                            {
                                names.Add(gifts[i]);
                                counts.Add(1);
                            }
                        }

                        financeController.AddPopcorn(gifts.Count);

                        for (int i = 0; i < names.Count; i++)
                        {
                            // add the element / objects
                            Transform t = Instantiate(giftObject, new Vector2(0, 0), Quaternion.identity) as Transform;
                            // set parent to the element container

                            Transform giftContainer = GameObject.Find("GiftContainer").transform;

                            t.SetParent(giftContainer);
                            // change the values
                            Text[] txts = t.GetComponentsInChildren<Text>();
                            txts[0].text = names[i];
                            txts[1].text = counts[i].ToString();
                        }

                        // show the popup
                        GameObject giftPanel = GameObject.Find("GiftList");
                        giftPanel.GetComponent<Canvas>().enabled = true;

                        DoAutosave();

                    }

                }
            }
            catch (Exception)
            {
                popupController.ShowPopup(0, "Error getting Gifts");
            }
        }

        #endregion

        // create some test screens
        for (int i = 0; i < ShopController.theScreens.Count; i++)
        {
            Vector3 pos = new Vector3(ShopController.theScreens[i].GetX(), ShopController.theScreens[i].GetY() * 0.8f, 0);

            // change pos and element here
            pos.y += 0.8f;

            shopController.AddScreen(ShopController.theScreens[i], pos, height);

            SetTiles(2, (int)(ShopController.theScreens[i].GetX()), (int)(ShopController.theScreens[i].GetY()), 11, 15);
        }

        // do same for other objects
        for (int i = 0; i < ShopController.otherObjects.Count; i++)
        {
            Vector3 pos = new Vector3(ShopController.otherObjects[i].xPos, ShopController.otherObjects[i].yPos * 0.8f, 0);

            DimensionTuple t = shopController.GetBounds(ShopController.otherObjects[i].type);

            shopController.AddObject(pos, i, height, ShopController.otherObjects[i].type, true);

            SetTiles(2, (int)(ShopController.otherObjects[i].xPos), (int)(ShopController.otherObjects[i].yPos), t.width, t.height);
        }

        //createColourPicker();

        if (updateTileState != null)
        {
            updateTileState(33, 0, 14, 16, 1, true);
            updateTileState(33, 16, 14, 4, 2, true);
        }

        GameObject[] pointers = GameObject.FindGameObjectsWithTag("Pointer");

        for (int i = 0; i < pointers.Length; i++)
        {
            pointers[i].GetComponent<Transform>().GetComponent<SpriteRenderer>().enabled = false;
        }

        dayLabel.text = "DAY: " + currDay.ToString();

        // create staff slots for food area if not null
        if (foodArea != null)
        {
            GameObject go = GameObject.FindGameObjectWithTag("Food Area");
            Vector2 pos = go.transform.position;

            for (int i = 0; i < foodArea.tableStatus + 1; i++) {
                OtherObjectScript.CreateStaffSlot(2, pos + new Vector2(3 + (2.5f * i), 7.95f));
            }

            if (foodArea.tableStatus == 1)
            {
                foodQueue.Upgrade();
            }
        }

        NewShowTimes();
    }
예제 #5
0
    /// <summary>
    /// Remove an object from the cinema
    /// </summary>
    /// <param name="x">The x coordinate of the item to remove</param>
    /// <param name="y">The y coordinate of the item to remove</param>
    /// <param name="w">How many tiles wide the item to remove is</param>
    /// <param name="h">How many tiles high the item to remove is</param>
    public void RemoveObject(int x, int y, int w, int h)
    {
        if (tagSelected.Equals("Food Area"))
        {
            foodArea = null;

            // destroy all staff slots associated
            GameObject[] foodSlots = GameObject.FindGameObjectsWithTag("Slot Type 2");

            for (int i = 0; i < staffSlot.Count; i++)
            {
                for (int j = 0; j < foodSlots.Length; j++)
                {
                    if (staffSlot[i].name.Equals(foodSlots[j].name))
                    {
                        staffSlot.RemoveAt(i);
                        Destroy(foodSlots[j]);
                    }
                }
            }

            // unassign staff members associated with the food area
            for (int i = 0; i < staffMembers.Count; i++)
            {
                if (staffMembers[i].GetJobID() == 2)
                {
                    UpdateStaffJob(i, 0, -1, false);
                }
            }
        }

        GameObject go = GameObject.Find(objectSelected);
        if (objectSelected.Contains("Screen"))
        {
            shopController.SellScreen(objectSelected);
        }
        else
        {
            shopController.SellObject(objectSelected);

        }

        GameObject.Destroy(go);
        theTileManager.fullHeight = h;
        theTileManager.fullWidth = w;
        popupController.HideObjectInfo();
        SetTiles(0, x, y, w, h);
        theTileManager.ColourAllTiles(x, y, carpetColour);
        theTileManager.fullHeight = -1;
        theTileManager.fullHeight = -1;

        theTileManager.ShowOutput();
    }
예제 #6
0
    /// <summary>
    /// Add a new object to the cinema
    /// </summary>
    /// <param name="x">The x position to add it in</param>
    /// <param name="y">The y position to add it in</param>
    public void AddNewObject(int x, int y)
    {
        popupController.confirmMovePanel.SetActive(false);
        popupController.moveButtons.SetActive(false);

        Vector3 pos = new Vector3(x, y * 0.8f, 0);

        //float xCorrection = 0;
        //float yCorrection = 0;

        if (itemToAddID == 0)
        {
            //xCorrection = 4.6f;
            //yCorrection = 6.05f;

            int newID = ShopController.theScreens.Count;
            ScreenObject aScreen = new ScreenObject(newID + 1, 0);
            aScreen.SetPosition(x, y);
            aScreen.Upgrade();
            ShopController.theScreens.Add(aScreen);

            //pos.x += xCorrection;
            //pos.y += yCorrection;
            pos.y += 0.8f; // gap at bottom

            GameObject screenThing = shopController.AddScreen(ShopController.theScreens[newID], pos, height);

            // check staff position
            CheckStaffPosition(screenThing);

            for (int i = 0; i < staffMembers.Count; i++)
            {
                staffMembers[i].GetTransform().Translate(new Vector3(0, 0, -1));
            }
        }
        else {

            if (itemToAddID == 7)
            {
                foodArea = new FoodArea();
                foodArea.hasHotFood = true;     // give them 1 thing to start with

                foodQueue = new CustomerQueue(70, x + 3, ((y + 4) * 0.8f) - 1, 1);

            }

            OtherObject oo = new OtherObject(x, y, itemToAddID, ShopController.otherObjects.Count + 1);

            ShopController.otherObjects.Add(oo);

            GameObject theObject = shopController.AddObject(pos, ShopController.otherObjects.Count, height, itemToAddID, true);

            // check staff position
            CheckStaffPosition(theObject);

            for (int i = 0; i < staffMembers.Count; i++)
            {
                staffMembers[i].GetTransform().Translate(new Vector3(0, 0, -1));
            }

            SpriteRenderer[] subImages = theObject.GetComponentsInChildren<SpriteRenderer>();

            if (itemToAddID == 7)
            {
                try
                {
                    subImages[1].enabled = foodArea.hasHotFood;
                    subImages[2].enabled = foodArea.hasPopcorn;
                    subImages[3].enabled = foodArea.hasIceCream;
                    subImages[4].enabled = true;
                    subImages[5].enabled = true;

                    int baseOrder = subImages[0].sortingOrder;
                    subImages[0].sortingOrder = baseOrder - 2;
                    subImages[1].sortingOrder = baseOrder + 1;
                    subImages[2].sortingOrder = baseOrder + 1;
                    subImages[3].sortingOrder = baseOrder + 1;
                    subImages[4].sortingOrder = baseOrder + 1;
                    subImages[5].sortingOrder = baseOrder - 5;

                    OtherObjectScript.CreateStaffSlot(2, theObject.transform.position + new Vector3(3, 7.95f, 0));
                    NewShowTimes();
                }
                catch (Exception) { }
            }
        }
        itemToAddID = -1;

        SetTiles(2, theTileManager.toMoveX, theTileManager.toMoveY, theTileManager.fullWidth, theTileManager.fullHeight);
        ChangeColour(carpetColour, theTileManager.toMoveX, theTileManager.toMoveY, theTileManager.fullWidth, theTileManager.fullHeight);

        CheckForPath();

        theTileManager.ResetStatusVariables();

        statusCode = 0;

        //GameObject[] staff = GameObject.FindGameObjectsWithTag("Staff");
        //for (int i = 0; i < staff.Length; i++)
        //{
        //    SpriteRenderer[] srs = staff[i].GetComponentsInChildren<SpriteRenderer>();
        //    for (int j = 0; j < 6; j++)
        //    {
        //        srs[j].enabled = true;
        //    }

        //    srs[5].enabled = false;

        //    // sort z position
        //    staff[i].transform.position = new Vector3(staff[i].transform.position.x, staff[i].transform.position.y, -1);

        //}

        ReShowStaffAndBuildings();

        GameObject foodPlace = GameObject.FindGameObjectWithTag("Food Area");
        if (foodPlace != null)
        {
            SpriteRenderer[] foodAreaRenderers = foodPlace.GetComponentsInChildren<SpriteRenderer>();
            foreach (SpriteRenderer sr in foodAreaRenderers)
            {
                sr.color = new Color(1, 1, 1, 1);
            }
        }

        objectSelected = "";
        tagSelected = "";
        upgradeLevelSelected = 0;
    }