Ejemplo n.º 1
0
 // Use this for initialization
 protected override void Start()
 {
     base.Start();
     tiledata = GetComponent <TileData>();
     Assert.IsNotNull(tiledata, "A lever require a TileData component!");
     currentState = (eLeverState)tiledata.Tile.paramContainer.GetIntParam("state");
 }
Ejemplo n.º 2
0
    public void SetState(eLeverState state)
    {
        if (state == eLeverState.Middle && DualStateOnly)
        {
            throw new ArgumentException("Cannot set as Middle a DualState Lever", "state");
        }

        lastState    = currentState;
        currentState = state;
        tiledata.Map.SetTileData(tiledata.Position, TileId[(int)state]);
        tiledata.Map.UpdateMesh();
    }
Ejemplo n.º 3
0
 private void ChangeState()
 {
     if (currentState == eLeverState.Left || currentState == eLeverState.Right)
     {
         lastState    = currentState;
         currentState = DualStateOnly ? (currentState == eLeverState.Left) ? eLeverState.Right : eLeverState.Left : eLeverState.Middle;
     }
     else // if(currentState == eLeverState.Middle)
     {
         currentState = (lastState == eLeverState.Left) ? eLeverState.Right : eLeverState.Left;
         lastState    = eLeverState.Middle;
     }
     tiledata.Map.SetTileData(tiledata.Position, TileId[(int)currentState]);
     tiledata.Map.UpdateMesh();
 }
    // 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();
                }
            }
        }
    }
    // 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();
                }
            }
        }
    }