Пример #1
0
        public void Register()
        {
            Console.Clear();
            // Enter Username
            string username = JHelper.InputString("Enter Username: "******"";
            string confirmPassword = "******";

            while (password != confirmPassword)
            {
                password        = JHelper.InputPassword("Enter Password: "******"Confirm Password: "******"> Please Enter the Same Password");
                }
            }


            Logic.Register(username, password);

            Console.WriteLine("User Registered. You may now log in to your account.");
            JHelper.ContinuePrompt();
        }
Пример #2
0
 public void WelcomeScreen()
 {
     while (true)
     {
         Console.Clear();
         Title("Welcome to Community");
         Console.WriteLine(
             "[1] Login " +
             "[2] Register " +
             "[X] Exit"
             );
         Console.Write(bar());
         string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("1", "2", "X"));
         if (selection == "1")
         {
             Login();
         }
         else if (selection == "2")
         {
             Register();
         }
         else if (selection == "X")
         {
             break;
         }
     }
     JHelper.ExitPrompt();
 }
Пример #3
0
    /// <summary>
    /// Causes the squad to move to hack the context indicator target.
    /// One squad member is randomly chosen to hack while the others occupy cover points
    /// near the target.
    /// </summary>
    /// <param name="_context"></param>
    void SquadHackCommand(CurrentContext _context)
    {
        HackableConsole console = _context.indicator_hit.GetComponent <HackableConsole>();

        if (console.hacked)
        {
            return;
        }

        order_target_bobber.SetTarget(console.transform);

        squad_sense.hacker_squaddie = squad_sense.squaddies[Random.Range(0, num_squaddies)];
        for (int i = 0; i < num_squaddies; ++i)
        {
            SquaddieAI squaddie = squad_sense.squaddies[i];
            squaddie.knowledge.order_console = console;

            if (squaddie == squad_sense.hacker_squaddie)
            {
                // Hacker squaddie moves to hack.
                squaddie.knowledge.current_order = OrderType.HACK;
                squaddie.nav.destination         = console.hack_point.position;
            }
            else
            {
                // The other squaddies move to defend.
                Vector3 pos = JHelper.PosToCirclePos(console.hack_point.position, num_squaddies, i, 5);

                squaddie.knowledge.current_order = OrderType.GUARD;
                squaddie.MoveToCoverNearPosition(pos);
            }
        }
    }
Пример #4
0
        public void SeeRecommendedUsers()
        {
            while (true)
            {
                IList <User> users = Logic.GetRecommendedUsers().ToList();

                Console.Clear();

                Title("Recommended Users");

                // Display Users
                Console.WriteLine("Select Recommended User:"******"\n    Communities in Common: " + string.Join(", ", Logic.CommonCommunities(e).Take(3).Select(f => f.Name)));
                Console.WriteLine("[-1] Go Back");
                Console.Write(bar());

                int userNumber = JHelper.InputInt("Enter Number: ", validator: e => e == -1 || (e > 0 && e <= users.Count));
                if (userNumber == -1)
                {
                    break;
                }
                UserProfile(users[userNumber - 1]);
            }
        }
Пример #5
0
        public void SearchUsers()
        {
            Console.Clear();

            Title("Search for Users");
            string       key   = JHelper.InputString("Enter Search Key: ");
            IList <User> users = Logic.SearchUser(key);

            while (true)
            {
                Console.Clear();
                Title($"Search Results for \"{key}\"");

                // Display list of users
                DisplayEnumeratedList(users, e => e.Name);
                Console.Write(bar());

                int userNumber = JHelper.InputInt("Enter Number (-1 to go Back): ", validator: e => e == -1 || (e > 0 && e <= users.Count));
                if (userNumber == -1)
                {
                    break;
                }
                UserProfile(users[userNumber - 1]);
            }
        }
Пример #6
0
        public void MainMenu()
        {
            IEnumerable <UserPost>       posts   = Logic.GetMainFeed();
            EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 7, PostDisplay);

            while (true)
            {
                Console.Clear();
                display.items = Logic.GetMainFeed().ToList();

                Title("Home");

                // Display List of Posts
                display.Display();

                // Display and Input Selection
                Console.WriteLine(
                    bar() +
                    $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" +
                    $"{(display.HasNextPage ? "[W] Next page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") +
                    "[1] Create Post " +
                    "[2] Users " +
                    "[3] Communities " +
                    "[4] Profile " +
                    "[X] Logout");
                Console.Write(bar());
                string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "3", "4", "X"));

                // Perform selection
                if (display.HasPreviousPage && selection == "Q")
                {
                    display.PreviousPage();
                }
                else if (display.HasNextPage && selection == "W")
                {
                    display.NextPage();
                }
                else if (selection == "1")
                {
                    CreatePost();
                }
                else if (selection == "2")
                {
                    UsersMenu();
                }
                else if (selection == "3")
                {
                    CommunitiesMenu();
                }
                else if (selection == "4")
                {
                    SeeOwnProfile();
                }
                else if (selection == "X")
                {
                    break;
                }
            }
        }
Пример #7
0
        private void PostToCommunity(Community community)
        {
            Title($"Post to {community.Name}");
            Console.Clear();
            // Input text
            string text = JHelper.InputString("Enter Text: ", validator: e => !string.IsNullOrWhiteSpace(e) && !e.Contains("|"));

            Logic.PostToCommunity(text, community);
        }
Пример #8
0
        public void CreateCommunity()
        {
            Console.Clear();

            Title("Create Community");
            string name = JHelper.InputString("Enter Community Name: ", validator: ValidCommunityName).ToLower();;

            Logic.CreateCommunity(name);
            Console.WriteLine("Community Created");
            JHelper.ContinuePrompt();
        }
Пример #9
0
    void SquadSpawn(SpawnSettings _settings, SquadSpawner _spawner)
    {
        RaycastHit hit;

        if (!JHelper.RaycastMousePosToLayer("Floor", out hit))
        {
            return;
        }

        AddSquad(_spawner.CreateSquad(_settings.faction, squad_spawn_size, hit.point));
    }
Пример #10
0
    void IndividualSpawn(SpawnSettings _settings, SquadSpawner _spawner)
    {
        RaycastHit hit;

        if (!JHelper.RaycastMousePosToLayer("Floor", out hit))
        {
            return;
        }

        selected_squad.AddSquaddie(_spawner.CreateSquaddie(_settings.faction, hit.point));
        selected_squad.SelectSquad();
    }
Пример #11
0
        public void SeeOwnProfile()
        {
            User user = Logic.GetLoggedinUser();
            IEnumerable <UserPost>       posts   = user.Posts;
            EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 5, PostDisplay);

            while (true)
            {
                Console.Clear();

                display.items = user.Posts.ToList();

                // Display Profile Description
                Title($"Profile of {user.Name}");

                // Display Posts
                Console.WriteLine("Posts: ");
                display.Display();
                // Get Input
                bool followed = Logic.IsFollowed(user);
                Console.WriteLine(
                    bar() +
                    $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" +
                    $"{(display.HasNextPage ? "[W] Next Page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") +
                    "[1] See Joined Communities " +
                    "[2] See Followed Users " +
                    "[X] Back");
                Console.Write(bar());
                string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "X"));
                if (display.HasPreviousPage && selection == "Q")
                {
                    display.PreviousPage();
                }
                else if (display.HasNextPage && selection == "W")
                {
                    display.NextPage();
                }
                else if (selection == "1")
                {
                    SeeFollowedCommunities(user);
                }
                else if (selection == "2")
                {
                    SeeFollowedUsers(user);
                }
                else if (selection == "X")
                {
                    break;
                }
            }
        }
Пример #12
0
    /// <summary>
    /// Creates a new squad with the passed faction settings.
    /// The squaddies are arranged in a circular pattern at the passed position, based on the squad size.
    /// </summary>
    /// <param name="_faction">The faction of the squad.</param>
    /// <param name="_num_squaddies">The size of the squad.</param>
    /// <param name="_pos">The where the squad should be arranged.</param>
    /// <returns>A reference to the instantiated squad.</returns>
    public SquadManager CreateSquad(FactionSettings _faction, int _num_squaddies, Vector3 _pos)
    {
        SquadManager squad_manager = new SquadManager(_faction);

        for (int i = 0; i < _num_squaddies; ++i)
        {
            SquaddieAI squaddie = CreateSquaddie(_faction, _pos);
            squaddie.transform.position = JHelper.PosToCirclePos(_pos, _num_squaddies, i, _num_squaddies * 0.5f);

            squad_manager.AddSquaddie(squaddie);
        }

        return(squad_manager);
    }
Пример #13
0
        // USERS MODULE
        public void UsersMenu()
        {
            IEnumerable <UserPost>       posts   = Logic.GetUserFeed();
            EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 7, PostDisplay);

            while (true)
            {
                Console.Clear();
                display.items = Logic.GetUserFeed().ToList();

                Title("Users Feed");

                display.Display();
                Console.WriteLine(
                    bar() +
                    $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" +
                    $"{(display.HasNextPage ? "[W] Next Page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") +
                    "[1] See Recommended Users " +
                    "[2] Search Users " +
                    "[X] Back");
                Console.Write(bar());
                string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "X"));

                if (display.HasPreviousPage && selection == "Q")
                {
                    display.PreviousPage();
                }
                else if (display.HasNextPage && selection == "W")
                {
                    display.NextPage();
                }
                else if (selection == "1")
                {
                    SeeRecommendedUsers();
                }
                else if (selection == "2")
                {
                    SearchUsers();
                }
                else if (selection == "X")
                {
                    break;
                }
                else
                {
                    Console.WriteLine("Please Enter a Valid Selection.");
                }
            }
        }
Пример #14
0
    // CollisionEventForwarder event.
    public void TriggerEnter(Collider _other)
    {
        if (!_other.CompareTag("DamageableBody"))
        {
            return;
        }

        SquaddieAI squaddie = _other.GetComponentInParent <SquaddieAI>();

        if (squaddie == null || JHelper.SameFaction(squaddie, this))
        {
            return;
        }

        knowledge.nearby_targets.Add(squaddie);
    }
Пример #15
0
    void DestroyMouseOverSquaddie()
    {
        RaycastHit hit;
        var        success = JHelper.RaycastMousePosToLayer("Damageable", out hit);

        if (!success)
        {
            return;
        }

        SquaddieAI squaddie = hit.collider.transform.root.GetComponent <SquaddieAI>();

        if (squaddie != null)
        {
            Destroy(squaddie.gameObject);
        }
    }
Пример #16
0
    void Start()
    {
        var gun_clone = Instantiate(chain_gun_prefab, instantiate_parent.position,
                                    instantiate_parent.rotation);

        gun_clone.transform.SetParent(instantiate_parent);

        chain_gun = gun_clone.GetComponent <ChainGun>();
        chain_gun.Init(ray_cast_origin);

        // Mainly used to allow the player's gun to be rendered above all else in FPS view.
        int layer = instantiate_layer != "" ? LayerMask.NameToLayer(instantiate_layer) : 0;

        JHelper.SetLayerRecursive(gun_clone, layer);

        instantiation_events.Invoke(chain_gun);
    }
Пример #17
0
    /// <summary>
    /// Causes the squad to engage the context indicator target.
    /// </summary>
    /// <param name="_context">The current context.</param>
    void SquadAttackCommand(CurrentContext _context)
    {
        SquaddieAI attack_target = _context.indicator_hit.GetComponent <SquaddieAI>();

        order_target_bobber.SetTarget(attack_target.transform);

        foreach (SquaddieAI squaddie in squad_sense.squaddies)
        {
            if (JHelper.SameFaction(squaddie, attack_target))
            {
                continue;
            }

            squaddie.knowledge.order_target  = attack_target;
            squaddie.knowledge.current_order = OrderType.ATTACK;
        }
    }
Пример #18
0
        public void SeeCommunityPosts(Community community)
        {
            var display = new EnumerableDisplay <UserPost>(community.Posts, 7, PostDisplay);

            while (true)
            {
                display.items = community.Posts.ToList();
                Console.Clear();

                Title($"{community.Name} Posts");

                display.Display();

                bool following = Logic.IsFollowingCommunity(community);
                Console.WriteLine(
                    bar() +
                    $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" +
                    $"{(display.HasNextPage ? "[W] Next page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") +
                    $"[1] {(following ? "Leave" : "Join")} " +
                    $"[2] Post " +
                    "[X] Back");
                Console.Write(bar());
                string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("1", "2", "X"));

                if (selection == "1")
                {
                    if (following)
                    {
                        Logic.UnfollowCommunity(community);
                    }
                    else
                    {
                        Logic.FollowCommunity(community);
                    }
                }
                else if (selection == "2")
                {
                    PostToCommunity(community);
                }
                else if (selection == "X")
                {
                    break;
                }
            }
        }
Пример #19
0
        public void SeeCommunities()
        {
            while (true)
            {
                var communities = Logic.GetCommunities().ToList();
                Console.Clear();

                Title("Communities");

                DisplayEnumeratedList(communities, e => e.Name);
                Console.Write(bar());

                int communityNumber = JHelper.InputInt("Enter Number (-1 to go Back): ", validator: e => e == -1 || (e > 0 && e <= communities.Count));
                if (communityNumber == -1)
                {
                    break;
                }
                SeeCommunityPosts(communities[communityNumber - 1]);
            }
        }
Пример #20
0
        public void Login()
        {
            while (true)
            {
                Console.Clear();
                // Enter Username
                string username = JHelper.InputString("Enter Username: "******"Enter Password: "******"Please Enter A Valid Username and Password");
                JHelper.ContinuePrompt();
            }
            MainMenu();
        }
Пример #21
0
        private void SeeFollowedCommunities(User user)
        {
            while (true)
            {
                IList <Community> followedCommunities = user.Communities.Inorder().ToList();
                Console.Clear();

                Title($"Communities Joined by {user.Name}");

                // Dispay List of Communities
                DisplayEnumeratedList(followedCommunities, e => e.Name);

                Console.Write(bar());
                int userNumber = JHelper.InputInt("Enter Number (-1 to go Back): ", validator: e => e == -1 || (e > 0 && e <= followedCommunities.Count));
                if (userNumber == -1)
                {
                    break;
                }
                SeeCommunityPosts(followedCommunities[userNumber - 1]);
            }
        }
Пример #22
0
        public void SeeFollowedUsers(User user)
        {
            IList <User> followedUsers = user.FollowedUsers.ToList();

            while (true)
            {
                Console.Clear();

                Title($"Users Followed by {user.Name}");

                // Dispay List of Users
                DisplayEnumeratedList(followedUsers, e => e.Name);
                Console.Write(bar());
                // Input Selection
                int userNumber = JHelper.InputInt("Enter Number (-1 to go Back): ", validator: e => e == -1 || (e > 0 && e <= followedUsers.Count));
                if (userNumber == -1)
                {
                    break;
                }
                UserProfile(followedUsers[userNumber - 1]);
            }
        }
Пример #23
0
        public void SeeFollowedCommunities()
        {
            while (true)
            {
                Console.Clear();
                IList <Community> followedCommunities = Logic.FollowedCommunities().ToList();

                Title($"Followed Communities");

                // Dispay List of Communities
                DisplayEnumeratedList(followedCommunities, e => e.Name);
                Console.WriteLine("[-1] Go Back");
                Console.Write(bar());
                // Input Selection

                int userNumber = JHelper.InputInt("Enter Number: ", validator: e => e == -1 || (e > 0 && e <= followedCommunities.Count));
                if (userNumber == -1)
                {
                    break;
                }
                SeeCommunityPosts(followedCommunities[userNumber - 1]);
            }
        }
Пример #24
0
        private void CreatePost()
        {
            Console.Clear();

            Title("Create Post");

            IList <Community> communities = Logic.GetFolowedCommunities().ToList();

            // Display Communities
            DisplayEnumeratedList(communities, e => e.Name);
            Console.WriteLine("[-1] Go Back");

            Console.Write(bar());
            // Input Community
            int communityNumber = JHelper.InputInt("Enter Number: ", validator: e => e == -1 || (e > 0 && e <= communities.Count));

            if (communityNumber == -1)
            {
                return;
            }
            var community = communities[communityNumber - 1];

            PostToCommunity(community);
        }
Пример #25
0
    // Read all ability properties from the JSON file and populate the abilities dictionary.
    void EnumerateProperties()
    {
        string file_name = Application.streamingAssetsPath + "/abilities.json";

        JsonData abilities_data = JsonMapper.ToObject(File.ReadAllText(file_name));

        ability_properties_dictionary = new Dictionary <string, AbilityProperties>();

        var keys = JHelper.GetObjectKeys(abilities_data);

        for (int index = 0; index < abilities_data.Count; ++index)
        {
            var    elem            = abilities_data[index];
            string projectile_name = keys[index];

            AbilityProperties properties = new AbilityProperties();

            if (elem.Keys.Contains("projectile"))
            {
                properties.projectile = projectile_dictionary[(string)elem["projectile"]];
            }

            if (elem.Keys.Contains("audio_clip"))
            {
                properties.audio_clip = audio_dictionary[(string)elem["audio_clip"]];
            }

            if (elem.Keys.Contains("cooldown"))
            {
                properties.cooldown = float.Parse(elem["cooldown"].ToString());
            }

            if (elem.Keys.Contains("lifetime"))
            {
                properties.lifetime = float.Parse(elem["lifetime"].ToString());
            }

            if (elem.Keys.Contains("damage"))
            {
                properties.damage = int.Parse(elem["damage"].ToString());
            }

            if (elem.Keys.Contains("effect_radius"))
            {
                properties.effect_radius = float.Parse(elem["effect_radius"].ToString());
            }

            if (elem.Keys.Contains("knockback_force"))
            {
                properties.knockback_force = float.Parse(elem["knockback_force"].ToString()) * 1000;
            }

            if (elem.Keys.Contains("stun_duration"))
            {
                properties.stun_duration = float.Parse(elem["stun_duration"].ToString());
            }

            if (elem.Keys.Contains("projectile_speed"))
            {
                properties.projectile_speed = float.Parse(elem["projectile_speed"].ToString());
            }

            if (elem.Keys.Contains("camera_shake_strength"))
            {
                properties.camera_shake_strength = float.Parse(elem["camera_shake_strength"].ToString());
            }

            if (elem.Keys.Contains("camera_shake_duration"))
            {
                properties.camera_shake_duration = float.Parse(elem["camera_shake_duration"].ToString());
            }

            ability_properties_dictionary.Add(projectile_name, properties);
        }
    }
Пример #26
0
 /// <summary>
 /// Tests the agent's sight to a position from its current location.
 /// </summary>
 /// <param name="_position">The sight location to test.</param>
 /// <returns>Returns true if it can see the position, otherwise returns false.</returns>
 public bool TestSightToPosition(Vector3 _position)
 {
     return(JHelper.RaycastAToB(view_point.position, _position,
                                settings.sight_distance, sight_test_layers));
 }
Пример #27
0
 /// <summary>
 /// Tests the agent's sight to a position, as if it were standing in a specific location.
 /// </summary>
 /// <param name="_standing_pos">The hypothetical standing location of the agent.</param>
 /// <param name="_position">The sight location to test.</param>
 /// <returns>Returns true if it can see the position, otherwise returns false.</returns>
 public bool TestSightToPosition(Vector3 _standing_pos, Vector3 _position)
 {
     return(JHelper.RaycastAToB(_standing_pos + new Vector3(0, view_point.position.y),
                                _position, settings.sight_distance, sight_test_layers));
 }
Пример #28
0
        public void UserProfile(User user)
        {
            IEnumerable <UserPost>       posts   = user.Posts;
            EnumerableDisplay <UserPost> display = new EnumerableDisplay <UserPost>(posts, 5, PostDisplay);

            while (true)
            {
                Console.Clear();
                IEnumerable <Community> communities   = Logic.CommonCommunities(user).Take(5);
                IEnumerable <User>      followedUsers = Logic.CommonFollowedUsers(user).Take(5);

                display.items = user.Posts.ToList();

                // Display Profile Description
                Title($"Profile of {user.Name}");

                // Display Common Communities
                Console.WriteLine("Communities in Common: " + string.Join(", ", communities.Select(e => e.Name)));

                Console.WriteLine("Followed Users in Common: " + string.Join(", ", followedUsers.Select(e => e.Name)));


                // Display Posts
                Console.WriteLine("\nPosts: ");
                display.Display();
                // Get Input
                bool followed = Logic.IsFollowed(user);
                Console.WriteLine(
                    bar() +
                    $"{(display.HasPreviousPage ? "[Q] Previous Page " : "")}" +
                    $"{(display.HasNextPage ? "[W] Next Page" : "")}" + (display.HasNextPage || display.HasPreviousPage ? "\n" : "") +
                    $"[1] {(followed ? "Unfollow User" : "Follow User ")} " +
                    "[2] See Joined Communities " +
                    "[3] See Followed Users " +
                    "[X] Back");
                Console.Write(bar());
                string selection = JHelper.InputString("Enter Selection: ", toUpper: true, validator: e => e.In("Q", "W", "1", "2", "3", "X"));
                if (display.HasPreviousPage && selection == "Q")
                {
                    display.PreviousPage();
                }
                else if (display.HasNextPage && selection == "W")
                {
                    display.NextPage();
                }
                else if (selection == "1")
                {
                    if (followed)
                    {
                        Logic.UnfollowUser(user);
                    }
                    else
                    {
                        Logic.FollowUser(user);
                    }
                }
                else if (selection == "2")
                {
                    SeeFollowedCommunities(user);
                }
                else if (selection == "3")
                {
                    SeeFollowedUsers(user);
                }
                else if (selection == "X")
                {
                    break;
                }
            }
        }