Beispiel #1
0
        public StationNames GetStationName()
        {
            int          i          = stationSelector.value;
            StationNames parsedEnum = (StationNames)Enum.Parse(typeof(StationNames), stationSelector.options[i].text);

            return(parsedEnum);
        }
Beispiel #2
0
        private void InitializeStationNames()
        {
            Console.WriteLine("At InitializeStatementNames, Parent is Null = " + (Parent == null));
            char c = 'A';

            for (int i = 50000; i < 65536; i += 1000)
            {
                StationNames.Add(i, c.ToString());
                c++;
            }
        }
Beispiel #3
0
 public static void SaveToDabase(string _guid, string _name, StationNames _stationName, string _date, string _pin)
 {
     if (!IsPassengerExists(_guid))
     {
         PassengerData newData = new PassengerData()
         {
             guid      = _guid,
             name      = _name,
             stationIn = _stationName,
             date      = _date,
             pin       = _pin
         };
         SetUpdatePassengerData(_guid, newData);
     }
 }
Beispiel #4
0
        public static void ProcessTransaction(string _guid, StationNames _station, StationMatrix _matrix, OnSetDisplayMessage onComplete = null)
        {
            if (IsPassengerExists(_guid))
            {
                PassengerData passenger = GetPassengerData(_guid);

                if (passenger.balance >= 13)//TODO consider replacing magic number to lowest price on matrix
                {
                    if (!passenger.isOnBoard)
                    {
                        passenger.isOnBoard = true;
                        passenger.stationIn = _station;
                        SetUpdatePassengerData(_guid, passenger);
                        StationGate.QRProcessed?.Invoke(true, "Accepted", Color.green);
                        onComplete?.Invoke(true, passenger.name, "Welcome!, your current balance is: ", passenger.balance.ToString(), Color.green);
                    }
                    else
                    {
                        passenger.stationOut = _station;
                        bool isSuccessful = CalculateTransaction(passenger, _matrix, passenger.stationIn, passenger.stationOut);

                        if (isSuccessful)
                        {
                            passenger.isOnBoard = false;
                            SetUpdatePassengerData(_guid, passenger);
                            StationGate.QRProcessed?.Invoke(true, "Accepted", Color.green);
                            onComplete?.Invoke(true, passenger.name, "Thankyou!, your current balance is: ", passenger.balance.ToString(), Color.green);
                        }
                        else
                        {
                            //TODO handle if balance is insufficient when exiting station
                            StationGate.QRProcessed?.Invoke(false, "Denied", Color.red);
                            onComplete?.Invoke(true, passenger.name, "Sorry your current balance is insufficient, please load at the teller: ", passenger.balance.ToString(), Color.red);
                        }
                    }
                }
                else
                {
                    StationGate.QRProcessed?.Invoke(false, "Denied", Color.red);
                    onComplete?.Invoke(true, passenger.name, "Sorry your current balance is insufficient, please load at the teller: ", passenger.balance.ToString(), Color.red);
                }
            }
            else
            {
                StationGate.QRProcessed?.Invoke(false, "Denied", Color.red);
                onComplete?.Invoke(true, "Unknown", "QR Code is not registered in this system", "Please register at the teller", Color.red);
            }
        }
Beispiel #5
0
        /// <summary>
        /// 获取观测数据的测站以及测站的所有doy
        /// </summary>
        /// <param name="path"></param>
        /// <returns></returns>
        public void GetStationDOY()
        {
            DirectoryInfo dir = new DirectoryInfo(Folder);

            if (!dir.Exists)
            {
                return;
            }

            foreach (var file in dir.GetFiles("*.??o"))
            {
                //// 匹配文件名(o文件)
                if (file.Name.Length != 12 ||
                    !Regex.IsMatch(file.Name, @"^\S{4}\d{3}\S.\d{2}[Oo]"))
                {
                    continue;
                }

                //// 截取测站名、年份、年积日
                string stationName = file.Name.Substring(0, 4);
                int    doy         = int.Parse(file.Name.Substring(4, 3));
                int    year        = int.Parse(file.Name.Substring(9, 2));
                if (year < 50)
                {
                    year += 2000;
                }
                else
                {
                    year += 1900;
                }

                if (!DOYs.ContainsKey(stationName))
                {
                    DOYs.Add(stationName, new List <DOY>());
                }

                StationNames.Add(stationName);
                DOYs[stationName].Add(new DOY(year, doy));
            }

            //// DOY排序
            foreach (var station in DOYs)
            {
                station.Value.Sort();
            }
        }
Beispiel #6
0
    void Start()
    {
        MurpheyPosition = MurpheyWalk.GetComponent <RectTransform>();
        MurpheyHelm.SetActive(true);
        MurpheyWalk.SetActive(false);
        MurpheyRudder.SetActive(false);
        MurpheySail.SetActive(false);
        MurpheyTend.SetActive(false);
        MurpheyLantern.SetActive(false);

        targetDeckPosition  = helmStationPosition;
        currentDeckPosition = helmStationPosition;

        targetStation  = StationNames.helm;
        currentStation = StationNames.helm;

        // Setup submanual
        SubManualText = SubManual.GetComponentInChildren <Text>();

        // Get walking animated image. It is assumed to be the first element of widget animated images.
        MurphyWalkWidgetAnimatedImage = widgetAnimatedImages[0];


        // Setup station positions
        deckTop    = SailButton.transform.position.y;
        deckBottom = RudderButton.transform.position.y;

        SetStationPosition(ref helmStationPosition, HelmButton);
        SetStationPosition(ref tendStationPosition, TendButton);
        SetStationPosition(ref lanternStationPosition, LanternButton);

        // Setup callbacks
        RudderButton.onClick.AddListener(RudderButtonPressed);
        RudderButton.onClick.AddListener(AnyButtonPressed);
        HelmButton.onClick.AddListener(HelmButtonPressed);
        HelmButton.onClick.AddListener(AnyButtonPressed);
        SailButton.onClick.AddListener(SailButtonPressed);
        SailButton.onClick.AddListener(AnyButtonPressed);
        LanternButton.onClick.AddListener(LanternButtonPressed);
        LanternButton.onClick.AddListener(AnyButtonPressed);
        TendButton.onClick.AddListener(TendButtonPressed);
        TendButton.onClick.AddListener(AnyButtonPressed);

        ManualButton.onClick.AddListener(ManualButtonPressed);
    }
Beispiel #7
0
        public static void PassengerEnter(string _guid, StationNames _stationName)
        {
            if (IsPassengerExists(_guid))
            {
                PassengerData passenger = GetPassengerData(_guid);

                if (!passenger.isOnBoard)
                {
                    passenger.isOnBoard = true;
                    passenger.stationIn = _stationName;
                    SetUpdatePassengerData(_guid, passenger);
                }
                else
                {
                    Debug.LogError("Error: Already inside");
                }
            }
        }
Beispiel #8
0
    public void AnyButtonPressed()
    {
        clickSource.Play();
        footStepLoop.Play();
        if (boat)
        {
            boat.steering.atHelm = false;
            boat.sail.atSail     = false;
        }

        MurpheyWalk.SetActive(true);
        MurpheyHelm.SetActive(false);
        MurpheyRudder.SetActive(false);
        MurpheySail.SetActive(false);
        MurpheyTend.SetActive(false);
        MurpheyLantern.SetActive(false);

        currentStation = StationNames.noStation;
    }
Beispiel #9
0
        private void InitializeStationNames()
        {
            char c = '0';
            char d = '0';

            for (int i = 0; i < 256; i++)
            {
                StationNames.Add(i, "0x" + c.ToString() + d.ToString());
                d++;
                if (d > '9' && !(d >= 'A'))
                {
                    d = 'A';
                }
                else if (d > 'F')
                {
                    d = '0';
                    c++;
                }
            }
        }
Beispiel #10
0
 public void TendButtonPressed()
 {
     TendButtonImage.sprite = TendNormalSprite;
     targetStation          = StationNames.tend;
     targetDeckPosition     = tendStationPosition;
 }
Beispiel #11
0
 public void LanternButtonPressed()
 {
     LanternButtonImage.sprite = LanternNormalSprite;
     targetStation             = StationNames.lantern;
     targetDeckPosition        = lanternStationPosition;
 }
Beispiel #12
0
 public void SailButtonPressed()
 {
     SailButtonImage.sprite = SailNormalSprite;
     targetStation          = StationNames.sail;
     targetDeckPosition     = sailStationPosition;
 }
Beispiel #13
0
 public void HelmButtonPressed()
 {
     HelmButtonImage.sprite = HelmNormalSprite;
     targetStation          = StationNames.helm;
     targetDeckPosition     = helmStationPosition;
 }
Beispiel #14
0
 public void RudderButtonPressed()
 {
     RudderButtonImage.sprite = RudderNormalSprite;
     targetStation            = StationNames.rudder;
     targetDeckPosition       = rudderStationPosition;
 }
Beispiel #15
0
    void Update()
    {
        // Check input
        if (Input.GetKeyDown(KeyCode.Space))
        {
            if (currentStation == StationNames.helm || targetStation == StationNames.helm)
            {
                SailButton.onClick.Invoke();
            }
            else
            {
                HelmButton.onClick.Invoke();
            }
        }

        // Move Murphey across the deck
        var delta = (targetDeckPosition - currentDeckPosition) * stationChangeTravelScale;

        if (Mathf.Abs(delta) > stationChangeAcceptableRange)
        {
            var targetSpeed = Mathf.Sign(delta) == 1f
                ?
                              // Target is above Murphey
                              Mathf.Clamp(delta, stationChangeMinSpeed, stationChangeTopSpeed)
                :
                              // Target is below Murphey
                              Mathf.Clamp(delta, -stationChangeTopSpeed, -stationChangeMinSpeed);
            stationChangeCurrentSpeed = Mathf.Lerp(stationChangeCurrentSpeed, targetSpeed, 0.1f);
            currentDeckPosition      += stationChangeCurrentSpeed * Time.deltaTime;
        }
        else // Murphey is close enough to man his targeted station.
        {
            stationChangeCurrentSpeed = 0f;
            // Set current to target to trigger station reached logic.
            currentDeckPosition = targetDeckPosition;
        }

        MurpheyPosition.position =
            new Vector2(MurpheyPosition.position.x, Mathf.Lerp(deckBottom, deckTop, currentDeckPosition));
        // Make Murphey face the direction he is walking.
        MurphyWalkWidgetAnimatedImage.variations =
            Mathf.Sign(stationChangeCurrentSpeed) == -1f ? MurpheyWalkingDown : MurpheyWalkingUp;
        // Check if station reached.
        if (currentDeckPosition == targetDeckPosition && currentStation != targetStation)
        {
            currentStation = targetStation;
            MurpheyWalk.SetActive(false);
            footStepLoop.Stop();
            stations[(int)currentStation].OnManStation.Invoke();
        }

        // Set sub-manual text
        if (currentStation == StationNames.noStation)
        {
            SubManual.SetActive(false);
        }
        else
        {
            SubManual.SetActive(true);
            var totalTime      = timeToDisplayControls + timeToDisplayStatus;
            var displayControl = ((Time.time % totalTime) < timeToDisplayControls) && boat.sailRaisedForFirstTime;
            SubManualText.text = stations[(int)currentStation].GetStationStatus(displayControl);
        }

        // Loop through stations
        for (var i = 0; i < (int)StationNames.noStation; i++)
        {
            var s = stations[(int)i];
            var playerIsAtStation = i == (int)currentStation;
            if (!s.repaired)
            {
                if (playerIsAtStation)
                {
                    s.ProgressRepair(1f);
                }
                else
                {
                    s.ProgressRepair(-0.1f);
                }

                s.ProcessFlareAndFlashForDisrepair(playerIsAtStation);
            }

            s.ProcessFlareForReveal(playerIsAtStation);
        }

        // Set sprite variants based on light level
        // TODO calculate light level
        var lightLevel = 1f;

        if (boat.lantern != null)
        {
            lightLevel = (boat.lantern.lit) ? 1f : 0.5f;
        }

        BoatCR.SetColor(Color.Lerp(Color.black, Color.white, lightLevel));
        // Iterate through images
        foreach (var i in widgetImages)
        {
            if (lightLevel > 0.5f)
            {
                i.image.sprite = i.variations.lit;
            }
            else if (lightLevel > 0.25f)
            {
                i.image.sprite = i.variations.dark;
            }
            else
            {
                i.image.sprite = i.variations.pitchBlack;
            }
        }

        // Iterate through animated images
        foreach (var ai in widgetAnimatedImages)
        {
            if (ai.animatedImage.sprites.Length != ai.variations.Length)
            {
            }

            if (lightLevel > 0.5f)
            {
                for (var i = 0; i < ai.animatedImage.sprites.Length; i++)
                {
                    ai.animatedImage.sprites[i] = ai.variations[i].lit;
                }
            }
            else if (lightLevel > 0.25f)
            {
                for (var i = 0; i < ai.animatedImage.sprites.Length; i++)
                {
                    ai.animatedImage.sprites[i] = ai.variations[i].dark;
                }
            }
            else
            {
                for (var i = 0; i < ai.animatedImage.sprites.Length; i++)
                {
                    ai.animatedImage.sprites[i] = ai.variations[i].pitchBlack;
                }
            }
        }
    }
Beispiel #16
0
 private static bool CalculateTransaction(PassengerData _data, StationMatrix _matrix, StationNames _in, StationNames _out)
 {
     foreach (var s in _matrix.GetMatrix()[0].stationMatrices)
     {
         if (s.from.Equals(_in))
         {
             foreach (var a in s.stationToStations)
             {
                 if (a.to.Equals(_out))
                 {
                     if (_data.balance >= a.price)
                     {
                         float price = a.price == 0? 13: a.price; //Deduct 13 if in and out is the same station
                         _data.balance -= price;
                         return(true);
                     }
                 }
             }
         }
     }
     return(false);
 }