Example #1
0
    private void handleOnShipDestroyed()
    {
        //unregister from event that don't happen again
        PlayerShipHealth.OnShipDestroyed -= handleOnShipDestroyed;

        state = ShipStates.dying;
    }
Example #2
0
    private void handleOnPlayStart()
    {
        //unregister from event that don't happen again
        GameManager.OnPlayStart -= handleOnPlayStart;

        state = ShipStates.controllable;
    }
Example #3
0
        public void ChangeState(ShipStates state)
        {
            if (_state != null)
            {
                _state.Stop();
            }

            _state = _stateFactory.CreateState(state);
            _state.Start();
        }
Example #4
0
        public void ChangeState(ShipStates state, params object[] constructorArgs)
        {
            if (_state != null)
            {
                _state.Stop();
            }

            _state = _stateFactory.Create(state, constructorArgs);
            _state.Start();
        }
Example #5
0
    private void handleOnVictory()
    {
        //unregister from event that don't happen again
        GameManager.OnVictory -= handleOnVictory;

        state = ShipStates.victorious;

        //Anim
        animator.SetFloat("Vertical Speed", 0f);
    }
Example #6
0
        public void ChangeState(ShipStates state)
        {
            if (_state != null)
            {
                _state.Stop();
            }

            _state = _stateFactory.CreateState(state);
            _state.Start();
        }
Example #7
0
        public void ChangeState(ShipStates state, params object[] constructorArgs)
        {
            if (_state != null)
            {
                _state.Stop();
            }

            _state = _stateFactory.Create(state, constructorArgs);
            _state.Start();
        }
Example #8
0
    // Use this for initialization
    void Awake()
    {
        state    = ShipStates.init;
        isFiring = false;

        currWeapon = weapons[0];
        currLvl    = 0;
        currGuns   = currWeapon.lvls[currLvl].guns;

        InitFireTimes();
    }
Example #9
0
 public void OnLevelChange(Vector3 initialPos)
 {
     transform.position = initialPos;
     transform.rotation = Quaternion.identity;
     rb.velocity        = Vector3.zero;
     rb.angularVelocity = 0.0f;
     if (ShipState != ShipStates.freeFall)
     {
         ShipState = ShipStates.freeFall;
         ChangeSprite();
     }
     InitialImpulse();
 }
Example #10
0
        private void UpdateState(ShipStates desiredShipState)
        {
            ShipState = desiredShipState;
            switch (desiredShipState)
            {
            case ShipStates.WaitingForIdInventory:
                SetStateWaitingForIdInventory();
                break;

            case ShipStates.WaitingForWeight:
                SetStateWaitingForWeight();
                break;
            }
        }
Example #11
0
        public ShipState Create(ShipStates state, params object[] constructorArgs)
        {
            switch (state)
            {
                case ShipStates.Dead:
                    return _instantiator.Instantiate<ShipStateDead>(constructorArgs);

                case ShipStates.Moving:
                    return _instantiator.Instantiate<ShipStateMoving>(constructorArgs);

                case ShipStates.WaitingToStart:
                    return _instantiator.Instantiate<ShipStateWaitingToStart>(constructorArgs);
            }

            Assert.That(false);
            return null;
        }
Example #12
0
        public ShipState Create(ShipStates state, params object[] constructorArgs)
        {
            switch (state)
            {
            case ShipStates.Dead:
                return(_container.Instantiate <ShipStateDead>(constructorArgs));

            case ShipStates.Moving:
                return(_container.Instantiate <ShipStateMoving>(constructorArgs));

            case ShipStates.WaitingToStart:
                return(_container.Instantiate <ShipStateWaitingToStart>(constructorArgs));
            }

            Assert.That(false);
            return(null);
        }
Example #13
0
 void OnCrash()
 {
     if (fuel > 0)
     {
         fuel -= fuelLostOnCrash;
         if (fuel < 0)
         {
             fuel = 0;
         }
     }
     ShipState = ShipStates.destroyed;
     ChangeSprite();
     ShowLandResultScreen(false);
     if (!displayingResults)
     {
         OnResultsScreenEnter();
     }
 }
Example #14
0
    private void Update()
    {
        if (rb.gravityScale != gravityScale)
        {
            rb.gravityScale = gravityScale;
        }

        if (Input.GetKey(KeyCode.Space) && ableToMove)
        {
            Impulse();
        }
        else if (ShipState == ShipStates.impulse)
        {
            ShipState = ShipStates.freeFall;
            ChangeSprite();
        }

        float rotate = -Input.GetAxisRaw("Horizontal");

        if (ableToMove)
        {
            transform.rotation = Quaternion.Euler(transform.rotation.eulerAngles + new Vector3(0, 0, rotate * rotationSpeed * Time.deltaTime));
        }

        hit = Physics2D.Raycast(transform.position, Vector2.down, rayDistance);
        if (hit.collider != null)
        {
            altitude = (int)(hit.distance * 10) - spriteOffset;
            if (altitude < 0)
            {
                altitude = 0;
            }
        }
        if (onLandingAltitude && altitude > landingAltitude)
        {
            SetCameraZoom(false);
            onLandingAltitude = false;
        }
        else if (!onLandingAltitude && altitude < landingAltitude)
        {
            SetCameraZoom(true);
            onLandingAltitude = true;
        }
    }
        public ShipState CreateState(ShipStates state)
        {
            switch (state)
            {
            case ShipStates.Dead: {
                return(_deadFactory.Create());
            }

            case ShipStates.WaitingToStart: {
                return(_waitingFactory.Create());
            }

            case ShipStates.Moving: {
                return(_movingFactory.Create());
            }
            }

            throw Assert.CreateException();
        }
Example #16
0
        public ShipState CreateState(ShipStates state)
        {
            switch (state)
            {
                case ShipStates.Dead:
                {
                    return _deadFactory.Create();
                }
                case ShipStates.WaitingToStart:
                {
                    return _waitingFactory.Create();
                }
                case ShipStates.Moving:
                {
                    return _movingFactory.Create();
                }
            }

            throw Assert.CreateException();
        }
Example #17
0
 void Impulse()
 {
     rb.AddForce(transform.up * impulseForce);
     if (fuel > 0)
     {
         fuel -= Time.deltaTime * fuelLosingSpeed;
         if (fuel < 0)
         {
             fuel = 0;
         }
     }
     if (fuel == 0)
     {
         ableToMove = false;
     }
     if (ShipState != ShipStates.impulse)
     {
         ShipState = ShipStates.impulse;
         ChangeSprite();
     }
 }
Example #18
0
    void Awake()
    {
        Me = this;

        state = ShipStates.init;
    }
Example #19
0
 private void HandleOnShipDestroyed()
 {
     state = ShipStates.dying;
     StopFiring();
 }
Example #20
0
 private void HandleOnVictory()
 {
     state = ShipStates.victorious;
     StopFiring();
 }
Example #21
0
 private void HandleOnPlayStart()
 {
     state = ShipStates.controllable;
 }