예제 #1
0
파일: Client.cs 프로젝트: sergheim/SharpMUD
        public String Recv()
        {
            if (this.InAvail())
            {
                try
                {
                    StreamReader sr = new StreamReader(stream);

                    return((sr.Peek() > 0) ? sr.ReadLine() : String.Empty);
                }
                catch (IOException)
                {
                    this.state = CStates.closing;
                    return(String.Empty);
                }
                catch (Exception e)
                {
                    Console.WriteLine("ERROR: {0}...Flushing Client Stream.", e.ToString());
                    stream.Flush();

                    // Failed, return nothing
                    return(String.Empty);
                }
            }
            else
            {
                return(String.Empty);
            }
        }
예제 #2
0
파일: Client.cs 프로젝트: sergheim/SharpMUD
        public bool Send(String outbound)
        {
            if (!this.OutAvail())
            {
                return(false);
            }

            try
            {
                stream.Write(Encoding.ASCII.GetBytes(outbound), 0, outbound.Length);
                return(true);
            }
            catch (IOException)
            {
                this.state = CStates.closing;
                return(false);
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}...Flushing Client Stream.", e.ToString());
                stream.Flush();

                return(false);
            }
        }
예제 #3
0
 public static IEnumerable <IState> GetStates(CStates obj)
 {
     foreach (IState s in obj.OrderedSet)
     {
         yield return(s);
     }
 }
예제 #4
0
        public String Recv()
        {
            // We only want to try receiving if data is actually there
            // due to the fact that receiving is a blocking action.
            if (this.InAvail())
            {
                try
                {
                    StreamReader sr = new StreamReader(stream);

                    return((sr.Peek() > 0) ? sr.ReadLine() : String.Empty);
                }
                catch (IOException)
                {
                    this.state = CStates.closing;
                    return(String.Empty);
                }
                catch (Exception e)
                {
                    Console.WriteLine("ERROR: {0}...Flushing Client Stream.", e.ToString());
                    stream.Flush();

                    // Failed, return nothing
                    return(String.Empty);
                }
            }
            else
            {
                return(String.Empty);
            }
        }
예제 #5
0
파일: Client.cs 프로젝트: sergheim/SharpMUD
        public Client(TcpClient handle)
        {
            this.state  = CStates.login_name;
            this.handle = handle;

            // Save some time because we are going to be mostly using streams for interaction
            this.stream = handle.GetStream();

            this.profile = new Profile();
        }
예제 #6
0
    //-------------------------------------------------------------------------------------------------------------------------------------//
    void StunRelease()
    {
        #region
        if (m_iQuickRelease >= iReleaseCount) //sets quick release to 0 and releases stun
        {
            m_bIsStunned    = false;
            m_cState        = CStates.OnFloor;
            m_iQuickRelease = 0;
            m_aAnimator.SetBool("IsStunned", false);
        }


        if (Input.GetButtonDown(playerNumber + "_Release")) // xbox controles
        {
            ++m_iQuickRelease;
        }
        #endregion
    }
예제 #7
0
 void HeadCheck()
 {
     #region
     RaycastHit hit;
     Debug.DrawRay(this.transform.position + this.transform.up, Vector3.up, Color.black, 1);
     if (Physics.Raycast(this.transform.position + this.transform.up, Vector3.up, out hit, 0.4f))
     {
         if (hit.transform.tag == "Wall")
         {
             Debug.Log("Head is htting something");
             m_cState = CStates.OnFloor;
             //m_cCharacterController.Move(Vector3.down * 0.2f);
             movementDirection.y  = 0;
             movementDirection.y -= (1.0f + refBlockController.m_fOverworldSpeed);
             // m_bIsKicking = false;
         }
     }
     #endregion
 }
예제 #8
0
    //-------------------------------------------------------------------------------------------------------------------------------------//
    public void PlayerStun()
    {
        #region
        if (m_bIsStunned == false)
        {
            movementDirection.y = -m_fKickKnockBack + -refBlockController.m_fOverworldSpeed;  // fall speed when kicked is the kick force with the stage fall speed.
        }
        m_bIsStunned        = true;
        m_cState            = CStates.Stunned;
        m_fCurrentStunTime += Time.deltaTime;
        m_aAnimator.SetBool("IsStunned", true);
        if (m_fCurrentStunTime >= m_fMaxStunTime)
        {
            m_bIsStunned = false;
            m_cState     = CStates.OnFloor;
            Debug.Log(playerNumber + " Leave stun");
            m_fCurrentStunTime = 0;
            m_aAnimator.SetBool("IsStunned", false);
        }

        #endregion
    }
예제 #9
0
 public void ResetPlayer()
 {
     if (m_cCharacterController)
     {
         m_cCharacterController.enabled = true;
     }
     m_bIsKicking      = false;
     m_bIsPushed       = false;
     m_bIsStunned      = false;
     m_cState          = CStates.OnFloor;
     m_aAnimator.speed = 1;
     Time.timeScale    = 1;
     if (TheAnimator)
     {
         TheAnimator.SetBool("IsSliding", false);
         TheAnimator.SetBool("IsRunning", false);
         TheAnimator.SetBool("IsStunned", false);
         TheAnimator.SetBool("IsPushing", false);
         TheAnimator.SetBool("IsDiveKick", false);
         TheAnimator.SetBool("IsDancing", false);
         TheAnimator.SetBool("IsWallGrab", false);
     }
 }
예제 #10
0
 //-------------------------------------------------------------------------------------------------------------------------------------//
 //wall jumping
 //TODO:// move in opposite direction, currently only moves up
 void WallJump()
 {
     #region
     //HasJumped = false;
     if (transform.rotation.eulerAngles.y >= 1.0f && transform.rotation.eulerAngles.y <= 91.0f)
     {
         //movementDirection.x = -m_fHorizontalWallJumpForce;
         movementDirection.x = -m_fHorizontalWallJumpForce;
         movementDirection.y = m_fVerticalWallJumpForce;
         //m_cCharacterController.Move(Vector3.up * m_fVerticalWallJumpForce * Time.deltaTime);
         //m_cCharacterController.Move(movementDirection * Time.deltaTime * m_fJumpForce);
         //m_cCharacterController.Move(temp * Time.deltaTime);
         //m_fMaxSpeedX = m_fHorizontalWallJumpForce;
         //m_bIsPushed = true;
         transform.rotation = Quaternion.Euler(0, -90, 0);
         m_cState           = CStates.OnFloor;
     }
     else if (transform.rotation.eulerAngles.y >= 181.0f && transform.rotation.eulerAngles.y <= 271.0f)
     {
         //movementDirection.x = m_fHorizontalWallJumpForce;
         movementDirection.x = m_fHorizontalWallJumpForce;
         movementDirection.y = m_fVerticalWallJumpForce;
         //m_fMaxSpeedX = m_fHorizontalWallJumpForce;
         //m_bIsPushed = true;
         //m_cCharacterController.Move(Vector3.up * m_fVerticalWallJumpForce * Time.deltaTime);
         //m_cCharacterController.Move(movementDirection * Time.deltaTime * m_fJumpForce);
         //m_cCharacterController.Move(temp * Time.deltaTime);
         transform.rotation = Quaternion.Euler(0, 90, 0);
         m_cState           = CStates.OnFloor;
     }
     m_fTimeSinceWallJump = 0;
     m_aAnimator.SetBool("IsWallGrab", false);
     m_aAnimator.SetBool("IsJumping", true);
     m_cState = CStates.OnFloor;
     #endregion
 }
예제 #11
0
        public void SendByte(byte[] outBytes)
        {
            if (!this.OutAvail())
            {
                return;
            }

            try
            {
                stream.Write(outBytes, 0, outBytes.Length);
            }
            catch (IOException)
            {
                this.state = CStates.closing;
                return;
            }
            catch (Exception e)
            {
                Console.WriteLine("ERROR: {0}...Flushing Client Stream.", e.ToString());
                stream.Flush();

                return;
            }
        }
예제 #12
0
    //-------------------------------------------------------------------------------------------------------------------------------------//
    public void PlayerKick(CharacterController Temp)
    {
        #region
        if (!Temp.isGrounded && Input.GetButtonDown(playerNumber + "_Kick") && m_fTimeSinceLastKick > m_fKickCoolDown && m_bIsKicking == false)
        {
            m_gTrailObject = Instantiate(m_gDiveKickTrail, this.transform.position, Quaternion.identity, this.transform) as GameObject;
            m_bIsKicking   = true;
            PlayerTurnAround();
            if (transform.rotation == Quaternion.Euler(0, -90, 0))
            {
                movementDirection.y = m_fKickYSpeed - refBlockController.m_fOverworldSpeed;
                movementDirection.x = -m_fKickXSpeed;;
            }
            else
            {
                movementDirection.y = m_fKickYSpeed - refBlockController.m_fOverworldSpeed;
                movementDirection.x = m_fKickXSpeed;
            }
        }


        // m_fMaxFallSpeed = 20f;
        if (m_bIsKicking == true)
        {
            //if kicking for too long, end it. or if on the ground
            if (m_fCurrentKickTime >= m_fMaxKickTime || Temp.isGrounded)
            {
                DetachTrail();
                m_fMaxFallSpeed = m_fTempFallSpeed;
                m_fMaxSpeedX    = m_fTempMoveSpeedX;
                m_bIsKicking    = false;
                ref_KickHitBox.SetActive(false);
                m_fCurrentKickTime   = 0f;
                m_cState             = CStates.OnFloor;
                m_fTimeSinceLastKick = 0;
                m_aAnimator.SetBool("IsDiveKick", false);
            }
            else
            {
                m_fMaxFallSpeed     = m_fMaxKickSpeedY;
                m_fMaxSpeedX        = m_fMaxKickSpeedX;
                movementDirection.y = -m_fKickYSpeed;
                m_aAnimator.SetBool("IsDiveKick", true);
                if (movementDirection.x > 0)
                {
                    movementDirection.x = m_fKickXSpeed;
                }
                else
                {
                    movementDirection.x = -m_fKickXSpeed;
                }
                ref_KickHitBox.SetActive(true);
                m_bIsKicking        = true;
                m_cState            = CStates.Kicking;
                m_fCurrentKickTime += Time.deltaTime;
            }
        }
        m_fTimeSinceLastKick += Time.deltaTime;

        #endregion
    }
예제 #13
0
    //-------------------------------------------------------------------------------------------------------------------------------------//
    //Lincoln's messy code
    void Update()
    {
        if (!m_bIsStunned)
        {
            m_iQuickRelease = 0;
        }
        //refPlayerStatus.sprite = mySprites[m_iCounter];
        #region
        m_fTimeSinceWallJump += Time.deltaTime;
        if (m_bGameRunning == true)
        {
            #region If GameRunning
            //begin of mess
            m_aAnimator.enabled = true;
            if (refPlayerStatus)
            {
                refPlayerStatus.sprite = (m_bIsDead) ? m_sStatusSprites[1] : m_sStatusSprites[0];
            }
            if (m_bIsPlaying)
            {
                #region if IsPlaying
                m_aAnimator.speed = 1;
                if (!m_bIsDead)
                {
                    //HeadCheck(); //check for head collisions
                    PushCheck(); //check to see if still pushed
                    // end of mess
                    if (m_cCharacterController.isGrounded)
                    {
                        m_fAirBourneTime = 0f;
                    }
                    switch (m_cState)
                    {
                    case CStates.Stunned:
                        PlayerStun();
                        StunRelease();
                        MovementCalculations();
                        m_cCharacterController.Move(new Vector3(movementDirection.x * Time.deltaTime, Time.deltaTime * movementDirection.y));
                        transform.FindChild("Birdies_Flying_001").gameObject.SetActive(true);
                        break;

                    case CStates.OnFloor:
                        transform.FindChild("Birdies_Flying_001").gameObject.SetActive(false);
                        m_aAnimator.SetBool("IsDiveKick", false);
                        m_aAnimator.SetBool("IsWallGrab", false);
                        OnFloor();

                        if (!m_bHasPushed)
                        {
                            Push();
                        }
                        if (m_bIsStunned)
                        {
                            transform.FindChild("Birdies_Flying_001").gameObject.SetActive(true);
                            PlayerStun();
                        }
                        else
                        {
                            transform.FindChild("Birdies_Flying_001").gameObject.SetActive(false);
                        }
                        break;

                    case CStates.Kicking:
                        transform.FindChild("Birdies_Flying_001").gameObject.SetActive(false);
                        if (m_bIsKicking == false)
                        {
                            m_cState = CStates.OnFloor;
                        }
                        PlayerKick(m_cCharacterController);
                        MovementCalculations();
                        m_fAirBourneTime = 0;
                        m_cCharacterController.Move(new Vector3(Time.deltaTime * movementDirection.x * m_fMoveSpeed, Time.deltaTime * movementDirection.y));
                        break;

                    case CStates.OnWall:
                        m_fAirBourneTime = 5;
                        if (m_bIsStunned)
                        {
                            transform.FindChild("Birdies_Flying_001").gameObject.SetActive(true);
                            PlayerStun();
                        }
                        else
                        {
                            transform.FindChild("Birdies_Flying_001").gameObject.SetActive(false);
                        }
                        if (!m_cCharacterController.isGrounded)
                        {
                            m_aAnimator.SetBool("IsWallGrab", true);
                            WallSlide(m_bIsStunned);
                        }

                        else if (m_cCharacterController.isGrounded)
                        {
                            OnFloor();
                        }

                        break;
                    }
                }
                #endregion
            }
            #endregion
        }
        if (m_bHasPushed == true && m_fTimeSinceLastPush >= .1)
        {
            m_aAnimator.SetBool("IsPushing", false);
            m_bHasPushed = false;
        }
        m_fTimeSinceLastPush += Time.deltaTime;
        //refPlayerStatus.text = "Press Start to join";



        #endregion
    }
예제 #14
0
 public СMouseStateMachine(CStates states) : base(states.ToArray())
 {
     AllStates = states;
 }