Пример #1
0
        public int extrasID;            // which extra option was selected

        // CONSTRUCTOR for the class
        public SaveableStaff(StaffMember s)
        {
            this.index = s.GetIndex();
            this.currentJob = s.GetJobID();
            this.dayHired = s.GetStartDay();
            this.name = s.GetStaffname();
            this.attributes = s.GetAttributes();
            this.transformID = s.GetTransformID();

            Color[] c = s.GetAllColours();

            // set colours
            for (int i = 0; i < 3; i++) {
                colourArrays[i,0] = c[i].r;
                colourArrays[i,1] = c[i].g;
                colourArrays[i,2] = c[i].b;
            }

            hairStyleID = s.GetHairID();
            extrasID = s.GetExtrasID();
        }
Пример #2
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();
    }
Пример #3
0
    /// <summary>
    /// Create a staff member
    /// </summary>
    /// <param name="staff">The staff member object associated with the Game Object</param>
    /// <param name="xPos">The x position of the staff member</param>
    /// <param name="yPos">The y position of the staff member</param>
    void CreateStaff(StaffMember staff, int xPos, int yPos)
    {
        // get the colours to set the components to
        Color[] colours = AppearanceScript.colours;

        Vector3 pos = new Vector3(xPos, yPos);

        Transform t = staff.GetTransform();

        GameObject goStaff = (GameObject)Instantiate(t.gameObject, pos, Quaternion.identity);
        goStaff.name = "Staff#" + staff.GetIndex();
        goStaff.tag = "Staff";
        goStaff.GetComponent<mouseDrag>().staffMember = staff;

        float x = pos.x;
        float y = pos.y;

        goStaff.GetComponent<mouseDrag>().staffMember.SetVector(x, y);

        // colours[2] = skin
        // colours[1] = hair
        // colours[0] = shirt

        SpriteRenderer[] components = goStaff.GetComponentsInChildren<SpriteRenderer>();
        components[0].color = colours[0];
        components[1].color = colours[2];
        components[2].color = colours[2];
        components[3].color = colours[1];
        components[4].color = colours[1];

        components[0].sortingOrder = xPos;
        components[1].sortingOrder = xPos + 2;
        components[2].sortingOrder = xPos + 1;
        components[3].sortingOrder = xPos + 3;
        components[4].sortingOrder = xPos + 2;
        components[5].sortingOrder = xPos + 3;
        components[6].sortingOrder = xPos + 1;

        // TODO: sort the colour if not 0 or 2
        components[3].sprite = AppearanceScript.hairStyle;
        components[4].sprite = AppearanceScript.extraOption;

        GameObject[] sms = GameObject.FindGameObjectsWithTag("Staff");
        for (int i = 0; i < sms.Length; i++)
        {
            sms[i].GetComponent<SpriteRenderer>().color = colours[0];
        }

        // staff menu stuff
        GameObject go = (GameObject)Instantiate(staffInfoObject.gameObject, new Vector3(0, 0, 0), Quaternion.identity);
        go.transform.SetParent(popupController.staffList, false);

        Image[] imgs = go.GetComponentsInChildren<Image>();
        Text[] txts = go.GetComponentsInChildren<Text>();

        imgs[1].color = staff.GetColourByIndex(2);
        imgs[2].color = staff.GetColourByIndex(1);
        imgs[3].color = staff.GetColourByIndex(1);

        if (staff.GetHairStyle() != null)
        {
            imgs[3].sprite = staff.GetHairStyle();
        }
        else
        {
            imgs[3].sprite = null;
            imgs[3].color = new Color(0, 0, 0, 0);
        }

        if (staff.GetExtras() != null)
        {
            imgs[2].sprite = staff.GetExtras();
        }
        else
        {
            imgs[2].sprite = null;
            imgs[2].color = new Color(0, 0, 0, 0);
        }

        txts[0].text = staff.GetStaffname();

        Button b = imgs[4].GetComponent<Button>();
        b.onClick.AddListener(() => MoveToStaffLocation(staff.GetIndex()));

        Button b2 = imgs[5].GetComponent<Button>();
        b2.onClick.AddListener(() => ViewStaffMemberInfo(staff.GetIndex()));

        staffMenuList.Add(go);

        // check if the collar needs to change
        int totalAttribute = staff.GetLevel();

        SpriteRenderer collar = goStaff.transform.FindChild("collar").GetComponent<SpriteRenderer>();
        collar.sprite = collarImages[totalAttribute - 1];
    }