Пример #1
0
        static void Main(string[] args)
        {
            var mDevServiceUrl = "http://100.126.0.19/TCRMDEV/XRMServices/2011/Organization.svc";
            var mDevService    = MSCRM.GetService("eseozde", "Ericsson2020", "comcel", mDevServiceUrl);

            var upliftServiceUrl = "http://100.126.0.217:5555/TCRMDEV2/XRMServices/2011/Organization.svc";
            var upliftService    = MSCRM.GetService("TCRMINSDR5", "ClaroFULL2017**", "comcel", upliftServiceUrl);

            var businessUnits = BusinessUnitHelper.GetAllBusinessUnits(mDevService);


            foreach (var businessUnit in businessUnits?.Entities)
            {
                var businessUnitName = businessUnit.GetAttributeValue <string>("name");

                var businessUnitTeams = TeamHelper.GetTeamByBusinessUnit(businessUnit.Id, mDevService);
                foreach (var businessUnitTeam in businessUnitTeams?.Entities)
                {
                    var businessUnitTeamName = businessUnitTeam.GetAttributeValue <string>("name");
                    var checkTeam            = TeamHelper.GetTeamByName(businessUnitTeamName, upliftService);

                    if (checkTeam == null)
                    {
                        var newTeamId = TeamHelper.CreateTeam(businessUnitTeam, businessUnit.Id, upliftService);
                        CommonHelper.TeamRoleProcess(newTeamId, businessUnit.Id, mDevService, upliftService);
                        CommonHelper.TeamMemberProcess(businessUnitTeam.Id, businessUnit.Id, mDevService, upliftService);
                    }
                    else
                    {
                        CommonHelper.TeamRoleProcess(checkTeam.Id, businessUnit.Id, mDevService, upliftService);
                        CommonHelper.TeamMemberProcess(checkTeam.Id, businessUnit.Id, mDevService, upliftService);
                    }
                }
            }
        }
Пример #2
0
        private void ReloadTeams()
        {
            if (mViewModel.SelectedSeason != null)
            {
                mViewModel.Teams.Clear();
                foreach (WcfRelation relation in WcfHelper.client.GetRelationsBySeason(mViewModel.SelectedSeason))
                {
                    TeamHelper team = new TeamHelper(relation);

                    foreach (WcfMatch match in SeasonMatches.Where(x => x.HomeTeamId == relation.TeamId))
                    {
                        team.NumberOfGames++;
                        team.GoalsDifference = team.GoalsDifference + match.HomeTeamScore - match.AwayTeamScore;
                        if (match.HomeTeamScore > match.AwayTeamScore)                         // Sieg
                        {
                            team.Points += 3;
                            team.Wins++;
                        }
                        else if (match.HomeTeamScore < match.AwayTeamScore)                        // Niederlage
                        {
                            team.Defeats++;
                        }
                        else                         // Unentschieden
                        {
                            team.Points++;
                            team.Draws++;
                        }
                    }

                    foreach (WcfMatch match in SeasonMatches.Where(x => x.AwayTeamId == relation.TeamId))
                    {
                        team.NumberOfGames++;
                        team.GoalsDifference = team.GoalsDifference - match.HomeTeamScore + match.AwayTeamScore;
                        if (match.HomeTeamScore < match.AwayTeamScore)                         // Sieg
                        {
                            team.Points += 3;
                            team.Wins++;
                        }
                        else if (match.HomeTeamScore > match.AwayTeamScore)                         // Niederlage
                        {
                            team.Defeats++;
                        }
                        else                         // Unentschieden
                        {
                            team.Points++;
                            team.Draws++;
                        }
                    }

                    mViewModel.Teams.Add(team);
                }
                mViewModel.Teams = mViewModel.Teams.OrderByDescending(x => x.Points).ToList();
                int rank = 1;
                foreach (WcfTeam team in mViewModel.Teams)
                {
                    team.Rank = rank;
                    rank++;
                }
            }
        }
 private void GetTeam()
 {
     teamList              = TeamHelper.GetTeam(tournament);
     cmbTeam.DataSource    = teamList;
     cmbTeam.DisplayMember = "teamName";
     cmbTeam.ValueMember   = "teamID";
 }
Пример #4
0
        public async Task <IActionResult> OnPostAsync()
        {
            if (Event != null)
            {
                using (var transaction = _context.Database.BeginTransaction())
                {
                    var eventTeams = from team in _context.Teams
                                     where team.Event == Event
                                     select team;

                    foreach (Team team in eventTeams)
                    {
                        await TeamHelper.DeleteTeamAsync(_context, team);
                    }

                    var eventPuzzles = from puzzle in _context.Puzzles
                                       where puzzle.Event == Event
                                       select puzzle;
                    foreach (Puzzle puzzle in eventPuzzles)
                    {
                        await PuzzleHelper.DeletePuzzleAsync(_context, puzzle);
                    }

                    _context.Events.Remove(Event);

                    await _context.SaveChangesAsync();

                    transaction.Commit();
                }
            }

            return(RedirectToPage("./Index"));
        }
Пример #5
0
        private void TeamOfficial()
        {
            var tournament = GetTournament();

            if (isAvailable(tournament) == false)
            {
                MessageBox.Show("No Available Tournament");
                return;
            }
            else if (tournament.tournamentStatus == 2 || tournament.tournamentStatus == 3)
            {
                MessageBox.Show("Sorry you cannot add more team fficial because the tournament already active or the tournament is close");
                return;
            }

            var team = TeamHelper.GetTeam(tournament);

            if (team.Count <= 0)
            {
                MessageBox.Show("Theres no team been created");
                return;
            }
            using (Form f = new frmViewTeamOfficial(tournament))
            {
                f.ShowDialog();
            }
        }
Пример #6
0
    // Spawn drones from each start location to each destination location
    void SpawnDrones()
    {
        //FIXME: This is an ugly fix for not spawning on each other
        Vector3 space = new Vector3(0, 0, 70);

        for (int j = 0; j < drones_per_location; j++)
        {
            for (int i = 0; i < spawn_locations.Length; i++)
            {
                GameObject droneInstance = (GameObject)Instantiate(drone, spawn_locations[i].position + (space * j), spawn_locations[i].rotation);
                droneInstance.tag = "Npc";
                if (TeamHelper.IsSameTeam(gameObject.layer, 8))
                {
                    droneInstance.layer = 8;
                }
                else
                {
                    droneInstance.layer = 11;
                }

                // Propagate layer
                TeamHelper.PropagateLayer(droneInstance, droneInstance.layer);
                GameObject triggerObject = droneInstance.transform.FindChild("Trigger").gameObject;
                triggerObject.layer = 3;

                droneInstance.GetComponent <GunSwitcher>().LayerChanged();

                DroneBehaviour behav = droneInstance.GetComponent <DroneBehaviour>();
                behav.target = destination[i];

                this.networkSyncDroneSpawn(droneInstance);
            }
        }
    }
Пример #7
0
        public async Task <IActionResult> OnGetAddMemberAsync(int teamId, int userId, int applicationId)
        {
            if (EventRole == EventRole.play && !Event.IsTeamMembershipChangeActive)
            {
                return(NotFound("Team membership change is not currently active."));
            }

            TeamApplication application = await(from app in _context.TeamApplications
                                                where app.ID == applicationId
                                                select app).FirstOrDefaultAsync();

            if (application == null)
            {
                return(NotFound("Could not find application"));
            }

            if (application.Player.ID != userId)
            {
                return(NotFound("Mismatched player and application"));
            }
            Team team = await _context.Teams.FirstOrDefaultAsync(m => m.ID == teamId);

            if (application.Team != team)
            {
                return(Forbid());
            }

            Tuple <bool, string> result = TeamHelper.AddMemberAsync(_context, Event, EventRole, teamId, userId).Result;

            if (result.Item1)
            {
                return(RedirectToPage("./Details", new { teamId = teamId }));
            }
            return(NotFound(result.Item2));
        }
Пример #8
0
        public void LoadGame(
            out List <Brands> brands,
            out List <Cards> cards,
            out List <Matches> matches,
            out List <Promotions> promotions,
            out List <Teams> teams,
            out List <TitlesMain> titles,
            out List <WrestlersMain> wrestlers
            )
        {
            BrandHelper     bHelper  = new BrandHelper();
            CardHelper      cHelper  = new CardHelper();
            MatchHelper     mHelper  = new MatchHelper();
            PromotionHelper pHelper  = new PromotionHelper();
            TeamHelper      tHelper  = new TeamHelper();
            TitleHelper     tlHelper = new TitleHelper();
            WrestlerHelper  wHelper  = new WrestlerHelper();

            brands     = bHelper.PopulateBrandsList();
            cards      = cHelper.PopulateCardsList();
            matches    = mHelper.PopulateMatchesList();
            promotions = pHelper.PopulatePromotionsList();
            teams      = tHelper.PopulateTeamsList();
            titles     = tlHelper.PopulateTitlesList();
            wrestlers  = wHelper.PopulateWrestlersList();
        }
Пример #9
0
        public void GivenTheTeamHasTheFollowingSeasons(Table table)
        {
            var teams = TeamHelper.CreateFrom(table);
            var teamRepositoryStub = Ioc.Get <ITeamRepository>() as TeamRepositoryStub;

            teamRepositoryStub.Teams.AddRange(teams);
        }
Пример #10
0
    void Update()
    {
        timeToLive -= Time.deltaTime;

        if (timeToLive <= 0)
        {
            if (raycastHit != null)
            {
                if (!TeamHelper.IsSameTeam(gameObject.layer, raycastHit.layer))
                {
                    Vector3 impactPoint = raycastHit.transform.position - ProjectileController.FlyControl.VelocityDirection;
                    switch (raycastHit.tag)
                    {
                    case "Player":
                        raycastHit.GetComponent <HealthControl>().TakeDamage(ProjectileController.Damage, impactPoint);
                        break;

                    case "Npc":
                        raycastHit.GetComponent <HealthControl>().TakeDamage(ProjectileController.Damage, impactPoint);
                        break;

                    case "Mothership":
                        raycastHit.GetComponent <HealthControl>().TakeDamage(ProjectileController.Damage, impactPoint);
                        break;
                    }
                }
            }

            Destroy(gameObject);
        }
    }
Пример #11
0
    //private IList<Material>

    // Use this for initialization
    void Start()
    {
        //Convert to ILists. These are not visible in the inspector, but easier to use.
        IList <Material> team1List = new List <Material>(team1Materials);
        IList <Material> team2List = new List <Material>(team2Materials);

        //Check own team
        //Make a list of material NAMES to replace, because direct comparison is hard in Unity :(
        if (TeamHelper.GetTeamNumber(transform.gameObject.layer) == 1)
        {
            IList <string> matNames = new List <string>();
            foreach (Material mat in team2List)
            {
                matNames.Add(mat.name);
            }
            ReplaceMaterialsWith(matNames, team1List);
        }
        else
        {
            IList <string> matNames = new List <string>();
            foreach (Material mat in team1List)
            {
                matNames.Add(mat.name);
            }
            ReplaceMaterialsWith(matNames, team2List);
        }
    }
Пример #12
0
        /// <summary>
        /// Add the specified <c>Principal</c> to the list of <c>Queue</c> members.
        /// <para>
        /// For more information look at https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.addprincipaltoqueuerequest(v=crm.8).aspx
        /// </para>
        /// </summary>
        /// <param name="queueId"><c>Queue</c> Id</param>
        /// <param name="principalType"><c>System User</c> or <c>Team</c>. If the passed-in <c>PrincipalType.Team</c> , add each team member to the queue.</param>
        /// <param name="principalId"><c>Principal</c> Id</param>
        /// <returns>
        /// <see cref="AddPrincipalToQueueResponse"/>
        /// </returns>
        public AddPrincipalToQueueResponse AddPrincipalToQueue(Guid queueId, PrincipalType principalType, Guid principalId)
        {
            ExceptionThrow.IfGuidEmpty(queueId, "queueId");
            ExceptionThrow.IfGuidEmpty(principalId, "principalId");

            Entity principalEntity = null;

            switch (principalType)
            {
            case PrincipalType.SystemUser:
                SystemUserHelper systemuserHelper = new SystemUserHelper(this.OrganizationService);
                principalEntity = systemuserHelper.Get(principalId, "fullname");
                break;

            case PrincipalType.Team:
                TeamHelper teamHelper = new TeamHelper(this.OrganizationService);
                principalEntity = teamHelper.Get(principalId, "name");
                break;
            }

            ExceptionThrow.IfNull(principalEntity, "principal", string.Format("Principal not found with '{0}'", principalId.ToString()));

            AddPrincipalToQueueRequest request = new AddPrincipalToQueueRequest()
            {
                QueueId   = queueId,
                Principal = principalEntity
            };

            return((AddPrincipalToQueueResponse)this.OrganizationService.Execute(request));
        }
 private void FillCombobox()
 {
     listOfTeam            = TeamHelper.GetTeam(tournament);
     cmbTeam.DataSource    = listOfTeam;
     cmbTeam.DisplayMember = "teamName";
     cmbTeam.ValueMember   = "teamID";
 }
        private void ActivateStatus()
        {
            tournamentDetails.tournamentStatus = 2;
            List <Team>         team         = TeamHelper.GetTeam(tournamentDetails);
            List <GameOfficial> gameofficial = GameOfficialHelper.GetAllGameOfficial(tournamentDetails);
            List <Player>       player       = PlayerHelper.GetPlayer(tournamentDetails);
            List <Venue>        venue        = VenueHelper.GetVenue();

            /* if(tournamentDetails.ValidationOfActivation(team,gameofficial,player) != true)
             * {
             *   MessageBox.Show("Error Activating");
             *   return;
             * }
             */

            List <Match> match = Match.GenerateMatch(team, venue, tournamentDetails);

            foreach (Match m in match)
            {
                MatchHelper.SaveMatch(m);
            }

            if (TournamentHelper.UpdateTournamentStatus(tournamentDetails) == 0)
            {
                //report an error
                MessageBox.Show("Error activating tournament");
                this.DialogResult = System.Windows.Forms.DialogResult.Cancel;
            }
            this.DialogResult = System.Windows.Forms.DialogResult.OK;
        }
Пример #15
0
        public Form1(IMatchServer matchServer)
        {
            _matchServer = matchServer;

            _teams = TeamHelper.GenerateTeams();
            InitializeComponent();
            UpdateDataGrid();
        }
Пример #16
0
        public ActionResult TeamTPE()
        {
            var viewModel = new TeamTPEViewModel();

            viewModel.Teams       = new List <TeamViewModel>();
            viewModel.AllPlayers  = new List <PlayerViewModel>();
            viewModel.lastUpdated = DateTimeHelper.GetDateTimeFromFile(@"~/Team Files/record.json");

            var playerFiles = TeamHelper.GetTeamPlayerFiles();

            foreach (var file in playerFiles)
            {
                if (System.IO.File.Exists(System.Web.HttpContext.Current.Server.MapPath(file.Value)))
                {
                    var team = new TeamViewModel();
                    team.TeamName = file.Key;
                    team.Players  = new List <PlayerViewModel>();

                    var lines = System.IO.File.ReadAllLines(System.Web.HttpContext.Current.Server.MapPath(file.Value));
                    foreach (var line in lines)
                    {
                        var playerFileLine = new PlayerFileLine(line);

                        var playerData = PlayerHelper.GetPlayerFromPlayerLine(playerFileLine);
                        if (string.IsNullOrEmpty(playerData.PlayerFirstName))
                        {
                            continue;
                        }

                        var player = new PlayerViewModel();
                        player.PlayerID            = playerData.PlayerID;
                        player.PlayerFirstName     = playerData.PlayerFirstName;
                        player.PlayerLastName      = playerData.PlayerLastName;
                        player.PlayerPosition      = playerData.PlayerPosition;
                        player.PlayerSeasonDrafted = playerData.PlayerSeasonDrafted;
                        player.PlayerTPE           = playerData.PlayerTPE;
                        player.TeamName            = team.TeamName;
                        player.PlayerProfileURL    = playerData.PlayerProfileURL;

                        team.Players.Add(player);
                        viewModel.AllPlayers.Add(player);
                    }

                    //var teamTPE = 0;

                    // TODO: convert this to read from the team file rather than using another loop to calculate
                    //foreach (var player in team.Players)
                    //{
                    //    teamTPE += player.PlayerTPE;
                    //}
                    //team.TeamTPE = teamTPE;

                    viewModel.Teams.Add(team);
                }
            }

            return(View(viewModel));
        }
Пример #17
0
        protected void Update()
        {
            if (Network.isServer && _state != MatchState.Ended)
            {
                MatchState previousState = _state;
                int        team1Count    = TeamHelper.GetPlayersCountInTeam(1);
                int        team2Count    = TeamHelper.GetPlayersCountInTeam(2);

                // Checks if there is missing players
                if ((team1Count < NumberOfPlayersRequiredInTeam || team2Count < NumberOfPlayersRequiredInTeam) && !BypassWaiting)
                {
                    // If so, set the state to Waiting for players
                    _state = MatchState.WaitingForPlayers;
                }
                else
                {
                    _state = MatchState.Running;

                    // Otherwise increases the timer
                    _timeElapsed += Time.deltaTime;
                    _networkView.RPC("SetTimer", RPCMode.OthersBuffered, _timeElapsed);

                    // If the time allotted for the game is elapsed, ended the match
                    if (_timeElapsed > MaxTime && false) // enless matches, edited by Damien
                    {
                        _state = MatchState.Ended;

                        // Figures which team has won
                        int team1Kills = _registeredKills[1];
                        int team2Kills = _registeredKills[2];

                        if (team1Kills > team2Kills)
                        {
                            _resultState = MatchResultState.Victory_Team1;
                        }
                        else if (team2Kills > team1Kills)
                        {
                            _resultState = MatchResultState.Victory_Team2;
                        }
                        else
                        {
                            _resultState = MatchResultState.Draw;
                        }

                        // Updates the clients' MatchResultState
                        _networkView.RPC("SetMatchResultState", RPCMode.OthersBuffered, (int)_resultState);
                    }
                }

                if (previousState != _state)
                {
                    // Updates the clients' MatchState
                    _networkView.RPC("SetMatchState", RPCMode.OthersBuffered, (int)_state);
                }
            }
        }
        public async Task <IActionResult> OnGetAddMemberAsync(int teamId, int userId, int applicationId)
        {
            Tuple <bool, string> result = TeamHelper.AddMemberAsync(_context, Event, EventRole, teamId, userId).Result;

            if (result.Item1)
            {
                return(RedirectToPage("./Details", new { teamId = teamId }));
            }
            return(NotFound(result.Item2));
        }
Пример #19
0
    private void SetObjectLayerRPC(NetworkViewID owner, int objectID, int layer)
    {
        //Debug.Log("SetObjectLayerRPC received.");

        GameObject obj = base.GetObject(owner, objectID);

        obj.name  = "Player_" + layer;
        obj.layer = layer;
        TeamHelper.PropagateLayer(obj, layer);
    }
Пример #20
0
 public string Training2()
 {
     if (Team != null)
     {
         return(TeamHelper.TrainingDayTime((DayOfWeek)Team.TrainingDay2, Team.TrainingTime2));
     }
     else
     {
         return(string.Empty);
     }
 }
Пример #21
0
        public async Task <IActionResult> OnPostAsync(int teamId)
        {
            Team = await _context.Teams.FindAsync(teamId);

            var mergeIntoTeam = await _context.Teams.FindAsync(MergeIntoID);

            if (Team == null || mergeIntoTeam == null || Team.Event != Event || mergeIntoTeam.Event != Event)
            {
                return(NotFound());
            }

            List <string> memberEmails          = null;
            List <string> mergeIntoMemberEmails = null;

            using (var transaction = await _context.Database.BeginTransactionAsync(IsolationLevel.Serializable))
            {
                var members = await _context.TeamMembers.Where(tm => tm.Team.ID == teamId).ToListAsync();

                memberEmails = await _context.TeamMembers.Where(tm => tm.Team.ID == teamId).Select(tm => tm.Member.Email).ToListAsync();

                mergeIntoMemberEmails = await _context.TeamMembers.Where(tm => tm.Team.ID == MergeIntoID).Select(m => m.Member.Email).ToListAsync();

                var states = await PuzzleStateHelper.GetSparseQuery(_context, Team.Event, null, Team).ToListAsync();

                var mergeIntoStates = await PuzzleStateHelper.GetSparseQuery(_context, Team.Event, null, mergeIntoTeam).ToDictionaryAsync(s => s.PuzzleID);

                // copy all the team members over
                foreach (var member in members)
                {
                    member.Team = mergeIntoTeam;
                }

                // also copy puzzle solves over
                foreach (var state in states)
                {
                    if (state.SolvedTime != null && mergeIntoStates.TryGetValue(state.PuzzleID, out var mergeIntoState) && mergeIntoState.SolvedTime == null)
                    {
                        await PuzzleStateHelper.SetSolveStateAsync(_context, Team.Event, mergeIntoState.Puzzle, mergeIntoTeam, state.UnlockedTime);
                    }
                }

                await TeamHelper.DeleteTeamAsync(_context, Team, sendEmail : false);

                await _context.SaveChangesAsync();

                transaction.Commit();
            }

            MailHelper.Singleton.SendPlaintextWithoutBcc(memberEmails.Union(mergeIntoMemberEmails),
                                                         $"{Event.Name}: Team '{Team.Name}' has been merged into '{mergeIntoTeam.Name}'",
                                                         $"These two teams have been merged into one superteam. Please welcome your new teammates!");

            return(RedirectToPage("./Index"));
        }
Пример #22
0
 private void DetermineProjectileLayer()
 {
     projectileTag       = TeamHelper.LayerToProjectileTag(gameObject.layer);
     projectileLayerMask = LayerMask.NameToLayer(projectileTag);
     //Debug.Log("Determining layers.");
     //Debug.Log(gameObject.name);
     //Debug.Log("Player ship layer: " + gameObject.layer);
     //Debug.Log("Previous ship layer: " + previousObjLayer);
     //Debug.Log("Output layer: " + projectileLayerMask);
     this.previousObjLayer = gameObject.layer;
 }
        public async Task <IActionResult> OnPostRequalifyAsync(int teamId)
        {
            Team = await _context.Teams.FindAsync(teamId);

            if (Team != null)
            {
                await TeamHelper.SetTeamQualificationAsync(_context, Team, false);
            }

            return(RedirectToPage("./Index"));
        }
Пример #24
0
        private void LoadTournament()
        {
            var tournament = GetTournament();

            if (isAvailable(tournament) == true)
            {
                if (tournament.tournamentStatus == 2)
                {
                    btnExportTeamRooster.Visible = true;
                }
                lblDate.Visible             = true;
                lblMotto.Visible            = true;
                lblTitle.Visible            = true;
                lblTournamentDate.Visible   = true;
                lblTournamentMotto.Visible  = true;
                lblTournamentTitle.Visible  = true;
                lblTournamentStatus.Visible = true;
                lblNoGameOfficial.Visible   = true;
                lblNoPlayer.Visible         = true;
                lblNoTeam.Visible           = true;
                lblGameOfficial.Visible     = true;
                lblTeam.Visible             = true;
                lblPlayer.Visible           = true;

                List <GameOfficial> gameOfficial = GameOfficialHelper.GetAllGameOfficial(tournament);
                List <Team>         team         = TeamHelper.GetTeam(tournament);
                List <Player>       player       = PlayerHelper.GetPlayer(tournament);

                lblGameOfficial.Text    = gameOfficial.Count.ToString();
                lblTeam.Text            = team.Count.ToString();
                lblPlayer.Text          = player.Count.ToString();
                lblStatus.Text          = GetStatus(tournament);
                lblTournamentTitle.Text = tournament.tournamentTitle;
                lblTournamentMotto.Text = tournament.tournamentMotto;
                lblTournamentDate.Text  = tournament.tournamentStart.ToShortDateString() + " - " + tournament.tournamentEnd.ToShortDateString();
                return;
            }
            else
            {
                btnExportTeamRooster.Visible = false;
                lblDate.Visible             = false;
                lblMotto.Visible            = false;
                lblTitle.Visible            = false;
                lblTournamentDate.Visible   = false;
                lblTournamentMotto.Visible  = false;
                lblTournamentTitle.Visible  = false;
                lblTournamentStatus.Visible = false;
                lblPlayer.Visible           = false;
                lblTeam.Visible             = false;
                lblGameOfficial.Visible     = false;
                lblStatus.Text = "No Available Tournament";
            }
        }
Пример #25
0
    /// <summary>
    /// Initializes the server-side objects.
    /// </summary>
    private void createServerSideObjects()
    {
        Player server = new Player(base.NetworkControl.LocalViewID, Network.player);

        base.NetworkControl.Players.Add(server.ID, server);
        base.ObjectTables.AddPlayerTable(server);
        Debug.Log("Created server player: " + server.ID);

        Player serverPlayer = base.NetworkControl.ThisPlayer;

        // Initialize the starting positions of the motherships.
        Vector3 team1MothershipPos = new Vector3(2000, 0, 0);
        Vector3 team2MothershipPos = new Vector3(-2000, 0, 0);

        // Initialize te motherships.
        GameObject team1Mothership = (GameObject)GameObject.Instantiate(
            this.MothershipPrefab, team1MothershipPos, Quaternion.identity
            );
        GameObject team2Mothership = (GameObject)GameObject.Instantiate(
            this.MothershipPrefab, team2MothershipPos, Quaternion.identity
            );

        // Assign teams to the motherships.
        TeamHelper.PropagateLayer(team1Mothership, (int)Layers.Team1Mothership);
        TeamHelper.PropagateLayer(team2Mothership, (int)Layers.Team2Mothership);
        team1Mothership.name = "Team1Mothership";
        team2Mothership.name = "Team2Mothership";

        // Generate object IDs for the motherships.
        int team1MothershipID = base.GUIDGenerator.GenerateID();
        int team2MothershipID = base.GUIDGenerator.GenerateID();

        // Assign some values.
        ObjectSync team1MSObjSync = team1Mothership.GetComponent <ObjectSync>();

        team1MSObjSync.Type = ObjectSyncType.Mothership;
        team1MSObjSync.AssignID(serverPlayer, team1MothershipID);
        HealthControl team1MSHealthControl = team1Mothership.GetComponent <HealthControl>();

        team1MSHealthControl.DrawHealthInfo = false;

        ObjectSync team2MSObjSync = team2Mothership.GetComponent <ObjectSync>();

        team2MSObjSync.Type = ObjectSyncType.Mothership;
        team2MSObjSync.AssignID(serverPlayer, team2MothershipID);
        HealthControl team2MSHealthControl = team2Mothership.GetComponent <HealthControl>();

        team2MSHealthControl.DrawHealthInfo = false;

        base.ObjectTables.AddPlayerObject(serverPlayer, team1MothershipID, team1Mothership);
        base.ObjectTables.AddPlayerObject(serverPlayer, team2MothershipID, team2Mothership);
    }
Пример #26
0
    public static void RemoveNpc(GameObject npc)
    {
        int team = TeamHelper.GetTeamNumber(npc.layer);

        if (team == 1)
        {
            Team1Npcs.Remove(npc);
        }
        else
        {
            Team2Npcs.Remove(npc);
        }
    }
Пример #27
0
    private void CreateDroneRPC(NetworkViewID owner, int objectID, Vector3 position, int layer)
    {
        GameObject drone = (GameObject)GameObject.Instantiate(this.AIDronePrefab, position, Quaternion.identity);

        //ObjectSync objSync = drone.GetComponent<ObjectSync>();
        drone.GetComponent <HealthControl>().DrawHealthInfo = false;
        //drone.GetComponent<DroneBehaviour>().enabled = false;
        //drone.GetComponent<NpcListUpdater>().enabled = false;
        //drone.GetComponent<MovingObjectSync>().SuppressVelocitySync = true;

        TeamHelper.PropagateLayer(drone, layer);

        base.AddToObjectTables(drone, owner, objectID);
    }
Пример #28
0
    public void ObjectDestroyed(GameObject obj)
    {
        ObjectSync objSync = obj.GetComponent <ObjectSync>();

        if (objSync == null)
        {
            throw new UnityException("Given GameObject must contain an ObjectSync component");
        }

        if (objSync.Type == ObjectSyncType.Mothership)
        {
            MatchResult result = TeamHelper.GetTeamNumber(obj.layer) == 1 ? MatchResult.Team2Win : MatchResult.Team1Win;
            this.EndMatch(result);
        }
    }
Пример #29
0
    private void HandleProjectileCollision(Collision info)
    {
        //if (Network.peerType == NetworkPeerType.Server || GlobalSettings.SinglePlayer)
        {
            //Debug.Log("Collision detected.");
            //Debug.Log(info.gameObject.name);

            if (!TeamHelper.IsSameTeam(info.collider.gameObject.tag, gameObject.layer))
            {
                HealthControl.TakeDamage(info.gameObject.GetComponent <ProjectileController>().Damage, info.contacts[0].point);
            }
        }

        Destroy(info.gameObject);
    }
Пример #30
0
    private void CreatePlayerShipRPC(NetworkViewID playerID, int objectID, NetworkMessageInfo info)
    {
        Debug.Log("Create player ship RPC received!");

        Player owner = base.NetworkControl.Players[playerID];

        // Create the player ship.
        GameObject playerShip = (GameObject)GameObject.Instantiate(this.PlayerPrefab);

        TeamHelper.PropagateLayer(playerShip, (int)owner.Team);

        if (base.NetworkControl.LocalViewID == playerID)
        {
            // Set variables for when this ship is controlled by the client receiving the RPC.
            base.ObjectTables.ThisPlayerObjects.PlayerShipID     = objectID;
            playerShip.GetComponentInChildren <Camera>().enabled = true;
        }
        else
        {
            // Disable components that mostly has to do with interface and controls for when the
            // ship is controlled by another player.
            playerShip.GetComponentInChildren <Camera>().enabled        = false;
            playerShip.GetComponentInChildren <AudioListener>().enabled = false;
            playerShip.GetComponent <ShipControl>().enabled             = false;
            playerShip.GetComponent <SoftwareMouse>().enabled           = false;
            playerShip.GetComponent <HUD>().enabled = false;
            playerShip.GetComponent <PlayerHealthControl>().DrawHealthInfo     = false;
            playerShip.GetComponentInChildren <ThirdPersonCrosshair>().enabled = false;
        }

        // Set object type.
        ObjectSync objSync = playerShip.GetComponent <ObjectSync>();

        objSync.Type = ObjectSyncType.PlayerShip;

        // Set spawn point reference.
        Player     player       = this.NetworkControl.Players[playerID];
        int        spawnPointID = this.ObjectTables.PlayerObjects[player].PlayerSpawnPointID;
        GameObject spawnPoint   = this.ObjectTables.GetPlayerObject(player, spawnPointID);

        playerShip.GetComponent <PlayerHealthControl>().RespawnPoint = spawnPoint.GetComponent <PlayerRespawner>();
        spawnPoint.GetComponent <PlayerRespawner>().AttachPlayer(playerShip);

        // Add to global object tables.
        base.ObjectTables.PlayerObjects[owner].PlayerShipID = objectID;
        base.AddToObjectTables(playerShip, playerID, objectID);
    }