示例#1
0
        private void M_ShotRecieved(object sender, EventArgs e)
        {
            if (!myTurn)
            {
                WeaponFireComm c   = (WeaponFireComm)sender;
                HitResponse    res = me.Battlefield.Hit(new Coords(getIntFromLetter(c.x), c.y));

                switch (res)
                {
                case HitResponse.Hit:
                    m.RespondToShot(FireResponse.hit, c.x, c.y, opponent.fleetName, this.region);
                    // myTurn = false;
                    break;

                case HitResponse.Miss:
                    m.RespondToShot(FireResponse.miss, c.x, c.y, opponent.fleetName, this.region);
                    //myTurn = true;
                    break;

                case HitResponse.Destroy:
                    //myTurn = false;
                    m.RespondToShot(FireResponse.hit, c.x, c.y, opponent.fleetName, this.region, me.isFleetDestroyed() ? FireResult.fleetdestroyed : FireResult.sunk);
                    break;

                default:
                    break;
                }
                if (me.isFleetDestroyed())
                {
                    Lost.Invoke(me, EventArgs.Empty);
                }

                myTurn = true;
            }
        }
示例#2
0
        public HitResponse Hit(Coords c)
        {
            HitResponse res = HitResponse.Miss;

            if (field[c.x, c.y] < 2)
            {
                foreach (Ship s in ships)
                {
                    res = s.CheckHit(c);
                    if (res == HitResponse.Hit)
                    {
                        field[c.x, c.y] = 3;
                        break;
                    }
                    else if (res == HitResponse.Destroy)
                    {
                        foreach (Coords co in s.squares)
                        {
                            field[co.x, co.y] = 4;
                        }
                        break;
                    }
                }
                if (res == HitResponse.Miss)
                {
                    field[c.x, c.y] = 2;
                }
            }
            else
            {
                res = HitResponse.Error;
            }
            return(res);
        }
示例#3
0
        private async Task <HitResponse <T> > MakeRequestAsync <T>(HttpRequestMessage httpRequestMessage, CancellationToken cancellationToken)
        {
            var result = new HitResponse <T>();

            //if (this.forbidAllRequests)
            //{
            //    result.ErrorCode = BinanceErrors.REQUEST_FORBIDDEN_MANUALLY;
            //    result.ErrorMessage = $"All requests are forbidden manual. Approximate time to release - {CalculateRemainingForbiddenTime()}";

            //    return result;
            //}

            var response = await this.httpClient.SendAsync(httpRequestMessage, cancellationToken);

            if (cancellationToken.IsCancellationRequested)
            {
                return(result);
            }

            var json = await response.Content.ReadAsStringAsync();

            if (response.IsSuccessStatusCode)
            {
                result.Result = JsonConvert.DeserializeObject <T>(json);
            }
            else
            {
                result = JsonConvert.DeserializeObject <HitResponse <T> >(json);
            }

            return(result);
        }
示例#4
0
        private void _Response(HitResponse obj)
        {
            HitRequest request;

            if (!_Requests.TryGetValue(obj.FishId, out request))
            {
                return;
            }

            switch (obj.DieResult)
            {
            case FISH_DETERMINATION.DEATH:
                var onDeathFish = _DeathFishEvent;
                if (onDeathFish != null)
                {
                    onDeathFish(obj.FishId);
                }

                AddMoney(request.WeaponData.GetTotalBet());
                _DeadFishCount++;
                break;

            case FISH_DETERMINATION.SURVIVAL:
                _PushFish(obj.FishId);
                break;
            }

            _Requests.Remove(obj.FishId);
        }
 public void PressHitButton(int no)
 {
     if (!bGameOver)
     {
         HitResponse hitResp = hitWindow.GetComponent <HitResponse>();
         hitResp.Hit();
     }
 }
示例#6
0
        public Hitbox(GameObject parent, Vector2 position, Vector2 dimensions, HitResponse onHit = null)
        {
            Parent = parent;

            SetPosition(position);
            this.dimensions = dimensions;
            OnHit           = onHit;

            // Priority = 0;
        }
示例#7
0
        protected T CheckHitResponse <T>(HitResponse <T> hitResponse, out HitError hitError, bool pushDealTicketOnError = false)
        {
            T result = hitResponse.Result;

            hitError = hitResponse.Error;

            if (hitError != null && pushDealTicketOnError)
            {
                var dealTicket = DealTicketGenerator.CreateRefuseDealTicket(hitError.Format());

                this.PushMessage(dealTicket);
            }

            return(result);
        }
 public void TryParseResponse(JObject jObject)
 {
     try
     {
         this.response = jObject.ToObject <HitResponse <T> >();
     }
     catch (Exception ex)
     {
         this.parseException = ex;
     }
     finally
     {
         this.Abort();
     }
 }
        // TRADING
        private HitOrder DoTrade(SnapshotStep currentStep, SnapshotStep nextStep)
        {
            var    watch        = new Stopwatch();
            string currencyPair = nextStep.Action == "SELL" ? (currentStep.Coin + nextStep.Coin) : (nextStep.Coin + currentStep.Coin);

            decimal amount = nextStep.Action == "BUY" ? nextStep.Amount : currentStep.Amount;

            amount = amount - (amount % nextStep.QuantityIncrement);

            Console.WriteLine("Amount: " + decimal.Round(amount, 8) + " Price: " + nextStep.Price + " Market: " + currencyPair + " Action: " + nextStep.Action);
            watch.Start();
            HitResponse <HitReport> placeOrder = _hitbctSocketApi.PlaceNewOrderAsync(currencyPair, nextStep.Action == "BUY" ? HitSide.Buy : HitSide.Sell, amount, nextStep.Price).Result;

            watch.Stop();
            var order = placeOrder.Result;

            Console.WriteLine("Time Elapsed: " + watch.ElapsedMilliseconds);

            return(order);
        }
示例#10
0
        public HitResponse CheckHit(Coords shot)
        {
            HitResponse res = HitResponse.Miss;

            for (int i = 0; i < aliveSquares.Count; i++)
            {
                if (aliveSquares[i].Equals(shot))
                {
                    aliveSquares.RemoveAt(i);
                    if (aliveSquares.Count > 0)
                    {
                        res = HitResponse.Hit;
                    }
                    else
                    {
                        res       = HitResponse.Destroy;
                        destroyed = true;
                    }
                }
            }
            return(res);
        }
    public uint CheckLastNote(int key)
    {
        if (bGameOver)
        {
            return(0);
        }

        bool          isHit         = false;
        uint          hitLevel      = 0;
        HitResponse   hitResp       = hitWindow.GetComponent <HitResponse>();
        Vector3       hitPosition   = hitWindow.transform.position;
        GUIController guiController = gameObject.GetComponent <GUIController>();

        //Get the leftmost note, if available
        LinkedListNode <Note> aNote = notes.First;

        while (aNote != null && aNote.Value != null)
        {
            Note noteScript = aNote.Value.GetComponent <Note>();
            hitIndicateText.transform.position = aNote.Value.transform.position + new Vector3(10.0f, 0, 0);
            //if (noteScript.Type != key)
            //    continue;

            float hitDiff = noteScript.GetHitDiff(Time.time);//= Mathf.Abs(hitPosition.x - aNote.Value.transform.position.x); // TODO
            if (hitDiff <= hitMargin)
            {
                if (hitDiff <= greatHitMargin)
                {
                    hitIndicateText.GetComponent <hitIndicate>().Show("Great");
                    hitLevel = 3;
                    ++numGreatHit;
                }
                else if (hitDiff <= goodHitMargin)
                {
                    hitIndicateText.GetComponent <hitIndicate>().Show("Good");
                    hitLevel = 2;
                    ++numGoodHit;
                }
                else
                {
                    hitIndicateText.GetComponent <hitIndicate>().Show("OK");
                    hitLevel = 1;
                    ++numOkHit;
                }

                hitResp.PlayHitEffect();
                isHit = true;

                notes.Remove(aNote);
                //noteScript.Die();
                aNote.Value.Disappear(false);
                aNote.Value.launcher.TriggerExplosion();
                break;
            }

            aNote = aNote.Next;
        }
        if (!isHit)
        {
            MissedNote();
        }
        else
        {
            ++comboCount;
            score += 100 * (1 + comboCount);
            scoreText.GetComponent <TextMesh>().text = "Score:" + score;
            comboText.GetComponent <TextMesh>().text = "HIT:" + comboCount;

            //Show special text to indicate
            //the player 5x combo has reached
            if (comboCount % 5 == 0)
            {
                comboValueText.GetComponent <ComboValue>().SetText(comboCount.ToString() + "x Bonus");
                comboValueText.GetComponent <ComboValue>().Show();
                int cheerType = Random.Range(0, cheersSounds.Count - 1);
                if (!cheersSounds[cheerType].isPlaying)
                {
                    StartCoroutine(PlayAudioSourceForDuration(cheersSounds[cheerType], 5.0f));
                }
            }

            guiController.IncreLiveBar(1);
        }

        return(hitLevel);
    }
    public void ReleaseHitButton()
    {
        HitResponse hitResp = hitWindow.GetComponent <HitResponse>();

        hitResp.Release();
    }
示例#13
0
 private static void ResponseBasicCheck <T>(HitResponse <T> hitResponse)
 {
     Assert.IsNotNull(hitResponse);
     Assert.IsNull(hitResponse.Error);
     Assert.IsNotNull(hitResponse.Result);
 }
示例#14
0
 void Awake()
 {
     hitResponse = GetComponent <HitResponse>();
     maxHealth   = maxHealthInitial;
     restore();
 }
示例#15
0
        public void SetResponse(HitResponse response)
        {
            this.response = response as HitResponse <T>;

            this.Abort();
        }