Ejemplo n.º 1
0
    void Start()
    {
        previousHp = hp.curHealth;
        if (playerController == null)
        {
            playerController = (Controller)GameObject.FindGameObjectWithTag("Player").GetComponent <Controller> ();
        }

        _state = new IdleState(this, 2f, -1);
    }
Ejemplo n.º 2
0
    void Update()
    {
        if (lizardPostitions.Count > 0)
        {
            switch (state)
            {
            case LizardState.Idle:
                break;

            case LizardState.Showing:
                if (t < 1.0f)
                {
                    Vector3         v;
                    LizardPostition pos = GetCurrentPosition();
                    t += Time.deltaTime * pos.speed;
                    float y = Mathf.Lerp(startY, startY + pos.maxY, t);
                    if (t < 1.0f)
                    {
                        v   = transform.position;
                        v.y = y;
                        transform.position = v;
                    }
                    else
                    {
                        state = LizardState.Idle;

                        v   = transform.position;
                        v.y = startY + pos.maxY;
                        transform.position = v;

                        BeginHide();
                    }
                }
                break;

            case LizardState.Hiding:
                if (t < 1.0f)
                {
                    Vector3         v;
                    LizardPostition pos = GetCurrentPosition();
                    t += Time.deltaTime * pos.speed;
                    float y = Mathf.Lerp(startY + pos.maxY, startY, t);
                    if (t < 1.0f)
                    {
                        v   = transform.position;
                        v.y = y;
                        transform.position = v;
                    }
                    else
                    {
                        state = LizardState.Idle;

                        v   = transform.position;
                        v.y = startY;
                        transform.position = v;

                        CalcNewPosition();
                        BeginShow();
                    }
                }
                break;
            }
        }
    }
Ejemplo n.º 3
0
 private void Show()
 {
     t     = 0.0f;
     state = LizardState.Showing;
 }
Ejemplo n.º 4
0
 private void Hide()
 {
     t     = 0.0f;
     state = LizardState.Hiding;
 }