コード例 #1
0
    public void BuildPaths()
    {
        ActiveLocations.Clear();
        foreach (var p in CurrentMap)
        {
            p.NextDir.Clear();
        }
        CurrentMap.Clear();
        MapGraph.Clear();

        ActiveLocations = new List <Location>(KingdomManager.instance.ActiveLocations);

        BuildGraph();

        int currentUID = 0;

        foreach (var l in ActiveLocations)
        {
            currentUID = l.LocationUID;
            CurrentMap.Add(new PathFromThisLocation(l));

            foreach (var l2 in ActiveLocations)
            {
                List <NextDirection> dirList = CurrentMap [CurrentMap.Count - 1].NextDir;
                var nd = new NextDirection(l2);
                CalculateDirection(nd, currentUID);
                dirList.Add(nd);
            }
        }
    }
コード例 #2
0
ファイル: EndGame.cs プロジェクト: 1264109842/Sight-City
    // Use this for initialization
    void Start()
    {
        EasyTTSUtil.Initialize(EasyTTSUtil.UnitedStates);
        nextDir = new NextDirection();

        readGameResults();
        readNextChoice();
    }
コード例 #3
0
    // Use this for initialization
    void Start()
    {
        EasyTTSUtil.Initialize(EasyTTSUtil.UnitedStates);

        nextDir       = new NextDirection();
        rlc           = new RoomLocationsConf();
        infoBrg       = new TheInformationBridge();
        curVal        = 0;
        startPoint    = new Vector3(151.3f, 2f, -137.1f); //rlc.setStartingPoint ();
        endPoint      = new Vector3(52f, 2f, 17f);        //rlc.setEndingPoint ();
        agent.enabled = false;
        isFeet        = false;

        player.transform.position = startPoint;
        //Debug.Log (player.position+"********************");
        //player.transform.rotation = ;
        nextDir.setStart(startPoint);
        target.transform.position = endPoint;

        agent.enabled = true;


        //isTutored = false;
        instructMode = 0;
        path         = agent.path;

        //nextDirection = "";
        crntDirection = "";
        fourDir       = " ";

        //degree = 0;           No longer used to get next direction to way point

        calculatePath();
        isFirstTime = true;
        adjustDirection();
        numWayPoint = path.corners.Length;
        elapsed     = 0;

        curMsg              = "constantly redefined";
        difMsg              = "redefined only is curmsg changes";
        moveTurnInstruct    = 1;
        moveTurnInstructEnd = false;
        //Debug.Log (player.position+"++++++++");
        //for (int i = 0; i < path.corners.Length; i++)
        //Debug.Log (path.corners[i]);
        totalDistance();
    }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        infoBrg = new TheInformationBridge();
        mode    = infoBrg.getTutorialMode();
        EasyTTSUtil.Initialize(EasyTTSUtil.UnitedStates);

        nextDir       = new NextDirection();
        rlc           = new RoomLocationsConf();
        infoBrg       = new TheInformationBridge();
        curVal        = 0;
        startPoint    = new Vector3(50.4f, 2f, -50.7f);
        endPoint      = new Vector3(50f, 2f, 38.2f);
        agent.enabled = false;
        isFeet        = false;

        //player.transform.position = startPoint;
        //Debug.Log (player.position+"********************");
        //player.transform.rotation = ;
        nextDir.setStart(startPoint);
        target.transform.position = endPoint;

        agent.enabled = true;
        //mode = infoBrg.getTutorialMode ();


        path = agent.path;

        //nextDirection = "";
        crntDirection = "";
        fourDir       = " ";

        //degree = 0;           No longer used to get next direction to way point

        if (!infoBrg.getReachTarget())
        {
            calculatePath();
        }
        numWayPoint = path.corners.Length;
        elapsed     = 0;

        curMsg = "constantly redefined";
        difMsg = "redefined only is curmsg changes";
        //Debug.Log (player.position+"++++++++");
        //for (int i = 0; i < path.corners.Length; i++)
        //Debug.Log (path.corners[i]);
        //adjustDirection ();
    }
コード例 #5
0
ファイル: BlockFactory.cs プロジェクト: jnyborg/Tetris
 public void Rotate()
 {
     if (BlockShape == Shape.Square)
     {
         return;
     }
     PreviousDirection = NextDirection;
     Square[] newSquares = NextDirection.Rotate(this);
     if (CheckRotation(newSquares))
     {
         Squares = newSquares;
     }
     else
     {
         // stay as before
         NextDirection = PreviousDirection;
     }
 }
コード例 #6
0
    /*
     * Resets avatar to their starting position and resets
     * the timer.
     */
    void resetGame()
    {
        nexDir = new NextDirection();
        NavMeshAgent agent = GetComponent <NavMeshAgent>();

        agent.enabled      = false;
        transform.rotation = Quaternion.Euler(0, 0, 0);
        playerRigidbody.MovePosition(playerStartingPoint);
        EasyTTSUtil.SpeechFlush("Your location has been reset to your original starting point");
        agent.enabled = true;

        countColli = 0;

        collisionText.text = "Collision count: " + countColli.ToString();

        restartTime = Time.timeSinceLevelLoad;
        Debug.Log("resartTime " + restartTime);
    }
コード例 #7
0
    /*
     * When avatar come into contact with a TRIGGER
     * such as the destination cube.
     * @param col - the trigger that was collided
     */
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.CompareTag("target"))
        {
            infoBrg = new NextDirection();
            //TheInformationBridge();
            infoBrg.setEndTime(timerText.text);
            infoBrg.setNumOfCollisions(countColli);

            EasyTTSUtil.SpeechFlush("Congratulations, you've reached your destination.");
            Debug.Log("Game Over, you've completed the course");

            Invoke("changeToEndGameScene", 4);             // Wait 4 seconds and then call the "changeToEndScene" Method.
        }

        if (col.gameObject.tag == "Door")
        {
            Debug.Log("Walking through room " + col.gameObject.name + " door");
            EasyTTSUtil.SpeechAdd("Walking through room " + col.gameObject.name + " door");
        }
    }
コード例 #8
0
ファイル: AutoPilot.cs プロジェクト: whampson/gta-save-data
        public bool Equals(AutoPilot other)
        {
            if (other == null)
            {
                return(false);
            }

            return(CurrRouteNode.Equals(other.CurrRouteNode) &&
                   NextRouteNode.Equals(other.NextRouteNode) &&
                   PrevRouteNode.Equals(other.PrevRouteNode) &&
                   TimeEnteredCurve.Equals(other.TimeEnteredCurve) &&
                   TimeToSpendOnCurrentCurve.Equals(other.TimeToSpendOnCurrentCurve) &&
                   CurrPathNodeInfo.Equals(other.CurrPathNodeInfo) &&
                   NextPathNodeInfo.Equals(other.NextPathNodeInfo) &&
                   PrevPathNodeInfo.Equals(other.PrevPathNodeInfo) &&
                   AntiReverseTimer.Equals(other.AntiReverseTimer) &&
                   TimeToStartMission.Equals(other.TimeToStartMission) &&
                   PrevDirection.Equals(other.PrevDirection) &&
                   CurrDirection.Equals(other.CurrDirection) &&
                   NextDirection.Equals(other.NextDirection) &&
                   CurrLane.Equals(other.CurrLane) &&
                   NextLane.Equals(other.NextLane) &&
                   DrivingStyle.Equals(other.DrivingStyle) &&
                   Mission.Equals(other.Mission) &&
                   TempAction.Equals(other.TempAction) &&
                   TimeTempAction.Equals(other.TimeTempAction) &&
                   MaxTrafficSpeed.Equals(other.MaxTrafficSpeed) &&
                   CruiseSpeed.Equals(other.CruiseSpeed) &&
                   SlowedDownByCars.Equals(other.SlowedDownByCars) &&
                   SlowedDownByPeds.Equals(other.SlowedDownByPeds) &&
                   StayInCurrentLevel.Equals(other.StayInCurrentLevel) &&
                   StayInFastLane.Equals(other.StayInFastLane) &&
                   IgnorePathFinding.Equals(other.IgnorePathFinding) &&
                   Destination.Equals(other.Destination) &&
                   PathFindNodesCount.Equals(other.PathFindNodesCount));
        }
コード例 #9
0
    // Use this for initialization
    void Start()
    {
        EasyTTSUtil.Initialize(EasyTTSUtil.UnitedStates);

        nextDir       = new NextDirection();
        rlc           = new RoomLocationsConf();
        infoBrg       = new TheInformationBridge();
        curVal        = 0;
        startPoint    = rlc.setStartingPoint();
        endPoint      = rlc.setEndingPoint();
        agent.enabled = false;
        isFeet        = false;

        player.transform.position = rlc.setStartingPoint();
        //Debug.Log (player.position+"********************");
        //player.transform.rotation = ;
        nextDir.setStart(rlc.setStartingPoint());
        target.transform.position = rlc.setEndingPoint();

        agent.enabled = true;


        path = agent.path;

        //nextDirection = "";
        crntDirection = "";
        fourDir       = " ";

        //degree = 0;           No longer used to get next direction to way point

        numWayPoint = path.corners.Length;
        elapsed     = 0;

        isAutoGerneratePath = infoBrg.getAutoGenerateStates();
        if (isAutoGerneratePath)
        {
            SaveJson();
        }
        curMsg = "constantly redefined";
        difMsg = "redefined only is curmsg changes";
        //Debug.Log (player.position+"++++++++");
        //for (int i = 0; i < path.corners.Length; i++)
        //Debug.Log (path.corners[i]);
        calculatePath();
        adjustDirection();
        summary();


        /*
         * if (isAutoGerneratePath) {
         *      if (rooms == null)
         *              rooms = GameObject.FindGameObjectsWithTag ("Door");
         *      //Debug.Log (rooms.Length);
         *      roomPosition = new Vector3[rooms.Length];
         *      int i = 0;
         *      foreach (GameObject room in rooms) {
         *              roomPosition [i] = new Vector3(room.transform.position.x, 2f, room.transform.position.z);
         *              Debug.Log (roomPosition[i]);
         *              i++;
         *      }
         *
         *
         *      Vector3[] a = new Vector3[2];
         *      for(int j = 0; j < roomPosition.Length; j++){
         *              for(int k = 0; k < roomPosition.Length; k++){
         *                      if(j != k){
         *                              Debug.Log ("start: " + roomPosition[j] + "End: " + roomPosition[k]);
         *
         *                              Debug.Log (totalRoomPassedBy (roomPosition[j],roomPosition[k]) + " rooms pass by. "
         + totalPossibleTurn (roomPosition[j],roomPosition[k]) + " turns include."
         + DifficultWeight (roomPosition[j],roomPosition[k]) + " turn weight."
         + totalDistance(roomPosition[j],roomPosition[k]) + " Distance."
         + (totalRoomPassedBy (roomPosition[j],roomPosition[k]) * 2 + totalPossibleTurn (roomPosition[j],roomPosition[k])* 2
         + DifficultWeight (roomPosition[j],roomPosition[k]) * 10 + totalDistance(roomPosition[j],roomPosition[k])*0.1) + " DIfficutly.");
         +
         +                              difficulty = totalRoomPassedBy(roomPosition[j],roomPosition[k]) * 2
         + totalPossibleTurn(roomPosition[j],roomPosition[k]) * 2
         + DifficultWeight(roomPosition[j],roomPosition[k]) * 10
         + (totalDistance(roomPosition[j],roomPosition[k]) * 0.1);
         +
         +                              //Debug.Log (difficulty);
         +                              if(difficulty < 20 && difficulty >= 0){
         +                                      Debug.Log ("add success");
         +                                      levelOne.Add(a);
         +                                      //Debug.Log ("add success");
         +                              }
         +                              if(difficulty < 50 && difficulty >= 20){
         +                                      levelTwo.Add(a);
         +                              }
         +                              if(difficulty < 80 && difficulty >= 50){
         +                                      levelThree.Add(a);
         +                              }
         +                              if(difficulty >= 80){
         +                                      levelFour.Add(a);
         +                              }
         +
         +                      }
         +
         +              }
         +      }
         +      //json.Add ("Level one", levelOne.ToArray());
         +
         +      //Debug.Log(levelOne);
         +
         +      //for (int j = 0; j < roomPosition.Length; j++)
         +      //Debug.Log (roomPosition[j]);
         + }*/
    }
コード例 #10
0
    /*
     * When avatar come into contact with a TRIGGER
     * such as the destination cube.
     * @param col - the trigger that was collided
     */
    void OnTriggerEnter(Collider col)
    {
        if (col.gameObject.tag == "Door")
        {
            Debug.Log("Walking through room " + col.gameObject.name + " door");
            EasyTTSUtil.SpeechAdd("Walking through room " + col.gameObject.name + " door");
        }


        if (col.gameObject.CompareTag("target"))
        {
            endOfGame = true;
            nexDir    = new NextDirection();
            nexDir.setEndTime(timerText.text);
            nexDir.setNumOfCollisions(countColli);
            WriteString();

            source.Stop();
            EasyTTSUtil.SpeechAdd("Congratulations, you've reached your destination.");

            Debug.Log("Game Over, you've completed the course");
            isAllowMove   = false;
            isReachTarget = true;
            infoBrg.setReachTarget(isReachTarget);
            StartCoroutine(MyCoroutine(5));

            //Application.Quit();

            /****************************************** not for test
             * //Invoke("EndGame", 4); // Wait 4 seconds and then call the "changeToEndScene" Method.
             *
             * /////// Get UnityPlayerActivity class from Android Side ////////////////
             * using (AndroidJavaClass jc = new AndroidJavaClass("com.jastworld.interfaceplugin.UnityPlayerActivity"))
             * {
             * if (jc != null)
             * {
             * //jc.CallStatic("UnitySendMessage", "text", "setText", "Got UnityPlayerActivity Class!");
             * //print("Got UnityPlayerActivity Class!");
             *
             * /////// Get the instance of UnityPlayerActivity class from Android Side ////////////////
             * using (AndroidJavaObject jo = jc.GetStatic<AndroidJavaObject>("currentActivity"))
             * {
             * if (jo != null)
             * {
             *  //jc.CallStatic("UnitySendMessage", "text", "setText", "Got UnityPlayerActivity Object!");
             *  //print("Got UnityPlayerActivity Object!");
             *
             *  //////// Call goToEnd() method in the instance of UnityPlayerActivity /////////
             *  jo.Call("EndScreen", timerText.text, (countColli+""));
             *  //jo.Call("goToEnd");
             * }
             * else
             * {
             *  //jc.CallStatic("UnitySendMessage", "text", "setText", "NOT Got UnityPlayerActivity Object!");
             *  print("NOT Got UnityPlayerActivity Object!");
             * }
             * }
             * }
             * else
             * {
             * jc.CallStatic("UnitySendMessage", "text", "setText", "NOT Got UnityPlayerActivity Class!");
             * print("NOT Got UnityPlayerActivity Class!");
             * }
             *
             * }**********************************************/
        }
    }
コード例 #11
0
 public void FlipDirection()
 {
     NextDirection = NextDirection.Opposite();
     NextTarget    = NextTarget.Move(NextDirection);
 }
コード例 #12
0
    NextDirection CalculateDirection(NextDirection nextDirection, int currentLocationUID)
    {
        if (nextDirection.FinalLocationUID == currentLocationUID)
        {
            nextDirection.NextLocationUID = currentLocationUID;
            nextDirection.BaseDistance    = 0;
            return(nextDirection);
        }

        List <MapPoint> graphSet = new List <MapPoint> (MapGraph);
        var             path     = new List <MapPoint> ();

        foreach (var mp in graphSet)
        {
            mp.CalcDistance = float.MaxValue;
            mp.CalcPrevious = null;
        }

        graphSet.Find(x => x.LocationUID == currentLocationUID).CalcDistance = 0;

        while (graphSet.Count != 0)
        {
            graphSet.Sort((x, y) => x.CalcDistance.CompareTo(y.CalcDistance));
            var smallestMP = graphSet [0];
            graphSet.RemoveAt(0);

            if (smallestMP.LocationUID == nextDirection.FinalLocationUID)
            {
                while (smallestMP.CalcPrevious != null)
                {
                    path.Add(smallestMP);
                    smallestMP = smallestMP.CalcPrevious;
                }
                break;
            }

            if (smallestMP.CalcDistance == float.MaxValue)
            {
                break;
            }

            foreach (var n in smallestMP.Neighbours)
            {
                if (graphSet.Find(x => x.LocationUID == n.NeighbourUID) != null)
                {
                    var alt = smallestMP.CalcDistance + n.Distance;
                    var nMP = graphSet.Find(x => x.LocationUID == n.NeighbourUID);
                    if (alt < nMP.CalcDistance)
                    {
                        nMP.CalcDistance = alt;
                        nMP.CalcPrevious = smallestMP;
                    }
                }
            }
        }

        if (path.Count == 0)
        {
            Debug.Log("Error: can't build path to this point");
            nextDirection.NextLocationUID = currentLocationUID;
            nextDirection.BaseDistance    = 0;
        }
        else
        {
            nextDirection.NextLocationUID = path [path.Count - 1].LocationUID;

            foreach (var mc in MapConnections)
            {
                if (currentLocationUID == mc.StartLocation.LocationUID && nextDirection.NextLocationUID == mc.EndLocation.LocationUID ||
                    currentLocationUID == mc.EndLocation.LocationUID && nextDirection.NextLocationUID == mc.StartLocation.LocationUID)
                {
                    nextDirection.BaseDistance = mc.Distance;
                }
            }
        }
        return(nextDirection);
    }
コード例 #13
0
        private static int GetFirstHighestNum(int input)
        {
            _spiral = new List <List <int> >();
            _spiral.Add(new List <int>()
            {
                1, 1
            });                                                  //First 2 values
            _nextDirection = NextDirection.Up;

            int rowIndex    = 0;
            int columnIndex = 1;

            for (int i = 3; i <= 100; i++)
            {
                List <int> row;
                int        result = 0;

                switch (_nextDirection)
                {
                case NextDirection.Up:
                    if (rowIndex == 0)
                    {
                        InsertRowAbove(rowIndex, columnIndex);
                        _nextDirection = NextDirection.Left;
                    }
                    else if (rowIndex - 1 == 0)
                    {
                        rowIndex--;
                        row    = _spiral[rowIndex];
                        result = _spiral[rowIndex][columnIndex - 1] + _spiral[rowIndex + 1][columnIndex - 1] + _spiral[rowIndex + 1][columnIndex];
                        row.Add(result);
                    }
                    else
                    {
                        rowIndex--;
                        row    = _spiral[rowIndex];
                        result = _spiral[rowIndex - 1][columnIndex - 1] + _spiral[rowIndex][columnIndex - 1] + _spiral[rowIndex + 1][columnIndex - 1] + _spiral[rowIndex + 1][columnIndex];
                        row.Add(result);
                    }
                    break;

                case NextDirection.Left:
                    row = _spiral[rowIndex];

                    if (columnIndex == 0)
                    {
                        InsertColumnsAtBeginning();
                        result           = _spiral[rowIndex][columnIndex + 1] + _spiral[rowIndex + 1][columnIndex + 1];
                        row[columnIndex] = result;
                        _nextDirection   = NextDirection.Down;
                    }
                    else if (columnIndex - 1 == 0)
                    {
                        result = _spiral[rowIndex][columnIndex] + _spiral[rowIndex + 1][columnIndex] + _spiral[rowIndex + 1][columnIndex - 1];
                        row[columnIndex - 1] = result;
                        columnIndex--;
                    }
                    else
                    {
                        result = _spiral[rowIndex][columnIndex] + _spiral[rowIndex + 1][columnIndex - 2] + _spiral[rowIndex + 1][columnIndex - 1] + _spiral[rowIndex + 1][columnIndex];
                        row[columnIndex - 1] = result;
                        columnIndex--;
                    }
                    break;

                case NextDirection.Down:
                    if (rowIndex == _spiral.Count - 1)
                    {
                        InsertRowBelow();
                        rowIndex++;
                        result = _spiral[rowIndex - 1][columnIndex] + _spiral[rowIndex - 1][columnIndex + 1];
                        _spiral[rowIndex][columnIndex] = result;
                        _nextDirection = NextDirection.Right;
                    }
                    else if (rowIndex + 1 == _spiral.Count - 1)
                    {
                        result = _spiral[rowIndex][columnIndex] + _spiral[rowIndex][columnIndex + 1] + _spiral[rowIndex + 1][columnIndex + 1];
                        _spiral[rowIndex + 1][columnIndex] = result;
                        rowIndex++;
                    }
                    else
                    {
                        result = _spiral[rowIndex][columnIndex] + _spiral[rowIndex][columnIndex + 1] + _spiral[rowIndex + 1][columnIndex + 1] + _spiral[rowIndex + 2][columnIndex + 1];
                        _spiral[rowIndex + 1][columnIndex] = result;
                        rowIndex++;
                    }
                    break;

                case NextDirection.Right:
                    row = _spiral[rowIndex];

                    if (columnIndex + 1 == row.Count)
                    {
                        result = _spiral[rowIndex - 1][columnIndex] + _spiral[rowIndex][columnIndex];
                        row.Add(result);
                        columnIndex++;
                        _nextDirection = NextDirection.Up;
                    }
                    else if (columnIndex + 2 == row.Count)
                    {
                        result = _spiral[rowIndex][columnIndex] + _spiral[rowIndex - 1][columnIndex] + _spiral[rowIndex - 1][columnIndex + 1];
                        row[columnIndex + 1] = result;
                        columnIndex++;
                    }
                    else
                    {
                        result = _spiral[rowIndex][columnIndex] + _spiral[rowIndex - 1][columnIndex] + _spiral[rowIndex - 1][columnIndex + 1] + _spiral[rowIndex - 1][columnIndex + 2];
                        row[columnIndex + 1] = result;
                        columnIndex++;
                    }
                    break;
                }

                if (result > input)
                {
                    return(result);
                }
            }
            return(0);
        }
コード例 #14
0
        private static void CreateSpiral(int amount)
        {
            _spiral = new List <List <int> >();
            _spiral.Add(new List <int>()
            {
                1, 2
            });                                                  //First 2 values
            _nextDirection = NextDirection.Up;

            int rowIndex    = 0;
            int columnIndex = 1;

            for (int i = 3; i <= amount; i++)
            {
                List <int> row;

                switch (_nextDirection)
                {
                case NextDirection.Up:
                    if (rowIndex == 0)
                    {
                        InsertRowAbove(columnIndex, i);
                        _nextDirection = NextDirection.Left;
                    }
                    else
                    {
                        rowIndex--;
                        row = _spiral[rowIndex];
                        row.Add(i);
                    }
                    break;

                case NextDirection.Left:
                    row = _spiral[rowIndex];

                    if (columnIndex == 0)
                    {
                        InsertColumnsAtBeginning();
                        row[columnIndex] = i;
                        _nextDirection   = NextDirection.Down;
                    }
                    else
                    {
                        row[columnIndex - 1] = i;
                        columnIndex--;
                    }
                    break;

                case NextDirection.Down:
                    if (rowIndex == _spiral.Count - 1)
                    {
                        InsertRowBelow();
                        rowIndex++;
                        _spiral[rowIndex][columnIndex] = i;
                        _nextDirection = NextDirection.Right;
                    }
                    else
                    {
                        _spiral[rowIndex + 1][columnIndex] = i;
                        rowIndex++;
                    }
                    break;

                case NextDirection.Right:
                    row = _spiral[rowIndex];

                    if (columnIndex + 1 == row.Count)
                    {
                        row.Add(i);
                        columnIndex++;
                        _nextDirection = NextDirection.Up;
                    }
                    else
                    {
                        row[columnIndex + 1] = i;
                        columnIndex++;
                    }
                    break;
                }
            }
        }