public static Boll Create() { GameObject instance = Instantiate(Resources.Load(PREFAB_PATH)) as GameObject; Boll boll = instance.GetComponent <Boll> (); return(boll); }
/// <summary> /// 初期化 /// </summary> public void OnInitiarize() { if (this.boll != null) { this.boll.Delete(); this.boll = null; } this.gameTime = 0.0f; this.player1.Initiarize(FIRST_PLAYER1_POSITION); this.player2.Initiarize(FIRST_PLAYER2_POSITION); this.boll = Boll.Create(); this.boll.gameObject.transform.SetParent(this.transform); this.boll.gameObject.transform.localScale = Vector3.one; this.boll.Initialize(); this.isPause = false; this.canPause = false; this.doNextStep = true; this.step = Step.Start; this.gameTime = GAME_MAX_TIME; float timeMinutue = (int)(this.gameTime / 60.0f); int timeSec = (int)this.gameTime % 60; this.time.text = string.Format(TIME_TEXT_FORMAT, timeMinutue, timeSec.ToString().PadLeft(2, '0')); this.statusText.gameObject.transform.parent.gameObject.SetActive(false); }
/// <summary> /// 获取排列强度 /// </summary> /// <param name="dir">大于0为多,其他均为空</param> /// <returns></returns> int GetValue(bool isOrder, int orderDir, bool isTest = false) { if (!isTest && (V_LongShortRatio > CommonData.Ins.ShortMaxRatio && V_LongShortRatio < CommonData.Ins.LongMaxRatio)) { if (!F_CanHanleOrder()) { return(0); } } bool isGreenKLine = V_Cache.V_KLineData[0].V_ClosePrice > V_Cache.V_KLineData[0].V_OpenPrice; float closeValue = V_Cache.V_KLineData[0].V_ClosePrice; float openValue = V_Cache.V_KLineData[0].V_OpenPrice; float highValue = V_Cache.V_KLineData[0].V_HightPrice; float lowValue = V_Cache.V_KLineData[0].V_LowPrice; float midValue = (highValue + lowValue) * 0.5f; KLine LastKLine = V_Cache.V_KLineData[1]; float minValue = V_Cache.V_KLineData[V_CycleList[0]].V_HightPrice; float maxValue = V_Cache.V_KLineData[V_CycleList[0]].V_LowPrice; for (int i = V_CycleList[0]; i < V_CycleList[2]; i++) { if (minValue > V_Cache.V_KLineData[i].V_HightPrice) { minValue = V_Cache.V_KLineData[i].V_HightPrice; } if (maxValue < V_Cache.V_KLineData[i].V_LowPrice) { maxValue = V_Cache.V_KLineData[i].V_LowPrice; } } List <float> volList = new List <float>(); List <float> perList = new List <float>(); for (int i = 0; i < V_Cache.V_KLineData.Count; i++) { KLine line = V_Cache.V_KLineData[i]; perList.Add((line.V_HightPrice - line.V_LowPrice) / line.V_HightPrice * 100); volList.Add(line.V_Vol); } float vol_avg = volList.Average(); float per_avg = perList.Average(); float a = F_GetMA(V_CycleList[0]); float b = F_GetMA(V_CycleList[0], 1); float k1 = (a - b) / b * 100; //Console.WriteLine("0 "+a+" "+b+" "+v); a = F_GetMA(V_CycleList[1]); b = F_GetMA(V_CycleList[1], 1); float k2 = (a - b) / b * 100; //Console.WriteLine("1 " + a + " " + b + " " + v); a = F_GetMA(V_CycleList[2]); b = F_GetMA(V_CycleList[2], 1); float k3 = (a - b) / b * 100; //Console.WriteLine("2 " + a + " " + b + " " + v); float MaValue = F_GetMA(V_CycleList[0]); float MaValue2 = F_GetMA(V_CycleList[1]); float LongMaValue = F_GetMA(V_CycleList[2]); float EMaValue = F_GetEMA(V_CycleList[0]); float EMaValue2 = F_GetEMA(V_CycleList[1]); float LongEMaValue = F_GetEMA(V_CycleList[2]); float boll_MidValue, boll_UpValue, boll_LowValue; boll_MidValue = Boll.GetBoll(V_CycleList[1], V_Cache.V_KLineData, out boll_UpValue, out boll_LowValue); float MaKValue = V_Cache.V_KLineData[0].V_ClosePrice - V_Cache.V_KLineData[V_CycleList[0]].V_ClosePrice; float MaKValue2 = V_Cache.V_KLineData[0].V_ClosePrice - V_Cache.V_KLineData[V_CycleList[1]].V_ClosePrice; float LongMaKValue = V_Cache.V_KLineData[0].V_ClosePrice - V_Cache.V_KLineData[V_CycleList[2]].V_ClosePrice; float vol = V_Cache.V_KLineData[0].V_Vol; bool isLong = false; bool isShort = false; float per1 = (closeValue - MaValue) / closeValue * 100; float per2 = (closeValue - MaValue2) / closeValue * 100; float per3 = (closeValue - LongMaValue) / closeValue * 100; float allVol = 0; bool bigVol = false; bool bigBigVol = false; for (int i = 0; i < V_CycleList[0]; i++) { if (V_Cache.V_KLineData[i].V_Vol >= vol_avg * 2) { bigVol = true; } if (V_Cache.V_KLineData[i].V_Vol >= vol_avg * 6) { bigBigVol = true; } } for (int i = 0; i < V_CycleList[1]; i++) { allVol += V_Cache.V_KLineData[i].V_OpenPrice >= V_Cache.V_KLineData[i].V_ClosePrice ? -V_Cache.V_KLineData[i].V_Vol : V_Cache.V_KLineData[i].V_Vol; } #region 4.0 if (midValue > EMaValue && MaKValue2 > 0 && per3 < 2f && LongMaKValue > 0 && per3 > 0) { isLong = true; } if (midValue < EMaValue && MaKValue2 < 0 && per3 > -2f && LongMaKValue < 0 && per3 < 0) { isShort = true; } if (isOrder) { if (isShort && V_LongShortRatio > CommonData.Ins.ShortRatio && (per3 > -2f && per3 < 0f) || per3 >= 5) { return(-1); } if (isLong && V_LongShortRatio < 1.2 && (per3 < 2f && per3 > 0f) || per3 <= -5) { return(1); } } else { if (orderDir > 0) { if (per3 > 5 && bigVol) { return(1); } return(isLong ? 0 : 1); } if (orderDir < 0) { if (per3 < -5 && bigVol) { return(1); } return(isShort ? 0 : 1); } } #endregion return(0); }