Exemplo n.º 1
0
    public void Change(screen _screen)
    {
        if (currentScreen == _screen)
        {
            return;
        }

        ScreenObject obj = Screens.Find(x => x.sceen == _screen);

        if (obj != null)
        {
            foreach (var i in Screens)
            {
                foreach (var j in i.objects)
                {
                    j.SetActive(false);
                }
            }

            currentScreen = _screen;

            foreach (var i in obj.objects)
            {
                i.SetActive(true);
            }
        }
    }
Exemplo n.º 2
0
        /// <inheritdoc />
        protected override void OnParentChanged(ScreenObject oldParent, ScreenObject newParent)
        {
            _surfaceParent = newParent as SurfaceBase;
            IsPaused       = _surfaceParent == null;

            if (_surfaceParent != null)
            {
                foreach (var zone in Zones)
                {
                    if (zone.Parent != _surfaceParent)
                    {
                        zone.Parent = _surfaceParent;
                    }
                }

                foreach (var spot in Hotspots)
                {
                    if (spot.Parent != _surfaceParent)
                    {
                        spot.Parent = _surfaceParent;
                    }
                }

                foreach (var entity in Entities)
                {
                    if (entity.Parent != _surfaceParent)
                    {
                        entity.Parent = _surfaceParent;
                    }
                }

                Sync();
            }
        }
Exemplo n.º 3
0
    static protected void loadMissingScreen(string screenName, Action <ScreenObject> onComplete)
    {
        ScreenLoading.showLoadingScreen();

        //re-add "screen-" prefix if missing
        string fullName = screenName;

        if (!fullName.StartsWith("screen-"))
        {
            fullName = "screen-" + fullName;
        }

        // first search if already exists
        ScreenObject so = getScreen(fullName);

        if (so != null)
        {
            onComplete(so);
            return;
        }

        Debug.Log("screen to open : <b>" + fullName + "</b> is not loaded");

        EngineLoader.queryScene(fullName, delegate()
        {
            so = getScreen(screenName);
            if (so == null)
            {
                Debug.LogError("ScreensManager | end of screen loading (name given : " + screenName + ") but no <ScreenObject> returned");
            }
            onComplete(so);
        });
    }
Exemplo n.º 4
0
        /// <summary>
        /// Remplace tous les écrans du jeu par nextScreen.
        /// l'apparition de l'écran se fait seulement quand tous les anciens écrans auront disparu.
        /// </summary>
        /// <param name="nextScreen"></param>
        public void Switch(ScreenObject nextScreen)
        {
            if (displayedScreens.Contains(nextScreen))
            {
                return;
            }

            if (displayedScreens.Count == 0)
            {
                Display(nextScreen);
                return;
            }

            callback           = DisplayNextScreen;
            nextScreenToAppear = nextScreen;
            ScreenObject lastScreen;

            for (int i = displayedScreens.Count - 1; i >= 0; i--)
            {
                lastScreen = displayedScreens[0];
                counter++;

                Remove(lastScreen);
            }
        }
Exemplo n.º 5
0
    /// <summary>
    /// best practice : should never call a screen by name but create a contextual enum
    /// this function won't return a screen that is not already loaded
    /// </summary>
    static public ScreenObject open(string nm, string filterName = "", Action onComplete = null)
    {
        Debug.Log("ScreensManager | opening screen of name : <b>" + nm + "</b> , filter ? " + filterName);

        // -- removing startup "screen-" prefix
        string prefix = "screen-";

        if (nm.StartsWith(prefix))
        {
            nm = nm.Substring(prefix.Length, nm.Length - prefix.Length);
        }

        ScreenObject so = getScreen(nm);

        if (so != null)
        {
            changeScreenVisibleState(nm, true, filterName);
            return(so);
        }

        //si le screen existe pas on essaye de le load
        loadMissingScreen(nm, delegate(ScreenObject loadedScreen)
        {
            Debug.Log("  ... missing screen '" + nm + "' is now loaded, opening");
            changeScreenVisibleState(nm, true, filterName);
            if (onComplete != null)
            {
                onComplete();
            }
        });

        return(null);
    }
Exemplo n.º 6
0
        private void ManCollision(ScreenObject man, ScreenObject ball2)
        {
            #region vars
            float  d;          //distance between
            double phi1;       //angle of collision
            double dmin;       //r1 + r2
            double difference; //move ball 2 this much outside of ball 1 after collision
            #endregion

            d    = Vector2.Distance(ball2.location, man.location);
            dmin = man.radius + ball2.sRadius;
            phi1 = Math.Atan2((ball2.location.Y - man.location.Y), (ball2.location.X - man.location.X));

            if (d <= dmin)
            {
                man.hit = true;
                #region displacement correction
                difference  = dmin;
                difference -= d;
                Vector2 dx = new Vector2((float)(difference * Math.Cos(phi1)), (float)(difference * Math.Sin(phi1)));
                man.location -= dx;
                #endregion

                man.oldLocation = man.location;
            }
        }
Exemplo n.º 7
0
        private void TransitionScreen_OnDisappearEnd(ScreenObject sender)
        {
            sender.OnDisappearEnd -= TransitionScreen_OnDisappearEnd;
            transitionScreen       = null;

            callback();
            callback = null;
        }
Exemplo n.º 8
0
        public void ScreenObject_SaveLoad()
        {
            new SadConsole.Tests.BasicGameHost();
            ScreenObject obj = new ScreenObject();

            obj.Position    = (10, 10);
            obj.IsEnabled   = false;
            obj.IsVisible   = false;
            obj.UseKeyboard = true;
            obj.UseMouse    = false;

            ScreenObject obj2 = new ScreenObject();

            obj2.Position    = (15, 2);
            obj2.IsEnabled   = true;
            obj2.IsVisible   = false;
            obj2.UseKeyboard = false;
            obj2.UseMouse    = true;

            obj.Children.Add(obj2);

            Component1 comp1 = new Component1()
            {
                Name = "component 1"
            };
            Component1 comp2 = new Component1()
            {
                Name = "component 2"
            };

            obj.SadComponents.Add(comp1);
            obj2.SadComponents.Add(comp2);

            SadConsole.Serializer.Save(obj, "test.file", false);
            var newObj = SadConsole.Serializer.Load <ScreenObject>("test.file", false);

            Assert.AreEqual(obj.Position, newObj.Position);
            Assert.AreEqual(obj.IsEnabled, newObj.IsEnabled);
            Assert.AreEqual(obj.IsVisible, newObj.IsVisible);
            Assert.AreEqual(obj.UseKeyboard, newObj.UseKeyboard);
            Assert.AreEqual(obj.UseMouse, newObj.UseMouse);
            Assert.AreEqual(obj.AbsolutePosition, newObj.AbsolutePosition);

            Assert.AreEqual(obj2.Position, newObj.Children[0].Position);
            Assert.AreEqual(obj2.IsEnabled, newObj.Children[0].IsEnabled);
            Assert.AreEqual(obj2.IsVisible, newObj.Children[0].IsVisible);
            Assert.AreEqual(obj2.UseKeyboard, newObj.Children[0].UseKeyboard);
            Assert.AreEqual(obj2.UseMouse, newObj.Children[0].UseMouse);
            Assert.AreEqual(obj2.AbsolutePosition, newObj.Children[0].AbsolutePosition);

            Assert.IsInstanceOfType(newObj.Children[0], typeof(ScreenObject));

            Assert.AreEqual(obj.SadComponents.Count, newObj.SadComponents.Count);
            Assert.AreEqual(obj2.SadComponents.Count, newObj.Children[0].SadComponents.Count);

            Assert.AreEqual(comp1.Name, ((Component1)newObj.SadComponents[0]).Name);
            Assert.AreEqual(comp2.Name, ((Component1)newObj.Children[0].SadComponents[0]).Name);
        }
Exemplo n.º 9
0
 internal override void OnNotify(ScreenObject obj, EventType eventType, Message data)
 {
     if (eventType == EventType.Release)
     {
         int x = data.Dict["X"];
         int y = data.Dict["Y"];
         _onRelease(x, y);
     }
 }
Exemplo n.º 10
0
    //updates the variables corresponding to the background color/text/list of buttons
    public ScreenObject UpdateScreenObject(ScreenObject newCurrentScreenObject)
    {
        currentColor   = newCurrentScreenObject.background;
        currentText    = newCurrentScreenObject.text;
        currentButtons = newCurrentScreenObject.screensToConnectTo;

        UpdateLook();
        return(newCurrentScreenObject);
    }
Exemplo n.º 11
0
        /// <summary>
        /// Enlève l'écran sen prendre en compte son animation
        /// </summary>
        /// <param name="screenObject"></param>
        public void ForceRemove(ScreenObject screenObject)
        {
            if (!displayedScreens.Contains(screenObject) || !screenObject.IsAppear)
            {
                return;
            }

            displayedScreens.Remove(screenObject);
            screenObject.ForceDisappear();
        }
Exemplo n.º 12
0
    static public void unloadScreen(string nm)
    {
        ScreenObject so = getScreen(nm);

        if (so != null)
        {
            Debug.Log("unloading screen | asked name : " + nm);
            so.unload();
        }
    }
Exemplo n.º 13
0
    static public bool hasOpenScreenOfType(ScreenType type)
    {
        ScreenObject so = getOpenedScreen();

        if (so == null)
        {
            return(false);
        }
        return(so.type == type);
    }
Exemplo n.º 14
0
        /// <summary>
        /// Enlève l'écran avec son animation
        /// </summary>
        /// <param name="screenObject"></param>
        public void Remove(ScreenObject screenObject)
        {
            if (!displayedScreens.Contains(screenObject) || !screenObject.IsAppear)
            {
                return;
            }

            screenObject.OnDisappearEnd += ScreenObject_OnDisappearEnd;
            screenObject.Disappear();
        }
Exemplo n.º 15
0
    static protected void changeScreenVisibleState(string scName, bool state, string containsFilter = "", bool force = false)
    {
        fetchScreens();

        //Debug.Log("opening " + scName + " (filter ? " + filter + ")");

        ScreenObject selected = getScreen(scName);

        if (selected == null)
        {
            Debug.LogWarning("trying to change visibility of screen " + scName + " but this ScreenObject doesn't exist");
            return;
        }

        bool hideOthers = !selected.dontHideOtherOnShow;

        //Debug.Log(selected.name + " visibilty to " + state+" (filter ? "+containsFilter+" | dont hide other ? "+selected.dontHideOtherOnShow+" => hide others ? "+hideOthers+")");

        //on opening a specific screen we close all other non sticky screens
        if (hideOthers && state)
        {
            for (int i = 0; i < screens.Count; i++)
            {
                if (screens[i] == selected)
                {
                    continue;
                }

                //do nothing with filtered screen
                if (containsFilter.Length > 0 && screens[i].name.Contains(containsFilter))
                {
                    continue;
                }

                screens[i].hide();
                //Debug.Log("  L "+screens[i].name + " hidden");
            }
        }

        if (state)
        {
            selected.show();
        }
        else
        {
            if (force)
            {
                selected.forceHide();
            }
            else
            {
                selected.hide(); // stickies won't hide
            }
        }
    }
Exemplo n.º 16
0
        public void ForceDisplay(ScreenObject screenObject, int index)
        {
            if (displayedScreens.Contains(screenObject) || screenObject.IsAppear)
            {
                return;
            }

            displayedScreens.Insert(index, screenObject);
            screenObject.ForceAppear();
            SortScreens();
        }
Exemplo n.º 17
0
        /// <summary>
        /// Affiche l'écran avec son animation
        /// </summary>
        /// <param name="screenObject"></param>
        public void Display(ScreenObject screenObject)
        {
            if (displayedScreens.Contains(screenObject))
            {
                return;
            }

            displayedScreens.Add(screenObject);
            screenObject.Appear();
            SortScreens();
        }
Exemplo n.º 18
0
        /// <summary>
        /// Affiche l'écran sen prendre en compte son animation
        /// </summary>
        /// <param name="screenObject"></param>
        public void ForceDisplay(ScreenObject screenObject)
        {
            if (displayedScreens.Contains(screenObject) || screenObject.IsAppear)
            {
                return;
            }

            displayedScreens.Add(screenObject);
            screenObject.ForceAppear();
            SortScreens();
        }
Exemplo n.º 19
0
        public void Display(ScreenObject screenObject, int index)
        {
            if (displayedScreens.Contains(screenObject))
            {
                return;
            }

            displayedScreens.Insert(index, screenObject);
            screenObject.Appear();
            SortScreens();
        }
Exemplo n.º 20
0
 public void Add(ScreenObject so, bool hasParent)
 {
     if (hasParent)
     {
         so.parent = this;
     }
     else
     {
         so.parent = null;
     }
     ScreenObjectList.Add(so);
 }
Exemplo n.º 21
0
        /// <summary>
        /// Remplace lastScreen par nextScreen
        /// l'apparition de l'écran se fait seulement quand tous les anciens écrans auront disparu.
        /// </summary>
        /// <param name="nextScreen"></param>
        public void Switch(ScreenObject nextScreen, ScreenObject lastScreen)
        {
            if (displayedScreens.Contains(nextScreen))
            {
                return;
            }

            callback           = DisplayNextScreen;
            nextScreenToAppear = nextScreen;

            Remove(lastScreen);
        }
Exemplo n.º 22
0
 internal override void OnNotify(ScreenObject obj, EventType eventType, Message data)
 {
     if (eventType == EventType.Press)
     {
         int  x        = data.Dict["X"];
         int  y        = data.Dict["Y"];
         bool contains = obj.Contains(x, y);
         if (contains)
         {
             _onPress(x, y);
         }
     }
 }
Exemplo n.º 23
0
        public override void Update()
        {
            //if (!ChangeState())
            //{
            //}

            if (!_displayMenu)
            {
                _elapsedTime += Time.deltaTime;
                if (_elapsedTime >= _uiDelay)
                {
                    _displayMenu = true;
                    ScreenObject.SetActive(true);
                }
            }
        }
Exemplo n.º 24
0
        private void GetConsoles(ScreenObject screen, ref List <Console> list)
        {
            if (screen is Console)
            {
                var console = screen as Console;

                if (console.UseMouse)
                {
                    list.Add(console);
                }
            }

            foreach (var child in screen.Children)
            {
                GetConsoles(child, ref list);
            }
        }
Exemplo n.º 25
0
        private void ScreenObject_OnDisappearEnd(ScreenObject screenObject)
        {
            screenObject.OnDisappearEnd -= ScreenObject_OnDisappearEnd;
            displayedScreens.Remove(screenObject);

            if (counter > 0)
            {
                counter--;

                if (counter != 0)
                {
                    return;
                }
            }

            callback?.Invoke();
            callback = null;
        }
Exemplo n.º 26
0
        public Container()
        {
            headerConsole                     = new HeaderConsole();
            selectedConsoleContainer          = new ScreenObject();
            selectedConsoleContainer.Position = (0, headerConsole.AbsoluteArea.MaxExtentY + 1);

            consoles = new CustomConsole[] {
                new CustomConsole(new CustomConsoles.AutoTypingConsole(), "Auto Typing", "Automatic typing to a console"),
                new CustomConsole(new CustomConsoles.SplashScreen()
                {
                    SplashCompleted = MoveNextConsole
                }, "Splash Screen - Using instructions", "Chains multiple SadConsole.Instruction types to create an animation."),
                new CustomConsole(new CustomConsoles.StringParsingConsole(), "String Parser", "Examples of using the string parser"),
                new CustomConsole(new CustomConsoles.ShapesConsole(), "Shape Drawing & Text Mouse Cursor", "Examples of drawing shapes and displaying a mouse cursor"),
                new CustomConsole(new CustomConsoles.ControlsTest(), "Controls Test", "Interact with SadConsole controls"),
                new CustomConsole(new CustomConsoles.ScrollableView(), "Surface view control", "The Surface View control can peek into surfaces and scroll. Click on one"),
                new CustomConsole(new CustomConsoles.StretchedConsole(), "Font Zoom", "Console where font has been zoomed x2"),
                new CustomConsole(new CustomConsoles.MultiCursor(), "Multiple Cursors", "Consoles can have multiple cursors. Press F3 to change the active cursor."),
                new CustomConsole(new CustomConsoles.DOSConsole(), "Prompt Console", "Emulates a command prompt"),
                new CustomConsole(new CustomConsoles.FadingChild(), "Transparent blend", "Renderer can set transparency on a surface."),
                new CustomConsole(new CustomConsoles.RandomScrollingConsole(), "Scrolling", "2000x2000 scrollable console. Use the cursor keys."),
                new CustomConsole(new CustomConsoles.SerializationTests(), "Serialization Tests", "Test serializing various types from SadConsole"),
                new CustomConsole(new CustomConsoles.EntityLiteConsole(), "Entity lite demonstration", "Demonstrate using multiple visible entities. Press Q to move them"),
                //new CustomConsole(new CustomConsoles.EntityZoneConsole(), "Entity zone demonstration", "Entity that can move in and out of zones."),
                new CustomConsole(new CustomConsoles.BorderedConsole(), "Border Component", "A component that draws a border around a console"),
                new CustomConsole(new CustomConsoles.AnsiConsole(), "Ansi parsing", "Read in old DOS ANSI files."),
                new CustomConsole(new CustomConsoles.ScrollableConsole(20, 10, 60), "Text scrolling", "Renders a tiny console with a cursor along with a scroll bar"),
                new CustomConsole(new CustomConsoles.SubConsoleCursor(), "Subconsole Cursor", "Two consoles with a single backing TextSurface"),
                //new CustomConsole(new CustomConsoles.ViewsAndSubViews(), "Sub Views", "Single text surface with two views into it. Click on either view."),

                //new CustomConsole(new CustomConsoles.EntityConsole(), "Game object", "Use the cursor keys to move the little character"),
                //new CustomConsole(new CustomConsoles.MouseRenderingDebug(), "SadConsole.Instructions", "Automatic typing to a console."),
                ////new CustomConsole(new CustomConsoles.WorldGenerationConsole(), "Random world generator", "Generates a random world, displaying it at half-font size."),
                //new CustomConsole(new CustomConsoles.TextCursorConsole(), "Text Mouse Cursor", "Draws a game object where ever the mouse cursor is."),
                //new CustomConsole(new CustomConsoles.SceneProjectionConsole(), "Scene Projection", "Translating a 3D scene to a TextSurface T=Toggle B=Block Mode"),
                //new CustomConsole(new CustomConsoles.HexSurface(80 / 2, 23 / 2) { FontSize = SadConsole.GameHost.Instance.DefaultFont.GetFontSize(Font.Sizes.Two) }, "Hex surface", "Using a custom renderer and custom mouse logic to draw hex cells"),
            };

            MoveNextConsole();
        }
Exemplo n.º 27
0
    static public ScreenObject getScreen(string nm)
    {
        fetchScreens();

        ScreenObject so = screens.Select(x => x).Where(x => x.name.EndsWith(nm)).FirstOrDefault();

        if (so != null)
        {
            return(so);
        }

        //no warning because it's called before loading to check if screen already exists

        /*
         * Debug.LogWarning("~Screens~ getScreen("+nm+") <color=red>no screen that ENDWITH that name</color> (screens count : "+screens.Count+")");
         * for (int i = 0; i < screens.Count; i++)
         * {
         * Debug.Log("  L " + screens[i].name);
         * }
         */

        return(null);
    }
Exemplo n.º 28
0
        private void Gravity(ScreenObject ball1, ScreenObject ball2, float d, double phi1)
        {
            double  Fg12mag;
            Vector2 Fg12 = Vector2.Zero; //gravitational force by particle 1 on particle 2
            Vector2 Fg21 = Vector2.Zero;

            if (d != 0)
            {
                //universal gravitation equation
                Fg12mag = -G * ((ball1.mass * ball2.mass) / (d * d));
                Fg12.X  = (float)(Fg12mag * Math.Cos(phi1));
                Fg12.Y  = (float)(Fg12mag * Math.Sin(phi1));
                Fg21    = -Fg12;
                if (Fg12.Length() != 0)
                {
                    ball2.acceleration += Fg12 / ball2.mass;
                }
                if (Fg21.Length() != 0)
                {
                    ball1.acceleration += Fg21 / ball1.mass;
                }
            }
        }
Exemplo n.º 29
0
 internal abstract void OnNotify(ScreenObject obj, EventType eventType, Message data);
Exemplo n.º 30
0
        private int addDependencies(int top = 8)
        {
            int numDeps  = mod.depends?.Count ?? 0;
            int numConfs = mod.conflicts?.Count ?? 0;

            if (numDeps + numConfs > 0)
            {
                int       midL  = Console.WindowWidth / 2 - 1;
                int       h     = Math.Min(11, numDeps + numConfs + 2);
                const int lblW  = 16;
                int       nameW = midL - 2 - lblW - 2;

                AddObject(new ConsoleFrame(
                              1, top, midL, top + h - 1,
                              () => "Dependencies",
                              () => ConsoleTheme.Current.NormalFrameFg,
                              false
                              ));
                if (numDeps > 0)
                {
                    AddObject(new ConsoleLabel(
                                  3, top + 1, 3 + lblW - 1,
                                  () => $"Required ({numDeps}):",
                                  null,
                                  () => ConsoleTheme.Current.DimLabelFg
                                  ));
                    ConsoleTextBox tb = new ConsoleTextBox(
                        3 + lblW, top + 1, midL - 2, top + 1 + numDeps - 1, false,
                        TextAlign.Left,
                        () => ConsoleTheme.Current.MainBg,
                        () => ConsoleTheme.Current.LabelFg
                        );
                    AddObject(tb);
                    foreach (RelationshipDescriptor rd in mod.depends)
                    {
                        tb.AddLine(ScreenObject.FormatExactWidth(
                                       // Show install status
                                       ModListScreen.StatusSymbol(plan.GetModStatus(manager, registry, rd.ToString()))
                                       + rd.ToString(),
                                       nameW
                                       ));
                    }
                }
                if (numConfs > 0)
                {
                    AddObject(new ConsoleLabel(
                                  3, top + 1 + numDeps, 3 + lblW - 1,
                                  () => $"Conflicts ({numConfs}):",
                                  null,
                                  () => ConsoleTheme.Current.DimLabelFg
                                  ));
                    ConsoleTextBox tb = new ConsoleTextBox(
                        3 + lblW, top + 1 + numDeps, midL - 2, top + h - 2, false,
                        TextAlign.Left,
                        () => ConsoleTheme.Current.MainBg,
                        () => ConsoleTheme.Current.LabelFg
                        );
                    AddObject(tb);
                    // FUTURE: Find mods that conflict with this one
                    //         See GUI/MainModList.cs::ComputeConflictsFromModList
                    foreach (RelationshipDescriptor rd in mod.conflicts)
                    {
                        tb.AddLine(ScreenObject.FormatExactWidth(
                                       // Show install status
                                       ModListScreen.StatusSymbol(plan.GetModStatus(manager, registry, rd.ToString()))
                                       + rd.ToString(),
                                       nameW
                                       ));
                    }
                }
                return(top + h - 1);
            }
            return(top - 1);
        }
Exemplo n.º 31
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;
    }
Exemplo n.º 32
0
    /// <summary>
    /// Get the value of tickets sold for a specific screen
    /// </summary>
    /// <param name="screen">The Screen object to get the tickets for</param>
    /// <returns>The value of tickets sold</returns>
    public int GetTicketsSoldValue(ScreenObject screen)
    {
        UnityEngine.Random ran = new UnityEngine.Random();
        int min = (int)(screen.GetNumSeats() / 1.5);  // this will be affected by the posters etc, and rep
        int max = screen.GetNumSeats();
        int ticketsSold = UnityEngine.Random.Range(min, max);
        float repMultiplier = customerController.reputation.GetMultiplier();
        ticketsSold = 3 + (int)(ticketsSold * repMultiplier);

        return ticketsSold;
    }
Exemplo n.º 33
0
    public GameObject AddScreen(ScreenObject theScreen, Vector3 pos, int height)
    {
        // create a new screen object
        GameObject instance = (GameObject)Instantiate(screenPrefab.gameObject, pos, Quaternion.identity);
        instance.GetComponent<Screen_Script>().theScreen = theScreen;
        instance.name = "Screen#" + theScreen.GetScreenNumber();
        instance.tag = "Screen";
        instance.GetComponent<SpriteRenderer>().sortingOrder = height - theScreen.GetY() - 1;

        if (!theScreen.ConstructionInProgress())
        {
            instance.GetComponent<SpriteRenderer>().sprite = screenImages[theScreen.GetUpgradeLevel()];
        }
        else
        {
            instance.GetComponent<SpriteRenderer>().sprite = screenImages[0];
            CreateBuilder(theScreen.GetX(), theScreen.GetY(), theScreen.GetScreenNumber());
        }

        screenObjectList.Add(instance);

        return instance;
    }