Пример #1
0
        public void Draw(SpriteBatch sb, int frame, DirectionState ds)
        {
            float s = MainManager.Instance.gameMan.player.armorScale + .2f;

            if (frame == 0)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 4 * s);
            }
            if (frame == 1)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 6 * s);
            }
            if (frame == 2)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 2 * s);
            }
            if (frame == 3)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 4 * s);
            }
            if (frame == 4)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 4 * s);
            }
            if (ds == DirectionState.right)
            {
                sb.Draw(MainManager.Instance.drawMan.spritesheet, position, selectionRect, color, 0, Vector2.Zero, MainManager.Instance.gameMan.player.armorScale + .2f, SpriteEffects.None, 0);
            }
            else
            {
                sb.Draw(MainManager.Instance.drawMan.spritesheet, position, selectionRect, color, 0, Vector2.Zero, MainManager.Instance.gameMan.player.armorScale + .2f, SpriteEffects.FlipHorizontally, 0);
            }
        }
Пример #2
0
 private void Update()
 {
     if (!isDead)
     {
         if (inPatrolling)
         {
             if (direction % 2 == 0)
             {
                 Patrol(Vector3.right);
                 directionState = DirectionState.RIGHT;
             }
             else
             {
                 Patrol(Vector3.left);
                 directionState = DirectionState.LEFT;
             }
             if (target && playerDetected)
             {
                 InvokeRepeating("Shot", .4f, 1f);
             }
         }
         if (target)
         {
             if (target.position.x < transform.position.x)
             {
                 directionState = DirectionState.LEFT;
             }
             else
             {
                 directionState = DirectionState.RIGHT;
             }
         }
     }
 }
Пример #3
0
 public static void SetDirection(KeyEventArgs e,string url,string id)
 {
     if ((e.KeyCode == Keys.Up)&& (CurrentDirection!=DirectionState.Down))
     {
         string response = Http.SendGETRequest(url, id+"u/");
         CurrentDirection = DirectionState.Up;
         return;
     }
     if ((e.KeyCode == Keys.Right) && (CurrentDirection != DirectionState.Left))
     {
         string response = Http.SendGETRequest(url, id + "r/");
         CurrentDirection = DirectionState.Right;
         return;
     }
     if ((e.KeyCode == Keys.Down) && (CurrentDirection != DirectionState.Up))
     {
         string response = Http.SendGETRequest(url, id + "d/");
         CurrentDirection = DirectionState.Down;
         return;
     }
     if ((e.KeyCode == Keys.Left) && (CurrentDirection != DirectionState.Right))
     {
         string response = Http.SendGETRequest(url, id + "l/");
         CurrentDirection = DirectionState.Left;
         return;
     }
 }
Пример #4
0
    public virtual void FlowStart(DirectionState inFlowSide, int inVal, OperationState operation)
    {
        _audioSource.clip = flowSound;
        _audioSource.Play();
        _inValue = inVal;
        if (_operation == OperationState.None)
        {
            _operation = operation;
        }
        fill.color      = Color.red;
        flowing         = true;
        this.inFlowSide = inFlowSide;
        flowStartTime   = Time.time;
        timeTillFill    = maxTimeTillFill;
        if (_thisVal != 0 && _operation != OperationState.None)
        {
            // If this is a numbered tube, perform the stored operation on it
            _outValue  = CalculateOperation(_inValue, _thisVal);
            _operation = OperationState.None;
        }
        else if (_thisVal != 0)
        {
            // No operation was between this number & the last number, so lose
            manager.GameOver();
        }
        else
        {
            // Otherwise, no operations are performed and the out value is passed the in value
            _outValue = _inValue;
        }
        manager.currentOut = _outValue;

        InvokeRepeating("FlowTick", startDelaySec, 0.075f);
    }
        public Vector3 InputDirection()
        {
            RefreshDirection();

            if (Input.GetKey(KeyCode.W))
            {
                NewPlayerDirection = DirectionState.UP;
                NewDirection      += Vector3.up;
                return(NewDirection);
            }
            if (Input.GetKey(KeyCode.S))
            {
                NewPlayerDirection = DirectionState.DOWN;
                NewDirection      += Vector3.down;
                return(NewDirection);
            }
            if (Input.GetKey(KeyCode.A))
            {
                NewPlayerDirection = DirectionState.LEFT;
                NewDirection      += Vector3.left;
                return(NewDirection);
            }
            if (Input.GetKey(KeyCode.D))
            {
                NewPlayerDirection = DirectionState.RIGHT;
                NewDirection      += Vector3.right;
                return(NewDirection);
            }

            return(NewDirection);
        }
Пример #6
0
 private void Start()
 {
     _transform          = GetComponent <Transform>();
     _rigidbody          = GetComponent <Rigidbody2D>();
     _animatorController = GetComponent <Animator>();
     _directionState     = transform.localScale.x > 0 ? DirectionState.Right : DirectionState.Left;
 }
Пример #7
0
 public Player(Random rand)
 {
     pos           = new Vector2(50, 1100);
     velocity      = new Vector2(0, 0);
     acceleration  = new Vector2(0, 0);
     forward       = new Vector2(1, 0);
     pState        = PlayerState.idle;
     dState        = DirectionState.right;
     width         = 23;
     height        = 45;
     rect          = new Rectangle((int)pos.X, (int)pos.Y, width, height);
     fps           = 10.0;
     timePerFrame  = 1.0 / fps;
     frame         = 0;
     maxForce      = 20f;
     maxSpeed      = new Vector2(3f, 5f);
     decceleration = .9f;
     canJump       = true;
     helmets       = new Stack <Helmet>();
     chestplates   = new Stack <ChestPlate>();
     gloves        = new Stack <Gloves>();
     this.rand     = rand;
     chargeCounter = 0.0;
     armorScale    = 1.0f;
     armorLevel    = 0;
     invincible    = false;
     Initialize();
 }
Пример #8
0
    private void Start()
    {
        nextXCord = xCord;
        nextYCord = yCord;
        switch (outputDir)
        {
        case DirectionState.North:
            flowTo = DirectionState.South;
            nextYCord--;
            break;

        case DirectionState.South:
            flowTo = DirectionState.North;
            nextYCord++;
            break;

        case DirectionState.East:
            flowTo = DirectionState.West;
            nextXCord++;
            break;

        case DirectionState.West:
            flowTo = DirectionState.East;
            nextXCord--;
            break;

        default:
            Debug.Log("It's all on fire...");
            break;
        }
    }
Пример #9
0
 /// <summary>
 /// 方向と親のプレイヤーを指定して初期化する
 /// </summary>
 /// <param name="p">親プレイヤー</param>
 /// <param name="dir">発射する方向</param>
 /// <param name="damage">弾のダメージ量</param>
 public Bullet(Player p, DirectionState dir, int damage)
 {
     Position  = p.Position.CopyTo();
     IsEnable  = p.CanShooting;
     Direction = dir;
     Damage    = damage;
 }
Пример #10
0
  public void UpdateDirection(Vector3 velocity) {
    // TIPS: 左に進んでいたら左向きにする
    transform.localScale = new Vector3((velocity.x < 0f) ? -1f : 1f, 1f, 1f);

    // TIPS: 画面奥に向かって進んでいたら上向きの画像にする
    _direction = (velocity.z > 0f) ? DirectionState.Up : DirectionState.Down;
  }
Пример #11
0
    private void Flow(int x, int y, DirectionState dir, int val)
    {
        Debug.Log("Flow starting...");
        GameObject startObj = _grid[x, y];
        Tube       tube     = startObj.GetComponent <Tube>();

        // If no tube found in the start spot, game over
        if (tube == null)
        {
            GameOver();
            return;
        }
        // If the tube in the start spot is facing the wrong way, game over
        TubeSideData[] sides        = tube.GetSides();
        bool           inputCorrect = false;

        for (int i = 0; i < sides.Length; i++)
        {
            if (sides[i].Direction == dir && (sides[i].State == InputOutputState.Input || sides[i].State == InputOutputState.Both))
            {
                inputCorrect = true;
            }
        }
        if (!inputCorrect)
        {
            GameOver();
            return;
        }

        tube.FlowStart(dir, val, OperationState.None);
    }
Пример #12
0
 public Player(Random rand)
 {
     pos = new Vector2(50, 1100);
     velocity = new Vector2(0, 0);
     acceleration = new Vector2(0, 0);
     forward = new Vector2(1, 0);
     pState = PlayerState.idle;
     dState = DirectionState.right;
     width = 23;
     height = 45;
     rect = new Rectangle((int)pos.X, (int)pos.Y, width, height);
     fps = 10.0;
     timePerFrame = 1.0 / fps;
     frame = 0;
     maxForce = 20f;
     maxSpeed = new Vector2(3f, 5f);
     decceleration = .9f;
     canJump = true;
     helmets = new Stack<Helmet>();
     chestplates = new Stack<ChestPlate>();
     gloves = new Stack<Gloves>();
     this.rand = rand;
     chargeCounter = 0.0;
     armorScale = 1.0f;
     armorLevel = 0;
     invincible = false;
     Initialize();
 }
Пример #13
0
 // Start is called before the first frame update
 void Start()
 {
     _transform          = GetComponent <Transform>();
     _boxCollider2D      = GetComponent <BoxCollider2D>();
     _animatorController = GetComponent <Animator>();
     _directionState     = transform.localScale.x > 0 ? DirectionState.Right : DirectionState.Left;
 }
Пример #14
0
    public void Walk(int aDirection)
    {
        Vector2 temp = new Vector2(myWalkSpeed * aDirection, myRigidBody.velocity.y);

        myRigidBody.velocity = temp;
        myDirectionState     = (DirectionState)aDirection;
    }
Пример #15
0
 public void CalcDirection()
 {
     if (Velocity.magnitude > 0.01f)
     {
         DirectionState d = _directionState;
         Vector2        v = Velocity;
         if (Mathf.Abs(v.x) > Mathf.Abs(v.y))
         {
             if (v.x < 0)
             {
                 d = DirectionState.Left;
             }
             else
             {
                 d = DirectionState.Right;
             }
         }
         else
         {
             if (v.y > 0)
             {
                 d = DirectionState.Up;
             }
             else
             {
                 d = DirectionState.Down;
             }
         }
         CurrentDirectionState = d;
     }
 }
Пример #16
0
        public void StateUpdate()
        {
            if (velocity.Y < 0)
            {
                pState = PlayerState.falling;
            }
            if (MainManager.Instance.inputMan.MoveLeft)
            {
                dState = DirectionState.left;
                if (pState != PlayerState.jumping)
                {
                    pState = PlayerState.walking;
                }
            }
            else if (MainManager.Instance.inputMan.MoveRight)
            {
                dState = DirectionState.right;
                if (pState != PlayerState.jumping)
                {
                    pState = PlayerState.walking;
                }
            }
            else if (pState != PlayerState.jumping && pState != PlayerState.dashing)
            {
                pState = PlayerState.idle;
            }

            if (MainManager.Instance.inputMan.Charge)
            {
                pState = PlayerState.charging;
            }
        }
Пример #17
0
        public void Draw(SpriteBatch sb, int frame, DirectionState ds)
        {
            float s = MainManager.Instance.gameMan.player.armorScale + .2f;
            if(frame ==0)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X , MainManager.Instance.gameMan.player.pos.Y-4*s);
            }
            if(frame == 1)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X , MainManager.Instance.gameMan.player.pos.Y-6*s);
            }
            if (frame == 2)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X , MainManager.Instance.gameMan.player.pos.Y-2*s);
            }
            if(frame == 3)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 4*s);
            }
            if (frame == 4)
            {
                position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y - 4*s);
            }
            if(ds == DirectionState.right)
            {
                sb.Draw(MainManager.Instance.drawMan.spritesheet, position, selectionRect, color, 0, Vector2.Zero, MainManager.Instance.gameMan.player.armorScale+.2f, SpriteEffects.None, 0);
            }
            else
            {
                sb.Draw(MainManager.Instance.drawMan.spritesheet, position, selectionRect, color, 0, Vector2.Zero, MainManager.Instance.gameMan.player.armorScale + .2f, SpriteEffects.FlipHorizontally, 0);

            }
        }
Пример #18
0
    public void SetDirectionTransformFromPacket(JObject packetData)
    {
        //TransformInfo directionTr = NetUtil.Instance.TransformUnzip(packetData["position"].ToString(), packetData["rotation"].ToString());
        if (GameData.Instance.UserType == UserType.Host)
        {
            return;
        }

        int            type = packetData.Value <int>("type");
        DirectionState temp = (DirectionState)type;

        gameObject.name = packetData.Value <string>("name");

        m_directionid = packetData.Value <int>("id");

        Vector3 directionPos = new Vector3(packetData.Value <float>("dpx"), packetData.Value <float>("dpy"), packetData.Value <float>("dpz"));

        transform.position = directionPos;

        Quaternion directionRot = new Quaternion(packetData.Value <float>("drx"), packetData.Value <float>("dry"), packetData.Value <float>("drz"), packetData.Value <float>("drw"));

        transform.rotation = directionRot;

        //SetTransform(transform);
    }
Пример #19
0
        public void SetStartPosition(DirectionState direction, int x, int y)
        {
            ValidateLocation(x, y);

            _state = direction;
            _x     = x;
            _y     = y;
        }
Пример #20
0
 public bool CheckWinState(int xCord, int yCord, DirectionState dir, float val)
 {
     if (xCord == _flowEndX && yCord == _flowEndY && dir == _flowEndDirection && val == _flowEndVal)
     {
         return(true);
     }
     return(false);
 }
 public void MoveLeft()
 {
     if (_directionState == DirectionState.Right)
     {
         _transform.localScale = new Vector3(-_transform.localScale.x, _transform.localScale.y, _transform.localScale.z);
         _directionState       = DirectionState.Left;
     }
 }
Пример #22
0
    private bool _isLeft;               //переключатель в зависимости от положения игрока

    private void Start()
    {
        _playerTransform = FindObjectOfType <PlayerControll>().transform;
        _transformEnemy  = GetComponent <Transform>();
        _rigidbodyEnemy  = GetComponent <Rigidbody>();
        //_animatorEnemy = GetComponent<Animator>(); инициализировать по готовности врага
        _directionState = transform.localScale.x > 0 ? DirectionState.Right : DirectionState.Left;
        Patrol();
    }
Пример #23
0
 private void FlipHorizontal()
 {
     if ((_directionState == DirectionState.Right && _stickDeviation.x < 0f) ||
         (_directionState == DirectionState.Left && _stickDeviation.x > 0f))
     {
         _directionState       = _directionState == DirectionState.Right ? DirectionState.Left : DirectionState.Right;
         _transform.localScale = new Vector3(-_transform.localScale.x, _transform.localScale.y, _transform.localScale.z);
     }
 }
Пример #24
0
 private void StartStep(DirectionState stepState)
 {
     this.m_StepState = stepState;
     if (stepState != 0 && this.RepeaterEnabled)
     {
         this.m_Timer.Interval = (double)this.RepeaterInitialDelay;
         this.m_Timer.Enabled  = true;
     }
 }
Пример #25
0
 private void Start()
 {
     _body           = GetComponent <Rigidbody2D>();
     _directionState = transform.localScale.x > 0 ? DirectionState.Right : DirectionState.Left;
     if (_invertGravity)
     {
         _body.gravityScale *= -1;
         _jumpForce         *= -1;
     }
 }
Пример #26
0
 public void AssignInputOutputStateSide(DirectionState dir, InputOutputState io)
 {
     foreach (TubeSideData side in _sides)
     {
         if (side.Direction == dir)
         {
             side.State = io;
         }
     }
 }
    public DirectionState CheckDirection(List <Room> grid, int currentPos, Door direction)
    {
        //Las opciones son 3: que arriba no haya nada (X), que arriba haya algo que bloquee (final del array o room sin puerta), que haya una room con puerta)
        DirectionState state = DirectionState.block;

        int posToCheck    = 0;
        int currentRow    = 0;
        int posToCheckRow = 0;

        switch (direction)
        {
        case Door.Up:
            //Comprobamos la casilla de arriba, viniendo de abajo
            posToCheck = currentPos - sizeY;
            state      = CheckPosition(grid, posToCheck, Door.Down);
            break;

        case Door.Right:
            posToCheck    = currentPos + 1;
            currentRow    = currentPos / sizeY;
            posToCheckRow = posToCheck / sizeY;
            //Debug.Log($"posToCheck = {posToCheck} == currentPos {currentPos}, pertenecen a las filas {posToCheckRow} == {currentRow}, sizeY == {sizeY}");
            if (currentRow == posToCheckRow)    //esto siginifica que estan en la misma fila, por lo tanto comprobamos el resto de condiciones, sino bloqued
            {
                state = CheckPosition(grid, posToCheck, Door.Left);
            }
            else
            {
                state = DirectionState.block;
            }
            break;

        case Door.Down:
            posToCheck = currentPos + sizeY;
            state      = CheckPosition(grid, posToCheck, Door.Up);
            break;

        case Door.Left:
            posToCheck    = currentPos - 1;
            currentRow    = currentPos / sizeY;
            posToCheckRow = posToCheck / sizeY;
            //Debug.Log($"posToCheck = {posToCheck} == currentPos {currentPos}, pertenecen a las filas {posToCheckRow} == {currentRow}, sizeY == {sizeY}");
            if (currentRow == posToCheckRow)     //esto siginifica que estan en la misma fila, por lo tanto comprobamos el resto de condiciones, sino bloqued
            {
                state = CheckPosition(grid, posToCheck, Door.Right);
            }
            else
            {
                state = DirectionState.block;
            }
            break;
        }
        Debug.Log($"En pos {currentPos} la direccion {direction} se encuentra en estado {state}");
        return(state);
    }
Пример #28
0
 private void StopStep(DirectionState stepState)
 {
     if (stepState == this.m_StepState)
     {
         this.StepIt();
     }
     if (this.RepeaterEnabled)
     {
         this.m_Timer.Enabled = false;
     }
 }
Пример #29
0
 bool NotInputSide(DirectionState dir)
 {
     for (int i = 0; i < _inFlowSides.Length; i++)
     {
         if (_inFlowSides[i] == dir)
         {
             return(false);
         }
     }
     return(true);
 }
Пример #30
0
 private void Start()
 {
     _transform          = GetComponent <Transform>();
     _rigidbody          = GetComponent <Rigidbody2D>();
     _collider           = GetComponent <BoxCollider2D>();
     _animatorController = GetComponent <Animator>();
     _directionState     = transform.localScale.x > 0 ? DirectionState.Right : DirectionState.Left;
     startX = transform.position.x;
     startY = transform.position.y;
     Debug.Log(Global.music);
     Debug.Log(Global.sound);
 }
Пример #31
0
 private void CheckSpriteDirectionChange(int inputX)
 {
     if (direction == DirectionState.LEFT && inputX > 0)
     {
         transform.rotation = Quaternion.Euler(0, 180f, 0);
         direction          = DirectionState.RIGHT;
     }
     if (direction == DirectionState.RIGHT && inputX < 0)
     {
         transform.rotation = Quaternion.Euler(0, 0, 0);
         direction          = DirectionState.LEFT;
     }
 }
Пример #32
0
 public PlayerSnake(int width, int height, int size, Color _colorSnake, Graphics g, int lvl, string name)
 {
     this._width = width;
     this._height = height;
     colorSnake = _colorSnake;
     this._gpPalette = g;
     this._size = size;
     this._level = lvl;
     this._blocks = new ArrayList();
     this._blocks.Insert(0, (new Block(Color.Red, this._size, new Point(width / 2, height / 2))));
     this._direction = DirectionState.Right;
     _isGameOver = false;
     namePlayer = name;
 }
Пример #33
0
 public void MoveLeft()
 {
     if (_moveState != MoveState.Jump)
     {
         _moveState = MoveState.Walk;
         if (_directionState == DirectionState.Right)
         {
             _transform.localScale = new Vector3(-_transform.localScale.x, _transform.localScale.y, _transform.localScale.z);
             _directionState       = DirectionState.Left;
         }
         _walkTime = _walkCooldown;
         _animatorController.Play("Run");
     }
 }
Пример #34
0
    public void DirectionController()                                          // изменяет направление скина и состаяние лево/право
    {
        if (_directionState == DirectionState.Right && directionBool == false) //если смотрим вправо
        {
            _directionState     = DirectionState.Left;                         //меняем состояние
            _transform.rotation = Quaternion.Euler(new Vector3(0, 270, 0));    //поворачиваем
        }

        if (_directionState == DirectionState.Left && directionBool == true) //если смотрим влево
        {
            _directionState     = DirectionState.Right;
            _transform.rotation = Quaternion.Euler(new Vector3(0, 90, 0));
        }
    }
Пример #35
0
 private Vector2 SetRayDirection(DirectionState state)
 {
     if (state == DirectionState.Left)
     {
         return(Vector2.left);
     }
     else if (state == DirectionState.Right)
     {
         return(Vector2.right);
     }
     else
     {
         return(Vector2.zero);
     }
 }
Пример #36
0
 public void Draw(SpriteBatch sb, DirectionState ds)
 {
     float s = MainManager.Instance.gameMan.player.armorScale + .2f;
     position = new Vector2(MainManager.Instance.gameMan.player.pos.X - 1, MainManager.Instance.gameMan.player.pos.Y +6 * s);
     if (MainManager.Instance.inputMan.Charge)
     {
         position = new Vector2(MainManager.Instance.gameMan.player.pos.X, MainManager.Instance.gameMan.player.pos.Y +11 * s);
     }
     if (MainManager.Instance.gameMan.player.pState == PlayerState.dashing && ds == DirectionState.left)
     {
         position.X += 5;
     }
     if (ds == DirectionState.right)
     {
         sb.Draw(MainManager.Instance.drawMan.spritesheet, position, selectionRect, color, 0, Vector2.Zero, MainManager.Instance.gameMan.player.armorScale + .2f, SpriteEffects.None, 0);
     }
     else
     {
         sb.Draw(MainManager.Instance.drawMan.spritesheet, position - new Vector2(5, 0), selectionRect, color, 0, Vector2.Zero, MainManager.Instance.gameMan.player.armorScale + .2f, SpriteEffects.FlipHorizontally, 0);
     }
 }
    public void FaceDirection(Direction toDirection, bool instantly = false)
    {
        Direction fromDirection = direction_;

        float newAbsoluteRotation = currentAbsoluteRotation_;

        switch (toDirection) {
        case Direction.Right:
            if (fromDirection == Direction.Down) newAbsoluteRotation -= 90;
            else if (fromDirection == Direction.Left) newAbsoluteRotation += 180;
            else if (fromDirection == Direction.Up) newAbsoluteRotation += 90;
            else if (fromDirection == Direction.None) newAbsoluteRotation = 0;
            break;
        case Direction.Down:
            if (fromDirection == Direction.Up) newAbsoluteRotation += 180;
            else if (fromDirection == Direction.Left) newAbsoluteRotation -= 90;
            else if (fromDirection == Direction.Right) newAbsoluteRotation += 90;
            else if (fromDirection == Direction.None) newAbsoluteRotation = 90;
            break;
        case Direction.Left:
            if (fromDirection == Direction.Down) newAbsoluteRotation += 90;
            else if (fromDirection == Direction.Right) newAbsoluteRotation += 180;
            else if (fromDirection == Direction.Up) newAbsoluteRotation -= 90;
            else if (fromDirection == Direction.None) newAbsoluteRotation = 180;
            break;
        case Direction.Up:
            if (fromDirection == Direction.Down) newAbsoluteRotation += 180;
            else if (fromDirection == Direction.Left) newAbsoluteRotation += 90;
            else if (fromDirection == Direction.Right) newAbsoluteRotation -= 90;
            else if (fromDirection == Direction.None) newAbsoluteRotation = -90;
            break;
        case Direction.None:
            Debug.Log("uhhh this guy has no direction");
            break;
        }

        if (direction_ == toDirection) {
            if (owner.rotatingContainer.rotation != newAbsoluteRotation) {
                if (directionState == DirectionState.Moving) return;
            }
        }

        if (directionState == DirectionState.Moving) {
            List<AbstractTween> tweens = Go.tweensWithId(currentTweenID);
            if (tweens != null && tweens.Count > 0) {
                foreach (AbstractTween tween in tweens) tween.destroy();
            }
        }

        currentAbsoluteRotation_ = newAbsoluteRotation;
        directionState = DirectionState.Moving;
        owner.isBeingControlledByDirectionComponent = true;
        direction_ = toDirection;

        if (instantly) {
            owner.rotatingContainer.rotation = currentAbsoluteRotation_;
            HandleDoneMovingToDirection(null);
        }
        else {
            currentTweenID = ++directionTweenID;

            Go.to(owner.rotatingContainer, 0.2f, new TweenConfig()
                .floatProp("rotation", currentAbsoluteRotation_)
                .setId(currentTweenID)
                .onComplete(HandleDoneMovingToDirection));
        }
    }
 public void HandleDoneMovingToDirection(AbstractTween tween)
 {
     directionState = DirectionState.Static;
     owner.isBeingControlledByDirectionComponent = false;
 }
Пример #39
0
		public DirectionInfo(double distance, double direction, DirectionState state)
		{
			this.distanceValue = distance;
			this.directionValue = direction;
			this.state = state;
		}
Пример #40
0
        public void StateUpdate()
        {
            if (velocity.Y < 0)
            {
                pState = PlayerState.falling;
            }
            if(MainManager.Instance.inputMan.MoveLeft)
            {
                dState = DirectionState.left;
                if(pState != PlayerState.jumping)
                {
                    pState = PlayerState.walking;
                }
            }
            else if(MainManager.Instance.inputMan.MoveRight)
            {
                dState = DirectionState.right;
                if(pState != PlayerState.jumping)
                {
                    pState = PlayerState.walking;
                }
            }
            else if(pState != PlayerState.jumping && pState != PlayerState.dashing)
            {
                pState = PlayerState.idle;
            }

            if(MainManager.Instance.inputMan.Charge)
            {
                pState = PlayerState.charging;
            }
        }