Ejemplo n.º 1
0
    void CreateGraphNode(List <NGraphNode> infoList, NGraphOverview overView, long startTime, long curTime)
    {
        AddPointCount(infoList.Count - graphPointList.Count + 3);
        int count = 0;

        foreach (var info in infoList)
        {
            float yScale;
            float posY;
            if (overView.highPrice <= overView.lowPrice)
            {
                posY = graphYNodes[1].trans.position.y;
            }
            else
            {
                yScale = System.Convert.ToSingle((info.price - overView.lowPrice) / (overView.highPrice - overView.lowPrice));
                posY   = Mathf.Lerp(graphYNodes[2].trans.position.y, graphYNodes[0].trans.position.y, yScale);
            }
            float      xScale = (info.time - startTime) / (curTime - startTime);
            float      posX   = Mathf.Lerp(graphXNodes[0].trans.position.x, graphYNodes[2].trans.position.x, xScale);
            GameObject point  = graphPointList[count++];
            if (count == 1)
            {
                point.transform.position = new Vector3(posX, posY, 1);
            }
            else
            {
                point.transform.position = new Vector3(posX, posY, 0);
            }
            point.gameObject.SetActive(true);
        }

        // add current node
        double curPrice = itemPackage.GetItemPrice(itemPackage.GetSelectionItemConfigID());
        float  curY;

        if (overView.lowPrice == overView.highPrice)
        {
            curY = graphYNodes[1].trans.position.y;
        }
        else
        {
            float scale = System.Convert.ToSingle((curPrice - overView.lowPrice) / (overView.highPrice - overView.lowPrice));
            curY = Mathf.Lerp(graphYNodes[2].trans.position.y, graphYNodes[0].trans.position.y, scale);
        }
        GameObject curNode = graphPointList[count++];

        curNode.transform.position = new Vector3(graphXNodes[2].trans.position.x, curY, 0);
        curNode.gameObject.SetActive(true);

        for (; count < graphPointList.Count; count++)
        {
            graphPointList[count].gameObject.SetActive(false);
        }
    }
Ejemplo n.º 2
0
 void RefreshAxis(long curTime, long startTime, NGraphOverview overview)
 {
     System.DateTime curDate = GlobalFunction.DateFormat(curTime);
     System.DateTime preDate = GlobalFunction.DateFormat(startTime);
     // set y
     graphYNodes[0].label.text = GlobalFunction.NumberFormat(overview.highPrice);
     graphYNodes[1].label.text = GlobalFunction.NumberFormat(overview.avgPrice);
     graphYNodes[2].label.text = GlobalFunction.NumberFormat(overview.lowPrice);
     // set x
     graphXNodes[0].label.text = string.Format("{0}.{1}", preDate.Month, preDate.Day);
     graphXNodes[1].label.text = string.Format("{0}.{1}", curDate.Month, curDate.Day);
 }
Ejemplo n.º 3
0
    void RefreshGraph()
    {
        long curTime   = GlobalFunction.GetTimeStamp();
        long startTime = GlobalFunction.GetGraphStartTimeStamp();

        //calculate node
        dynamicPackage.CalculateGraphInfo(itemPackage.GetSelectionItemConfigID(), startTime, curTime);
        List <NGraphNode> graphInfoList = dynamicPackage.GetGraphInfoList();

        dynamicPackage.CalculateGraphOverview();
        NGraphOverview overview = dynamicPackage.GetGraphOverview();

        //set axis
        RefreshAxis(curTime, startTime, overview);
        //craete node
        CreateGraphNode(graphInfoList, overview, startTime, curTime);
        //draw line
        DrawLine();
    }