예제 #1
0
        void OnPlayerDied(Player p)
        {
            if (!Remaining.Remove(p) || !RoundInProgress)
            {
                return;
            }
            Player[] players = Remaining.Items;

            switch (players.Length)
            {
            case 1:
                Map.Message(players[0].ColoredName + " %Sis the winner!");
                EndRound(players[0]);
                break;

            case 2:
                Map.Message("Only 2 Players left:");
                Map.Message(players[0].ColoredName + " %Sand " + players[1].ColoredName);
                break;

            default:
                Map.Message(players.Length + " players left!");
                break;
            }
            UpdateAllStatus2();
        }
예제 #2
0
        protected override bool Receive(object message) => message.Match()
        .With <ReadResult>(x =>
        {
            if (_result != null && x.Envelope != null)
            {
                _result = _result.Merge(x.Envelope.Data);
            }
            else if (_result == null && x.Envelope != null)
            {
                _result = x.Envelope;
            }
            else if (_result != null && x.Envelope == null)
            {
                _result = _result;
            }
            else
            {
                _result = null;
            }

            Remaining = Remaining.Remove(Sender.Path.Address);
            if (Remaining.Count == DoneWhenRemainingSize)
            {
                Reply(true);
            }
        })
        .With <SendToSecondary>(x =>
        {
            foreach (var n in PrimaryAndSecondaryNodes.Value.Item2)
            {
                Replica(n).Tell(_read);
            }
        })
        .With <ReceiveTimeout>(_ => Reply(false))
        .WasHandled;
예제 #3
0
        public void EndRound(Player winner)
        {
            squaresLeft.Clear();
            RoundInProgress = false;
            Remaining.Clear();
            squaresLeft.Clear();
            UpdateAllStatus();
            if (FreezeMode)
            {
                UpdateAllMotd();
            }

            if (winner != null)
            {
                winner.Message("Congratulations, you won this round of countdown!");
                PlayerActions.Respawn(winner);
            }
            else
            {
                Player[] players = Players.Items;
                foreach (Player pl in players)
                {
                    PlayerActions.Respawn(pl);
                }
            }
        }
예제 #4
0
    IEnumerator Start()
    {
        foreach (var go in duplicateMe)
        {
            go.GetComponent <MeshRenderer>().enabled = false;
            go.GetComponent <Collider>().enabled     = false;
        }

        /* wait until we hit the finalbigcell once */
        float initial_energy = finalHexCell.energy;

        while (initial_energy == finalHexCell.energy)
        {
            yield return(null);
        }
        SetIgnoreHits(true);

        /* Spawn coroutines that handle the regular HexCells appearing */

        Ball.speed_limit += 0.01f;   /* will increase further in PongPadBuilder.KilledOneCell */

        foreach (var go in duplicateMe)
        {
            var rem = new Remaining {
                remaining = numberOfDuplicates, lives = new List <Rigidbody>()
            };
            StartCoroutine(DuplicateMe(go, rem));
            StartCoroutine(DisposeMe(go, rem));
        }
    }
예제 #5
0
        public Analysize(Remaining remaining, IStrategy st)
        {
            ema     = new EMA();
            bands   = st.Base > 1 && st.Sigma > 0 && st.Percent > 0 && st.Max > 0 ? true : false;
            days    = st.ShortDayPeriod > 1 && st.LongDayPeriod > 2 ? true : false;
            count   = st.Quantity + 1;
            Headway = st.Time;

            if (bands)
            {
                over     = new BollingerBands(st.Sigma * 0.1, st.Base, st.Percent, st.Max);
                baseTick = new List <double>(2097152);
            }
            if (days)
            {
                shortDay = new List <double>(512);
                longDay  = new List <double>(512);
            }
            shortTick      = new List <double>(2097152);
            longTick       = new List <double>(2097152);
            Send          += Analysis;
            this.st        = st;
            info           = new Information(st);
            this.remaining = remaining;
            GetChart();
            info.Log();
        }
예제 #6
0
        protected override bool Receive(object message) => message.Match()
        .With <ReadResult>(x =>
        {
            if (x.Envelope != null)
            {
                _result = _result?.Merge(x.Envelope) ?? x.Envelope;
            }

            Remaining = Remaining.Remove(Sender.Path.Address);
            var done  = DoneWhenRemainingSize;
            Log.Debug("read acks remaining: {0}, done when: {1}, current state: {2}", Remaining.Count, done, _result);
            if (Remaining.Count == done)
            {
                Reply(true);
            }
        })
        .With <SendToSecondary>(x =>
        {
            foreach (var n in SecondaryNodes)
            {
                Replica(n).Tell(_read);
            }
        })
        .With <ReceiveTimeout>(_ => Reply(false))
        .WasHandled;
예제 #7
0
        protected override bool Receive(object message) => message.Match()
        .With <WriteAck>(x =>
        {
            Remaining = Remaining.Remove(SenderAddress);
            if (IsDone)
            {
                Reply(isTimeout: false);
            }
        })
        .With <WriteNack>(x =>
        {
            _gotNackFrom = _gotNackFrom.Add(SenderAddress);
            if (IsDone)
            {
                Reply(isTimeout: false);
            }
        })
        .With <DeltaNack>(_ =>
        {
            // ok, will be retried with full state
        })
        .With <UpdateSuccess>(x =>
        {
            _gotLocalStoreReply = true;
            if (IsDone)
            {
                Reply(isTimeout: false);
            }
        })
        .With <StoreFailure>(x =>
        {
            _gotLocalStoreReply = true;
            _gotNackFrom        = _gotNackFrom.Remove(_selfUniqueAddress.Address);
            if (IsDone)
            {
                Reply(isTimeout: false);
            }
        })
        .With <SendToSecondary>(x =>
        {
            // Deltas must be applied in order and we can't keep track of ordering of
            // simultaneous updates so there is a chance that the delta could not be applied.
            // Try again with the full state to the primary nodes that have not acked.
            if (_delta != null)
            {
                foreach (var address in PrimaryNodes.Intersect(Remaining))
                {
                    Replica(address).Tell(_write);
                }
            }

            foreach (var n in SecondaryNodes)
            {
                Replica(n).Tell(_write);
            }
        })
        .With <ReceiveTimeout>(x => Reply(isTimeout: true))
        .WasHandled;
예제 #8
0
        /// <summary>
        /// Returns true if InventoryOrderStatistic instances are equal
        /// </summary>
        /// <param name="other">Instance of InventoryOrderStatistic to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(InventoryOrderStatistic other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Id == other.Id ||
                     Id != null &&
                     Id.Equals(other.Id)
                     ) &&
                 (
                     Total == other.Total ||
                     Total != null &&
                     Total.Equals(other.Total)
                 ) &&
                 (
                     Default == other.Default ||
                     Default != null &&
                     Default.Equals(other.Default)
                 ) &&
                 (
                     Missed == other.Missed ||
                     Missed != null &&
                     Missed.Equals(other.Missed)
                 ) &&
                 (
                     Broken == other.Broken ||
                     Broken != null &&
                     Broken.Equals(other.Broken)
                 ) &&
                 (
                     Active == other.Active ||
                     Active != null &&
                     Active.Equals(other.Active)
                 ) &&
                 (
                     Remaining == other.Remaining ||
                     Remaining != null &&
                     Remaining.Equals(other.Remaining)
                 ) &&
                 (
                     Research == other.Research ||
                     Research != null &&
                     Research.Equals(other.Research)
                 ) &&
                 (
                     Transferred == other.Transferred ||
                     Transferred != null &&
                     Transferred.Equals(other.Transferred)
                 ));
        }
예제 #9
0
 void HandlePlayerSpawning(Player p, ref Position pos, ref byte yaw, ref byte pitch, bool respawning)
 {
     if (!respawning || !Remaining.Contains(p))
     {
         return;
     }
     Map.Message(p.ColoredName + " &Sis out of countdown!");
     OnPlayerDied(p);
 }
예제 #10
0
 public override int GetHashCode()
 {
     return(HashCodeHelper.GetHashCode(
                Limited.GetHashCode(),
                MaxLimit.GetHashCode(),
                Remaining.GetHashCode(),
                ResetAfter.GetHashCode(),
                RetryAfter.GetHashCode()));
 }
예제 #11
0
        private void StartBackTesting(IStrategySetting set)
        {
            button.Text        = string.Concat("Estimated Back Testing Time is ", pro.Rate(Estimate.Count, count).ToString("N0"), " Minutes.");
            button.ForeColor   = Color.Maroon;
            checkBox.ForeColor = Color.DarkRed;
            checkBox.Text      = "BackTesting";
            new Transmit(asset.Account, set.Capital);
            string path = Path.Combine(Application.StartupPath, @"..\Log\", DateTime.Now.Hour > 23 || DateTime.Now.Hour < 9 ? DateTime.Now.AddDays(-1).ToString("yyMMdd") : DateTime.Now.ToString("yyMMdd"));

            InterLink = false;
            List <Specify> list = new List <Specify>(131072);

            foreach (string str in Estimate)
            {
                string[] temp = str.Split('^');
                list.Add(new Specify
                {
                    ShortTickPeriod = int.Parse(temp[0]),
                    ShortDayPeriod  = int.Parse(temp[1]),
                    LongTickPeriod  = int.Parse(temp[2]),
                    LongDayPeriod   = int.Parse(temp[3]),
                    Reaction        = int.Parse(temp[4]),
                    Hedge           = int.Parse(temp[5]),
                    Base            = int.Parse(temp[6]),
                    Sigma           = int.Parse(temp[7]),
                    Percent         = int.Parse(temp[8]),
                    Max             = int.Parse(temp[9]),
                    Quantity        = int.Parse(temp[10]),
                    Time            = int.Parse(temp[11]),
                    Repository      = options.Repository,
                    BasicAssets     = set.Capital,
                    PathLog         = path,
                    Strategy        = str
                });
            }
            EstimateCount = Estimate.Count;
            Estimate      = null;
            GC.Collect();
            Count = Process.GetCurrentProcess().Threads.Count;
            new Task(() =>
            {
                Remaining remaining = new Remaining();
                Parallel.ForEach(list, new ParallelOptions
                {
                    MaxDegreeOfParallelism = (int)(Environment.ProcessorCount * 1.5)
                },
                                 new Action <Specify>((analysis) =>
                {
                    new Analysize(remaining, analysis);
                    pro.ProgressBarValue++;
                }));
                list             = null;
                button.ForeColor = Color.Yellow;
                SetMarketTick(GC.GetTotalMemory(true));
            }).Start();
        }
예제 #12
0
        public void Add(Item item)
        {
            // Dupe-check list

            bool stacked = item.StackCount > 1 ||
                           _cache.StackableRecords.Contains(item.BaseRecord) ||
                           _cache.SpecialRecords.Contains(item.BaseRecord); // Special "single seed" items.

            if (stacked)
            {
                Stacked.Add(item);
                All.Add(item);
                return;
            }

            // TODO: Detect slith rings etc


            // We don't have this record at all, unknown to IA. Probably need to parse DB.
            bool unknownItem = !_cache.AllRecords.Contains(item.BaseRecord);

            if (unknownItem)
            {
                if (item.BaseRecord.StartsWith("records/storyelements/rewards/"))
                {
                    Quest.Add(item);
                }
                else
                {
                    Unknown.Add(item);
                }

                All.Add(item);
                return;
            }

            // We already have this item..
            if (All.Any(m => m.Equals(item)))
            {
                Duplicates.Add(item);
                All.Add(item);
                return;
            }

            // We already have this item..
            if (_playerItemDao.Exists(TransferStashService.Map(item, null, false)))
            {
                Duplicates.Add(item);
                All.Add(item);
                return;
            }

            Remaining.Add(item);
            All.Add(item);
        }
예제 #13
0
        /* Decrease Remaining, Update Button, and Close with Yes Result on 0. */

        private void TmrConfirm_Tick(object sender, EventArgs e)
        {
            Remaining--;
            btnYes.Text = Remaining.ToString();

            if (Remaining == 0)
            {
                DialogResult = DialogResult.Yes;
                Close();
            }
        }
예제 #14
0
        internal void UpdateRemaining(double remaining)
        {
            Remaining.UT = remaining;

            //Do we need to update strings?
            if (Math.Floor(remaining) != _lastRemainingUTStringUpdate)
            {
                _remainingTimeStamp3         = Remaining.ToStringStandard(KerbalAlarmClock.settings.TimeSpanFormat, 3);
                _lastRemainingUTStringUpdate = Math.Floor(remaining);
            }
        }
예제 #15
0
 private Receive WaitRepairAck(DataEnvelope envelope) => msg => msg.Match()
 .With <ReadRepairAck>(x =>
 {
     var reply = envelope.Data is DeletedData
             ? (object)new DataDeleted(_key, null)
             : new GetSuccess(_key, _req, envelope.Data);
     _replyTo.Tell(reply, Context.Parent);
     Context.Stop(Self);
 })
 .With <ReadResult>(x => Remaining = Remaining.Remove(Sender.Path.Address))
 .With <SendToSecondary>(_ => { })
 .With <ReceiveTimeout>(_ => { })
 .WasHandled;
 /// <summary>
 /// Returns a string that represents the current object.
 /// </summary>
 /// <returns>
 /// A string that represents the current object.
 /// </returns>
 public override string ToString()
 {
     return($"OrderId: {OrderId.ToStringInvariant()}, " +
            $"Status: {Status}, " +
            $"Filled: {Filled.ToStringInvariant()}, " +
            $"Remaining: {Remaining.ToStringInvariant()}, " +
            $"AverageFillPrice: {AverageFillPrice.ToStringInvariant()}, " +
            $"PermId: {PermId.ToStringInvariant()}, " +
            $"ParentId: {ParentId.ToStringInvariant()}, " +
            $"LastFillPrice: {LastFillPrice.ToStringInvariant()}, " +
            $"ClientId: {ClientId.ToStringInvariant()}, " +
            $"WhyHeld: {WhyHeld}");
 }
예제 #17
0
        void BeginRound()
        {
            if (Interval == 0)
            {
                SetSpeed("normal");
            }
            string modeSuffix = FreezeMode ? " in freeze mode" : "";

            Map.Message("Starting " + SpeedType + " speed Countdown" + modeSuffix);

            if (FreezeMode)
            {
                Map.Message("You have 20 seconds to stand on a square");
                Map.Message("You won't be able to move from that square once the game starts!");
                DoCountdown("&b{0} &Sseconds left", 20, 20);
            }
            else
            {
                Map.Message("You have 5 seconds before squares start disappearing");
                DoCountdown("&b{0} &Sseconds left", 5, 5);
            }

            if (!Running)
            {
                return;
            }
            Map.Message("GO!!!!!!!");

            Player[] players = Players.Items;
            Remaining.Clear();
            foreach (Player pl in players)
            {
                Remaining.Add(pl);
            }

            if (!Running || !FreezeMode)
            {
                return;
            }
            Map.Message("&bPlayers Frozen");

            foreach (Player pl in players)
            {
                Position pos = pl.Pos;
                pl.Extras["MCG_CD_X"] = pos.X;
                pl.Extras["MCG_CD_Z"] = pos.Z;
            }
            RemoveAllSquareBorders();
        }
 public override int GetHashCode()
 {
     unchecked
     {
         var hashCode = (WorkCell != null ? WorkCell.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (WorkUnit != null ? WorkUnit.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ Actual.GetHashCode();
         hashCode = (hashCode * 397) ^ Remaining.GetHashCode();
         hashCode = (hashCode * 397) ^ Set.GetHashCode();
         hashCode = (hashCode * 397) ^ OverflowRemaining.GetHashCode();
         hashCode = (hashCode * 397) ^ OverflowSet.GetHashCode();
         hashCode = (hashCode * 397) ^ (RuleName != null ? RuleName.GetHashCode() : 0);
         hashCode = (hashCode * 397) ^ (RuleType != null ? RuleType.GetHashCode() : 0);
         return(hashCode);
     }
 }
예제 #19
0
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (Id != null)
         {
             hashCode = hashCode * 59 + Id.GetHashCode();
         }
         if (Total != null)
         {
             hashCode = hashCode * 59 + Total.GetHashCode();
         }
         if (Default != null)
         {
             hashCode = hashCode * 59 + Default.GetHashCode();
         }
         if (Missed != null)
         {
             hashCode = hashCode * 59 + Missed.GetHashCode();
         }
         if (Broken != null)
         {
             hashCode = hashCode * 59 + Broken.GetHashCode();
         }
         if (Active != null)
         {
             hashCode = hashCode * 59 + Active.GetHashCode();
         }
         if (Remaining != null)
         {
             hashCode = hashCode * 59 + Remaining.GetHashCode();
         }
         if (Research != null)
         {
             hashCode = hashCode * 59 + Research.GetHashCode();
         }
         if (Transferred != null)
         {
             hashCode = hashCode * 59 + Transferred.GetHashCode();
         }
         return(hashCode);
     }
 }
예제 #20
0
 protected override bool Receive(object message) => message.Match()
 .With <WriteAck>(x =>
 {
     Remaining = Remaining.Remove(SenderAddress);
     if (Remaining.Count == DoneWhenRemainingSize)
     {
         Reply(true);
     }
 })
 .With <SendToSecondary>(x =>
 {
     foreach (var n in PrimaryAndSecondaryNodes.Value.Item2)
     {
         Replica(n).Tell(_write);
     }
 })
 .With <ReceiveTimeout>(x => Reply(false))
 .WasHandled;
예제 #21
0
 protected override bool Receive(object message) => message.Match()
 .With <WriteAck>(x =>
 {
     Remaining = Remaining.Remove(SenderAddress);
     if (IsDone)
     {
         Reply(isTimeout: false);
     }
 })
 .With <WriteNack>(x =>
 {
     _gotNackFrom = _gotNackFrom.Remove(SenderAddress);
     if (IsDone)
     {
         Reply(isTimeout: false);
     }
 })
 .With <UpdateSuccess>(x =>
 {
     _gotLocalStoreReply = true;
     if (IsDone)
     {
         Reply(isTimeout: false);
     }
 })
 .With <StoreFailure>(x =>
 {
     _gotLocalStoreReply = true;
     _gotNackFrom        = _gotNackFrom.Remove(Cluster.Cluster.Get(Context.System).SelfAddress);
     if (IsDone)
     {
         Reply(isTimeout: false);
     }
 })
 .With <SendToSecondary>(x =>
 {
     foreach (var n in SecondaryNodes)
     {
         Replica(n).Tell(_write);
     }
 })
 .With <ReceiveTimeout>(x => Reply(isTimeout: true))
 .WasHandled;
예제 #22
0
        protected void Page_Load(object sender, EventArgs e)
        {
            SqlCommand     cmd = new SqlCommand("select AccountMaster.MemberID ,tblmembermaster.UserName,Sum(case when dateoftransaction>=getdate()then isnull(Credit,0) else 0 end) as Remaining, Sum(case when dateoftransaction<getdate()then isnull(Credit,0) else 0 end) as Paid,Sum(Credit) as Total from AccountMaster Inner Join tblMemberMaster on AccountMaster.MemberID=tblMemberMaster.UserCode WHERE TxnType=3 Group by AccountMaster.MemberID,tblmembermaster.UserName", con);
            SqlDataAdapter da  = new SqlDataAdapter(cmd);

            using (DataTable dt = new DataTable())
            {
                da.Fill(dt);
                GridView1.DataSource = dt;
                GridView1.DataBind();
                total     = dt.AsEnumerable().Sum(row => row.Field <decimal>("Total"));
                Paid      = dt.AsEnumerable().Sum(row => row.Field <decimal>("Paid"));
                Remaining = dt.AsEnumerable().Sum(row => row.Field <decimal>("Remaining"));
                GridView1.FooterRow.Cells[2].Text = "Total";
                GridView1.FooterRow.Cells[3].Text = total.ToString();
                GridView1.FooterRow.Cells[4].Text = Paid.ToString();
                GridView1.FooterRow.Cells[5].Text = Remaining.ToString();
            }
        }
예제 #23
0
    IEnumerator DuplicateMe(GameObject prefab, Remaining rem)
    {
        Vector3 center = prefab.transform.position;

        while (true)
        {
            yield return(new WaitForSeconds(Random.Range(0.5f, 0.8f)));

            if (rem.remaining <= 0)
            {
                continue;
            }

            Rigidbody rb = DuplicateHexCell(prefab);
            rb.useGravity  = false;
            rb.isKinematic = true;
            Vector3 pos1    = rb.position;
            float   y_limit = pos1.y + 0.255f;

            rem.remaining -= 1;
            rem.lives.Add(rb);

            while (pos1.y < y_limit)
            {
                yield return(new WaitForFixedUpdate());

                if (rb == null)   /* destroyed already */
                {
                    break;
                }
                pos1 += Vector3.up * (0.35f * Time.fixedDeltaTime);
                rb.MovePosition(pos1);
            }

            if (rb != null)
            {
                rb.useGravity  = true;
                rb.isKinematic = false;
            }
        }
    }
예제 #24
0
        public Analysize(Remaining remaining, IStrategy st)
        {
            ema     = new EMA();
            days    = st.ShortDayPeriod > 1 && st.LongDayPeriod > 2 ? true : false;
            count   = st.Quantity + 1;
            Headway = st.Time;

            if (days)
            {
                shortDay = new List <double>(512);
                longDay  = new List <double>(512);
            }
            shortTick      = new List <double>(2097152);
            longTick       = new List <double>(2097152);
            Send          += Analysis;
            this.st        = st;
            info           = new Information(st);
            this.remaining = remaining;
            GetChart();
            info.Log();
        }
예제 #25
0
        /// <summary>
        /// Saves the door definition
        /// </summary>
        /// <param name="writer">XML writer handle</param>
        /// <returns></returns>
        public override bool Save(XmlWriter writer)
        {
            if (writer == null)
            {
                return(false);
            }


            writer.WriteStartElement(Tag);


            writer.WriteAttributeString("color", MessageColor.ToArgb().ToString());
            writer.WriteAttributeString("mustface", MustFace.ToString());
            writer.WriteAttributeString("direction", Direction.ToString());
            writer.WriteAttributeString("remaining", Remaining.ToString());
            writer.WriteAttributeString("soundname", SoundName);
            writer.WriteAttributeString("loopsound", LoopSound.ToString());
            writer.WriteAttributeString("displayborder", DisplayBorder.ToString());
            writer.WriteAttributeString("intelligence", Intelligence.ToString());
            writer.WriteAttributeString("message", Message);
            writer.WriteAttributeString("picturename", PictureName);

            //
            writer.WriteStartElement("text");
            writer.WriteString(Text);
            writer.WriteEndElement();



            foreach (ScriptChoice choice in Choices)
            {
                choice.Save(writer);
            }


            base.Save(writer);
            writer.WriteEndElement();

            return(true);
        }
예제 #26
0
        public override void GetProperties(ObjectPropertyList list)
        {
            if (Expires > DateTime.UtcNow)
            {
                if (DisplaySeconds)
                {
                    list.Add(1072517, Remaining.ToString()); // Lifespan: ~1_val~ seconds
                }
                else
                {
                    TimeSpan t = Expires - DateTime.UtcNow;

                    int weeks   = t.Days / 7;
                    int days    = t.Days;
                    int hours   = t.Hours;
                    int minutes = t.Minutes;

                    if (weeks > 1)
                    {
                        list.Add(1153092, (t.Days / 7).ToString()); // Lifespan: ~1_val~ weeks
                    }
                    else if (days > 1)
                    {
                        list.Add(1153091, t.Days.ToString()); // Lifespan: ~1_val~ days
                    }
                    else if (hours > 1)
                    {
                        list.Add(1153090, t.Hours.ToString()); // Lifespan: ~1_val~ hours
                    }
                    else if (minutes > 1)
                    {
                        list.Add(1153089, t.Minutes.ToString()); // Lifespan: ~1_val~ minutes
                    }
                    else
                    {
                        list.Add(1072517, t.Seconds.ToString()); // Lifespan: ~1_val~ seconds
                    }
                }
            }
        }
예제 #27
0
        void HandlePlayerMove(Player p, Position next, byte yaw, byte pitch)
        {
            if (!RoundInProgress || !FreezeMode)
            {
                return;
            }
            if (!Remaining.Contains(p))
            {
                return;
            }

            int freezeX = p.Extras.GetInt("MCG_CD_X");
            int freezeZ = p.Extras.GetInt("MCG_CD_Z");

            if (next.X != freezeX || next.Z != freezeZ)
            {
                next.X = freezeX; next.Z = freezeZ;
                p.SendPos(Entities.SelfID, next, new Orientation(yaw, pitch));
            }

            p.Pos = next;
            p.SetYawPitch(yaw, pitch);
            p.cancelmove = true;
        }
예제 #28
0
    IEnumerator DisposeMe(GameObject prefab, Remaining rem)
    {
        Vector3 center = prefab.transform.position;

        center.y += 0.25f;

        while (rem.remaining + rem.lives.Count > 0)
        {
            int i = 0;
            while (i < rem.lives.Count)    /* rem.lives.Count can change */
            {
                var rb = rem.lives[i];
                if (rb == null)
                {
                    rem.lives[i] = rem.lives[rem.lives.Count - 1];
                    rem.lives.RemoveAt(rem.lives.Count - 1);
                    continue;
                }
                i++;

                if (rb.IsSleeping() && rb.position.y < 0.35f &&
                    Vector3.Distance(rb.position, center) > 0.1f)
                {
                    rb.useGravity  = false;
                    rb.isKinematic = true;
                    const float y_limit = -0.1f;
                    Vector3     pos1    = rb.position;

                    while (pos1.y > y_limit)
                    {
                        yield return(new WaitForFixedUpdate());

                        if (rb == null)   /* destroyed already */
                        {
                            break;
                        }
                        pos1 -= Vector3.up * (0.35f * Time.fixedDeltaTime);
                        rb.MovePosition(pos1);
                    }

                    if (rb != null)
                    {
                        Destroy((GameObject)rb.gameObject);
                        rem.remaining += 1;
                    }
                }
                else
                {
                    yield return(null);
                }
            }
            yield return(null);
        }

        Destroy((GameObject)prefab);

        complete += 1;
        if (complete == 3)
        {
            SetIgnoreHits(false);
        }
    }
 public bool PeekWord(string word)
 {
     return(Start + word.Length <= Remaining.Length && Remaining.ToString(Start, word.Length) == word);
 }
예제 #30
0
        protected override bool Receive(object message)
        {
            switch (message)
            {
            case WriteAck _:
                Remaining = Remaining.Remove(SenderAddress);
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case WriteNack _:
                _gotNackFrom = _gotNackFrom.Add(SenderAddress);
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case DeltaNack _:
                Sender.Tell(_write);
                return(true);

            case UpdateSuccess _:
                _gotLocalStoreReply = true;
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case StoreFailure _:
                _gotLocalStoreReply = true;
                _gotNackFrom        = _gotNackFrom.Add(_selfUniqueAddress.Address);
                if (IsDone)
                {
                    Reply(isTimeout: false);
                }
                return(true);

            case SendToSecondary _:
                if (_delta != null)
                {
                    // Deltas must be applied in order and we can't keep track of ordering of
                    // simultaneous updates so there is a chance that the delta could not be applied.
                    // Try again with the full state to the primary nodes that have not acked.
                    foreach (var address in PrimaryNodes)
                    {
                        if (Remaining.Contains(address))
                        {
                            Replica(address).Tell(_write);
                        }
                    }
                }

                foreach (var n in SecondaryNodes)
                {
                    Replica(n).Tell(_write);
                }
                return(true);

            case ReceiveTimeout _:
                Reply(isTimeout: true);
                return(true);
            }

            return(false);
        }