예제 #1
0
    public void SaveReplay()
    {
        GetInfoToSave();
        string       newfileName = filePath + fileName + ".txt";
        StreamWriter writer      = new StreamWriter(newfileName);

        //Populate
        while (pointsInTimeToSave.Count > 0)
        {
            PointInTime pointInTime = pointsInTimeToSave[0];
            string      tmpPos      = pointInTime.position.x.ToString() + ":" +
                                      pointInTime.position.y.ToString() + ":" +
                                      pointInTime.position.z.ToString();

            string tmpRot = pointInTime.rotation.x.ToString() + ":" +
                            pointInTime.rotation.y.ToString() + ":" +
                            pointInTime.rotation.z.ToString() + ":" +
                            pointInTime.rotation.w.ToString();

            string output = tmpPos + ":" + tmpRot;
            writer.WriteLine(output);
            pointsInTimeToSave.RemoveAt(0);
            //print(output);
        }
        writer.Close();
    }
예제 #2
0
    public void SetPointInTime(float point)
    {
        if (isWarping && recordAmount > 0)
        {
            int total = recordAmount - 1;

            int offset          = ((int)recordTime * (int)(recordsPerSecond)) - recordAmount;
            int normalizedIndex = Mathf.FloorToInt(point * (total - 1));

            int desiredIndex = normalizedIndex - (total - warpIndex);
            if (desiredIndex < 0)
            {
                desiredIndex = total + desiredIndex + 1 + offset;
            }

            try
            {
                PointInTime pointInTime = pointsInTime[desiredIndex];
                transform.position = pointInTime.position;
                transform.rotation = pointInTime.rotation;

                currentIndex = desiredIndex;
            }
            catch (IndexOutOfRangeException e)
            {
                Debug.Log(e.ToString() + " " + desiredIndex);
            }
        }
    }
예제 #3
0
 void Rewinding()
 {
     if (pointsInTime.Count > 0)
     {
         PointInTime poinInTime = pointsInTime[0];
         transform.position = poinInTime.position;
         transform.rotation = poinInTime.rotation;
         pointsInTime.RemoveAt(0);
     }
     else
     {
         if (gameObject.tag == "FractRoot")
         {
             if (SceneManager.GetActiveScene().name == "TwoObjWater" || SceneManager.GetActiveScene().name == "TwoObjPine")
             {
                 GameObject obj1 = GameObject.Find("Obj1");
                 GameObject obj2 = GameObject.Find("Obj2");
                 obj1.GetComponent <MeshRenderer>().enabled    = true;
                 obj1.GetComponent <CapsuleCollider>().enabled = true;
                 obj2.GetComponent <MeshRenderer>().enabled    = true;
                 obj2.GetComponent <CapsuleCollider>().enabled = true;
                 gameObject.SetActive(false);
             }
             else
             {
                 GameObject.FindWithTag("Obj").GetComponent <MeshRenderer>().enabled    = true;
                 GameObject.FindWithTag("Obj").GetComponent <CapsuleCollider>().enabled = true;
                 gameObject.SetActive(false);
             }
         }
         StopRewind();
     }
 }
예제 #4
0
 private void RecordThisTimestep()
 {
     if (IndexOfMostRecentPointInTime > 0)
     {
         PointInTime lastPoint = pointsInTime[IndexOfMostRecentPointInTime];
         if (transform.position == lastPoint.position && transform.rotation == lastPoint.rotation)
         {
             if (stillFrameCounter.ContainsKey(IndexOfMostRecentPointInTime))
             {
                 stillFrameCounter[IndexOfMostRecentPointInTime]++;
             }
             else
             {
                 stillFrameCounter.Add(IndexOfMostRecentPointInTime, 1);
             }
         }
         else
         {
             pointsInTime.Add(new PointInTime(transform.position, transform.rotation, rb.velocity, rb.angularVelocity));
         }
     }
     else
     {
         pointsInTime.Add(new PointInTime(transform.position, transform.rotation, rb.velocity, rb.angularVelocity));
     }
 }
예제 #5
0
    private void Rewind()
    {
        if (pointsInTime.Count > 0)
        {
            // Set transform and velocities
            PointInTime pointInTime = pointsInTime[IndexOfMostRecentPointInTime];
            SetObjectToPointInTime(pointInTime);

            // Manage the stillFrameCounter and the pointsInTime
            if (stillFrameCounter.ContainsKey(IndexOfMostRecentPointInTime))
            {
                stillFrameCounter[IndexOfMostRecentPointInTime]--;

                //Debug.Log("Time --> " + Time.time + " --- Popping key " + IndexOfMostRecentPointInTime + ": indices left --> " + stillFrameCounter[IndexOfMostRecentPointInTime]);
                if (stillFrameCounter[IndexOfMostRecentPointInTime] == 0)
                {
                    int index = IndexOfMostRecentPointInTime;
                    pointsInTime.RemoveAt(index);
                    stillFrameCounter.Remove(index);
                }
            }
            else
            {
                pointsInTime.RemoveAt(IndexOfMostRecentPointInTime);
            }
        }
        else
        {
            StopRewind();
        }
    }
예제 #6
0
 List <PointInTime> CalDiscount(DicMallitemEntity entity)
 {
     if (string.IsNullOrEmpty(entity.CurrencyDiscount))
     {
         return(new List <PointInTime>(0));
     }
     else
     {
         //0,0~100&1000,2000~60
         string[] commandValues = entity.CurrencyDiscount.Split('&');
         var      pointInTimes  = new List <PointInTime>(commandValues.Length);
         foreach (var commandValue in commandValues)
         {
             string[] rateInTimes = commandValue.Split('~');
             string[] times       = rateInTimes[0].Split(',');
             int      discount    = Convert.ToInt32(rateInTimes[1]);
             var      pointEntity = new PointInTime();
             pointEntity.Point     = entity.CurrencyCount * discount / 100;
             pointEntity.StartTime = ShareUtil.BaseTime.AddMinutes(Convert.ToInt32(times[0]));
             pointEntity.EndTime   = ShareUtil.BaseTime.AddMinutes(Convert.ToInt32(times[1]));
             pointInTimes.Add(pointEntity);
         }
         return(pointInTimes);
     }
 }
예제 #7
0
        private ChartPoint CreateChartPoint(PointInTime point, IDateTimeHelper dateTimeHelper, string pattern)
        {
            // TODO: Conversion to local date time should be moved to services
            string stringDate = string.Format(pattern, dateTimeHelper.GetLocalUserDate(point.Date));

            return(new ChartPoint(stringDate, point.Value));
        }
예제 #8
0
    public void UpdateFreeze()
    {
        offset += Time.fixedDeltaTime;
        PointInTime pointInTime = pointsInTime[0];

        transform.position = pointInTime.position;
        transform.rotation = pointInTime.rotation;
    }
예제 #9
0
    void Rewind()
    {
        if (pointsInTime.Count > 0)
        {
            PointInTime pointInTime = pointsInTime[0];
            transform.position   = pointInTime.position;
            canvas.rotation      = pointInTime.rotation;
            myRigidBody.velocity = pointInTime.velocity;
            up             = pointInTime.up;
            down           = pointInTime.down;
            sideways       = pointInTime.sideways;
            sprite.enabled = pointInTime.spriteActive;
            if (myRigidBody.velocity.z < 0)
            {
                up       = true;
                down     = false;
                sideways = false;
            }
            if (myRigidBody.velocity.z > 0)
            {
                up       = false;
                down     = true;
                sideways = false;
            }
            if (myRigidBody.velocity.x != 0)
            {
                up       = false;
                down     = false;
                sideways = true;
            }

            myAnim.SetBool("Up", up);
            myAnim.SetBool("Down", down);
            myAnim.SetBool("Vertical", sideways);
            pointsInTime.RemoveAt(0);
            acceleration += Time.deltaTime;
            if (acceleration > 0.8 && pointsInTime.Count > 0)
            {
                pointsInTime.RemoveAt(0);
            }
            if (acceleration > 1.4 && pointsInTime.Count > 1)
            {
                pointsInTime.RemoveAt(0);
            }
            if (acceleration > 1.8 && pointsInTime.Count > 2)
            {
                pointsInTime.RemoveAt(0);
            }
            if (acceleration > 2 && pointsInTime.Count > 3)
            {
                pointsInTime.RemoveAt(0);
            }
        }
        else
        {
            StopRewind();
        }
    }
예제 #10
0
        /// <inheritdoc />
        protected override void Print(ExpressionPrinter expressionPrinter)
        {
            if (!string.IsNullOrEmpty(Schema))
            {
                expressionPrinter.Append(Schema).Append(".");
            }

            expressionPrinter
            .Append(Name)
            .Append(" FOR SYSTEM_TIME ");

            switch (TemporalOperationType)
            {
            case TemporalOperationType.AsOf:
                expressionPrinter
                .Append("AS OF ")
                .Append(PointInTime.ToString() !);
                break;

            case TemporalOperationType.FromTo:
                expressionPrinter
                .Append("FROM ")
                .Append(From.ToString() !)
                .Append(" TO ")
                .Append(To.ToString() !);
                break;

            case TemporalOperationType.Between:
                expressionPrinter
                .Append("BETWEEN ")
                .Append(From.ToString() !)
                .Append(" AND ")
                .Append(To.ToString() !);
                break;

            case TemporalOperationType.ContainedIn:
                expressionPrinter
                .Append("CONTAINED IN (")
                .Append(From.ToString() !)
                .Append(", ")
                .Append(To.ToString() !)
                .Append(")");
                break;

            default:
                // TemporalOperationType.All
                expressionPrinter
                .Append("ALL");
                break;
            }

            if (Alias != null)
            {
                expressionPrinter.Append(" AS ").Append(Alias);
            }
        }
예제 #11
0
    /// <summary>
    /// Record a point in time and do all appropriate logic.
    /// </summary>
    private void RecordPoint()
    {
        //Store the current position and rotation in a PointInTime.
        recordedPoint = new PointInTime(transform.position, transform.rotation);

        //Now uparent the player's outer core from the player and put it in the recorded position.
        outerCore.parent   = null;
        outerCore.position = recordedPoint.position;
        outerCore.rotation = recordedPoint.rotation;
    }
예제 #12
0
 void ReWind()
 {
     Time.timeScale = 1;
     if (pointsInTime.Count > 0)
     {
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(0);
     }
 }
예제 #13
0
    private void SetObjectToPointInTime(PointInTime pointInTime)
    {
        transform.position = pointInTime.position;
        transform.rotation = pointInTime.rotation;

        if (conserveVelocity)
        {
            rb.velocity        = -pointInTime.velocity;
            rb.angularVelocity = -pointInTime.angularVelocity;
        }
    }
예제 #14
0
 void Rewind()
 {
     if (pointsInTime.Count > 0)
     {
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         pointsInTime.RemoveAt(0);
     }
     else
     {
         StopRewind();
     }
 }
예제 #15
0
 private void Rewind()
 {
     if (_pointsInTime.Count > 0)
     {
         PointInTime pointInTime = _pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         _pointsInTime.RemoveAt(0);
     }
     else
     {
         StopRewinding();
     }
 }
예제 #16
0
 //Default Constructor
 public ClientConnection(TcpClient Connection)
 {
     //Store the connection and assign a new network ID
     this.Connection = Connection;
     ClientID        = ((IPEndPoint)Connection.Client.RemoteEndPoint).Port;
     //Set up the datastream and buffer for listening for messages from the client
     Connection.SendBufferSize    = 262144;
     Connection.ReceiveBufferSize = 262144;
     DataStream = Connection.GetStream();
     DataBuffer = new byte[Connection.Available];
     DataStream.BeginRead(DataBuffer, 0, DataBuffer.Length, ReadPacket, null);
     //Set the time of last contact to now
     LastCommunication = new PointInTime();
 }
예제 #17
0
    /// <summary>
    /// Moves the player back to the recorded point in time, and does other relevant logic.
    /// </summary>
    private void RewindToPoint()
    {
        //Move the player to the recorded PointInTime.
        transform.position = recordedPoint.position;
        transform.rotation = recordedPoint.rotation;

        //Reparent the outer core to the player and make sure it lines up with the player.
        outerCore.parent   = transform;
        outerCore.position = transform.position;
        outerCore.rotation = transform.rotation;

        //Erase the old recorded point because we just used it up.
        recordedPoint = null;
    }
예제 #18
0
 private void Play()
 {
     if (index >= 0)
     {
         PointInTime point = pointsInTime[index];
         transform.position = point.position;
         transform.rotation = point.rotation;
         index -= 1;
     }
     else
     {
         transform.Translate(Vector3.back);
     }
 }
예제 #19
0
 void Rewind()
 {
     if (positions.Count > 0)
     {
         PointInTime pointintime = positions [0];
         transform.position = pointintime.pos;
         transform.rotation = pointintime.rot;
         positions.RemoveAt(0);
     }
     else
     {
         StopRewind();
     }
 }
예제 #20
0
 void rewind()
 {
     if (rewindList.Count > 0)
     {
         PointInTime pointInTime = rewindList[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         rewindList.RemoveAt(0);
     }
     else
     {
         StopRewinding();
     }
 }
예제 #21
0
 public void Rewind()
 {
     if (pointsInTime.Count > 0)
     {
         PointInTime pointInTime = pointsInTime[pointsInTime.Count - 1];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(pointsInTime.Count - 1);
     }
     else
     {
         StopRewind();
     }
 }
예제 #22
0
 private void Rewind()
 {
     if (index < pointsInTime.Count - 1)
     {
         PointInTime point = pointsInTime[index];
         transform.position = point.position;
         transform.rotation = point.rotation;
         index += 1;
     }
     else
     {
         rewinding = false;
     }
 }
예제 #23
0
 private void Rewind()
 {
     if (pointsInTimes.Count > 0)
     {
         PointInTime pointInTime = pointsInTimes[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTimes.RemoveAt(0);
     }
     else
     {
         StopRewind();
     }
 }
예제 #24
0
 private void Replay()
 {
     if (pointsInTime.Count > 0)
     {
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(0);
     }
     else
     {
         playingReplay = false;
     }
 }
예제 #25
0
 public void RewindBackward()
 {
     if (pointsInTime.Count > 0)
     {
         offset += Time.fixedDeltaTime;
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(0);
     }
     else
     {
         StopRewind();
     }
 }
예제 #26
0
 void Rewind()
 {
     if (pointsInTime.Count > 0)
     {
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(0);
     }
     else
     {
         StopRewind();
         doSomething?.Invoke(4);
     }
 }
예제 #27
0
 void Rewind()
 {
     if (pointInTimes.Count > 0)
     {
         PointInTime pointInTime = pointInTimes[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointInTimes.RemoveAt(0);
     }
     else
     {
         StopRewind();
         GameObject.FindGameObjectWithTag("Time").GetComponent <TimeControlSystem>().TimeControl.value = 0;
     }
 }
        public ThumbnailGenerationOptions(PointInTime pointInTime, ImageType imageType, ImageSize imageSize)
        {
            if (pointInTime == null)
                throw new ArgumentNullException("pointInTime");

            if (imageType == null)
                throw new ArgumentNullException("imageType");

            if (imageSize == null)
                throw new ArgumentNullException("imageSize");

            PointInTime = pointInTime;
            ImageType = imageType;
            ImageSize = imageSize;
        }
 public void Rewind()
 {
     if (pointsInTime.Count > 0)
     {
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(0);
         //Time.timeScale = 2;
     }
     else
     {
         StopRewind();
     }
 }
예제 #30
0
 void Rewind()
 {
     if (pointsInTime.Count > 0 && DataManager.Instance.playerTimeLapseFuel >= 0.03)
     {
         PointInTime pointInTime = pointsInTime[0];
         transform.position = pointInTime.position;
         transform.rotation = pointInTime.rotation;
         pointsInTime.RemoveAt(0);
         DataManager.Instance.playerTimeLapseFuel -= 0.2f * Time.deltaTime;
     }
     else
     {
         StopRewind();
     }
 }
예제 #31
0
    void Rewind()
    {
        if (pointsInTime.Count > 0)
        {
            rb.isKinematic = true;
            PointInTime pointInTime = pointsInTime.First.Value;
            transform.position = pointInTime.position;
            transform.rotation = pointInTime.rotation;
            pointsInTime.RemoveFirst();
        }

        if (pointsInTime.Count == 0)
        {
            turnSystem.ResetMatch();
        }
    }
예제 #32
0
 public static PointInTime CreatePointInTime(string @ref, global::System.DateTime date)
 {
     PointInTime pointInTime = new PointInTime();
     pointInTime.Ref = @ref;
     pointInTime.Date = date;
     return pointInTime;
 }