// Update is called once per frame
        void Update()
        {
            if (GameController.GameActive && Input.GetMouseButtonDown(0))
            {
                List <CookObjectController> activeCopy = new List <CookObjectController>(Active);

                foreach (CookObjectController cookObject in activeCopy)
                {
                    cookObject.CheckIfRemoved();
                }

                if (!AnyRemoved)
                {
                    Vector3 mousePosition = Input.mousePosition;
                    Vector3 worldPosition = MainCamera.ScreenToWorldPoint(mousePosition);
                    worldPosition.z = ZIndex;

                    CookObjectController instantiated = Instantiate(CookObject);

                    AudioSource   SFXPlayer = instantiated.gameObject.AddComponent <AudioSource>();
                    SFXController SFX       = instantiated.gameObject.AddComponent <SFXController>();

                    SFX.SFXPlayer = SFXPlayer;

                    SFX.Meat    = Meat;
                    SFX.Sizzle  = Sizzle;
                    SFX.Spatula = Spatula;
                    SFX.Fire    = Fire;

                    instantiated.GameController = GameController;
                    instantiated.ScoreKeeper    = Scorekeeper;

                    instantiated.ActiveList = this;
                    instantiated.MainCamera = Camera.main;

                    instantiated.PlatingSound = PlatingSound;
                    instantiated.SFX          = SFX;
                    instantiated.SFX.PlayMeat();
                    instantiated.SFX.PlaySizzle();

                    instantiated.gameObject.transform.position = worldPosition;

                    bool within   = WithinBounds(instantiated, GrillCollider);
                    bool touching = IsTouching(instantiated, Active);

                    if (within && !touching)
                    {
                        Active.Add(instantiated);
                    }
                    else
                    {
                        DestroyImmediate(instantiated.gameObject);
                    }
                }
                else
                {
                    AnyRemoved = false;
                }
            }
        }
Esempio n. 2
0
        public static void Start()
        {
            Countdown = new System.Timers.Timer
            {
                Interval = 250
            };
            Countdown.Elapsed += CountdownElapsed;

            if (!Directory.Exists("./cache/timers"))
            {
                Directory.CreateDirectory("./cache/timers");
            }

            //knowing that it exists, proceed to read contents

            Active = new();

            StreamReader reader;

            foreach (String s in Directory.GetFiles("./cache/timers"))
            {
                //keep this from throwing a fatal error
                //if an exception occurs, it just means the timer adding procedure took a little longer than usual
                try
                {
                    reader = new StreamReader(File.OpenRead(s));
                    Active.Add(JsonConvert.DeserializeObject <Timer>(reader.ReadToEnd()));
                    reader.Close();
                }
                catch { }
            }


            Countdown.Start();
        }
Esempio n. 3
0
        public override ISegment Add(ISegment segment)
        {
            switch (segment.SegmentType)
            {
            case SegmentType.Field:
            case SegmentType.Value:
            case SegmentType.Query:
            case SegmentType.Group:
            case SegmentType.Compare:
                ISegment result = Active != null?Active.Add(segment) : segment;

                if (result.SegmentType == SegmentType.Compare &&
                    ((CompareSegment)result).Right != null)
                {
                    AddSub(result);
                    ((CompareSegment)result).Parent = this;
                    Active = null;
                }
                else
                {
                    Active = result;
                }
                return(this);

            case SegmentType.Merge:
                var mergeSegment = (MergeSegment)segment;
                mergeSegment.AddSub(this);
                Parent = mergeSegment;
                return(mergeSegment);

            default:
                return(this);
            }
        }
Esempio n. 4
0
 /// <summary>
 /// pushes a contact onto the end of the list since that is where all new contacts will be added.
 /// </summary>
 public void AddContact()
 {
     Thermal.Add(0);
     ThermalYear.Add(0);
     EM.Add(0);
     EMYear.Add(0);
     Active.Add(0);
     ActiveYear.Add(0);
 }
Esempio n. 5
0
 public Plans(Plan[] plans)
 {
     foreach (var plan in plans)
     {
         if (plan.IsActive)
         {
             Active.Add(plan);
         }
         plansById.Add(plan.Id, plan);
         All.Add(plan);
         if (plan.IsDefault)
         {
             Default = plan;
         }
     }
     if (Default == null)
     {
         Default = All[0];
     }
 }
Esempio n. 6
0
        public static void AddTimer(Timer timer)
        {
            Countdown.Stop();

            StreamWriter writer;

            if (!File.Exists($"./cache/timers/{timer.Identifier}"))
            {
                File.Create($"./cache/timers/{timer.Identifier}").Close();
            }

            writer = new StreamWriter(File.Open($"./cache/timers/{timer.Identifier}", FileMode.Truncate));

            writer.Write(JsonConvert.SerializeObject(timer));

            writer.Close();

            Active.Add(timer);

            Thread.Sleep(50);
            Countdown.Start();
        }
Esempio n. 7
0
        // Callback Parse for Twitch API call
        static void ParseActiveViewers(object sender, DownloadStringCompletedEventArgs eventArgs)
        {
            state = RefreshViewerState.PARSING;

            if (eventArgs.Error != null)
            {
                throw new Exception("No chatters received from tmi.twitch.tv API - This can be ignored most of the time");
            }

            if (eventArgs.Result != null)
            {
                Helper.Log("Twitch Active Chatters API: " + eventArgs.Result);
            }

            List <string> viewers = new List <string>();

            // Parse chatters from list

            JSONNode resultNode = JSON.Parse(eventArgs.Result);

            if (resultNode["chatters"] != null)
            {
                JSONNode chatters = resultNode["chatters"];

                string[] viewerTypes = { "broadcaster", "vips", "moderators", "staff", "admins", "global_mods", "viewers" };

                foreach (string type in viewerTypes)
                {
                    for (int i = 0; i < chatters[type].Count; i++)
                    {
                        Active.Add(TwitchViewer.GetViewer(chatters[type][i]));
                    }
                }
            }

            state = RefreshViewerState.FINISHED;
        }
Esempio n. 8
0
 /// <summary> Adds object. </summary>
 public void Add(T toAdd)
 {
     Active.Add(toAdd);
     Stored.Remove(toAdd);
 }
Esempio n. 9
0
 public Paths(Cave start)
 {
     Active.Add(new Path(start));
 }