예제 #1
0
    public static void AddState(State state)
    {
        switch (state.Type)
        {
        case States.Idle:
            var idle = state as IdleState;
            IdleStates.Add(idle);
            break;

        case States.Build:
            var build = state as BuildState;
            BuildStates.Add(build);
            break;

        case States.Attack:
            var attack = state as AttackState;
            AttackStates.Add(attack);
            break;

        case States.Conquer:
            var conquer = state as ConquerState;
            ConquerStates.Add(conquer);
            break;

        case States.Move:
            var move = state as MoveState;
            MoveStates.Add(move);
            break;
        }
    }
예제 #2
0
    //called on the last frame of an attack. Make sure to use InterruptAttack if the attack is being cancelled by something else
    public void EndAttack()
    {
        pam.DestroyHitboxes();

        if (isGrounded)
        {
            //checks if this move should end with landing lag
            if (currAttack.landingLag != 0 && !currAttack.frameData[currAttackFrame].autoCancel)
            {
                moveState = MoveStates.LANDINGLAG;
                lagCount  = currAttack.landingLag;
            }
            else
            {
                moveState = MoveStates.STILL;
            }
        }
        else
        {
            moveState = MoveStates.AIRBORNE;
        }

        //resets the nullified attacks list
        foreach (List <Attack> nullifier in PlayerAttackManager.nullAttackLists)
        {
            nullifier.Remove(currAttack);
        }

        currAttack      = null;
        currAttackFrame = 0;
        MakeInvincible(true);
        render.material = GameLoader.SetAlpha(render.material, 1);
    }
예제 #3
0
 void HandleAttack()
 {
     if(moveState == MoveStates.grounded)
     {
         if (Input.GetButtonDown("Light Attack"))
         {
             if (myPlayerCharacter.canLightAttack)
             {
                 myPlayerCharacter.LightAttack();
                 moveState = MoveStates.noMove;
                 myAnimationController.LightAttack();
                 myColliderController.LightAttack(facingLeft);
             }
         }
         else if (Input.GetButtonDown("Heavy Attack"))
         {
             if (myPlayerCharacter.canHeavyAttack)
             {
                 myPlayerCharacter.HeavyAttack();
                 moveState = MoveStates.noMove;
                 myAnimationController.HeavyAttack();
                 myColliderController.HeavyAttack(facingLeft);
             }
         }
     }        
 }
예제 #4
0
    //called when hitstun starts, signals end of hitstun
    public virtual IEnumerator Hitstun()
    {
        if ((isGrounded || PreventClipping()) && Mathf.Abs(knockbackMomentum.y) < 0.12F)
        {
            knockbackMomentum.y = 0;
        }
        else
        {
            transform.Translate(new Vector3(0, 0.1F));
            isGrounded = false;
        }
        for (int i = 0; i < hitStunDuration; i++)
        {
            yield return(null);
        }
        if (isGrounded)
        {
            moveState        = MoveStates.STILL;
            groundMomentum.x = knockbackMomentum.x;
            hitStunDuration  = 0;
            inHitstun        = false;
        }
        else
        {
            moveState       = MoveStates.AIRBORNE;
            airMomentum     = knockbackMomentum;
            hitStunDuration = 0;
            inHitstun       = false;
        }

        knockbackMomentum = Vector3.zero;
    }
예제 #5
0
    //initiates the player's jump after jumpsquat ends
    void Jump(bool aerial = false)
    {
        //sets position to be just above the ground to avoid staying grounded after jumping
        transform.position += new Vector3(0, 0.01F);
        isGrounded          = false;
        moveState           = MoveStates.AIRBORNE;
        Vector3 momen = new Vector3(0, 0);

        if (aerial)
        {
            framesSinceLedgeGrab = 0;

            if (jumpUsed == jumpCount)
            {
                return;
            }
            else
            {
                jumpUsed++;
                fastFalling = false;
                momen.y    += jumpMomentum;

                //determines if jumping in a directon
                if (hori > horiThreshold)
                {
                    momen.x -= maxAirSpeed;
                }

                if (hori < -horiThreshold)
                {
                    momen.x += maxAirSpeed;
                }
            }
        }
        else
        {
            //determines if this is a shorthop or fullhop
            if (xHold || yHold)
            {
                momen.y += jumpMomentum;
            }
            else
            {
                momen.y += 0.75F * (jumpMomentum);
            }

            //determines if jumping in a directon
            if (hori > horiThreshold)
            {
                momen.x -= maxAirSpeed;
            }

            if (hori < -horiThreshold)
            {
                momen.x += maxAirSpeed;
            }
        }
        airMomentum = momen;
    }
예제 #6
0
 private void ChangeAnimationState(MoveStates moveState)
 {
     if (_currentState != moveState)
     {
         _currentState = moveState;
         var animationName = Array.Find(_animationNames, a => a.state == _currentState).animationName;
         _animator.SetBool(animationName, true);
     }
 }
예제 #7
0
    //Called while running (and first 4 frames of skidding)
    void RunControl()
    {
        //checks direction
        if (moveState == MoveStates.LEFTRUN)
        {
            isFacingLeft = true;
        }
        else if (moveState == MoveStates.RIGHTRUN)
        {
            isFacingLeft = false;
        }

        if (yPress || xPress)
        {
            StartJumpsquat();
        }

        //skids if necessary
        if (!(hori >= horiThreshold) && !(hori <= -horiThreshold) && moveState != MoveStates.SKID)
        {
            moveState = MoveStates.SKID;
            lagCount  = 15;
        }
        else

        if (lHold || rHold)
        {
            if (onStickBuff)
            {
                pam.UseDefensiveOption(this);
            }
            else
            {
                StartShielding();
            }
        }
        else
        //allows dashdancing
        if (moveState == MoveStates.LEFTRUN || moveState == MoveStates.SKID)
        {
            if (hori >= horiThreshold && runFrames <= 29)
            {
                groundMomentum = Vector3.zero;
                StartRun();
            }
        }

        if (moveState == MoveStates.RIGHTRUN || moveState == MoveStates.SKID)
        {
            if (hori <= -horiThreshold && runFrames <= 29)
            {
                groundMomentum = Vector3.zero;
                StartRun(true);
            }
        }
    }
예제 #8
0
 private void ChangeState(MoveStates newState)
 {
     _timer    = 0;
     _evadeDir = Vector3.zero;
     MyAI.Whiteboard.Parameters["SpeedLimit"]     = -1f;
     MyAI.Whiteboard.Parameters["StrafeForce"]    = 0f;
     MyAI.Whiteboard.Parameters["IsEngineKilled"] = false;
     MyAI.Whiteboard.Parameters["IsThrusting"]    = false;
     State = newState;
 }
예제 #9
0
    IEnumerator CheckTouchUpdate()
    {
        //Get touch start positions
        Vector3 startPivotPosition      = transform.position;
        Vector2 startTouchPivotPosition = Vector2.zero;

        startTouchPivotPosition = GetMeanPositionFromTouches();
        touchPosition           = startTouchPivotPosition;

        //Start TouchDelta Calculations
        if (TouchDeltasCalculator == null)
        {
            TouchDeltasCalculator = CalculateTouchDeltas();
        }
        StartCoroutine(TouchDeltasCalculator);

        //CheckTouch Updater
        while (Input.touchCount > 0)
        {
            //Calculate touch drag angle from mean position and pivot position
            dragVector  = startTouchPivotPosition - touchPosition;
            dragVector *= 0.015f * scrollSpeed;

            //Calculate touch mean position
            touchPosition = Input.touches[0].position; //previously: GetMeanPositionFromTouches();
            if (Input.touchCount == 1)
            {
                if (cameraMoveState == MoveStates.zooming)
                {
                    cameraMoveState         = MoveStates.scrolling;
                    startTouchPivotPosition = GetMeanPositionFromTouches();
                    startPivotPosition      = transform.position;
                    dragVector = Vector2.zero;
                }
                transform.position = startPivotPosition + new Vector3(dragVector.x, 0f, dragVector.y);
            }

            //If the player is using 2 fingers, calculate the change in touch if any
            else if (Input.touchCount == 2)
            {
                if (cameraMoveState == MoveStates.scrolling)
                {
                    cameraMoveState = MoveStates.zooming;
                }
                cam.orthographicSize = Mathf.Clamp(cam.orthographicSize + -pinchDelta * 0.010f * zoomSpeed, zoomLimits.x, zoomLimits.y);
                UIController.uiController.ChangeStatusScaleUIToMatchZoom();
            }

            yield return(null);
        }

        ResetTouchCheckers();
        yield return(null);
    }
예제 #10
0
 // Token: 0x06001AD6 RID: 6870 RVA: 0x00011D3E File Offset: 0x0000FF3E
 public void Set(MoveStates state, bool on)
 {
     if (on)
     {
         this.MovementState |= state;
     }
     else
     {
         this.MovementState &= ~state;
     }
 }
예제 #11
0
 void StartRun(bool left = false)
 {
     runFrames = 0;
     if (left)
     {
         moveState = MoveStates.LEFTRUN;
     }
     else
     {
         moveState = MoveStates.RIGHTRUN;
     }
 }
예제 #12
0
 //called when the player grabs a ledge
 public void GrabLedge(LedgeNode ledge)
 {
     currLedge    = ledge;
     isFacingLeft = ledge.ledgeGrabLeft;
     moveState    = PlayerController.MoveStates.LEDGEGRAB;
     lagCount     = 12;
     isInvincible = true;
     airMomentum  = Vector3.zero;
     jumpUsed     = 0;
     upBUsed      = 0;
     sideBUsed    = 0;
     fastFalling  = false;
 }
예제 #13
0
    private void ChangeState()
    {
        Vector2 direction = player.transform.position - transform.position;

        if (direction.x > 0)
        {
            state = MoveStates.Right;
        }
        else if (direction.x < 0)
        {
            state = MoveStates.Left;
        }
    }
예제 #14
0
파일: Player.cs 프로젝트: shuidong/Voxalia
        public override void Tick()
        {
            Direction.X += MouseHandler.MouseDelta.X;
            Direction.Y += MouseHandler.MouseDelta.Y;
            TickMovement(ClientMain.Delta);
            ClientMain.CameraEye = Position + new Location(0, 0, Maxes.Z);
            Location forward = Utilities.ForwardVector_Deg(Direction.X, Direction.Y);

            ClientMain.CameraTarget = ClientMain.CameraEye + forward;
            ltime += ClientMain.Delta;
            Location seltarg = ClientMain.CameraEye + forward * 10;

            SelectedBlock = Collision.BoxRayTrace(new Location(-0.001), new Location(0.001), ClientMain.CameraEye, seltarg, -1);
            if (SelectedBlock == seltarg)
            {
                SelectedBlock = Location.NaN;
            }
            if ((Forward != pForward || Backward != pBackward ||
                 Leftward != pLeftward || Rightward != pRightward ||
                 Upward != pUpward || Downward != pDownward ||
                 Slow != pSlow || Use != pUse ||
                 Attack != pAttack || Secondary != pSecondary ||
                 Direction.X != pDirection.X ||
                 Direction.Y != pDirection.Y) ||
                ltime >= 0.1)
            {
                pForward   = Forward;
                pBackward  = Backward;
                pLeftward  = Leftward;
                pRightward = Rightward;
                pUpward    = Upward;
                pDownward  = Downward;
                pDirection = Direction;
                pSlow      = Slow;
                pUse       = Use;
                pAttack    = Attack;
                pSecondary = Secondary;
                ltime      = 0;
                AddMS();
                if (ClientNetworkBase.Connected)
                {
                    ClientNetworkBase.SendPacket(new MoveKeysPacketOut(MoveStates[MoveStates.Count - 1]));
                }
                if (MoveStates.Count > 250)
                {
                    MoveStates.RemoveRange(0, 50);
                }
            }
        }
예제 #15
0
파일: BaseLogic.cs 프로젝트: Victor-UA/G
 public void DoMoves(TimeSpan timeElapsed)
 {
     lock (_lock)
     {
         foreach (var item in _entities.Values)
         {
             if (item is IMovable)
             {
                 IMovable   movableItem = item as IMovable;
                 MoveStates mState      = movableItem.MoveState;
                 if (mState.RotateLeft)
                 {
                     item.Position.Direction = item.Position.Direction.RotateZ(-4 * timeElapsed.TotalSeconds);
                 }
                 if (mState.RotateRight)
                 {
                     item.Position.Direction = item.Position.Direction.RotateZ(4 * timeElapsed.TotalSeconds);
                 }
                 Vector3 delta = new Vector3();
                 if (mState.Forward)
                 {
                     delta += item.Position.Direction;
                 }
                 if (mState.Backward)
                 {
                     delta -= item.Position.Direction;
                 }
                 if (mState.StrafeLeft)
                 {
                     delta -= item.Position.Direction.RotateZ(Math.PI / 2);
                 }
                 if (mState.StrafeRight)
                 {
                     delta += item.Position.Direction.RotateZ(Math.PI / 2);
                 }
                 if (delta.Magnitude != 0)
                 {
                     movableItem.Velocity    = 50;
                     item.Position.Location += delta * timeElapsed.TotalSeconds * movableItem.Velocity;
                 }
                 else
                 {
                     movableItem.Velocity = 0;
                 }
             }
         }
     }
 }
예제 #16
0
    void CheckState(Rigidbody _rigid, Player _player, float _delta)
    {
        MoveStates _state = _currentMovement.CheckState(_player);

        if (_state != MoveStates.current)
        {
            _currentMovement.Exit(_rigid, _player, _delta);
            switch (_state)
            {
            case MoveStates.grounded: _currentMovement = new MoveGround(); break;

            case MoveStates.airborn: _currentMovement = new MoveAirborn(); break;
            }
            _currentMovement.Enter(_rigid, _player, Time.deltaTime);
        }
    }
예제 #17
0
 private void CheckMoveState()
 {
     if (acceleration > 0)
     {
         moveStates = MoveStates.FlyUp;
     }
     else if (acceleration < 0)
     {
         moveStates = MoveStates.FlyDown;
     }
     else
     {
         moveStates = MoveStates.Idle;
     }
     Debug.Log(moveStates);
 }
예제 #18
0
 void ShieldControl()
 {
     moveState = MoveStates.SHIELD;
     ApplyTraction();
     if (!lHold && !rHold)
     {
         moveState = MoveStates.SHIELDDROP;
         lagCount  = 6;
     }
     if (yPress || xPress)
     {
         StartJumpsquat();
     }
     else if (onStick && Mathf.Abs(hori) >= horiThreshold)
     {
         pam.UseDefensiveOption(this);
     }
 }
예제 #19
0
    //called when the player dies
    public void Death()
    {
        InterruptAttack();
        currDamage         = 0;
        transform.position = new Vector3(0, 5);
        airMomentum        = Vector3.zero;
        groundMomentum     = Vector3.zero;
        knockbackMomentum  = Vector3.zero;
        moveState          = MoveStates.AIRBORNE;

        foreach (Transform child in transform)
        {
            if (child.gameObject.tag == "Hitbox")
            {
                Destroy(child.gameObject);
            }
        }

        ScoreManager.IncrementScore(playerNum);
    }
    // Updates the movement compoent of the enemy.
    public void Move()
    {
        bool attacked = false;

        // Start processing.
        state = MoveStates.PROCESSING;


        // Calls attack method. Should return true if everything is cool
        if (_attackMethod != null)
        {
            attacked = _attackMethod();
            if (attacked)
            {
                state = MoveStates.IDLE;                 // DO NOT MOVE IF TRUE
            }
        }

        // Only call movement if the enemy did not attack.
        if (_movMethod != null && attacked == false)
        {
            // Grab movement from the _movMethod
            declaredMovement = _movMethod();

            // Upon exiting, it should either be IDLE or MOVING.
            ProcessState();
        }

        if (state == MoveStates.MOVING)
        {
            GridSpriteTranslate gst = GetComponentInChildren <GridSpriteTranslate>();
            gst.StartTranslation();

            transform.position += (Vector3)declaredMovement;

            gst.SetPosition();
        }

        // LABEL AS FINISHED
        state = MoveStates.FINISHED;
    }
예제 #21
0
    public static void RemoveState(State state)
    {
        switch (state.Type)
        {
        case States.Idle:
            if (IdleStates.Contains(state))
            {
                IdleStates.Remove(state);
            }
            break;

        case States.Build:
            if (BuildStates.Contains(state))
            {
                BuildStates.Remove(state);
            }
            break;

        case States.Attack:
            if (AttackStates.Contains(state))
            {
                AttackStates.Remove(state);
            }
            break;

        case States.Conquer:
            if (ConquerStates.Contains(state))
            {
                ConquerStates.Remove(state);
            }
            break;

        case States.Move:
            if (MoveStates.Contains(state))
            {
                MoveStates.Remove(state);
            }
            break;
        }
    }
예제 #22
0
    void SetDead()
    {
        canMove = false;
        playerAgent.isStopped = true;
        playerAgent.SetDestination(playerTransform.position);
        cameraBehaviour.SetPlayerCanMove(false);

        thorAnimator.SetTrigger("die");
        endingPlayer.PlayGameEnding(PlayEnding.EndingTypes.Defeat, playerTransform, 2, 0.2f, new Vector3(0, 4, -4));
        moveStates = MoveStates.Dead;

        foreach (GameObject enemy in GameObject.FindGameObjectsWithTag("Enemy"))
        {
            enemy.GetComponent <EnemyBehaviour>().SetPlayerDeath();
        }

        /*foreach (string enemy in enemiesWhoAttacked)
         * {
         *  EnemyBehaviour enemyBehaviour = GameObject.Find(enemy).GetComponent<EnemyBehaviour>();
         *  enemyBehaviour.SetPlayerDeath();
         * }*/
    }
예제 #23
0
    // Handles collisions with platforms
    private void OnCollisionEnter2D(Collision2D collision)
    {
        if (collision.gameObject.tag == "platform" && moveState != MoveStates.IDLE && CheckBelowGhost())
        {
            //// Collect contact info
            //ContactPoint2D contactPoint = collision.GetContact(0);
            //if (contactPoint.normal.y < 1f) return;

            // Velocity magnitude large enough to cause sound to trigger
            if (collision.relativeVelocity.magnitude > 4)
            {
                GameObject impact = (collision.collider.name == "greenPlatform") ? impact = Instantiate(greenImpact, null) : impact = Instantiate(redImpact, null);
                Screenshake.smallShakeEvent.Invoke();
                ContactPoint2D contact = collision.GetContact(0);
                impact.transform.position = contact.point;
                landSound.pitch           = Random.Range(.5f, .8f);
                landSound.Play();
            }
            moveState  = MoveStates.IDLE;
            isGrounded = true;
        }
    }
예제 #24
0
    // Update is called once per frame
    void FixedUpdate()
    {
        //set state for accelerating and reversing
        if (Input.GetKey(KeyCode.UpArrow))
        {
            moveStates = MoveStates.forward;
        }
        else if (Input.GetKey(KeyCode.DownArrow))
        {
            moveStates = MoveStates.reverse;
        }
        else
        {
            moveStates = MoveStates.idle;
        }

        //steering
        if (Input.GetKey(KeyCode.LeftArrow))
        {
            Turn(1);
        }
        if (Input.GetKey(KeyCode.RightArrow))
        {
            Turn(-1);
        }

        //apply movement forces
        if (moveStates == MoveStates.forward)
        {
            Forward();
        }
        if (moveStates == MoveStates.reverse)
        {
            Reverse();
        }

        //print(transform.forward);
    }
예제 #25
0
 public void MoveRight()
 {
     state = MoveStates.MoveRight;
 }
예제 #26
0
 void SetMove()
 {
     moveStates = MoveStates.Move;
 }
예제 #27
0
 void SetIdle()
 {
     moveStates = MoveStates.Idle;
 }
예제 #28
0
 // Token: 0x06001B20 RID: 6944 RVA: 0x00003C87 File Offset: 0x00001E87
 public void AddSample(Vector3 position, MoveStates state)
 {
 }
예제 #29
0
    private void MoveStateHandler(ShipController controller, RaycastHit2D hit)
    {
        Debug.Log(moveState);
        switch (moveState)
        {
        case MoveStates.Roaming:
            if (hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.PlayerEngaged;
            }
            if (hit.distance > 1f && !hit.transform.gameObject.CompareTag("Player"))
            {
                MoveAndRotate(controller);
            }
            controller.OnRotateEmitted(GetRotationDirection(controller));
            break;

        case MoveStates.PlayerEngaged:
            if (hit.distance <= 1f && !hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.Roaming;
            }
            if (hit.distance <= attackRange)
            {
                moveState = MoveStates.AttackingPlayer;
            }
            if (!hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.TryingToReengage;
            }
            if (hit.distance > attackRange && hit.transform.gameObject.CompareTag("Player"))
            {
                controller.OnMoveEmitted();
            }
            break;

        case MoveStates.TryingToReengage:
            if (hit.distance <= 1f && !hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.Roaming;
            }
            if (hit.distance <= attackRange && hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.AttackingPlayer;
            }
            if (hit.distance > attackRange && hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.AttackingPlayer;
            }
            if (GetDistanceFromPlayer(controller) <= attackRange)
            {
                controller.OnRotateEmitted(GetRotationDirection(controller));
            }
            if (GetDistanceFromPlayer(controller) > attackRange)
            {
                MoveAndRotate(controller);
            }
            break;

        case MoveStates.AttackingPlayer:
            if (hit.distance <= 1f && !hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.Roaming;
            }
            if (hit.distance > attackRange && !hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.TryingToReengage;
            }
            if (hit.distance > attackRange && hit.transform.gameObject.CompareTag("Player"))
            {
                moveState = MoveStates.PlayerEngaged;
            }
            break;
        }
    }
예제 #30
0
 public override void Initialize()
 {
     inCooldown = false;
     moveState  = MoveStates.Roaming;
 }
예제 #31
0
 private void Awake()
 {
     controller  = GetComponent <PlayerController>();
     rgdBody     = GetComponent <Rigidbody>();
     myStateType = MoveStates.ERROR;
 }
예제 #32
0
 // Token: 0x06001B35 RID: 6965 RVA: 0x00012091 File Offset: 0x00010291
 public bool Is(MoveStates state)
 {
     return((byte)(this.MovementState & state) != 0);
 }
예제 #33
0
 public void MoveLeft()
 {
     state = MoveStates.MoveLeft;
 }
예제 #34
0
 public void FinishedAttack()
 {
     moveState = MoveStates.jump;
 }
예제 #35
0
    Vector3 HandleMovement()
    {
        Vector3 velocity = myCharacterController.velocity;

        if(myCharacterController.isGrounded)
        {
            velocity.y = 0;
            moveState = MoveStates.grounded;

            if (Input.GetAxisRaw("Horizontal") > 0)
            {
                velocity.x = speed;
                facingLeft = false;
                myAnimationController.WalkRight();
            }
            else if (Input.GetAxisRaw("Horizontal") < 0)
            {
                velocity.x = -speed;
                facingLeft = true;
                myAnimationController.WalkLeft();
            }
            else
            {
                velocity.x = 0;

                if (myCharacterController.isGrounded)
                {
                    myAnimationController.Idle();
                }
            }
        }
        else
        {
            myAnimationController.Jump();
        }

        

        if(Input.GetButtonDown("Dash"))
        {
            if(myPlayerCharacter.canDash)
            {
                velocity.x *= 25;
                moveState = MoveStates.dash;
                myPlayerCharacter.Dash();
            }            
        }

        if(moveState != MoveStates.jump && Input.GetButtonDown("Jump"))
        {
            velocity.y = Mathf.Sqrt(2f * jumpHeight * -gravity);

            moveState = MoveStates.jump;

            myAnimationController.Jump();
        }

        velocity.y += gravity * Time.deltaTime;

        return velocity;
    }
예제 #36
0
 public void ShowShootUI()
 {
     state = state == MoveStates.ShootReady ? MoveStates.Idle : MoveStates.ShootReady;
 }
예제 #37
0
 /// <summary>
 /// Initializes a new instance of the <see cref="NavigationInfo"/> class.
 /// </summary>
 /// <param name="command">The command.</param>
 /// <param name="state">The state.</param>
 public NavigationInfo(CommandType command, MoveStates state) : this(command)
 {
     _actionState = state;
 }
예제 #38
0
 public void Stop()
 {
     state = MoveStates.Idle;
 }