Exemplo n.º 1
0
 public void Colected()
 {
     State = RocketState.Idle;
     gameObject.SetActive(false);
     m_Battery.CollectRocket();
     m_StandTrans.localScale = new Vector3(1.0f, 1.0f, 1.0f);
 }
Exemplo n.º 2
0
    void OnCollisionEnter(Collision collision)
    {
        if (state != RocketState.Alive || collisionsDisabled)
        {
            return;
        }

        switch (collision.gameObject.tag)
        {
        case "Friendly":
            break;

        case "Finish":
            state = RocketState.Transcending;
            audioSource.Stop();
            ThrustParticles.Stop();
            SuccessParticles.Play();
            audioSource.PlayOneShot(Success);
            Invoke("LoadNextScene", LevelLoadDelay);
            break;

        default:
            state = RocketState.Dying;
            ThrustParticles.Stop();
            ExplosionParticles.Play();
            audioSource.Stop();
            audioSource.PlayOneShot(Explosion);
            Invoke("LoadFirstScene", LevelLoadDelay);
            break;
        }
    }
Exemplo n.º 3
0
 // Start is called before the first frame update
 void Start()
 {
     _rocketState = RocketState.big;
     rb           = GetComponent <Rigidbody2D>();
     bomb         = transform.GetChild(2).GetComponent <AudioSource>();
     score        = GameObject.Find("Score").GetComponent <Score>();
 }
Exemplo n.º 4
0
    private void KillTheRocket(Vector3 explosionPosition)
    {
        if (this.State == RocketState.Dead)
        {
            // Already dead, waiting for the animation to complete
            return;
        }

        this.State = RocketState.Dead;

        rigidBody.constraints = RigidbodyConstraints.None;

        if (!explosionPosition.IsInfinityOrNaN())
        {
            // Protect against really low rocket velocity when collision occurs
            var velocityMultiplier = Mathf.Max(rigidBody.velocity.magnitude, minExplosionForceMultiplier);
            var explosionForce     = this.deathExplosionBaseForce + (velocityMultiplier * explosionVelocityMultiplier);

            rigidBody.AddExplosionForce(explosionForce, explosionPosition, 0f, 0f, ForceMode.Force);
        }

        StopThrustSounds();

        this.deathAudioSource.Play();
        this.deathParticles.Play();
        // Gives a cool smoking effect
        this.thrustParticles.Play();

        Invoke(nameof(ReloadLevelPostDelay), this.deathDelay);
    }
Exemplo n.º 5
0
    // Use this for initialization
    void OnCollisionEnter(Collision collision)
    {
        if (state != RocketState.Alive)
        {
            return;
        }

        switch (collision.gameObject.tag)
        {
        case "Friendly":
            // Do nothing
            break;

        case "Finish":
            state = RocketState.Transcending;
            audioSource.PlayOneShot(levelEnd);
            successParticles.Play();
            Invoke("LoadNextScene", reloadTimer);
            break;

        case "Dangerous":
            state = RocketState.Dying;
            audioSource.PlayOneShot(explosion);
            explosionParticles.Play();
            Invoke("RestartLevel", reloadTimer);
            break;
        }
    }
Exemplo n.º 6
0
 private void ApplyThrust()
 {
     rigidBody.AddRelativeForce(Vector3.up * thrust * Time.deltaTime);
     currentState       = RocketState.Thrusting;
     trailRenderer.time = 1;
     mainEngineParticles.Play();
 }
Exemplo n.º 7
0
        public Rocket(int playerId, RocketType type, Vector2 target)
        {
            this.playerId         = playerId;
            this.type             = type;
            this.state            = RocketState.Idle;
            this.target           = target;
            this.velocity         = Vector2.Zero;
            this.acc              = Vector2.Zero;
            this.angle            = 0f;
            this.airFrictionCoeff = 0f;
            this.cruiseAltitude   = 0f;
            this.impact           = false;

            switch (type)
            {
            case RocketType.Thor4:
                this.airFrictionCoeff = 0.002f;
                this.cruiseAltitude   = -60f;
                break;

            case RocketType.Scout8:
                this.airFrictionCoeff = 0.002f;
                this.cruiseAltitude   = -40f;
                break;

            case RocketType.Northstar10:
                this.airFrictionCoeff = 0.002f;
                this.cruiseAltitude   = -80f;
                break;
            }
        }
Exemplo n.º 8
0
 void Start()
 {
     maxNumScenes    = SceneManager.sceneCountInBuildSettings;
     audio           = GetComponent <AudioSource>();
     thrusterControl = thrusters.GetComponent <ThrusterControl>();
     turretControl   = turret.GetComponent <BoosterTurretControl>();
     state           = RocketState.Alive;
 }
Exemplo n.º 9
0
 private bool ValidateState(RocketState expectedState)
 {
     if (State != expectedState)
     {
         ProcessError("Cant execute rocket action: Current state: '" + State + "', expected state: '" + expectedState + "'");
         return(false);
     }
     return(true);
 }
Exemplo n.º 10
0
    void LaunchingRocket()
    {
        rocketTime += Time.deltaTime;

        switch (myRocketState)
        {
        case RocketState.Countdown:
        {
            if (rocketTime >= 1f)
            {
                countDown  -= 1;
                cdText.text = countDown.ToString();
                rocketTime  = 0f;
                Debug.Log("Counting down: " + countDown);
            }

            if (countDown == 0)
            {
                myRocketState = RocketState.Fire;
                myRocket.GetComponent <Image>().color = Color.red;
                rocketTime = 0f;
                Debug.Log("Start firing up!");
            }
        }
        break;

        case RocketState.Fire:
        {
            if (rocketTime >= 2f)
            {
                myRocketState = RocketState.Fly;
                rocketTime    = 0f;
                myRocket.GetComponent <Image>().color = Color.white;
                Debug.Log("Launch!");
            }
        }
        break;

        case RocketState.Fly:
        {
            if (rocketTime >= 10f)
            {
                myRocketState = RocketState.Gone;
                rocketTime    = 0f;
                Destroy(myRocket.gameObject);
                Debug.Log("My rocket has gone to the space!");
            }
            else
            {
                myRocket.position += new Vector3(10f, 20f, 0f);
                //Debug.Log("x:" + myRocket.position.x + ", y:" + myRocket.position.y + ", z:" + myRocket.position.z);
            }
        }
        break;
        }
    }
Exemplo n.º 11
0
    /// <summary>
    /// 발사효과 이후 실제 로켓 움직임. 천장에 열기 메시지, 이펙트 시작 메시지, 로켓모양복원. 종료시 종료코루틴 시작.
    /// </summary>
    /// <returns></returns>
    IEnumerator LaunchBehavior()
    {
        UIManager.SendMessage("HideInhaleHud");
        Ceiling.SendMessage("CeilingOpening");
        EffectCtrl.SendMessage("Boost");
        currState = RocketState.EXHALE;
        yield return(1f);

        intakeGuage.value = 0f;
    }
Exemplo n.º 12
0
    private void LoadNextScene()
    {
        int currentSceneIndex = SceneManager.GetActiveScene().buildIndex;
        int nextSceneIndex    = currentSceneIndex + 1;

        if (nextSceneIndex == SceneManager.sceneCountInBuildSettings)
        {
            nextSceneIndex = 0;
        }
        state = RocketState.Alive;
        SceneManager.LoadScene(nextSceneIndex);
    }
Exemplo n.º 13
0
 private void ExecuteTranscending()
 {
     if (state == RocketState.Alive && disableCollisionDebug == false)
     {
         state = RocketState.Transcending;
         audio.Stop();
         audio.PlayOneShot(newLevelChime);
         newLevelChimeParticles.Play();
         disableRocketControl.Invoke();
         Invoke("loadNextLevel", levelLoadDelay);
     }
 }
Exemplo n.º 14
0
 public void ExecuteDeath()
 {
     if (state == RocketState.Alive && disableCollisionDebug == false)
     {
         state = RocketState.Dead;
         audio.Stop();
         audio.PlayOneShot(deathNoise);
         deathNoiseParticles.Play();
         disableRocketControl.Invoke();
         Invoke("loadCurrentLevel", levelLoadDelay);
     }
 }
Exemplo n.º 15
0
 /// <summary>
 /// 로켓 행동 컨트롤 위한 Flag 변환.
 /// </summary>
 /// <returns></returns>
 IEnumerator StateCtrl()
 {
     while (true)
     {
         if (rocketRb.velocity.magnitude <= 1f && currState == RocketState.EXHALE)
         {
             currState = RocketState.FINISH;
             StartCoroutine(FinishRocket());
         }
         yield return(null);
     }
 }
Exemplo n.º 16
0
    private void ApplyStateFromServer(object newState)
    {
        var newRocketState = (RocketState)newState;

        Client.ApplyRigidbodyState(
            newRocketState.RigidBodyState,
            State.RigidBodyState,
            Rigidbody,
            OsFps.Instance.Client.ClientPeer.RoundTripTimeInSeconds ?? 0
            );

        State = newRocketState;
    }
Exemplo n.º 17
0
        private void OnTakeoffComplete()
        {
            if (State == RocketState.Takeoff)
            {
                ProcessError("Multiply OnTakeoffComplete() call detected!");
                return;
            }

            State = RocketState.WaitForStartInput;
            StartScaleFire();
            StartShake();
            GameMessenger.Broadcast(TakeoffCompleteEventName);
        }
Exemplo n.º 18
0
 public void Fire()
 {
     gameObject.SetActive(true);
     m_StandTrans.localScale *= 0.0f;
     transform.position       = m_StandTrans.position;
     transform.rotation       = m_Battery.transform.rotation;
     m_Rb.rotation            = transform.rotation;
     //transform.rotation = Quaternion.Euler(new Vector3(20, 0, 0));
     //Debug.Log(transform.rotation.eulerAngles);
     State = RocketState.Fire;
     m_AudioSrc.PlayOneShot(m_SEFire);
     m_Timer = 0;
 }
Exemplo n.º 19
0
    void PrintRocket()
    {
        currentTime += Time.deltaTime;
        int countNumber  = 0;
        int countSeconds = 0;
        int speed        = 5;

        switch (currentRocketState)
        {
        case RocketState.RocketState_counting:
        {
            currentTime += Time.deltaTime;
            if (currentTime >= 1.0f && countNumber > 0)
            {
                countNumber--;
                Debug.Log(countNumber);
                if (currentTime > 10.0f)
                {
                    currentRocketState = RocketState.RocketState_firing;
                    currentTime        = 0.0f;
                }
            }
        }
        break;

        case RocketState.RocketState_firing:
        {
            currentTime += Time.deltaTime;
            if (currentTime > 2.0f)
            {
                currentRocketState = RocketState.RocketState_flying;
                currentTime        = 0.0f;
                Debug.Log("火箭点火");
            }
        }
        break;

        case RocketState.RocketState_flying:
        {
            Debug.Log("火箭升空");
            currentTime += Time.deltaTime;
            if (currentTime > 0)
            {
                countSeconds++;
                Rocket.GetComponent <RectTransform>().anchoredPosition = new Vector3(100.0f, 1.0f + speed * countSeconds, 1.0f);
            }
        }
        break;
        }
    }
Exemplo n.º 20
0
    private void HandleLevelComplete()
    {
        if (this.State == RocketState.Alive)
        {
            this.State = RocketState.WaitingToFinish;

            StopThrustSounds();

            this.finishAudioSource.Play();

            this.finishParticles.Play();

            Invoke(nameof(CheckRocketPostDelay), this.finishDelay);
        }
    }
Exemplo n.º 21
0
    private void ThrustInputs()
    {
        var spacePressed = Input.GetKey(KeyCode.Space);
        var spaceUp      = Input.GetKeyUp(KeyCode.Space);

        if (spacePressed)
        {
            ApplyThrust();
        }

        if (spaceUp)
        {
            currentState       = RocketState.Stalled;
            trailRenderer.time = 0;
        }
    }
Exemplo n.º 22
0
    void Update()
    {
        m_Timer += Time.deltaTime;
        if (m_Timer > 10)
        {
            State = RocketState.Idle;
            gameObject.SetActive(false);
            m_Battery.CollectRocket();
            m_StandTrans.localScale = new Vector3(1.0f, 1.0f, 1.0f);
        }

        switch (State)
        {
        case RocketState.Idle:
            m_Timer = 0.0f;
            break;

        case RocketState.Fire:
            if (m_Timer > m_AdvanceTime)
            {
                //雑魚を巻き込んでいなければ時間で戻る
                if (m_ChildEnemys.Count == 0 && State != RocketState.Buried)
                {
                    State = RocketState.Back;
                }
            }
            break;

        case RocketState.Back:
            transform.LookAt(m_StandTrans);
            break;

        case RocketState.Reflected:
            transform.LookAt(m_StandTrans);
            break;

        case RocketState.Buried:
            if (m_Timer > m_BuriedTime)
            {
                State = RocketState.Back;
            }
            break;

        default:
            break;
        }
    }
Exemplo n.º 23
0
    void Rocket(ref float RocketTime, ref RocketState rocketstate)
    {
        switch (rocketstate)
        {
        case RocketState.Countdown:
        {
            RocketTime += Time.deltaTime;
            if (RocketTime > 1.0f && countNumber >= 0)
            {
                countNumber--;
                Debug.Log(countNumber);
                RocketTime = 0.0f;
                if (countNumber == 1)
                {
                    rocketstate  = RocketState.Fire;
                    rocket.color = Color.red;
                    RocketTime   = 0.0f;
                    Debug.Log("Fire");
                }
            }
        }
        break;

        case RocketState.Fire:
        {
            RocketTime += Time.deltaTime;
            if (RocketTime > 2.0f)
            {
                rocketstate  = RocketState.Launch;
                rocket.color = Color.white;
                RocketTime   = 0.0f;
                Debug.Log("Launch");
            }
        }
        break;

        case RocketState.Launch:
        {
            RocketTime += Time.deltaTime;
            rocket.transform.localPosition += new Vector3(0, 20, 0);
        }
        break;
        }
    }
Exemplo n.º 24
0
    void HandleInputs()
    {
        Vector2 vel = rgb2d.velocity;

        vel.x *= 0.9f;

        float x = Input.GetAxis("Horizontal_P" + playerNumber);
        float y = 0;

        if (Input.GetButtonDown("Jump_P" + playerNumber) && IsGrounded())
        {
            y = JumpSpeed;
        }

        if (rocketState == RocketState.Available)
        {
            float aimDir = Input.GetAxis("RStickHor_P" + playerNumber);

            aim.transform.RotateAround(transform.position, Vector3.forward, -aimDir * aimSpeed);
        }

        if (Input.GetButtonDown("Fire1_P" + playerNumber) && rocketState == RocketState.Available)
        {
            //Fire
            GameObject laaunchedRocket = Instantiate(rocket, transform.position + (aim.transform.up * (GetComponent <BoxCollider2D>().bounds.extents.y + 0.75f)), aim.transform.rotation);
            laaunchedRocket.GetComponent <Rocket>().LiftOff(playerNumber);

            rocketState = RocketState.Fired;

            aim.SetActive(false);
        }


        vel.x += x;

        if (Mathf.Abs(vel.x) > MAX_SPEED)
        {
            vel.x = MAX_SPEED * (Mathf.Abs(vel.x) / vel.x);
        }

        rgb2d.velocity = vel;
        rgb2d.AddForce(Vector2.up * y, ForceMode2D.Impulse);
    }
Exemplo n.º 25
0
    public GameObject SpawnLocalRocketObject(RocketState rocketState)
    {
        var rocketObject = GameObject.Instantiate(
            OsFps.Instance.RocketPrefab,
            rocketState.RigidBodyState.Position,
            Quaternion.Euler(rocketState.RigidBodyState.EulerAngles)
            );

        var rocketComponent = rocketObject.GetComponent <RocketComponent>();

        rocketComponent.State = rocketState;

        var rigidbody = rocketComponent.Rigidbody;

        rigidbody.velocity        = rocketState.RigidBodyState.Velocity;
        rigidbody.angularVelocity = rocketState.RigidBodyState.AngularVelocity;

        return(rocketObject);
    }
Exemplo n.º 26
0
        public RocketState[] GetRocketsStates()
        {
            var states = new RocketState[_rockets.Values.Count];

            for (int i = 0; i < states.Length; i++)
            {
                var rocket = _rockets.Values[i];
                var state  = new RocketState();

                state.CurVelocity = rocket.Rb.velocity;
                state.RocketType  = rocket.RocketType;
                state.Rotation    = rocket.Rb.transform.rotation.eulerAngles;
                state.WorldCoords = rocket.Rb.transform.position;

                states[i] = state;
            }

            return(states);
        }
Exemplo n.º 27
0
        void ResetRocket()
        {
            rocketState = RocketState.None;

            CgfThrust.ForcePower = 0f;

            lockOnTo._alignDirection   = CGF.ConstraintProperties.AlignDirection.Down;
            lockOnTo.RotationRigidbody = true;
            lockOnTo.SlerpSpeed        = 10f;

            rocketRigidbody.velocity        = Vector3.zero;
            rocketRigidbody.angularVelocity = Vector3.zero;

            explosion.transform.position = Vector3.zero;
            explosion.gameObject.SetActive(false);

            timer.StartTimer = false;
            timer.Alarm      = false;
        }
Exemplo n.º 28
0
    public void ServerFireRocketLauncher(
        Server server, PlayerObjectComponent shootingPlayerObjectComponent, Ray shotRay
        )
    {
        var rocketState = new RocketState
        {
            Id             = server.GenerateNetworkId(),
            RigidBodyState = new RigidBodyState
            {
                Position        = shotRay.origin + shotRay.direction,
                EulerAngles     = Quaternion.LookRotation(shotRay.direction, Vector3.up).eulerAngles,
                Velocity        = OsFps.RocketSpeed * shotRay.direction,
                AngularVelocity = Vector3.zero
            },
            ShooterPlayerId = shootingPlayerObjectComponent.State.Id
        };
        var rocket = RocketSystem.Instance.SpawnLocalRocketObject(rocketState);

        // Make grenade ignore collisions with thrower.
        GameObjectExtensions.IgnoreCollisionsRecursive(rocket, shootingPlayerObjectComponent.gameObject);
    }
Exemplo n.º 29
0
        public void Arm()
        {
            //Set the armTime
            armTime = 0;

            //Set the state
            state = RocketState.Armed;
        }
Exemplo n.º 30
0
        public void Explode()
        {
            //Set the visibility
            rocket.Visible = false;
            cRocket.Visible = false;
            explosion.Visible = true;

            //Set the explosion bounds
            explosionBounds.Radius = 16;

            //Change the state
            state = RocketState.Exploded;

            //Trigger the explode sound
            AudioEngine.PlayExplosion();
        }
Exemplo n.º 31
0
 void RestartLevel()
 {
     SceneManager.LoadScene(0);
     explosionParticles.Stop();
     state = RocketState.Alive;
 }
Exemplo n.º 32
0
        public virtual void Fire(Car sender)
        {
            //Set the position and rotation
            rotation = sender.Rotation;
            position = sender.Position;

            rocket.Position = position;
            cRocket.Position = position;
            explosion.Position = position;

            cRocket.Rotation = rotation;
            rocket.Rotation = rotation;
            bounds.Rotation = rotation;
            bounds.Position = position;

            //Set the state
            state = RocketState.Fired;

            //Set the armTime
            armTime = 0;

            //Set visibility
            rocket.Visible = true;
            cRocket.Visible = true;
            explosion.Visible = false;

            //Set the owner
            owner = sender.Driver;
        }
Exemplo n.º 33
0
 /// <summary>
 /// 통신으로 데이터 받아옴
 /// </summary>
 public void InHaleStart()
 {
     currState = RocketState.INHALE;
 }
Exemplo n.º 34
0
        public virtual void Initialize()
        {
            //Initialize the sprites
            rocket.Initialize(Vector2.Zero);
            cRocket.Initialize(Vector2.Zero);

            //Set the state
            state = RocketState.Ready;

            //Set the origins
            rocket.Origin = new Vector2(32, 8);
            cRocket.Origin = new Vector2(32, 8);
            explosion.Origin = new Vector2(128);

            //Not fully blown
            fullyBlown = false;

            //Set the speed
            speed = 20f;

            for (int i = 0; i < 4; i++)
            {
                hasHit[i] = false;
            }
        }