Esempio n. 1
0
    /// <summary>
    /// 创建小兵
    /// </summary>
    /// <param name="response"></param>
    private void OnDog(OperationResponse response)
    {
        DogModel[] dogs = JsonMapper.ToObject <DogModel[]>(response[0].ToString());
        for (int i = 0; i < dogs.Length; i++)
        {
            DogModel   dog    = dogs[i];
            GameObject go     = PoolManager.Instance.GetObject("Dog");
            DogControl con    = go.GetComponent <DogControl>();
            int        myTeam = this.GetTeam(this.Heros, GameData.Player.id);
            //初始化小兵控制器
            con.Init(dog, dog.Team == myTeam);
            con.SetCamp(team1Builds[1].transform, team2Builds[1].transform);

            if (dog.Team == 1)
            {
                con.transform.position = con.camp1.position;
                con.Move(con.camp2.position);
            }
            else
            {
                con.transform.position = con.camp2.position;
                con.Move(con.camp1.position);
            }
            idControlDict.Add(dog.Id, con);
        }
    }
Esempio n. 2
0
        public async Task CreateDogControl(DogControl dogControl)
        {
            if (dogControl.QuoteCurrency != "usdt" &&
                dogControl.QuoteCurrency != "btc" &&
                dogControl.QuoteCurrency != "eth" &&
                dogControl.QuoteCurrency != "ht")
            {
                throw new ApplicationException("管控数据QuoteCurrency出错");
            }

            if (dogControl.MaxInputPrice <= 0 ||
                dogControl.EmptyPrice <= 0)
            {
                throw new ApplicationException("管控数据出错");
            }

            var indb = GetDogControlBySet(dogControl.SymbolName, dogControl.QuoteCurrency);

            if (indb != null)
            {
                var emptyPrice    = Math.Max(dogControl.EmptyPrice, indb.HistoryMin * (decimal)1.5);
                var maxInputPrice = Math.Min(dogControl.MaxInputPrice, indb.HistoryMax * (decimal)1.5);
                await Database.UpdateAsync <DogControl>(new { EmptyPrice = emptyPrice, MaxInputPrice = maxInputPrice, dogControl.WillDelist }, new { dogControl.SymbolName, dogControl.QuoteCurrency });
            }
            else
            {
                dogControl.CreateTime = DateTime.Now;
                await Database.InsertAsync(dogControl);
            }
        }
Esempio n. 3
0
 void Awake()
 {
     instance                 = this;
     rb                       = GetComponent <Rigidbody>();
     rb.centerOfMass          = Vector3.zero;
     rb.inertiaTensorRotation = Quaternion.identity;
     lastRotationDir          = transform.forward;
 }
Esempio n. 4
0
        public static void RefreshHistoryMaxMinAsync(string symbolName, string quoteCurrency)
        {
            try
            {
                // 先计算最近500天的数据, 如果数据量少, 则计算4小时数据1000天
                PlatformApi api    = PlatformApi.GetInstance("xx");
                var         klines = api.GetHistoryKline(symbolName + quoteCurrency, "1day", 500);
                if (klines.Count < 180)
                {
                    klines = api.GetHistoryKline(symbolName + quoteCurrency, "4hour", 1000);
                }
                var min = decimal.MinValue;
                var max = decimal.MaxValue;

                min = klines.Where(it => it.Low > min).Min(it => it.Low);
                min = klines.Where(it => it.Low > min).Min(it => it.Low);
                min = klines.Where(it => it.Low > min).Min(it => it.Low);

                max = klines.Where(it => it.High < max).Max(it => it.High);
                max = klines.Where(it => it.High < max).Max(it => it.High);
                max = klines.Where(it => it.High < max).Max(it => it.High);

                // 判断max
                var maxNotSell = new DogMoreBuyDao().GetMaxPriceOfNotSellFinished(quoteCurrency, symbolName);
                if (maxNotSell > max)
                {
                    max = maxNotSell;
                }

                var avgPrice = (decimal)0;
                foreach (var item in klines)
                {
                    avgPrice += (item.Open + item.Close) / 2;
                }
                avgPrice = avgPrice / klines.Count;

                var dogControl = new DogControl()
                {
                    HistoryMax    = max,
                    HistoryMin    = min,
                    SymbolName    = symbolName,
                    QuoteCurrency = quoteCurrency,
                    AvgPrice      = avgPrice
                };

                new DogControlDao().UpdateDogControlMaxAndMin(dogControl);
            }
            catch (Exception ex)
            {
                logger.Error(ex.Message, ex);
                throw ex;
            }
        }
 public async Task Create([FromBody] DogControl dogControl)
 {
     try
     {
         await new DogControlDao().CreateDogControl(dogControl);
     }
     catch (Exception ex)
     {
         logger.Error(ex.Message, ex);
         throw ex;
     }
 }
Esempio n. 6
0
        public void UpdateDogControlMaxAndMin(DogControl dogControl)
        {
            if (dogControl.QuoteCurrency != "usdt" &&
                dogControl.QuoteCurrency != "btc" &&
                dogControl.QuoteCurrency != "eth" &&
                dogControl.QuoteCurrency != "ht")
            {
                throw new ApplicationException("管控数据QuoteCurrency出错");
            }

            Database.Update <DogControl>(new { dogControl.HistoryMax, dogControl.HistoryMin, dogControl.AvgPrice }, new { dogControl.SymbolName, dogControl.QuoteCurrency });
        }
Esempio n. 7
0
    private void Awake()
    {
        //  animCtrl = GetComponent<Animator>();
        //애니메이터 컴포넌트를 animCtrl변수 설정


        // animCtrl.enabled = false;
        startingLvPlus = currentLvPlus;
        userId.text    = PlayerPrefs.GetString("USER_ID", userId.text);

        //Start 함수 시작되기전에 불러오기
        instance = this;
        //싱글톤 설정
    }