void updatePushingPlayers(bool pvMine)
    {
        teamCaptains.Clear();
        int count = detectionColl.Cast(Vector2.zero, rch2ds, 0, true);

        for (int i = 0; i < count; i++)
        {
            RaycastHit2D rch2d = rch2ds[i];
            GameObject   rchGO = rch2d.collider.gameObject;
            if (rchGO.CompareTag("Player"))
            {
                TeamToken  tt         = TeamToken.getTeamToken(rchGO);
                HealthPool healthPool = rchGO.GetComponentInChildren <HealthPool>();
                if (healthPool)
                {
                    if (!teamCaptains.ContainsKey(tt.teamCaptain))
                    {
                        teamCaptains.Add(tt.teamCaptain, 0);
                    }
                    float amount = healthPool.Health;
                    //Add in distance to caravan
                    float distance           = (rchGO.transform.position - transform.position).magnitude;
                    float distanceMultiplier = 1 + ((maxAllowedDistance - distance) / maxAllowedDistance);
                    //Update team captains dict
                    teamCaptains[tt.teamCaptain] += amount * distanceMultiplier;
                }
            }
        }
        updateDirection(pvMine);
    }
Esempio n. 2
0
 protected List <T> FindObjectsToEffect <T>(TeamTokenCaptain teamCaptain) where T : Component
 {
     return(FindObjectsOfType <T>().ToList()
            .FindAll(t => t &&
                     (TeamToken.getTeamToken(t.gameObject)?.onSameTeam(teamCaptain) ?? false)
                     ));
 }
 public void Display(bool display)
 {
     //Destroy all current icons
     glg.transform.DetachChildren();
     playerIcons.ForEach(pi => Destroy(pi));
     playerIcons.Clear();
     //Create new icons
     if (display)
     {
         List <TeamTokenCaptain> ttcList = FindObjectsOfType <TeamTokenCaptain>().ToList();
         List <PlayerController> pcList  = FindObjectsOfType <PlayerController>().ToList();
         //Red team
         TeamTokenCaptain ttcRed = ttcList.Find(
             ttc => ttc.colorGroupIndex == redColorGroupIndex
             );
         pcList.FindAll(
             pc => ttcRed.onSameTeam(TeamToken.getTeamToken(pc.gameObject))
             )
         .ForEach(pc => playerIcons.Add(CreatePlayerIcon(pc)));
         //Separator
         playerIcons.Add(Instantiate(separatorPrefab));
         //Blue team
         TeamTokenCaptain ttcBlue = ttcList.Find(
             ttc => ttc.colorGroupIndex == blueColorGroupIndex
             );
         pcList.FindAll(
             pc => ttcBlue.onSameTeam(TeamToken.getTeamToken(pc.gameObject))
             )
         .ForEach(pc => playerIcons.Add(CreatePlayerIcon(pc)));
         //Layout icons
         playerIcons.ForEach(pi => pi.transform.parent = glg.transform);
     }
 }
Esempio n. 4
0
    IEnumerator spawn()
    {
        Transform spawn = GameSetup.instance.spawnPoint;

        myAvatar = PhotonNetwork.Instantiate(
            Path.Combine("PhotonPrefabs", "PlayerAvatar"),
            spawn.position,
            Quaternion.identity
            );
        TeamToken teamToken = TeamToken.getTeamToken(myAvatar);

        teamToken.assignTeam();
        while (teamToken.teamCaptain == null)
        {
            yield return(null);
        }
        spawn = teamToken.teamCaptain.getNextSpawnPoint();
        Rigidbody2D rb2d = myAvatar.GetComponent <Rigidbody2D>();

        rb2d.isKinematic = true;
        while (myAvatar.transform.position != spawn.position)
        {
            myAvatar.transform.position = spawn.position;
            yield return(null);
        }
        rb2d.isKinematic = false;
        myAvatar.GetComponent <AvatarSetup>().setTeamIndicator();
        yield return(null);
    }
Esempio n. 5
0
    private MapMarker CreateMapMarkerFollow(PhotonView placer, Transform follow, MapMarkerInfo markerInfo)
    {
        MapMarker marker = GetOrCreateMapMarker(placer.ViewID);

        marker.Init(markerInfo, TeamToken.getTeamToken(placer.gameObject)); //placer.teamCaptain.teamColor, Color.white);
        marker.Mark(follow);
        return(marker);
    }
Esempio n. 6
0
    private MapMarker CreateMapMarkerPos(PhotonView placer, Vector2 pos, MapMarkerInfo markerInfo)
    {
        MapMarker marker = GetOrCreateMapMarker(placer.ViewID);

        marker.Init(markerInfo, TeamToken.getTeamToken(placer.gameObject)); //placer.teamCaptain.teamColor, Color.white);
        marker.Mark(pos);
        return(marker);
    }
 private void Awake()
 {
     teamToken = TeamToken.getTeamToken(gameObject);
     PV        = gameObject.FindComponent <PhotonView>();
     if (PV.IsMine)
     {
         //Subfoldername
         if (string.IsNullOrEmpty(folderName))
         {
             throw new UnityException(
                       $"folderName is null! foldername: {folderName}, " +
                       $"gameObject: {gameObject.name}"
                       );
         }
     }
 }
Esempio n. 8
0
    private bool CanCreateMapMarker(PhotonView placerPV, MapMarkerPermission permission)
    {
        TeamToken placer = TeamToken.getTeamToken(placerPV.gameObject);

        switch (permission)
        {
        case MapMarkerPermission.EVERYONE:
            return(true);

        case MapMarkerPermission.ALLIES_ONLY:
            return(placer.onSameTeam(localPlayerTeamToken));

        case MapMarkerPermission.SELF_ONLY:
            return(placer.ownedBySamePlayer(localPlayerTeamToken));
        }
        throw new System.InvalidOperationException($"No such permission handled: {permission}");
    }
 void RPC_ShowResultScreen(int winnerID)
 {
     foreach (TeamTokenCaptain ttc in FindObjectsOfType <TeamTokenCaptain>())
     {
         if (ttc.PV.ViewID == winnerID)
         {
             if (ttc.onSameTeam(TeamToken.getTeamToken(PhotonPlayer.localPlayer.myAvatar)))
             {
                 showResultsScreen(true);
             }
             else
             {
                 showResultsScreen(false);
             }
             break;
         }
     }
 }
Esempio n. 10
0
 // Start is called before the first frame update
 void Start()
 {
     PV = GetComponent <PhotonView>();
     if (PV.IsMine)
     {
         PV.RPC(
             "RPC_AddCharacter",
             RpcTarget.AllBuffered,
             PlayerInfo.instance.characterSelection.Index
             );
         Camera.main.GetComponent <CameraController>().FocusObject = gameObject;
     }
     teamToken = TeamToken.getTeamToken(gameObject);
     if (teamToken.teamCaptain)
     {
         setTeamIndicator();
     }
 }
Esempio n. 11
0
 public void setTeamIndicator()
 {
     if (!teamToken)
     {
         teamToken = TeamToken.getTeamToken(gameObject);
     }
     //Team Color
     shadowSR.color = shadowSR.color.setRGB(
         teamToken.teamCaptain.teamColor
         );
     //Player Color
     myCharacter.FindComponent <PlayerController>().playerColor =
         PlayerInfo.instance.colorGroups[teamToken.teamCaptain.colorGroupIndex]
         .SelectedItem;
     //RPC
     if (PV && PV.IsMine || this.isPhotonViewMine())
     {
         PV.RPC("RPC_SetTeamIndicator", RpcTarget.OthersBuffered);
     }
 }
Esempio n. 12
0
 private void Start()
 {
     teamToken = TeamToken.getTeamToken(gameObject);
     PV        = GetComponent <PhotonView>();
 }
 public static TeamToken FindTeamToken(int viewID)
 => TeamToken.getTeamToken(PhotonView.Find(viewID).gameObject);