コード例 #1
0
    public void CrashingCollision(Collider2D other)
    {
        if (_landing)
        {
            return;
        }

        if (_state.GetState() != PlayerStates.States.InLandedShip && _state.GetState() != PlayerStates.States.WalkingOnPlanet)
        {
            Debug.Log("Crashed crashing collider");

            Crash();
        }
    }
コード例 #2
0
    // Update is called once per frame
    void Update()
    {
        if (_state.GetState() != PlayerStates.States.WalkingOnPlanet)
        {
            return;
        }

        if (Input.GetButtonDown("Action"))
        {
            Debug.Log("ACTION");
            if (_isTouchingShip)
            {
                EnterShip();
            }
        }
    }
コード例 #3
0
    // Update is called once per frame
    void Update()
    {
        if (_playerStates.GetState() == PlayerStates.States.InFlyingShip)
        {
            return;
        }



        if (Input.GetButtonDown("Action"))
        {
            if (_playerStates.GetState() == PlayerStates.States.InLandedShip)
            {
                if (ControlIndicator.currentCommand == "TO  LEAVE  SHIP" && ControlIndicator.isActive)
                {
                    CommandShower.GetComponent <ControlIndicator>().HideCommand();
                }

                StartWalking();
            }
        }

        if (Input.GetButton("Horizontal"))
        {
            if (_playerStates.GetState() == PlayerStates.States.WalkingOnPlanet)
            {
                FlipSprite(Input.GetAxis("Horizontal"));

                if (_isTouchingResource)
                {
                    StopWalkingAnim();
                    return;
                }

                StartWalkingAnim();
                currentAngle -= Input.GetAxis("Horizontal") * speed * Time.deltaTime;

                _rigidbody.rotation = currentAngle;
                transform.position  = currentPlanet.transform.position + (spriteOffset + _planetRadius) * (Quaternion.AngleAxis(currentAngle, Vector3.forward) * Vector3.up);
            }
        }
        else
        {
            StopWalkingAnim();
        }
    }
コード例 #4
0
ファイル: ResourceCollector.cs プロジェクト: jeepitou/USPS
    // Update is called once per frame
    void Update()
    {
        if (_state.GetState() != PlayerStates.States.WalkingOnPlanet)
        {
            return;
        }

        if (Input.GetButton("Action"))
        {
            if (_isTouchingResource)
            {
                GatherResource();
            }
        }

        VerifyIfTouchingResource();
    }
コード例 #5
0
    // Update is called once per frame
    void LateUpdate()
    {
        if (_states.GetState() == PlayerStates.States.WalkingOnPlanet)
        {
            Vector3 newPos = _states.GetPlanet().transform.position;
            newPos.z = transform.position.z;

            transform.position = Vector3.MoveTowards(transform.position, newPos, 0.6f);
        }
        else
        {
            Vector3 newPos = playerShip.transform.position;
            newPos.z = transform.position.z;

            //transform.position = Vector3.MoveTowards(transform.position, newPos, 2);
            transform.position = newPos;
        }
    }
コード例 #6
0
ファイル: ShipMovement.cs プロジェクト: jeepitou/USPS
    // Update is called once per frame
    void Update()
    {
        UpdateSoundVolume();

        if (_fuelController.IsEmpty())
        {
            _animator.SetBool("Accelerating", false);
            StopSound();
            return;
        }

        if (_playerStates.GetState() == PlayerStates.States.InLandedShip)
        {
            if (ControlIndicator.currentCommand != "TO  LEAVE  SHIP" || !ControlIndicator.isActive)
            {
                CommandShower.GetComponent <ControlIndicator>().ShowCommand("TO  LEAVE  SHIP");
            }
            if (Input.GetButtonDown("Vertical"))
            {
                if (Input.GetAxis("Vertical") > 0)
                {
                    PlayerShipCollision.Player.transform.parent = null;
                    PlayerStates.canLand = false;
                    _animator.SetBool("Accelerating", true);


                    if (_playerStates.SetState(PlayerStates.States.InFlyingShip))
                    {
                        if (ControlIndicator.currentCommand == "TO  LEAVE  SHIP" && ControlIndicator.isActive)
                        {
                            CommandShower.GetComponent <ControlIndicator>().HideCommand();
                        }

                        canCrash = false;
                        StartCoroutine(shipLeavingPlanetDelay());

                        mainMusicController.GetComponent <DrumChanger>().AddDrum();
                        PlaySound();

                        PlayerShipCollision.Player.transform.parent = null;

                        _rigidbody.AddForce(force * 100 * transform.up * Time.deltaTime);
                        _fuelController.ConsumeFuel(fuelConsuptionPerSecond * Time.deltaTime * 125);


                        _playerStates.GetPlanet().GetComponent <Planet>().LeavePlanet();
                    }
                }
            }
            else
            {
                _animator.SetBool("Accelerating", false);
                StopSound();
            }
        }

        if (_playerStates.GetState() == PlayerStates.States.InFlyingShip)
        {
            if (Input.GetButton("Vertical"))
            {
                PlaySound();

                _fuelController.ConsumeFuel(fuelConsuptionPerSecond * Time.deltaTime);

                if (Input.GetAxis("Vertical") > 0)
                {
                    _animator.SetBool("Accelerating", true);
                    _animator.SetBool("Back", false);

                    _rigidbody.AddForce(force * transform.up * Time.deltaTime);
                }
                else
                {
                    _animator.SetBool("Accelerating", false);
                    _animator.SetBool("Back", true);
                    _rigidbody.AddForce(-force * transform.up * Time.deltaTime);
                }
            }

            if (Input.GetButton("Horizontal"))
            {
                PlaySound();
                _fuelController.ConsumeFuel(fueldConsuptionPerSecondOnTurn * Time.deltaTime);

                if (Input.GetAxis("Horizontal") > 0)
                {
                    _rigidbody.AddTorque(-torque * Time.deltaTime);
                }
                else
                {
                    _rigidbody.AddTorque(torque * Time.deltaTime);
                }
            }

            if (_rigidbody.velocity.magnitude >= maxSpeed)
            {
                _rigidbody.velocity = _rigidbody.velocity.normalized * maxSpeed;
            }

            if (!Input.GetButton("Horizontal") && !Input.GetButton("Vertical"))
            {
                StopSound();
                _animator.SetBool("Accelerating", false);
                _animator.SetBool("Back", false);
            }
        }
        else
        {
            StopSound();
        }

        VerifyIfPlayersIsInbound();
    }