Пример #1
0
        public AEnnemy(SpriteManager s, EOrientation e)
            : base(s, e)
        {
            state_ = EState.ALIVE;

            deadTimer_ = TimeSpan.Zero;

            random_ = new Random();

            freePath_ = new Dictionary<EOrientation, bool>();

            freePath_.Add(EOrientation.DOWN, false);
            freePath_.Add(EOrientation.UP, false);
            freePath_.Add(EOrientation.RIGHT, false);
            freePath_.Add(EOrientation.LEFT, false);
            freePath_.Add(EOrientation.NEUTRAL, false);

            stateOrientationToSprite_ = new Dictionary<Tuple<EState, EOrientation>, SpriteManager.ESprite>();

            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.UP), SpriteManager.ESprite.EYESUP);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.DOWN), SpriteManager.ESprite.EYESDOWN);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.LEFT), SpriteManager.ESprite.EYESLEFT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.RIGHT), SpriteManager.ESprite.EYESRIGHT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD, ACharacter.EOrientation.NEUTRAL), SpriteManager.ESprite.EYESDOWN);

            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.UP), SpriteManager.ESprite.DEADENDINGUP);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.DOWN), SpriteManager.ESprite.DEADENDINGDOWN);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.LEFT), SpriteManager.ESprite.DEADENDINGLEFT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.RIGHT), SpriteManager.ESprite.DEADENDINGRIGHT);
            stateOrientationToSprite_.Add(Tuple.Create(EState.DEAD_ENDING, ACharacter.EOrientation.NEUTRAL), SpriteManager.ESprite.DEADENDINGDOWN);
        }
	internal override void Init (AInteractable a_interactable)
	{
		base.Init (a_interactable);
		_renderers = new List<InteractableRenderer>();
		_state = 0;
		UpdateRenderersList();
	}
Пример #3
0
    void RandState()
    {
        int r = Random.Range(0, 3);
        if (r == 2)
        {
            m_state = EState.Stand;
            m_anim.CrossFade("idle");
        }
        else
        {
            m_state = EState.Walk;
            m_walkForward = Random.insideUnitSphere;
            m_walkForward.y = 0;
            m_walkForward.Normalize();
            m_anim.CrossFade("run");

            //-- 设置旋转角度
            Quaternion rot = Quaternion.FromToRotation(Vector3.forward, m_walkForward);
            this.transform.rotation = rot;

        }

        m_stateDuration = (float)Random.Range(1, 5);
        m_stateStartTime = Time.realtimeSinceStartup;
    }
Пример #4
0
 public XReport(Guid _uid, IEnumerable<AbstractXReportItem> _items, int _kind, EState _state)
 {
     State = _state;
     Uid = _uid;
     Items = _items.ToList();
     Kind = _kind;
 }
Пример #5
0
 public Climby(CoordHelper.EProfile pt)
     : base(App.Game)
 {
     playerType = pt;
     if (playerType == CoordHelper.EProfile.ONEPLAYER)
         skin = SpriteManager.ESprite.CLIMBYBLUE;
     else
         skin = SpriteManager.ESprite.CLIMBYRED;
     pos = new Vector2(CoordHelper.Instance.getLeftMargin(playerType) + Constants.Measures.boardWidth / 2,
                           Constants.Measures.upBoardMargin + Constants.Measures.boardHeight - Constants.Measures.blockSize);
     actualPosition = new Rectangle((int)pos.X, (int)pos.Y, (int)Constants.Measures.blockSize, (int)Constants.Measures.blockSize);
     deadZone = new Rectangle((int)pos.X + (int)(Constants.Measures.blockSize / 3),
                              (int)pos.Y + (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3), (int)(Constants.Measures.blockSize / 3));
     actions = new Dictionary<EState, Action<GameTime>>();
     #region Actions
     actions.Add(EState.CLIMB, climb);
     actions.Add(EState.END_CLIMB, move);
     actions.Add(EState.FALL, move);
     actions.Add(EState.FREE_FALL, fall);
     actions.Add(EState.MOVE, move);
     actions.Add(EState.STOP, stop);
     #endregion
     state = EState.MOVE;
     direction = EDirection.RIGHT;
     rotation = 0f;
     setSpeedFromLevel(0);
     influence = 1f;
     minHeight = (int)((pos.Y - Constants.Measures.upBoardMargin) / Constants.Measures.blockSize);
     oldMinHeight = minHeight;
 }
Пример #6
0
    //-------------------------------------------------------------------------------
    /// 
    //-------------------------------------------------------------------------------
    public void SetState(EState eState)
    {
        m_eState = eState;

        switch(m_eState)
        {
            case EState.e_veille :
            {
                break;
            }
            case EState.e_alerte :
            {
                break;
            }
            case EState.e_actif :
            {
                break;
            }
            case EState.e_mange :
            {
                break;
            }
            case EState.e_eclaire :
            {
                break;
            }
        }
    }
Пример #7
0
 void Start()
 {
     cachedState = state;
     if ( state == EState.Inside )
     {
         Reverse();
     }
 }
Пример #8
0
 public Game()
 {
     this.GameId = Guid.NewGuid().ToString();
     
     _items[0] = new EState[3];
     _items[1] = new EState[3];
     _items[2] = new EState[3];
 }
Пример #9
0
    // Use this for initialization
    void Start()
    {
        m_state = EState.Stand;
        m_stateDuration = 0;
        m_stateStartTime = Time.realtimeSinceStartup;

        Transform mesh = this.transform.FindChild("luxue_LOD1");
        m_anim = mesh.gameObject.GetComponent<Animation>();
    }
Пример #10
0
        public void onStartGame(StartGameResponse response)
        {
            _turnClientId = "";
            _figure = EState.empty;

            _welcomeDiv.innerHTML = "";
            if (_welcomeDiv.parentNode != null)
            {
                _welcomeDiv.parentNode.removeChild(_welcomeDiv);
            }

            if (null != _tableCnt && _tableCnt.parentNode != null)
            {
                _tableCnt.parentNode.removeChild(_tableCnt);
            }

            if (null != _turn && _turn.parentNode != null)
            {
                _turn.parentNode.removeChild(_turn);
            }

            _turn = new HtmlDivElement();
            js.addClass(_turn, "turn");
            _div.appendChild(_turn);

            _tableCnt = new HtmlSpanElement();
            js.addClass(_tableCnt, "tableCnt");

            _table = new HtmlTableElement();
            _tableCnt.appendChild(_table);
            js.attach(_table, "click", onTableClick);
            js.attach(_table, "touchstart", onTableClick);
            js.addClass(_table, "table");
            for (int y = 0; y < 3; ++y)
            {
                var row = new HtmlTableRowElement();
                _table.appendChild(row);
                row.setAttribute("rowIdx", y.ToString());
                for (int x = 0; x < 3; ++x)
                {
                    var cell = new HtmlTableCellElement();
                    row.appendChild(cell);
                    js.addClass(cell, "tableCell");
                }
            }
            _div.appendChild(_tableCnt);


            //_div.innerHTML += "Start Game ID = " + response.GameId + "<br/>";
            _figure = (response.FirstClientId == ClientId) ? EState.blue : EState.red;
            //_div.innerHTML += "You are " + _figure + "<br/>";

            _turnClientId = response.FirstClientId;

            RefreshTurn();
        }
Пример #11
0
 private void Form1_KeyDown(object sender, KeyEventArgs e)
 {
     if(e.KeyCode == Keys.Delete && points.Count > 0)
     {
         int index = points.Count - 1;
         points.RemoveAt(index);
         state = EState.Unselected;
         Recalculate();
         panel1.Refresh();
     }
 }
Пример #12
0
    // Use this for initialization
    void Start()
    {
        m_eState = EState.ES_Fix;
        m_Board = GameObject.Find ("Board").GetComponent<Board>();

        transform.position = GetWorldPosition();

        m_Board.SetPiece(m_iPosX, m_iPosY, m_iSizeX, m_iSizeY);

        Debug.Log("Piece " + ToString() + " at " + transform.position);
    }
Пример #13
0
	// Update is called once per frame
	void Update () {
		if( Mathf.Approximately(Time.timeScale, 0.0f) )
		{
			return;
		}

		if (m_state == EState.DYING) {
			return;
		}

		if (m_HP <= 0) {
			if( m_state == EState.ON_WALL )
			{
				m_dyingFallRotation = new Vector3(0, Random.Range(-10, 10) * 10, Random.Range(-10, 10) * 10);
			}
		
			SetOnDying();
			m_state = EState.DYING;
			m_animator.CrossFade(ANIM_DYING, 0.0f, 0, 0.0f);
			m_animator.speed = 1.0f;
		} else {
			if( Player.Instance.IsDying )
			{
				m_animator.enabled = false;
				return;
			}
			
			if( Blizzard.Instance.Duration > 0.0f )
			{
				m_speedFactor += (0.01f - m_speedFactor) * Time.deltaTime * 2;
			}
			else
			{
				m_speedFactor += (1.0f - m_speedFactor) * Time.deltaTime;
			}
		
			switch (m_state) {
			case EState.PATROL:
				Patrol();
				break;
			case EState.CLIMB:
				Climb();
				break;
			case EState.PUSH_UP:
				PushUp();
				break;
			case EState.ON_WALL:
				OnWall();
				break;		
			}
		}
	}
Пример #14
0
	public void CreateWorkshopItem(string contentFolder, string previewFile, string name, string description, ERemoteStoragePublishedFileVisibility visibility) {
		Reset();
		m_State = EState.Creating;

		m_tmpContentFolder = contentFolder;
		m_tmpPreviewFile = previewFile;
		m_tmpName = name;
		m_tmpDescription = description;
		m_tmpVisibility = visibility;

		SteamAPICall_t handle = SteamUGC.CreateItem(s_AppId, EWorkshopFileType.k_EWorkshopFileTypeCommunity);
		m_CrateItemResult.Set(handle, OnCreateItemResult);
	}
Пример #15
0
	protected virtual void PlayShowTransition ()
	{
		//Debug.Log("Showing : " + gameObject.name);
		if (state == EState.Hidden)
		{
			state = EState.Showing;
			tweens.PlayForward ();
		}
		else if (state == EState.Hidding)
		{
			state = EState.Showing;
			tweens.Toggle ();
		}
	}
Пример #16
0
	private void Reset() {
		m_State = EState.Initialized;
		m_tmpPublishedFileId = PublishedFileId_t.Invalid;
		m_tmpNeedsToAcceptTOS = false;
		m_tmpUpdateHandle = UGCUpdateHandle_t.Invalid;

		m_tmpContentFolder = "";
		m_tmpPreviewFile = "";
		m_tmpName = "";
		m_tmpDescription = "";
		m_tmpVisibility = ERemoteStoragePublishedFileVisibility.k_ERemoteStoragePublishedFileVisibilityPrivate;

		m_CrateItemResult.Cancel();
		m_SubmitItemUpdateResult.Cancel();
	}
Пример #17
0
 public bool SetState(EState newState)
 {
     if ( cachedState != newState )
     {
     //			Debug.LogWarning ( "State change from " + cachedState + " to " + newState );
         Reverse ( );
         state = newState;
         cachedState = newState;
         return true;
     }
     else
     {
     //			Debug.LogError("No change: "+newState);
     }
     return false;
 }
Пример #18
0
	// Update is called once per frame
	void Update () {
		if( Mathf.Approximately(Time.timeScale, 0.0f) )
		{
			return;
		}
		
		if (m_state == EState.DYING) {
			return;
		}
		
		if (m_HP <= 0) {		
			SetOnDying();	
			m_state = EState.DYING;
			m_animator.CrossFade(ANIM_DYING, 0.0f, 0, 0.0f);
			m_animator.speed = 1.0f;
		} else {
			if( Player.Instance.IsDying )
			{
				m_animator.enabled = false;
				return;
			}
			
			if( Blizzard.Instance.Duration > 0.0f )
			{
				m_speedFactor += (0.01f - m_speedFactor) * Time.deltaTime * 2;
			}
			else
			{
				m_speedFactor += (1.0f - m_speedFactor) * Time.deltaTime;
			}
			
			switch (m_state) {
			case EState.PATROL:
				Patrol();
				break;			
				
			case EState.SHOOT:
				Shoot();
				break;
			}
		}
	}
Пример #19
0
    public void SetState(EState state)
    {
        this.state = state;

        switch (state)
        {
            case EState.LOGIN:
                {
                    timeControl.len = 20.0f;
                }
                break;
            case EState.PVP:
                {
                    timeControl.len = 35.0f;
                }
                break;
            default:
                break;
        }    
    }
Пример #20
0
	private void OnCreateItemResult(CreateItemResult_t pCallback, bool bIOFailed) {
		print("OnCreateItemResult - m_eResult: " + pCallback.m_eResult + " | m_nPublishedFileId: " + pCallback.m_nPublishedFileId + " | m_bUserNeedsToAcceptWorkshopLegalAgreement: " + pCallback.m_bUserNeedsToAcceptWorkshopLegalAgreement);

		if (bIOFailed) {
			//ESteamAPICallFailure failureReason = SteamUtils.GetAPICallFailureReason(m_CrateItemResult.Handle);
			//Debug.LogError("OnCreateItemResult bIOFailed = true. Reason: " + failureReason);
			m_State = EState.Failed;
			return;
		}

		if (pCallback.m_eResult != EResult.k_EResultOK) {
			Debug.LogError("OnCreateItemResult m_eResult != k_EResultOK");
			m_State = EState.Failed;
			return;
		}

		m_tmpPublishedFileId = pCallback.m_nPublishedFileId;
		m_tmpNeedsToAcceptTOS = pCallback.m_bUserNeedsToAcceptWorkshopLegalAgreement;

		UpdateWorkshopItem();
	}
Пример #21
0
 public AttackingState(AIStateMachine AI, EState EState)
 {
     this.AI     = AI;
     this.EState = EState;
 }
Пример #22
0
        /// <summary>
        /// 获取/设置 字段值。
        /// 一个索引,基类使用反射实现。
        /// 派生实体类可重写该索引,以避免反射带来的性能损耗
        /// </summary>
        /// <param name="name">字段名</param>
        /// <returns></returns>
        public override Object this[String name]
        {
            get
            {
                switch (name)
                {
                case "ID": return(_ID);

                case "Number": return(_Number);

                case "OwnedEnterprise": return(_OwnedEnterprise);

                case "AssetNumber": return(_AssetNumber);

                case "Name": return(_Name);

                case "SpecificationModel": return(_SpecificationModel);

                case "EquipmentType": return(_EquipmentType);

                case "Manufacturer": return(_Manufacturer);

                case "DeviceSerialNumber": return(_DeviceSerialNumber);

                case "Purpose": return(_Purpose);

                case "InstallationTime": return(_InstallationTime);

                case "IntstallationPerson": return(_IntstallationPerson);

                case "DetailedInstallPlace": return(_DetailedInstallPlace);

                case "Position": return(_Position);

                case "LiveTips": return(_LiveTips);

                case "GPSPosition": return(_GPSPosition);

                case "LiveImage": return(_LiveImage);

                case "EquipmentState": return(_EquipmentState);

                case "PowerSupplyMode": return(_PowerSupplyMode);

                case "DiscardedTime": return(_DiscardedTime);

                case "DiscardedReason": return(_DiscardedReason);

                case "Remarks": return(_Remarks);

                default: return(base[name]);
                }
            }
            set
            {
                switch (name)
                {
                case "ID": _ID = Convert.ToInt32(value); break;

                case "Number": _Number = Convert.ToInt32(value); break;

                case "OwnedEnterprise": _OwnedEnterprise = Convert.ToString(value); break;

                case "AssetNumber": _AssetNumber = Convert.ToString(value); break;

                case "Name": _Name = Convert.ToString(value); break;

                case "SpecificationModel": _SpecificationModel = Convert.ToString(value); break;

                case "EquipmentType": _EquipmentType = (EType)value; break;

                case "Manufacturer": _Manufacturer = Convert.ToString(value); break;

                case "DeviceSerialNumber": _DeviceSerialNumber = Convert.ToString(value); break;

                case "Purpose": _Purpose = (NewPurpose)value; break;

                case "InstallationTime": _InstallationTime = Convert.ToDateTime(value); break;

                case "IntstallationPerson": _IntstallationPerson = Convert.ToString(value); break;

                case "DetailedInstallPlace": _DetailedInstallPlace = Convert.ToString(value); break;

                case "Position": _Position = Convert.ToString(value); break;

                case "LiveTips": _LiveTips = Convert.ToString(value); break;

                case "GPSPosition": _GPSPosition = Convert.ToString(value); break;

                case "LiveImage": _LiveImage = Convert.ToString(value); break;

                case "EquipmentState": _EquipmentState = (EState)value; break;

                case "PowerSupplyMode": _PowerSupplyMode = (PowerMode)value; break;

                case "DiscardedTime": _DiscardedTime = Convert.ToDateTime(value); break;

                case "DiscardedReason": _DiscardedReason = Convert.ToString(value); break;

                case "Remarks": _Remarks = Convert.ToString(value); break;

                default: base[name] = value; break;
                }
            }
        }
        public void CommentStateAnotherTest(EState state)
        {
            var presenter = new PresenterCreatePost(_viewMock.Object, _interactorMock.Object, _routerMock.Object, _stylesHolderMock.Object, Localization.Lang);

            presenter.CommentState(state);
        }
Пример #24
0
        public void DoWork(EMode mode = EMode.Default, int scannerFlags = 0)
        {
            Stopwatch timerTotal = new Stopwatch();
            Stopwatch timerStep  = new Stopwatch();

            timerTotal.Start();

            bool debugMode = (mode & EMode.Debug) != EMode.None;

            activeScanner = null;
            currentMode   = mode;

            // load input
            bool hasInputImage = LoadInputImage(mode, timerStep, scanClipBounds);

            if (hasInputImage)
            {
                // convert to HSL representation
                timerStep.Restart();
                cachedFastBitmap = ImageUtils.ConvertToFastBitmap(screenReader.cachedScreenshot);
                timerStep.Stop();
                if (debugMode)
                {
                    Logger.WriteLine("Screenshot convert: " + timerStep.ElapsedMilliseconds + "ms");
                }
                if (Logger.IsSuperVerbose())
                {
                    Logger.WriteLine("Screenshot: {0}x{1}", screenReader.cachedScreenshot.Width, screenReader.cachedScreenshot.Height);
                }

                // reset scanner's intermediate data
                bool canResetCache = (mode & EMode.NeverResetCache) == EMode.None;
                if (canResetCache)
                {
                    bool forceResetCache = (mode & EMode.AlwaysResetCache) != EMode.None;
                    if (forceResetCache)
                    {
                        unknownHashes.Clear();
                        currentHashMatches.Clear();
                    }

                    // invalidate scanner's cache if input image size has changed
                    if (forceResetCache || cachedBitmapSize.Width <= 0 || cachedBitmapSize.Width != cachedFastBitmap.Width || cachedBitmapSize.Height != cachedFastBitmap.Height)
                    {
                        cachedBitmapSize = new Size(cachedFastBitmap.Width, cachedFastBitmap.Height);
                        foreach (var kvp in mapScanners)
                        {
                            kvp.Value.InvalidateCache();
                        }
                    }
                }

                currentState = EState.NoScannerMatch;

                // pass 1: check if cache is still valid for requested scanner
                foreach (var kvp in mapScanners)
                {
                    if ((kvp.Key & mode) != EMode.None && kvp.Value.HasValidCache(cachedFastBitmap, scannerFlags))
                    {
                        bool scanned = false;
                        try
                        {
                            scanned = kvp.Value.DoWork(cachedFastBitmap, scannerFlags, timerStep, debugMode);
                        }
                        catch (Exception ex)
                        {
                            Logger.WriteLine("Failed to scan [1] image! {0}", ex);
                            scanned = false;
                        }

                        if (scanned)
                        {
                            activeScanner = kvp.Value;
                            currentState  = (currentState == EState.NoScannerMatch) ? EState.NoErrors : currentState;
                            if (debugMode)
                            {
                                Logger.WriteLine("Scan [1] successful, type:{0}, state:{1}", kvp.Key, currentState);
                            }
                        }
                        else
                        {
                            currentState = EState.ScannerErrors;
                        }

                        break;
                    }
                }

                // pass 2: all requested
                if (activeScanner == null)
                {
                    foreach (var kvp in mapScanners)
                    {
                        if ((kvp.Key & mode) != EMode.None)
                        {
                            bool scanned = false;
                            try
                            {
                                scanned = kvp.Value.DoWork(cachedFastBitmap, scannerFlags, timerStep, debugMode);
                            }
                            catch (Exception ex)
                            {
                                Logger.WriteLine("Failed to scan [2] image! {0}", ex);
                                scanned = false;
                            }

                            if (scanned)
                            {
                                activeScanner = kvp.Value;
                                currentState  = (currentState == EState.NoScannerMatch) ? EState.NoErrors : currentState;
                                if (debugMode)
                                {
                                    Logger.WriteLine("Scan [2] successful, type:{0}, state:{1}", kvp.Key, currentState);
                                }
                                break;
                            }
                        }
                    }
                }

                // save debug markup if needed
                if ((activeScanner != null) && ((mode & EMode.DebugSaveMarkup) != EMode.None))
                {
                    List <Rectangle> debugBounds = new List <Rectangle>();
                    List <ImageUtils.HashPreview> debugHashes = new List <ImageUtils.HashPreview>();
                    activeScanner.AppendDebugShapes(debugBounds, debugHashes);

                    if (currentScanArea.Width > 0)
                    {
                        debugBounds.Add(currentScanArea);
                    }

                    timerStep.Restart();

                    string imagePath = GetDefaultScreenshotPath() + "screenshot-markup.png";
                    if (File.Exists(imagePath))
                    {
                        File.Delete(imagePath);
                    }

                    using (Bitmap markupBitmap = ImageUtils.ConvertToBitmap(cachedFastBitmap))
                    {
                        ImageUtils.DrawDebugShapes(markupBitmap, debugBounds);
                        ImageUtils.DrawDebugHashes(markupBitmap, debugHashes);

                        markupBitmap.Save(imagePath, ImageFormat.Png);
                    }

                    timerStep.Stop();
                    Logger.WriteLine("Screenshot save: " + timerStep.ElapsedMilliseconds + "ms");
                }
            }
            else
            {
                currentState = EState.NoInputImage;
            }

            timerTotal.Stop();
            if (debugMode)
            {
                Logger.WriteLine("Screenshot TOTAL: " + timerTotal.ElapsedMilliseconds + "ms");
            }
        }
Пример #25
0
 public void InitializeScreenData()
 {
     screenReader.InitializeScreenData();
     currentState = (screenReader.currentState == ScreenReader.EState.NoErrors) ? EState.NoErrors : EState.NoInputImage;
 }
Пример #26
0
 internal void clean()
 {
     mRoot.evtOnLMUp -= onClick;
     mRoot.evtOnLMUp -= endToWin;
     mState = EState.invalid;
     mPrompt.visible = false;
     mScore.visible = false;
     clearBonus();
     if (mMainRole != null)
         mMainRole.clean();
     TimerManager.get().clearTimer(timeIDGenBonus);
     TimerManager.get().clearTimer(timeIDFailToInit);
 }
 public void UnUsed()
 {
     eState = EState.Unused;
 }
Пример #28
0
 public void Init(EState s)
 {
     state = EState.Inside;
 }
Пример #29
0
 public void init()
 {
     clean();
     mMainRole.init();
     mMainRole.hide();
     mState = EState.ready;
     showColorHint("get ready?");
     mRoot.evtOnLMUp += onClick;
     mState = EState.ready;
 }
Пример #30
0
    private static Dictionary <string, object> AnalyzeObject(StreamReader input)
    {
        Dictionary <string, object> dictionary = new Dictionary <string, object>();
        EState        state = 0;
        StringBuilder key   = new StringBuilder();

        char ch;

        input.Read();

        // Somehow loop consumes '}' after AnalyzeValue is returned, so this variable prevents this.
        bool beforeValue = true;

        while ((ch = (char)input.Peek()) != '}' & input.Peek() != -1)
        {
            //if (ch == '}')
            //Console.WriteLine("HERE");

            switch (ch)
            {
            case '\n':
                break;

            case '\r':
                break;

            case '\t':
                break;

            case ' ':
                break;

            case ',':
                break;

            case '{':
                dictionary.Add(key.ToString(), AnalyzeObject(input));
                key.Clear();
                state = EState.key;
                break;

            case '[':
                dictionary.Add(key.ToString(), AnalyzeArray(input));
                key.Clear();
                state = EState.key;
                break;

            case ':':
                state = EState.value;
                break;

            default:
                if (state == EState.key)
                {
                    if (ch != '"')
                    {
                        key.Append(ch);
                    }
                }
                if (state == EState.value)
                {
                    dictionary.Add(key.ToString(), AnalyzeValue(input));
                    beforeValue = false;
                    state       = EState.key;
                    key.Clear();
                }
                break;
            }
            if (beforeValue)
            {
                input.Read();
            }
            else
            {
                beforeValue = true;
            }
        }
        return(dictionary);
    }
Пример #31
0
        public void CheckNameStateAnotherTest(EState state)
        {
            var presenter = new PresenterRegName(_viewMock.Object, _interactorMock.Object, _routerMock.Object, _stylesHolderMock.Object, _regLocaleStrings.Object);

            presenter.SetNameState(state);
        }
Пример #32
0
 public EvadingState(AIStateMachine AI, EState EState)
 {
     this.AI     = AI;
     this.EState = EState;
 }
 public TestObject(int iID)
 {
     this.iID = iID;
     eState   = EState.Init;
 }
Пример #34
0
 public void Win()
 {
     m_eState = EState.e_Win;
     m_fTimerEndLevel = CGame.ms_fMenuTimerEndLevel;
     PauseGame ();
 }
 public void Used()
 {
     eState = EState.Used;
 }
Пример #36
0
 public void Init(EState s)
 {
     state = s;
 }
 public void OnDestroy()
 {
     eState = EState.Destroyed;
 }
Пример #38
0
 public void OnSpawn(float spawnTime)
 {
     _state     = EState.Spawning;
     _spawnTime = spawnTime;
 }
Пример #39
0
 private void _StateExit(EState _nextState)
 {
     //do nothing
 }
Пример #40
0
    void CheckCurrentCombinedConnectStatus()
    {
        if (mCombinedHttpConnect != null)
        {
            // if request got response, handler the response and refresh requests list
            if (mCombinedHttpConnect.IsGotResponse())
            {
                bool result = mCombinedHttpConnect.ParseResponse();
                mCombinedHttpConnect.Release();

                if (NETWORK_CAL_RESPONDING_TIME)
                {
                    mRespondTime = mCurTime - mConnectTime;
                    if (mRespondTime > mMaxRespondTime)
                    {
                        mMaxRespondTime = mRespondTime;
                    }
                }
                //RefreshAllRequests();

                if (result)
                {
                    mState = EState.Idle;
                    if (mRetryCombineTimes > 0)
                    {
                        // if (IsIPStyle(mCombinedHttpConnect.GetGameServerURL()))
                        //     NetworkDefine.RegroupURLWithIPFirst();
                        // else
                        //     NetworkDefine.RegroupURLWithURLFirst();
                    }
                    mRetryCombineTimes = 0;
                }
                else
                {
                    // if (mErrorCode == 201 && mRetryCombineTimes < NetworkDefine.sMaxRetryTime)
                    // {
                    //  mRetryCombineTimes++;
                    //  mState = EState.Idle;

                    //                    mWaitingDialog = true;
                    //                    // Debug.LogError("retry 333");
                    //                    MessageBox.instance.ShowReconnecting(true);
                    //                    DebugUtils.LogNetwork("Retry "+mRetryCombineTimes);
                    // }
                    // else
                    // {
                    //  string title = TextManager.GetInstance().GetText(Text.NET_ERROR);
                    //  string str;

                    //  if (mErrorCode == 201)
                    //  {
                    //      str = TextManager.GetInstance().GetText(Text.NO_NETWORK_CONNECTION);
                    //  }
                    //  // special error for invalid session
                    //  else if (mErrorCode == 69000001)
                    //  {
                    //      str = TextManager.GetInstance().GetText(Text.LOGIN_SESSION_OUT_OF_DATE);
                    //  }
                    //  // special error string for attacking online or shield players
                    //  else if (mErrorCode == 1009012 || mErrorCode == 1009014)
                    //  {
                    //      title = TextManager.GetInstance().GetText(Text.WARN);
                    //      if (mErrorCode == 1009012)
                    //      {
                    //          str = TextManager.GetInstance().GetText(Text.BATTLE_PLAYER_ONLINE);
                    //      }
                    //      else
                    //      {
                    //          str = TextManager.GetInstance().GetText(Text.BATTLE_PLAYER_IN_SHIELD);
                    //      }
                    //  }
                    //  else
                    //  {
                    //      str = TextManager.GetInstance().GetText(Text.NET_RESPONSE_DATA_ERROR);
                    //      str += " "+mErrorRequestSerialId+", cmd:"+mErrorCommandId + ", code:"+mErrorCode;
                    //  }
                    //  MessageBox.instance.CloseWaitingDialog();


                    //  if (mErrorCode == 10001002 || mErrorCode == 10001003 || mErrorCode == 10001004 || mErrorCode == 10001005 || mErrorCode == 10001006 || mErrorCode == 10001009)
                    //  {
                    //      CommonDataManager.RequestGetResource();
                    //      title = TextManager.GetInstance().GetText(Text.WARN);
                    //      string StrWarning = TextManager.GetInstance().GetText(Text.Resource_Error_Warning);
                    //      MessageBox.instance.OpenMessageBox(MessageBox.eStyle.OK, title, StrWarning, null, null);
                    //      return;
                    //  }
                    //  MessageBox.instance.OpenLiveMessageBox(MessageBox.eStyle.NoButton, title, str, handler_error_release, null);
                    //  mState = EState.DataError;
                    //  mHasReportedError = false;
                    //  Clear();
                    // }
                }
            }
            else
            {
                // Debug.LogError("mCurTime " + mCurTime);
                // Debug.LogError("mConnectTime " + mConnectTime);
                // Debug.LogError("NetworkDefine.sConnectTimeout " + NetworkDefine.sConnectTimeout);
                if (mCurTime - mConnectTime > NetworkDefine.sConnectTimeout)
                {
                    mCurTime = mConnectTime + NetworkDefine.sConnectTimeout + 1f;
                    // Debug.LogError("2mCurTime " + mCurTime);
                    // Debug.LogError("2mConnectTime " + mConnectTime);
                    // Debug.LogError("2NetworkDefine.sConnectTimeout " + NetworkDefine.sConnectTimeout);
                    if (NETWORK_CAL_RESPONDING_TIME)
                    {
                        mRespondTime = mCurTime - mConnectTime;
                        if (mRespondTime > mMaxRespondTime)
                        {
                            mMaxRespondTime = mRespondTime;
                        }
                    }

                    mCombinedHttpConnect.Release();

                    if (mRetryCombineTimes < NetworkDefine.sMaxRetryTime)
                    {
                        // Debug.LogError("mRetryCombineTimes " + mRetryCombineTimes);
                        // Debug.LogError("NetworkDefine.sMaxRetryTime " + NetworkDefine.sMaxRetryTime);
                        mRetryCombineTimes++;
                        mState = EState.Idle;

                        mWaitingDialog = true;
                        // MessageBox.instance.ShowReconnecting(true);

                        Debug.Log("Retry " + mRetryCombineTimes);
                    }
                    else
                    {
                        // // Debug.LogError("retry times out");
                        // string title = TextManager.GetInstance().GetText(Text.NET_ERROR);
                        // string str = TextManager.GetInstance().GetText(Text.NO_NETWORK_CONNECTION);
                        // MessageBox.instance.CloseWaitingDialog();
                        // MessageBox.instance.OpenLiveMessageBox(MessageBox.eStyle.NoButton, title, str, handler_error_release, null);
                        mState = EState.Timeout;
                        Clear();
                    }
                }
            }
        }
        else
        {
            mState = EState.Idle;
        }
    }
Пример #41
0
 public void AddPendingState(EState state, Dictionary <string, object> passedData)
 {
     _sm.AddPendingState(state, passedData);
 }
Пример #42
0
 public void SetState(EState state)
 {
     currentState = state;
 }
Пример #43
0
    // void ProcessNextImageConnect(string _url)
    // {
    //  if (mImageHttpConnect == null)
    //  {
    //      mImageHttpConnect = new ImageHttpConnect();
    //  }

    //  mImageHttpConnect.Initial(_url);
    //  //mCatchingImageTime = mCurTime;
    //  if (mImageHttpConnect.Connect())
    //  {
    //      DebugUtils.LogNetwork("Catching image:" + _url);
    //      mCatchingImageTime = mCurTime;
    //      if (NETWORK_SINGLE_WWW_GET_IMAGE)
    //      {
    //          mState = EState.WaitingImageResponse;
    //      }
    //      else
    //      {
    //          mCatchingImage = true;
    //      }
    //  }
    // }

    // void CheckCurrentImageConnectStatus()
    // {
    //  if (mImageHttpConnect != null)
    //  {
    //      // if request got response, handler the response and refresh requests list
    //      if (mImageHttpConnect.IsGotResponse())
    //      {
    //          string url = mImageHttpConnect.GetURL();
    //          Texture tex = mImageHttpConnect.ParseResponse();

    //          AvatarManager.instance.CacheTheImage(url, tex);
    //          DebugUtils.LogNetwork("Cached image:" + url);

    //          mImageHttpConnect.Release();

    //          if (NETWORK_SINGLE_WWW_GET_IMAGE)
    //          {
    //              mState = EState.Idle;
    //          }
    //          else
    //          {
    //              mCatchingImage = false;
    //          }
    //      }
    //      else
    //      {
    //          // only wait 5 second to catch the facebook image
    //          if (mCurTime - mCatchingImageTime > 10)
    //          {
    //              string url = mImageHttpConnect.GetURL();
    //              DebugUtils.LogNetwork("Time out for image:"+url);
    //              AvatarManager.instance.FailCacheTheImage(url);

    //              //mCatchingImageTime = Time.realtimeSinceStartup;
    //              mImageHttpConnect.Release2();

    //              //DebugUtils.LogNetwork("release time:" + (Time.realtimeSinceStartup-mCatchingImageTime));

    //              if (NETWORK_SINGLE_WWW_GET_IMAGE)
    //              {
    //                  mState = EState.Idle;
    //              }
    //              else
    //              {
    //                  mCatchingImage = false;
    //              }
    //          }
    //      }
    //  }
    //  else
    //  {
    //      if (NETWORK_SINGLE_WWW_GET_IMAGE)
    //      {
    //          mState = EState.Idle;
    //      }
    //      else
    //      {
    //          mCatchingImage = false;
    //      }
    //  }
    // }

    void CheckCurrentImageUrlConnectStatus()
    {
        if (mImageUrlHttpConnect != null)
        {
            // if request got response, handler the response and refresh requests list
            if (mImageUrlHttpConnect.IsGotResponse())
            {
                string    url = mImageUrlHttpConnect.GetURL();
                Texture2D tex = mImageUrlHttpConnect.ParseResponse();

                // EventImageManager.instance.CacheTheImage(url, tex);
                Debug.Log("Cached image:" + url);

                mImageUrlHttpConnect.Release();

                if (NETWORK_SINGLE_URL_WWW_GET_IMAGE)
                {
                    mState = EState.Idle;
                }
                else
                {
                    mCatchingImageUrl = false;
                }
            }
            else
            {
                // only wait 5 second to catch the facebook image
                if (mCurTime - mCatchingImageUrlTime > 10)
                {
                    string url = mImageUrlHttpConnect.GetURL();
                    Debug.Log("Time out for image:" + url);
                    // EventImageManager.instance.FailCacheTheImage(url);

                    //mCatchingImageTime = Time.realtimeSinceStartup;
                    mImageUrlHttpConnect.Release2();

                    //DebugUtils.LogNetwork("release time:" + (Time.realtimeSinceStartup-mCatchingImageTime));

                    if (NETWORK_SINGLE_URL_WWW_GET_IMAGE)
                    {
                        mState = EState.Idle;
                    }
                    else
                    {
                        mCatchingImageUrl = false;
                    }
                }
            }
        }
        else
        {
            if (NETWORK_SINGLE_URL_WWW_GET_IMAGE)
            {
                mState = EState.Idle;
            }
            else
            {
                mCatchingImageUrl = false;
            }
        }
    }
Пример #44
0
        public void OnFrame(object sender, FrameEventArgs args)
        {
            Frame frame           = args.frame;
            int   extendedfingers = 0;
            bool  pause           = false;
            int   stop            = 0;

            foreach (Hand hand in frame.Hands)
            {
                if (hand.IsLeft)
                {
                    for (int f = 0; f < hand.Fingers.Count; ++f)
                    {
                        Finger digit = hand.Fingers[f];
                        if (digit.IsExtended)
                        {
                            extendedfingers++;
                        }
                    }
                    if (extendedfingers == 0)
                    {
                        pause = true;
                    }

                    if (hand.Fingers[0].IsExtended == false && hand.Fingers[1].IsExtended &&
                        hand.Fingers[2].IsExtended == false && hand.Fingers[3].IsExtended == false &&
                        hand.Fingers[4].IsExtended == false)
                    {
                        if (hand.Fingers[1].StabilizedTipPosition.y > _height)
                        {
                            _mediaPlayer.settings.volume += 1;
                        }
                        else
                        {
                            _mediaPlayer.settings.volume -= 1;
                        }
                        _height = hand.Fingers[1].StabilizedTipPosition.y;
                    }

                    if (hand.Rotation.w > 0.95 && hand.PinchStrength > 0.9 && _state != EState.PREVIOUS)
                    {
                        _mediaPlayer.Ctlcontrols.previous();
                        _state = EState.PREVIOUS;
                    }

                    if (hand.Rotation.w < 0.1)
                    {
                        _mediaPlayer.settings.volume = 100;
                    }

                    if (hand.Rotation.w < 0.70)
                    {
                        ++stop;
                    }
                }

                else if (hand.IsRight)
                {
                    for (int f = 0; f < hand.Fingers.Count; ++f)
                    {
                        Finger digit = hand.Fingers[f];
                        if (digit.IsExtended)
                        {
                            extendedfingers++;
                        }
                    }
                    if (extendedfingers == 0)
                    {
                        pause = true;
                    }

                    if (hand.Fingers[0].IsExtended == false && hand.Fingers[1].IsExtended &&
                        hand.Fingers[2].IsExtended == false && hand.Fingers[3].IsExtended == false &&
                        hand.Fingers[4].IsExtended == false)
                    {
                        if (hand.Fingers[1].StabilizedTipPosition.y > _height)
                        {
                            _mediaPlayer.settings.volume += 1;
                        }
                        else
                        {
                            _mediaPlayer.settings.volume -= 1;
                        }
                        _height = hand.Fingers[1].StabilizedTipPosition.y;
                    }

                    if (hand.Rotation.w > 0.95 && hand.PinchStrength > 0.9 && _state != EState.NEXT)
                    {
                        _mediaPlayer.Ctlcontrols.next();
                        _state = EState.NEXT;
                    }

                    if (hand.Rotation.w < 0.1)
                    {
                        _mediaPlayer.settings.volume = 0;
                    }
                    if (hand.Rotation.w < 0.70)
                    {
                        ++stop;
                    }
                }
            }
            if (stop == 2)
            {
                if (frame.Hands[0].PalmPosition.DistanceTo(frame.Hands[1].PalmPosition) < 20 && _state != EState.STOP)
                {
                    _mediaPlayer.Ctlcontrols.stop();
                    _state     = EState.STOP;
                    _isStarted = false;
                }
            }
            else
            {
                if (pause == true && extendedfingers == 0 && _state != EState.PAUSE)
                {
                    _mediaPlayer.Ctlcontrols.pause();
                    _state = EState.PAUSE;
                }
                else if (frame.Hands.Count == 2 && _state != EState.PLAY)
                {
                    if (_isStarted == false)
                    {
                        playPlaylist();
                    }
                    _mediaPlayer.Ctlcontrols.play();
                    _state     = EState.PLAY;
                    _isStarted = true;
                }
            }
        }
Пример #45
0
		void ClockStart()
		{
			State = EState.Select;
			BitsLeft = 8;
			Console.WriteLine("STATE: SELECT");
		}
Пример #46
0
 public Wave(int index, WaveContent content)
 {
     _Index   = index;
     _Content = content;
     _State   = EState.UNSTARTED;
 }
Пример #47
0
		public void SyncState(Serializer ser)
		{
			ser.BeginSection("SEEPROM");
			ser.Sync("rom", ref rom, false);
			ser.Sync("OutEnable", ref OutEnable);
			ser.Sync("SCK", ref SCK);
			ser.Sync("SDA", ref SDA);
			ser.Sync("PullDown", ref PullDown);
			ser.Sync("BitsLeft", ref BitsLeft);
			ser.Sync("Data", ref Data);
			ser.Sync("Addr", ref Addr);
			int tmp = (int)State;
			ser.Sync("State", ref tmp);
			State = (EState)tmp;
			ser.EndSection();
		}
Пример #48
0
    // ONLY SERVER SHOULD CALL THIS
    public void SetState(EState _eState)
    {
        if (Network.isServer)
        {
            networkView.RPC("SetState", RPCMode.OthersBuffered, (int)_eState);
        }


        if (m_eState != _eState)
        {
            m_ePrevState = m_eState;
        }


        m_eState = _eState;


        switch (m_eState)
        {
        case EState.LOBBY:
            GameApp.GetInstance().GetCursor().SetSideScrollingEnabled(true);
            GameApp.GetInstance().GetGameCamera().GetComponent <CCameraController>().ResetToStartPosition();
            break;

        case EState.GAME_START_FADE:
            GameApp.GetInstance().GetCursor().SetVisible(false);             // Show cursor
            Destroy(m_cLobby);
            SetWarlockSpellbookMovementDisabled(true);
            m_fCountdownTimer = 4;
            GameApp.GetInstance().GetGameCamera().GetComponent <CCameraController>().FadeOutIn(4, 6);
            break;

        case EState.GAME_START_PAN:
            GameApp.GetInstance().GetGameCamera().GetComponent <CCameraController>().RunStartGamePan(2.0f, 0.01f, 5.0f, 20.0f, 3.0f);
            break;

        case EState.ROUND_RESTART_FADE:
            m_oShop.enabled = false;
            GameApp.GetInstance().GetWarlock().GetComponent <CWarlockHealth>().WarlockHealth_Reset(true);
            GameApp.GetInstance().GetGameCamera().GetComponent <CCameraController>().FadeOutIn(3, 4);
            m_fCountdownTimer = 3.0f;
            break;

        case EState.ROUND_START_COUNTDOWN:
            ++m_uiRoundCount;
            GameApp.GetInstance().GetGameCamera().GetComponent <CCursor>().SetSideScrollingEnabled(true);
            GameApp.GetInstance().GetCursor().SetVisible(true);             // Hide cursor
            m_fCountdownTimer = m_kfCountdownDuration;
            break;

        case EState.FIGHTING:
            if (Network.isServer)
            {
                networkView.RPC("Terrain_Pause", RPCMode.AllBuffered, false);
            }
            SetWarlockSpellbookMovementDisabled(false);
            GameApp.GetInstance().GetWarlock().GetComponent <CWarlockHealth>().SetHealthBarVisable(true, true);

            GameApp.GetInstance().GetWarlock().GetComponent <CWarlockController>().WarlockController_SetLastAttacker(-1);
            GetComponent <CArenaAwards>().InitialiseAwards();

            break;

        case EState.SHOPPING_FADE:
            GameApp.GetInstance().GetCursor().SetSideScrollingEnabled(false); // Stop side scrollling
            SetWarlockSpellbookMovementDisabled(true);                        // Stop movement & Casting
            GameApp.GetInstance().GetWarlock().GetComponent <CWarlockHealth>().SetHealthBarVisable(false, true);
            m_fCountdownTimer = 4.0f;
            GameApp.GetInstance().GetGameCamera().GetComponent <CCameraController>().FadeOutIn(4, 4);

            GetComponent <CArenaAwards>().AwardRoundBonus();

            break;

        case EState.SHOPPING:
            if (Network.isServer)
            {
                networkView.RPC("Terrain_Initialise", RPCMode.AllBuffered, Random.Range(0, int.MaxValue), 800);
            }
            m_fShopTimer    = m_kfShoppingDuration;
            m_oShop.enabled = true;
            break;

        case EState.END_GAME_FADE:
            if (Network.isServer)
            {
                networkView.RPC("Terrain_Pause", RPCMode.AllBuffered, true);
            }
            GameApp.GetInstance().GetCursor().SetSideScrollingEnabled(false); // Stop side scrollling
            SetWarlockSpellbookMovementDisabled(true);                        // Stop movement & Casting
            GameApp.GetInstance().GetWarlock().GetComponent <CWarlockHealth>().SetHealthBarVisable(false, true);
            m_fCountdownTimer = 4.0f;                                         //Switch scene
            GameApp.GetInstance().GetGameCamera().GetComponent <CCameraController>().FadeOutIn(4, 6);
            break;

        case EState.END_GAME_PODIUM:
            m_fCountdownTimer = 4.0f;
            SetWarlockWinningPosition();
            break;
        }
    }
        private void Update()
        {
            switch (m_State)
            {
            case EState.FADING_IN:
                t += Time.deltaTime;
                if (t >= m_FadeTime)
                {
                    m_State = EState.WAITING;
                    t       = 0f;
                    TutorialManager.Instance.UpdateFocusObjects(1f, true);
                }
                else
                {
                    //fade in focus objects
                    float a = Mathf.Lerp(TutorialManager.MIN_ALPHA, 1f, CAMath.SmoothStep(t / m_FadeTime));
                    m_InfoText.alpha = a;
                    TutorialManager.Instance.UpdateFocusObjects(a, true);
                }
                break;

            case EState.WAITING:
                t += Time.deltaTime;
                if (t > (m_ClickToContinueTime) && t < (m_ClickToContinueTime + m_FadeTime)) //if timer still counting
                {
                    //fade in click anywhere to continue text
                    if (m_ClickToContinueText != null)
                    {
                        float a = Mathf.Lerp(0f, c_ClickToContinueAlphaMax,
                                             Mathf.Min(1.0f, CAMath.SmoothStep((t - m_ClickToContinueTime) / m_FadeTime)));
                        m_ClickToContinueText.alpha = a;
                        m_ClickToContinueEtc.ForEach(item => TutorialManager.Instance.ChangeAlphaOnCompatibleComponents(item, a));
                    }
                }
                else if (b_CanAdvanceWithoutEventTrigger)
                {
                    AdvanceTutorialStage(true);
                }
                break;

            case EState.FADING_OUT:
                t += Time.deltaTime;
                if (b_FadeOut || t >= m_FadeTime)
                {
                    t = 0f;
                    OnFadeOut();
                }
                else
                {
                    //fade out focus objects
                    if (m_ClickToContinueText != null)
                    {
                        m_ClickToContinueText.alpha = 0f;
                        m_ClickToContinueEtc.ForEach(item => TutorialManager.Instance.ChangeAlphaOnCompatibleComponents(item, 0f));
                    }
                    float a = Mathf.Lerp(1f, 0f, Mathf.Min(1.0f, CAMath.SmoothStep(t / m_FadeTime)));
                    m_InfoText.alpha = a;
                }
                break;

            default:
                break;
            }
        }
Пример #50
0
    void CheckCurrentHttpConnectStatus()
    {
        if (mCommonHttpConnect != null)
        {
            // if request got response, handler the response and refresh requests list
            if (mCommonHttpConnect.IsGotResponse())
            {
                bool result = mCommonHttpConnect.ParseResponse();
                //bool canRetry = mCommonHttpConnect.CanRetryWhenErrorOrTimeout();
                bool canIgnore = mCommonHttpConnect.CanIgnoreWhenErrorOrTimeout();
                if (!result && canIgnore)
                {
                    mCommonHttpConnect.Ignore();
                }


                if (NETWORK_CAL_RESPONDING_TIME)
                {
                    mRespondTime = mCurTime - mConnectTime;
                    if (mRespondTime > mMaxRespondTime)
                    {
                        mMaxRespondTime = mRespondTime;
                    }
                }

                if (result)
                {
                    mState = EState.Idle;
                    if (mRetryTimes > 0)
                    {
                        // if (IsIPStyle(mCommonHttpConnect.URL))
                        //     NetworkDefine.RegroupURLWithIPFirst();
                        // else
                        //     NetworkDefine.RegroupURLWithURLFirst();
                    }
                    mRetryTimes = 0;
                }
                // www.error != null
                else
                {
                    bool canRetry = mCommonHttpConnect.CanRetryWhenErrorOrTimeout();
                    if (canRetry && mRetryTimes < NetworkDefine.sMaxRetryTime)
                    {
                        mRetryTimes++;
                        mState = EState.Idle;

                        mWaitingDialog = true;
                        // Debug.LogError("retry 11111");
                        // MessageBox.instance.ShowReconnecting(true);
                        Debug.Log("Retry " + mRetryTimes);
                    }
                    else
                    {
                        if (mCommonHttpConnect.FailOperation() == HttpRequest.FailOperationType.ErrorDialog)
                        {
                            // string title = TextManager.GetInstance().GetText(Text.NET_ERROR);
                            // string str = TextManager.GetInstance().GetText(Text.NO_NETWORK_CONNECTION);

                            // MessageBox.instance.OpenLiveMessageBox(MessageBox.eStyle.NoButton, title, str, handler_error_release, null);

                            mHasReportedError = false;
                            mState            = EState.DataError;
                        }
                        else
                        {
                            mState = EState.Idle;
                        }

                        System.Action cb = mCommonHttpConnect.FailCallBack();
                        // MessageBox.instance.CloseWaitingDialog();
                        Clear();
                        if (cb != null)
                        {
                            cb();
                        }
                    }
                }

                mCommonHttpConnect.Release();
            }
            else
            {
                if (mCurTime - mConnectTime > NetworkDefine.sConnectTimeout)
                {
                    if (NETWORK_CAL_RESPONDING_TIME)
                    {
                        mRespondTime = mCurTime - mConnectTime;
                        if (mRespondTime > mMaxRespondTime)
                        {
                            mMaxRespondTime = mRespondTime;
                        }
                    }

                    bool canRetry  = mCommonHttpConnect.CanRetryWhenErrorOrTimeout();
                    bool canIgnore = mCommonHttpConnect.CanIgnoreWhenErrorOrTimeout();
                    if (canIgnore)
                    {
                        mCommonHttpConnect.Ignore();
                    }

                    if ((canRetry || canIgnore) && mRetryTimes < NetworkDefine.sMaxRetryTime)
                    {
                        mRetryTimes++;
                        mState = EState.Idle;

                        mWaitingDialog = true;
                        // Debug.LogError("retry 22222");
                        // MessageBox.instance.ShowReconnecting(true);
                        Debug.Log("Retry " + mRetryTimes);
                    }
                    else
                    {
                        if (mCommonHttpConnect.FailOperation() == HttpRequest.FailOperationType.ErrorDialog)
                        {
                            // string title = TextManager.GetInstance().GetText(Text.NET_ERROR);
                            // string str = TextManager.GetInstance().GetText(Text.NO_NETWORK_CONNECTION);

                            // MessageBox.instance.OpenLiveMessageBox(MessageBox.eStyle.NoButton, title, str, handler_error_release, null);
                            mState = EState.Timeout;
                        }
                        else
                        {
                            mState = EState.Idle;
                        }
                        System.Action cb = mCommonHttpConnect.FailCallBack();
                        // MessageBox.instance.CloseWaitingDialog();
                        Clear();
                        if (cb != null)
                        {
                            cb();
                        }
                    }
                    mCommonHttpConnect.Release();
                }
            }
        }
        else
        {
            mState = EState.Idle;
        }
    }
Пример #51
0
 public void start()
 {
     mState = EState.gaming;
     mMainRole.show();
     mMainRole.start();
     showColorHint();
     timeIDGenBonus = TimerManager.get().setInterval(onTimerGenBonus, 300);
 }
Пример #52
0
        public void OnScreenCaptureReceivedEvent(object sender, ScreenCaptureStateEventArgs eventArgs)
        {
            if (eventArgs.HasNewData)
            {
                //Log.d(TAG, "Received screencapture data, size: " + eventArgs.Data.Length + " Remaining: " + eventArgs.Data.Remaining());
                if (State == EState.ACTIVE && !m_CancelToken.Token.IsCancellationRequested)
                {
                    m_transferRateList.Enqueue(new Tuple <int, int>(Environment.TickCount, (int)eventArgs.Data.Length));
                    m_nTransferRate += (int)eventArgs.Data.Length;
                    while (m_transferRateList.Count > 0 && Environment.TickCount - m_transferRateList.Peek().Item1 > 5000)
                    {
                        m_nTransferRate -= m_transferRateList.Dequeue().Item2;
                    }
                    m_payloadQueue.Post(new Payload()
                    {
                        Data = eventArgs.Data
                    });
                }
            }
            else if (eventArgs.HasNewState)
            {
                if ((State == EState.WAITING_FOR_PERMISSION || State == EState.REQUESTED) && eventArgs.CaptureState == ECaptureState.STARTING)
                {
                    Log.i(TAG, "Screen capture successfully started", true);
                    m_bDidCaptureDuringConnection = true;
                    State = EState.ACTIVE;
                    //DbgShowTransferRateAsync();
                    m_decodeTask = StartDecoder();
                }
                else if (State == EState.REQUESTED && eventArgs.CaptureState == ECaptureState.WAITINGFORPERMISSION)
                {
                    Log.i(TAG, "Waiting for permission on the Android device");
                    State = EState.WAITING_FOR_PERMISSION;
                }
                else if (State != EState.NONE && eventArgs.CaptureState == ECaptureState.ERROR)
                {
                    if (eventArgs.ErrorCode == BBProtocol.CAPTURE_ERRORCDOE_TRIALOVER)
                    {
                        Log.i(TAG, "Screen capture ended due to time limit of the free version", true);
                    }
                    else if (eventArgs.ErrorCode == BBProtocol.CAPTURE_ERRORCDOE_TRIALNOTALLOWED)
                    {
                        Log.i(TAG, "The free version of Wireboard allows only one screen capture per connection", true);
                    }
                    else
                    {
                        Log.i(TAG, "Screen capture failed due to an error on the Android device", true);
                    }

                    StopCapture(false, true);
                }
                else if (State != EState.NONE && eventArgs.CaptureState == ECaptureState.PERMISSIONDENIED)
                {
                    Log.i(TAG, "Permission to capture the screen was denied on the Android device", true);
                    StopCapture(false, true);
                }

                m_startScreenCaptureTCS?.TrySetResult(State == EState.ACTIVE || State == EState.WAITING_FOR_PERMISSION);
                m_startScreenCaptureTCS = null;
            }
        }
Пример #53
0
 //-------------------------------------------------------------------------------
 /// Unity
 //-------------------------------------------------------------------------------
 void Start()
 {
     m_eState = EState.e_InGame;
     m_TextureWinPlayer = m_Texture_Player1;
     m_fTimerEndLevel = 0.0f;
     m_fDeltaTime = Time.deltaTime;
 }
Пример #54
0
 public void ResetUI()
 {
     State = EState.Normal;
 }
Пример #55
0
 //-------------------------------------------------------------------------------
 /// Unity
 //-------------------------------------------------------------------------------
 void OnGUI()
 {
     switch(m_eState)
     {
         case EState.e_InGame:
         {
             break;
         }
         case EState.e_Win:
         {
             if(m_fTimerEndLevel > 0.0f)
             {
                 m_fTimerEndLevel -= m_fDeltaTime;
                 float fHeightFond = m_TextureWinPlayer.height * 5.0f/4.0f;
                 GUI.DrawTexture(new Rect(0, Screen.height/2.0f - fHeightFond/2.0f, Screen.width, fHeightFond), m_Texture_Blue);
                 GUI.DrawTexture(new Rect(Screen.width/2.0f - m_TextureWinPlayer.width/2.0f, Screen.height/2.0f - m_TextureWinPlayer.height/2.0f, m_TextureWinPlayer.width, m_TextureWinPlayer.height), m_TextureWinPlayer);
             }
             else
             {
                 m_eState = EState.e_InGame;
                 ResumeGame();
                 m_ObjectGame.GetComponent<CGame>().GoToNextLevel();
             }
             break;
         }
     }
 }
Пример #56
0
        private async void buttonFastStart_Click(object sender, EventArgs e)
        {
            buttonRollStart.Enabled = false;
            buttonFastStart.Enabled = false;
            buttonFastStop.Enabled  = true;

            int h = -1;

            try
            {
                fastCts = new CancellationTokenSource();
                var ct = fastCts.Token;
                await Task.Run(async() =>
                {
                    h = pigpiodIf.spi_open(2, 1000000, 256 + 0);
                    if (h < 0)
                    {
                        throw new PigpiodIfException(h, "PigpiodIf: " + pigpiodIf.pigpio_error(h));
                    }

                    List <DataPoint>[] dataPoints = new List <DataPoint> [NUM_FAST_CHANNELS];
                    for (int ch = 0; ch < NUM_FAST_CHANNELS; ch++)
                    {
                        dataPoints[ch] = new List <DataPoint>();
                    }

                    while (!ct.IsCancellationRequested)
                    {
                        EState state = EState.Arming;
                        for (int ch = 0; ch < NUM_FAST_CHANNELS; ch++)
                        {
                            dataPoints[ch].Clear();
                        }
                        DateTime start = DateTime.Now;
                        while (true)
                        {
                            double[] volts = new double[NUM_FAST_CHANNELS];
                            for (int ch = 0; ch < NUM_FAST_CHANNELS; ch++)
                            {
                                byte[] buf = new byte[] { (byte)(0x06 + (ch >> 2)), (byte)(ch << 6), 0x00 };
                                int b      = pigpiodIf.spi_xfer((UInt32)h, buf, buf);
                                if (b == 3)
                                {
                                    TimeSpan ts = DateTime.Now - start;
                                    volts[ch]   = 3.3 * (((buf[1] & 0x0f) * 256) + buf[2]) / 4096.0;
                                    if (EState.Arming < state && state < EState.Triggered)
                                    {
                                        dataPoints[ch].RemoveAt(0);
                                    }
                                    dataPoints[ch].Add(new DataPoint(ts.TotalSeconds, volts[ch]));
                                }
                            }

                            if (dataPoints[0].Count >= NUM_FAST_SAMPLES / 2)
                            {
                                switch (state)
                                {
                                case EState.Arming:
                                    state = EState.WaitingForTrigger1;
                                    break;

                                case EState.WaitingForTrigger1:
                                    if (dataPoints[0].Last().Y < 3.3 / 2)
                                    {
                                        state = EState.WaitingForTrigger2;
                                    }
                                    else if ((DateTime.Now - start) >= TimeSpan.FromSeconds(AUTO_TRIGGER))
                                    {
                                        state = EState.Triggered;
                                    }
                                    break;

                                case EState.WaitingForTrigger2:
                                    if (dataPoints[0].Last().Y > 3.3 / 2)
                                    {
                                        state = EState.Triggered;
                                    }
                                    else if ((DateTime.Now - start) >= TimeSpan.FromSeconds(AUTO_TRIGGER))
                                    {
                                        state = EState.Triggered;
                                    }
                                    break;
                                }
                            }

                            if (dataPoints[0].Count >= NUM_FAST_SAMPLES)
                            {
                                if (state == EState.Triggered)
                                {
                                    state = EState.Idle;
                                    break;
                                }
                            }
                        }
                        for (int ch = 0; ch < NUM_FAST_CHANNELS; ch++)
                        {
                            double x0 = dataPoints[ch][0].X;
                            for (int sample = 0; sample < dataPoints[ch].Count; sample++)
                            {
                                var dp = dataPoints[ch][sample];
                                dataPoints[ch][sample] = new DataPoint(dp.X - x0, dp.Y);
                            }
                        }

                        int leftInMS = INTERVAL_IN_MS - (int)(DateTime.Now - lastDispleyTime).TotalMilliseconds;
                        if (leftInMS > 0)
                        {
                            //Console.WriteLine("spentTime: {0}", leftInMS);
                            await Task.Delay(leftInMS, ct);
                        }
                        lastDispleyTime = DateTime.Now;

                        Invoke(new Action(() =>
                        {
                            for (int ch = 0; ch < NUM_FAST_CHANNELS; ch++)
                            {
                                fastSeries[ch].Points.Clear();
                                fastSeries[ch].Points.AddRange(dataPoints[ch]);
                            }
                            fastPlotModel.InvalidatePlot(true);
                            if (plotView1.Model != fastPlotModel)
                            {
                                plotView1.Model = fastPlotModel;
                            }
                            else
                            {
                                plotView1.Invalidate();
                            }
                        }));
                    }
                }, ct);
            }
            catch (OperationCanceledException)
            {
                // nothing to do
            }
            catch (PigpiodIfException ex)
            {
                Console.WriteLine(ex.Message);
            }
            finally
            {
                if (h >= 0)
                {
                    pigpiodIf.spi_close((UInt32)h);
                }

                fastCts = null;

                buttonRollStart.Enabled = true;
                buttonFastStart.Enabled = true;
                buttonFastStop.Enabled  = false;
            }
        }
Пример #57
0
		void ClockStop()
		{
			State = EState.Off;
			Console.WriteLine("STATE: OFF");
			PullDown = false;
		}
Пример #58
0
 public void OnConfire()
 {
     State = EState.Confire;
 }
Пример #59
0
		/// <summary>
		/// called on the 9th bit of a write
		/// </summary>
		void ClockByteWrite()
		{
			if (State == EState.Write)
			{
				PullDown = true; // ack
				// commit
				Console.WriteLine("{1:x2} => rom[{0:x2}]", Addr, Data);
				rom[Addr] = Data;
				Addr++;
				Addr &= (byte)(rom.Length - 1);
				// next byte
				BitsLeft = 8;
			}
			else if (State == EState.Select)
			{
				if (Big) // 24C02: select contains a device selector, plus mode
				{
					Console.WriteLine("256B Select: {0:x2}", Data);

					// device selector byte should be 1010 000x
					// x = 0: write.  x = 1: read

					if ((Data & 0xfe) != 0xa0)
					{
						Console.WriteLine("STATE: IGNORE");
						State = EState.Ignore;
					}
					else
					{
						if (Data.Bit(0))
						{
							PullDown = true; // ack
							Console.WriteLine("STATE: READ");
							State = EState.Read;
							BitsLeft = 8;
							Data = rom[Addr];
						}
						else
						{
							PullDown = true; // ack
							Console.WriteLine("STATE: ADDRESS");
							State = EState.Address;
							BitsLeft = 8;
						}
					}
				}
				else // 24C01: select contains a 7 bit address, plus mode
				{
					Addr = (byte)(Data >> 1);
					Console.WriteLine("128B Addr: {0:x2}", Addr);
					if (Data.Bit(0))
					{
						PullDown = true; // ack
						Console.WriteLine("STATE: READ");
						State = EState.Read;
						BitsLeft = 8;
						Data = rom[Addr];
					}
					else
					{
						PullDown = true; // ack
						Console.WriteLine("STATE: WRITE");
						State = EState.Write;
						BitsLeft = 8;
					}
				}
			}
			else if (State == EState.Address) // (Only on 24C02): a byte of address
			{
				Addr = Data;
				Console.WriteLine("256B Addr: {0:x2}", Data);
				PullDown = true; // ack
				Console.WriteLine("STATE: WRITE"); // to random read, the device will be set to read mode right after this
				State = EState.Write;
				BitsLeft = 8;
			}
		}
Пример #60
0
    private IEnumerator Run()
    {
        while (true)
        {
            if (State != EState.Stop)
            {
                if (State == EState.Move)
                {
                    OnMove();
                }

                if (Input.GetKeyDown(KeyCode.Space))
                {
                    State = EState.Confire;
                }

                _lastTouch = null;
                if (_touchSceneObjects.Count > 0)
                {
                    _lastTouch = _touchSceneObjects[0];
                }

                if (State == EState.Confire)
                {
                    if (_lastTouch != null)
                    {
                        Anim.Play(MoveIdle, true);
                    }
                    else
                    {
                        State = EState.Move;
                    }
                }

                if (_lastTouch != null)
                {
                    switch (_lastTouch.GetType())
                    {
                    case ESceneObjectType.Link:
                    {
                        if (State == EState.Confire)
                        {
                            var link = _lastTouch as SceneLink;
                            link.ImageSwitch_Link.SetImage(1);
                            yield return(new WaitForSeconds(0.3f));

                            gameObject.transform.position = link.TargeLink.transform.position;
                            yield return(new WaitForSeconds(0.1f));

                            link.ImageSwitch_Link.SetImage(0);
                            SceneSwitchManager.Instance.Mask.DOFade(1, 0.3f);
                            yield return(new WaitForSeconds(0.3f));

                            SceneSwitchManager.Instance.Mask.DOFade(0, 0.3f);
                            SceneSwitchManager.Instance.SetScene(link.TargeScene);
                            SceneSwitchManager.Instance.SceneMap[SceneSwitchManager.Instance.CurrentScene].FollowObj.transform.position = gameObject.transform.position;
                            yield return(new WaitForSeconds(0.3f));
                        }
                    }
                    break;

                    case ESceneObjectType.Item:
                    {
                        var item = _lastTouch as SceneItem;

                        switch (item.TiggerType)
                        {
                        case ESceneTriggerType.Confire:
                        {
                            if (State == EState.Confire)
                            {
                                Show.gameObject.SetActive(!item.IsHideModel);
                                Anim.Play(MoveIdle, true);
                                yield return(item.TriggerPlot.Run());

                                item.Get();
                                Show.gameObject.SetActive(true);
                                CharaterData.CollectItemCount++;
                            }
                        }
                        break;

                        case ESceneTriggerType.Auto:
                        {
                            Show.gameObject.SetActive(!item.IsHideModel);
                            Anim.Play(MoveIdle, true);
                            yield return(item.TriggerPlot.Run());

                            // Show.gameObject.SetActive(true);
                            item.Get();
                        }
                        break;
                        }
                    }
                    break;
                    }

                    if (State == EState.Confire)
                    {
                        State = EState.Move;
                    }
                }
            }



            yield return(null);
        }
    }