Beispiel #1
0
        /// <summary>
        /// Helper method to check if the node matches the current line rendering policy.
        /// </summary>
        /// <param name="snn">The node to check</param>
        /// <returns>The result of the match against the policy. True if matching.</returns>
        public bool MatchesConditions(SocialNetworkNode snn)
        {
            switch (currCondition)
            {
            case 0:
                // Never true.
                return(false);

            case 1:
                // Only true if matches the current selected.
                return(snn.Equals(CURRENTSELECTED));

            case 2:
                // Only true if in the current selected has them on their friends list
                return(CURRENTSELECTED != null && CURRENTSELECTED.IsFriendPresent(snn));

            case 3:
                // Always true.
                return(true);

            default:
                Debug.LogError("Failed to match a current condition!");
                return(false);
            }
        }
Beispiel #2
0
        public bool AddFriend(SocialNetworkNode friend, LineRenderer line)
        {
            if (!IsFriendPresent(friend))
            {
                friendRelations.Add(friend, line);
                return(true);
            }

            return(false);
        }
Beispiel #3
0
        /// <summary>
        /// Temporary testing structure to verify friend relation functionality.
        /// </summary>
        void GenerateFakeFriends()
        {
            // Local instance for consistent results.
            System.Random localRandom = new System.Random(1);
            for (int count = 0; count < nodes.Count; count++)
            {
                SocialNetworkNode currentActive = nodes[count];
                int randomAmountOfFriends       = localRandom.Next(0, 15); //(int)Math.Ceiling(nodes.Count / 5d));
                for (int inner = 0; inner < randomAmountOfFriends; inner++)
                {
                    // Get a random index of the friend to add.
                    int randomFriend = localRandom.Next(0, nodes.Count);

                    // Not adding youself as a friend.
                    if (randomFriend == count)
                    {
                        continue;
                    }

                    // Fish out the friend from the node list.
                    SocialNetworkNode selected = nodes[randomFriend];

                    // Make sure that we do not already have this friend added.
                    if (!currentActive.IsFriendPresent(selected))
                    {
                        GameObject emptyPos = Instantiate(empty, zero_pos, Quaternion.identity);

                        LineRenderer lr = emptyPos.AddComponent <LineRenderer>();
                        lr.material        = new Material(Shader.Find("Sprites/Default"));
                        lr.positionCount   = 2;
                        lr.widthMultiplier = 0.1f;

                        Vector3 pos1 = selected.GetNode().transform.position;
                        Vector3 pos2 = currentActive.GetNode().transform.position;

                        Vector3[] positions = { pos1, pos2 };

                        lr.SetPositions(positions);

                        currentActive.AddFriend(selected, lr);
                        selected.AddFriend(currentActive, lr);
                    }
                    else
                    {
                        continue;
                    }
                }
            }
        }
Beispiel #4
0
 public LineRenderer GetLineForFriend(SocialNetworkNode other)
 {
     if (friendRelations != null && friendRelations.TryGetValue(other, out LineRenderer lr))
     {
         return(lr);
     }
     else
     {
         if (DataStructure.debugging && friendRelations == null)
         {
             Debug.LogError("FriendRelations were NULL!");
         }
         return(null);
     }
 }
Beispiel #5
0
 public bool IsFriendPresent(SocialNetworkNode friend)
 {
     return(friendRelations.ContainsKey(friend));
 }