Exemple #1
0
    public IEnumerator moveAnimation()
    {
        Transform t = this.transform;

        startPosition = t.position;
        moveTime      = 0;
        while (moveTime < 1f)
        {
            moveTime  += Time.deltaTime * moveSpeed;
            t.position = Vector3.Lerp(startPosition, endPosition, moveTime);
            yield return(null);
        }
        //移动结束 状态变为idle
        nowState = BoxStateType.Idle;
        setInt();
        yield return(0);
    }
Exemple #2
0
    public void move(string direction)
    {
        nowState = BoxStateType.Moving;
        Transform t = this.transform;

        switch (direction)
        {
        case "W":
            endPosition = new Vector3(t.position.x, t.position.y, t.position.z + 1);
            break;

        case "S":
            endPosition = new Vector3(t.position.x, t.position.y, t.position.z - 1);
            break;

        case "A":
            endPosition = new Vector3(t.position.x - 1, t.position.y, t.position.z);
            break;

        case "D":
            endPosition = new Vector3(t.position.x + 1, t.position.y, t.position.z);
            break;
        }
    }