Beispiel #1
0
    internal static void Move(Place.ExitDirections direction)
    {
        if (CruiseControl.waitingForConfirmation)
        {
            return;
        }
        else
        {
            switch (direction)
            {
            case Place.ExitDirections.North:
                WoTUnityClient.Send("n\nexits");
                break;

            case Place.ExitDirections.East:
                WoTUnityClient.Send("e\nexits");
                break;

            case Place.ExitDirections.South:
                WoTUnityClient.Send("s\nexits");
                break;

            case Place.ExitDirections.West:
                WoTUnityClient.Send("w\nexits");
                break;
            }
            Player.me.attemptedMoveDirection = direction;
            CruiseControl.ConfirmationPending();
            Coroutiner.StartCoroutine(TimeoutMove());
        }
    }
Beispiel #2
0
        public static bool ConnectPlaces(ref Place newPlace, ref Place currentPlace)
        {
            //Don't bother connecting a place to itself
            if (newPlace.placeHash == currentPlace.placeHash)
            {
                return(true);
            }
            //Don't connect places with ambiguous exit direcions
            string currentPlaceHeading = currentPlace.heading;

            if (newPlace.exitHeadings.Where(e => e == currentPlaceHeading).Count() > 1)
            {
                //UnityEngine.Debug.LogWarning(newPlace.heading + " has multiple exits named " + currentPlace.heading
                //    + ", direction can not be determined");
                return(false);
            }
            //Connect this location to the last
            Place.ExitDirections direction = Place.ExitDirections.North;
            foreach (string newExitHeading in newPlace.exitHeadings)
            {
                //If there is an exit in this direcion
                if (newExitHeading != null)
                {
                    Console.WriteLine(newExitHeading + " " + currentPlace.heading);
                    //And its name matches our last new location
                    if (newExitHeading.Contains(currentPlace.heading))
                    {
                        //TODO: Check that the last direction moved matches this heading also.
                        //Connect these two places
                        Console.WriteLine("Connected " + newPlace.heading + " to "
                                          + currentPlace.heading, ConsoleColor.Yellow);
                        //Connect backward
                        int directionIntBackward = (int)direction;
                        newPlace.connectedPlaces[directionIntBackward]      = currentPlace;
                        newPlace.connectedPlaceHashes[directionIntBackward] = currentPlace.GetHashCode();
                        //Connect forward
                        int directionIntForward = (int)Place.InvertExitState(direction);
                        currentPlace.connectedPlaces[directionIntForward]      = newPlace;
                        currentPlace.connectedPlaceHashes[directionIntForward] = newPlace.GetHashCode();

                        //Set up grid ref
                        newPlace.PlaceGridRef = currentPlace.GetOffsetGridRef(direction);

                        return(true);//Connection created, stop processing.
                    }
                }
                direction = (Place.ExitDirections)(int)(direction + 1);
            }
            Console.WriteLine("Unable to connect given places " + newPlace.heading
                              + " and " + currentPlace.heading, ConsoleColor.Red);
            return(false);
        }