Ejemplo n.º 1
0
    void OnTriggerStay(Collider collider)
    {
        if (!enabled)
        {
            return;
        }

        Rigidbody rBody = collider.gameObject.GetComponent <Rigidbody>();

        if (rBody == null)
        {
            return;
        }

        if (rBody.velocity.y < MaximumVelocity.y)
        {
            rBody.AddForce(new Vector3(0.0f, ForceToApply.y, 0.0f));
        }

        CEntityPlayer player = CEntityPlayer.GetInstance();

        if (player)
        {
            player.Physics.MakeJump();

            player.Physics.Velocity += ForceToApply.x;
            if (player.Physics.Velocity > MaximumVelocity.x)
            {
                player.Physics.Velocity = MaximumVelocity.x;
            }
        }
    }
Ejemplo n.º 2
0
    /*
     * \brief Called whilst a collision is taking place
     */
    void OnCollisionStay(Collision collision)
    {
        if (m_playerState == GruntState.FallingFromTower)
        {
            return;
        }

        m_physics.CallOnCollisionStay(collision, ref m_playerState, ref m_playerPositionAlpha);
        if (m_physics.CollisionType == CollisionState.OnWall)
        {
            m_playerPositionAlpha = m_lastPlayerPositionAlpha;
        }

        foreach (ContactPoint contact in collision)
        {
            //Debug.Log("This Collider: " + contact.thisCollider.gameObject.name);
            //Debug.Log("Other Collider: " + contact.otherCollider.gameObject.name);
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                if (contact.thisCollider.gameObject.name == "Bip001 L Hand001" && contact.otherCollider.gameObject.name == "Player Spawn")
                {
                    Debug.Log("Hit player");
                    CEntityPlayer.GetInstance().PushPlayerFromTower();
                    m_playerDetected = false;
                }
            }
        }
    }
 public void MakeJump()
 {
     m_fakeJump  = true;
     m_jumpTimer = ((Time.time) * 1000.0f);
     m_jumpState = JumpState.Jumping;
     CEntityPlayer.GetInstance().SetPlayerState(PlayerState.Jumping);
     m_collisionState = CollisionState.None;
 }
Ejemplo n.º 4
0
 public override void LogicStateChange(bool newState)
 {
     if (!m_active)
     {
         enabled  = true;
         m_camera = CCamera.GetInstance();
         m_player = CEntityPlayer.GetInstance();
     }
 }
    void OnTriggerStay(Collider collider)
    {
        if (collider.name != "Player Spawn")
        {
            return;
        }

        if (Enabled)
        {
            CEntityPlayer.GetInstance().PushPlayerFromTower();
        }
    }
Ejemplo n.º 6
0
    /*
     * \brief Called when this first collides with something
     */
    void OnCollisionEnter(Collision collision)
    {
        if (m_playerState == GruntState.FallingFromTower)
        {
            return;
        }

        foreach (ContactPoint contact in collision)
        {
            //Debug.Log("This Collider: " + contact.thisCollider.gameObject.name);
            //Debug.Log("Other Collider: " + contact.otherCollider.gameObject.name);
            if (contact.otherCollider != null && contact.otherCollider.gameObject != null)
            {
                if (contact.otherCollider.gameObject.name == "Player Spawn")
                {
                    //Debug.Log("Collided with player");
                    m_playerState = GruntState.Attacking;
                    m_ticksInContactWithPlayer++;
                }
            }
            if (contact.thisCollider.gameObject.name == "Bip001 L Hand001" && contact.otherCollider.gameObject.name == "Player Spawn")
            {
                Debug.Log("Hit player");
                CEntityPlayer.GetInstance().PushPlayerFromTower();
                m_playerDetected = false;
            }
        }


        m_physics.CallOnCollisionEnter(collision, m_playerDetected);

        if (collision.collider.gameObject.name == "GruntBarrier")
        {
            m_onBarrier = true;
        }
        if (collision.collider.gameObject.name == "GruntSpawn" && !m_playerDetected)
        {
            m_playerState             = GruntState.Standing;
            m_physics.MovingDirection = -1;
        }
        if (collision.collider.gameObject.name == "Electricity")
        {
            //Kill grunt
            Object deathBlast = Instantiate(DeathEffect, transform.position, transform.rotation);
            Destroy(deathBlast, 2);
            Debug.Log(this);
            this.transform.gameObject.SetActiveRecursively(false);
        }
    }
 void OnTriggerEnter()
 {
     if (!m_active)
     {
         CEntityPlayer player = CEntityPlayer.GetInstance();
         if (player == null)
         {
             return;
         }
         player.SetPlayerState(PlayerState.InCutScene);
         m_active = true;
         //m_animation.Play();
         this.transform.rotation.SetLookRotation(this.transform.position - player.transform.position);
     }
 }
Ejemplo n.º 8
0
    // Something entered the trigger area
    void OnTriggerEnter(Collider other)
    {
        if (!enabled)
        {
            return;
        }

        if (m_animation == null || m_animation.GetClipCount() == 0)
        {
            Debug.LogWarning("Cutscene '" + name + "' is missing an animation!");
            return;
        }

        if (other.name != "Player Spawn")
        {
            return;
        }

        m_player = CEntityPlayer.GetInstance();
        if (m_player == null)
        {
            return;
        }

        m_camera = CCamera.GetInstance();
        if (m_camera == null)
        {
            return;
        }

        m_player.SetPlayerState(PlayerState.InCutScene);
        if (GruntObject != null)
        {
            GruntObject.GetComponent <CEntityGrunt>().SetGruntState(GruntState.Standing);
        }

        m_camera.ClearFrames();
        m_initialDistanceFromPlayer = m_camera.DistanceFromPlayer;
        m_maxPositionsStored        = m_camera.MaxPositionsStored;
        m_camera.MaxPositionsStored = NumberOfLerpKeys;

        m_animation.Play();
        m_active = true;
    }
Ejemplo n.º 9
0
    /*
     * \brief Called when the object is created. At the start.
     *        Only called once per instaniation.
     */
    public void Start()
    {
        if (INSTANCE == null)
        {
            INSTANCE = this;
            CGUIOptions.GetInstance().ApplyOptions();
        }

        m_transform        = this.transform;
        DistanceFromPlayer = InitialDistanceFromPlayer;
        m_playerEntity     = CEntityPlayer.GetInstance();
        if (m_playerEntity == null)
        {
            m_playerEntity = GameObject.Find("Player Spawn").GetComponent <CEntityPlayer>();
        }
        m_playerPelvis = m_playerEntity.transform.FindChild("Player_Mesh/Bip001/Bip001 Pelvis");

        m_currentTransform = m_playerPelvis;

        m_storedPositions = new ArrayList();
        m_storedPositions.Add(m_currentTransform.position);
        m_countIgnoredFrames = 0;

        m_storedCameraPositions = new ArrayList();

        m_credits = this.gameObject.GetComponentInChildren <CEndCredits>();
        if (m_credits)
        {
            m_credits.gameObject.SetActiveRecursively(false);
        }
        if (this.transform.FindChild("Background"))
        {
            m_creditsBackground = this.transform.FindChild("Background").gameObject;
            if (m_creditsBackground)
            {
                m_creditsBackground.SetActiveRecursively(false);
            }
        }
    }
Ejemplo n.º 10
0
    //called if a collidable object triggers the volume
    void OnTriggerEnter(Collider collider)
    {
        if (!enabled)
        {
            return;
        }

        Rigidbody rBody = collider.gameObject.GetComponent <Rigidbody>();

        if (rBody == null)
        {
            return;
        }

        rBody.AddForce(ForceToApply);
        CEntityPlayer player = CEntityPlayer.GetInstance();

        if (player)
        {
            player.Physics.MakeJump();
        }
    }
    // Update is called once per frame
    void Update()
    {
        if (m_leverState == eLeverState.InUse && m_animation["Take 001"].normalizedTime > 0.9f)
        {
            m_leverState = eLeverState.Reseting;
            m_animation["Take 001"].speed = -1.0f;

            CEntityPlayer player = CEntityPlayer.GetInstance();
            player.SetPlayerState(PlayerState.Standing);
        }

        if (m_leverState == eLeverState.Reseting && m_animation["Take 001"].normalizedTime <= 0.1f)
        {
            m_leverState = eLeverState.ReadyForUse;
            m_animation["Take 001"].speed = 0.0f;
            state = false;
        }

        if (m_triggerEntered)
        {
            bool pulled = CheckContextButton();
            if (pulled && m_leverState == eLeverState.ReadyForUse)
            {
                CEntityPlayer player = CEntityPlayer.GetInstance();
                player.SetPlayerState(PlayerState.PullingWallLeverDown);

                state        = true;
                m_leverState = eLeverState.InUse;
                m_timePulled = Time.time;
                m_animation["Take 001"].speed = 1.0f;

                if (m_audio != null)
                {
                    m_audio.Play();
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
        INSTANCE           = this;
        m_initialTransform = this.transform;

        m_storedYPositions = new ArrayList();

        m_fireTimer = 0.0f;
        m_isFiring  = false;
        testLength  = 0.0f;

        m_playerEntity = CEntityPlayer.GetInstance();
        if (m_playerEntity == null)
        {
            GameObject playerObject = GameObject.Find("Player Spawn");
            if (playerObject != null)
            {
                m_playerEntity = playerObject.GetComponent <CEntityPlayer>();
            }
            if (m_playerEntity == null)
            {
                Debug.LogError("CEntityAirship: Cannot find player");
                return;
            }
        }

        m_playerTransform = m_playerEntity.transform.FindChild("Player_Mesh/Bip001/Bip001 Pelvis");

        float playerY = m_playerTransform.position.y;

        for (int posCount = 0; posCount < NumYPositions; posCount++)
        {
            m_storedYPositions.Add(playerY);
        }
        this.gameObject.SetActiveRecursively(false);
    }
Ejemplo n.º 13
0
    private void OnMainPausedMenu()
    {
        const float BUTTON_WIDTH = 256;

        float yPosition = 100;

        string  pausedText      = "Paused";
        Vector2 textDimensions  = GUI.skin.label.CalcSize(new GUIContent(pausedText));
        Rect    pausedLabelRect = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(pausedLabelRect, pausedText);

        yPosition += 96;
        Rect continueRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("continue");
        if (GUI.Button(continueRect, "Continue") || (m_pressedOK && m_highlighted == "continue"))
        {
            m_pressedOK   = false;
            m_highlighted = "continue";
            CEntityPlayer.GetInstance().CurrentGameState = GameState.Running;
            Time.timeScale = 1.0f;
            CEntityPlayer.GetInstance().Physics.SkipNextJump();
            return;
        }

        yPosition += 42;
        Rect restartRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("restart");
        if (GUI.Button(restartRect, "Restart Level") || (m_pressedOK && m_highlighted == "restart"))
        {
            m_pressedOK       = false;
            m_highlighted     = "no";
            m_pausedMenuState = PausedMenuState.Restart;
            return;
        }

        yPosition += 42;
        Rect optionsRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("options");
        if (GUI.Button(optionsRect, "Options") || (m_pressedOK && m_highlighted == "options"))
        {
            m_pressedOK       = false;
            m_highlighted     = "graphics";
            m_pausedMenuState = PausedMenuState.Options;
            return;
        }

        yPosition += 84;
        Rect mainMenuRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("mainmenu");
        if (GUI.Button(mainMenuRect, "Main Menu") || (m_pressedOK && m_highlighted == "mainmenu"))
        {
            m_pressedOK       = false;
            m_highlighted     = "no";
            m_pausedMenuState = PausedMenuState.MainMenu;
            return;
        }

        yPosition += 42;
        Rect quitRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f), yPosition, BUTTON_WIDTH, 48);

        GUI.SetNextControlName("quit");
        if (GUI.Button(quitRect, "Quit") || (m_pressedOK && m_highlighted == "quit"))
        {
            m_pressedOK       = false;
            m_highlighted     = "no";
            m_pausedMenuState = PausedMenuState.Quit;
            return;
        }
    }
Ejemplo n.º 14
0
    private void AreYouSureMenu()
    {
        string labelText = "Are you sure you want to ";

        switch (m_pausedMenuState)
        {
        case PausedMenuState.MainMenu:
            labelText += "return to the main menu?";
            break;

        case PausedMenuState.Quit:
            labelText += "quit the game?";
            break;

        case PausedMenuState.Restart:
            labelText += "restart the current level?";
            break;
        }
        ;

        const float BUTTON_WIDTH = 256;
        float       yPosition    = 100;

        Vector2 textDimensions = GUI.skin.label.CalcSize(new GUIContent(labelText));
        Rect    labelRect      = new Rect((Screen.width * 0.5f) - (textDimensions.x * 0.5f), yPosition, textDimensions.x, textDimensions.y);

        GUI.Label(labelRect, labelText);

        yPosition += 96;

        Rect yesRect = new Rect((Screen.width * 0.5f) - (BUTTON_WIDTH * 0.5f) - 5, yPosition, BUTTON_WIDTH * 0.5f, 48);

        GUI.SetNextControlName("yes");
        if (GUI.Button(yesRect, "Yes") || (m_pressedOK && m_highlighted == "yes"))
        {
            m_pressedOK   = false;
            m_highlighted = "continue";

            if (m_pausedMenuState == PausedMenuState.Quit)
            {
                Application.Quit();
            }
            else if (m_pausedMenuState == PausedMenuState.MainMenu)
            {
                Time.timeScale = 1.0f;
                Application.LoadLevel("Main_Menu");
                m_pausedMenuState = PausedMenuState.Main;
            }
            else if (m_pausedMenuState == PausedMenuState.Restart)
            {
                string currentLevel = CEntityPlayer.GetInstance().CurrentLevel;
                Time.timeScale = 1.0f;
                Application.LoadLevel(currentLevel);
                m_pausedMenuState = PausedMenuState.Main;
            }

            return;
        }

        Rect noRect = new Rect((Screen.width * 0.5f) + 5, yPosition, BUTTON_WIDTH * 0.5f, 48);

        GUI.SetNextControlName("no");
        if (GUI.Button(noRect, "No") || (m_pressedOK && m_highlighted == "no"))
        {
            m_pausedMenuState = PausedMenuState.Main;
            m_pressedOK       = false;
            m_highlighted     = "continue";
            return;
        }
    }
    // Update is called once per frame
    new void Update()
    {
        if (m_leverState == eLevelState.InUse && LeverType == eLevelType.MultiUse && (Time.time - m_timePulled > (ResetTime + SendSignalDelay)))
        {
            m_leverState = eLevelState.ReadyForUse;
            state        = false;
        }

        if (SendSignalDelay != 0.0f && Time.time - m_timePulled >= SendSignalDelay && !m_sentSignal)
        {
            state        = true;
            m_sentSignal = true;
        }

        if (m_triggerEntered)
        {
            if (m_animation != null && (Time.time - m_timePulled > TimeDelaySecs && m_leverState == eLevelState.InUse))
            {
                m_animation[AnimationName].speed = 1.0f;
            }

            if (m_animation != null && m_leverState == eLevelState.Reseting)
            {
                m_animation[AnimationName].speed = -1.0f;
            }

            bool pulled = CheckContextButton();
            if (pulled && m_leverState == eLevelState.ReadyForUse)
            {
                CEntityPlayer player = CEntityPlayer.GetInstance();

                if (OnWall)
                {
                    player.SetPlayerState(PlayerState.PullingWallLeverDown);
                }
                else
                {
                    if (AnimationName == "KickActivate")
                    {
                        player.SetPlayerState(PlayerState.KickFloorLever);
                    }
                    else
                    {
                        player.SetPlayerState(PlayerState.NormalFloorLever);
                    }
                }

                if (SendSignalDelay == 0.0f)
                {
                    state = true;
                }
                else
                {
                    m_sentSignal = false;
                }

                m_leverState = eLevelState.InUse;
                m_timePulled = Time.time;
            }
            else if (LeverType == eLevelType.Toggle && pulled && m_leverState == eLevelState.Finished)
            {
                CEntityPlayer player = CEntityPlayer.GetInstance();
                player.SetPlayerState(PlayerState.PullingWallLeverUp);

                state        = false;
                m_leverState = eLevelState.Reseting;
                m_timePulled = Time.time;
            }
        }

        if (m_animation == null)
        {
            return;
        }

        if (m_leverState == eLevelState.InUse && m_animation[AnimationName].normalizedTime > 0.9f)
        {
            if (LeverType == eLevelType.InstantReset)
            {
                m_animation[AnimationName].speed = -1.0f;
                m_leverState = eLevelState.Reseting;
            }
            else if (LeverType == eLevelType.Toggle)
            {
                m_animation[AnimationName].speed = 0.0f;
                m_leverState = eLevelState.Finished;
            }
            else if (LeverType == eLevelType.MultiUse)
            {
                m_leverState = eLevelState.Reseting;
                m_animation[AnimationName].speed = -1.0f;
                state = false;
            }

            CEntityPlayer player = CEntityPlayer.GetInstance();
            player.SetPlayerState(PlayerState.Standing);
        }

        if (m_leverState == eLevelState.Reseting && m_animation[AnimationName].normalizedTime < 0.1f)
        {
            m_animation[AnimationName].speed = 0.0f;
            m_leverState = eLevelState.ReadyForUse;

            CEntityPlayer player = CEntityPlayer.GetInstance();
            player.SetPlayerState(PlayerState.Standing);
        }
    }
Ejemplo n.º 16
0
    /*
     * \brief Called once per frame
     */
    public override void FixedUpdate()
    {
        if (m_ticksInContactWithPlayer > 1)
        {
            CEntityPlayer.GetInstance().PushPlayerFromTower();
            m_ticksInContactWithPlayer = 0;
            m_playerDetected           = false;
        }
        if (m_playerDetected)
        {
            if (m_resetTimer + TimeToReset < Time.time)
            {
                //reset detection
                m_playerDetected = false;
                m_playerState    = GruntState.Turning;
                if (m_physics.MovingDirection == 1)
                {
                    m_physics.MovingDirection = -1;
                    //m_physics.MovingDirection = -1;
                }
                else if (m_physics.MovingDirection == -1)
                {
                    m_physics.MovingDirection = 1;
                    //m_direction = 1;
                }
            }
        }

        if (m_playerPositionAlpha > 360.0f)
        {
            m_playerPositionAlpha -= 360.0f;
        }
        else if (m_playerPositionAlpha <= -360.0f)
        {
            m_playerPositionAlpha += 360.0f;
        }


        m_lastPlayerPositionAlpha = m_playerPositionAlpha;

        m_physics.OnFixedUpdate(ref m_playerState, m_playerDetected);


        m_playerPositionAlpha -= m_physics.Velocity;
        m_playerPositionAlpha += m_physics.PlatformVelocity;

        m_physics.PlatformVelocity = 0.0f;

        float additionalY = 0.0f;

        if (m_playerState == GruntState.FallingFromTower)
        {
            m_additionalRadius   += (0.025f * m_physics.Invert);
            m_additionalRadius    = Mathf.Clamp(m_additionalRadius, -3.0f, 3.0f);
            m_playerPositionAlpha = m_lastPlayerPositionAlpha;
        }

        float yPosition = transform.position.y + additionalY;

        m_position = new Vector3(
            Mathf.Sin(m_playerPositionAlpha * Mathf.Deg2Rad) * (PlayerPathRadius + m_additionalRadius),
            yPosition,
            Mathf.Cos(m_playerPositionAlpha * Mathf.Deg2Rad) * (PlayerPathRadius + m_additionalRadius)
            );

        // Animate and position the player model mesh
        {
            if (m_playerState == GruntState.Turning)
            {
                //Debug.Log("NOT IN ROTATION CODE");
            }
            else
            {
                //Debug.Log("rOTATION");
                if (m_physics.Direction > 0)
                {
                    m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0));
                }
                else if (m_physics.Direction < 0)
                {
                    m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0));
                }
                else if (m_physics.MovingDirection > 0)
                {
                    m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y + 90, 0));
                }
                else if (m_physics.MovingDirection < 0)
                {
                    m_characterMesh.rotation = Quaternion.Euler(new Vector3(0, this.transform.rotation.eulerAngles.y - 90, 0));
                }
            }

            int mDirection = m_physics.MovingDirection;
            m_animation.OnFixedUpdate(ref m_playerState, ref mDirection, m_physics, m_physics.GetFootMaterial(), m_playerDetected);
            m_physics.MovingDirection = mDirection;
        }


        if (m_playerState == GruntState.FallingFromTower && (Time.time * 1000.0f) - m_dead.time > 3000)
        {
            OnDeath();
        }

        base.FixedUpdate();
    }