Esempio n. 1
0
 public string PostNewTravelLocation(string username, string travelplan, string travelroute, [FromBody] JsonElement value)
 {
     if (_userRepository.GetAllUsersShort().Where(u => u.UserName == username).Count() < 1)
     {
         return("Error: Unknown user");
     }
     else
     {
         User user = _userRepository.GetByName(username);
         if (user.Travelplans.Where(t => t.Name == travelplan).Count() < 1)
         {
             return("Error: Unknown travelplan");
         }
         if (user.Travelplans.Where(t => t.Name == travelplan).First().RouteList.Where(i => i.Name == travelroute).Count() < 1)
         {
             return("Error: Unknown travelroute");
         }
         TravelLocation response = JsonConvert.DeserializeObject <TravelLocation>(value.GetRawText());
         if (user.Travelplans.Where(t => t.Name == travelplan).First().RouteList.Where(i => i.Name == travelroute).First().Locations.Where(l => l.Name == response.Name).Count() > 0)
         {
             return("Error: TravelRoute already has this location");
         }
         user.Travelplans.Where(t => t.Name == travelplan).First().RouteList.Where(i => i.Name == travelroute).First().AddTravelLocation(response);
         _userRepository.Update(user);
         _userRepository.SaveChanges();
         return(response.Name + " succesfully added to " + username + "'s TravelRoute \"" + travelroute + "\"");
     }
 }
Esempio n. 2
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player" && !isFleeing)
     {
         ScareNPC(2);
     }
     else if (other.tag == "Sound" && !isFleeing)
     {
         finalTarget  = specterData.currentRoom.GetComponentInChildren <TravelLocation>();
         selectedRoom = finalTarget.GetComponentInParent <RoomController>();
         if (selectedRoom == currentRoom)
         {
             ScareNPC(2);
         }
         else
         {
             audioSource.PlayOneShot(heardSomething);
             TrackLocation(finalTarget);
         }
     }
     else if (other.tag == "Room")
     {
         currentRoom    = other.gameObject.GetComponent <RoomController>();
         tensionFalling = !currentRoom.isHaunted;
         terrorFalling  = !currentRoom.isHaunted;
     }
     else if (other.tag == "Lock")
     {
         Debug.Log("LockEnter");
         canMove = false;
     }
 }
    public TravelLocation GetLocation()
    {
        do
        {
            location = travelLocations[Random.Range(0, travelLocations.Length)];
            room     = location.GetComponentInParent <RoomController>();
        }while (room.isHaunted == true);

        return(location);
    }
 /// <summary>
 ///
 /// </summary>
 /// <param name="travlLocation"></param>
 /// <returns></returns>
 public Task <int> SaveTravelingLocationAsync(TravelLocation travlLocation)
 {
     if (travlLocation.TravelLocationId != 0)
     {
         return(_database.UpdateAsync(travlLocation));
     }
     else
     {
         return(_database.InsertAsync(travlLocation));
     }
 }
Esempio n. 5
0
    void SetNewTarget()
    {
        do
        {
            finalTarget  = locationController.GetLocation();
            selectedRoom = finalTarget.GetComponentInParent <RoomController>();
        }while (selectedRoom == currentRoom);

        //finalTarget = locationController.GetLocation();
        TrackLocation(finalTarget);
    }
Esempio n. 6
0
 void TrackLocation(TravelLocation location)
 {
     targetReached       = false;
     finalTargetPosition = location.transform.position;
     if (Mathf.Abs(transform.position.y - finalTargetPosition.y) < .1f)
     {
         onCorrectFloor = true;
     }
     else
     {
         onCorrectFloor = false;
     }
 }
        private void OnAddCheckout_Click(object sender, EventArgs e)
        {
            if (App.selectedLocation == null)
            {
                SetContentView(Resource.Layout.locationPage);
            }

            TravelLocation travelLoc = new TravelLocation()
            {
                LocationId = App.selectedLocation.LocationID,
                Username   = App.username
            };

            traveLocation.SaveTravelingLocationAsync(travelLoc);
            Intent location = new Intent(this, typeof(LocationActivity));

            StartActivity(location);
        }
        public ScenePointBehavior ObtainSpawnPoint(TravelLocation thisPoint)
        {
            ScenePointBehavior thisSpawn = null;

            switch (thisPoint)
            {
            case TravelLocation.ThreeGatesPilgrim:
                thisSpawn = pilgrimSpawn;
                break;

            case TravelLocation.ForestOfRetsnom:
                thisSpawn = forestSpawn;
                break;

            case TravelLocation.MountainOfAli:
                thisSpawn = mountainSpawn;
                break;

            default:
                break;
            }

            return(thisSpawn);
        }
 /// <summary>
 ///
 /// </summary>
 /// <param name="note"></param>
 /// <returns></returns>
 public Task <int> DeleteLocationAsync(TravelLocation TravelLoc)
 {
     return(_database.DeleteAsync(TravelLoc));
 }
Esempio n. 10
0
        public void SummonRandomTraveller(TravelLocation startingPoint, TravellerType travellerType, int unitCount)
        {
            ScenePointBehavior spawnPoint    = ObtainSpawnPoint(startingPoint);
            BaseTravellerData  travellerData = new BaseTravellerData();
            GameObject         tmp           = null;

            tmp = GameObject.Instantiate(basicInvaderPrefab, spawnPoint.transform.position, Quaternion.identity, null);


            int rand = UnityEngine.Random.Range(0, 100);

            switch (travellerType)
            {
            case TravellerType.Invader:
                travellerData = travellerGenerator.GenerateRandomWarbandTraveller(unitCount, -100);
                travellerData.travellersName = "Sweet Bandits" + rand.ToString();     // Create a name generator
                break;

            case TravellerType.Merchant:
                travellerData = travellerGenerator.GenerateRandomMerchantTraveller(unitCount, 0);
                travellerData.travellersName = "Merchant of " + rand.ToString();     // Create a name generator
                break;

            case TravellerType.Hero:
                break;

            case TravellerType.Warband:
                travellerData = travellerGenerator.GenerateRandomWarbandTraveller(unitCount, 0);
                travellerData.travellersName = "Mercenary " + rand.ToString();
                break;

            default:
                break;
            }

            // Positions and Target locations
            travellerData.originalSpawnPoint      = spawnPoint.gameObject.name;
            travellerData.currentScenePoint       = spawnPoint.gameObject.name;
            travellerData.currentSceneTargetPoint = frontGate.gameObject.name;

            BaseTravellerBehavior inv = tmp.GetComponent <BaseTravellerBehavior>();

            inv.InitializeSpawnInvasion(travellerData);
            inv.armyMovement.SetPosition(spawnPoint, true);
            inv.TravelMovement(frontGate);

            if (spawnedUnits == null)
            {
                spawnedUnits = new List <BaseTravellerBehavior>();
            }

            spawnedUnits.Add(inv);
            CheckRelationship(travellerData.relationship);

            if (TransitionManager.GetInstance != null && !TransitionManager.GetInstance.isNewGame)
            {
                if (PlayerGameManager.GetInstance != null)
                {
                    PlayerGameManager.GetInstance.SaveTraveller(travellerData);
                    SaveData.SaveLoadManager.GetInstance.SaveCurrentCampaignData();
                }
            }
        }
Esempio n. 11
0
        public async void OnNewLocationClicked(string newName, string newLocation, double newLatitude, double newLongitude)
        {
            if (SelectedRoute != null)
            {
                if (!ShowNewLocationFields)
                {
                    ShowNewLocationFields = true;
                }
                else
                {
                    if (string.IsNullOrEmpty(newName))
                    {
                        Message = "A name is required, try again.";
                        return;
                    }

                    if (string.IsNullOrEmpty(newLocation))
                    {
                        Message = "A location is required, try again.";
                        return;
                    }

                    IsLoading = true;
                    Message   = "Processing, please wait.";
                    TravelLocation newTravelLocation = new TravelLocation(newName, newLocation, newLatitude, newLongitude);

                    //REST
                    try
                    {
                        HttpClient httpClient = new HttpClient();
                        Uri        uri        = new Uri(BASE_URL + "User/addTravelLocation/" + UserName + "/" + TravelPlan.Name + "/" + SelectedRoute.Name);

                        HttpStringContent content = new HttpStringContent(
                            JsonConvert.SerializeObject(newTravelLocation),
                            UnicodeEncoding.Utf8,
                            "application/json");

                        HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(
                            uri,
                            content);

                        httpResponseMessage.EnsureSuccessStatusCode();
                        var httpResponseBody = await httpResponseMessage.Content.ReadAsStringAsync();

                        Message = httpResponseBody;

                        if (httpResponseBody.Split(" ")[0] != "Error:")
                        {
                            SelectedRoute.AddTravelLocation(newTravelLocation);
                            RaisePropertyChanged("LocationList");
                            RequestMapUpdate?.Invoke(this, new EventArgs());
                        }
                    }
                    catch (Exception ex)
                    {
                        Message = ex.Message;
                    }

                    ShowNewRouteFields = false;
                    IsLoading          = false;
                }
            }
        }