Example #1
0
 private void RPCSendClientRegistrationData(int team, int teamOrder)
 {
     IAIBase.ETeam teamVal = (IAIBase.ETeam)team;
     clientManager.SendGameMessage(new RegistrationOnServer()
     {
         Team = teamVal, TeamOrder = teamOrder
     });
 }
Example #2
0
        public ClientDataOnServer(User user, Profile profile, NetworkPlayer networkPlayer, IAIBase.ETeam team)
        {
            User          = user;
            Profile       = profile;
            NetworkPlayer = networkPlayer;
            ClientTeam    = team;

            CurrentHealth = Constants.DEFAULT_HEALTH_DRONE;
        }
Example #3
0
        private void ShowPlayerDrivenMessage(string playerName, IAIBase.ETeam playerTeam, string message)
        {
            GameObject go = Instantiate(playerLogMessagePrefab) as GameObject;

            go.transform.SetParent(logParent.transform);

            Text[] textComponents = go.GetComponentsInChildren <Text>();

            SetTeamColourOnText(playerTeam, textComponents[0]);
            textComponents[0].text = playerName;
            textComponents[1].text = message;

            AddToLogList(go);
        }
Example #4
0
        public TeamList(IAIBase.ETeam colour, ClientDataOnServer[] players)
        {
            TeamColour       = colour;
            TeamDisplayNames = new TeamListRecord[players.Length];
            int i = 0;

            foreach (ClientDataOnServer p in players)
            {
                TeamDisplayNames[i] = new TeamListRecord()
                {
                    PlayerName = p.Profile.DisplayName, ReadyInLobby = p.ReadyToPlay, ReadyInMatch = p.LoadedLevel
                };
                ++i;
            }
        }
Example #5
0
        private void ShowKillMessage(string killerName, IAIBase.ETeam killerTeam, string victimName, IAIBase.ETeam victimTeam)
        {
            GameObject go = Instantiate(killMessagePrefab) as GameObject;

            go.transform.SetParent(logParent.transform);

            Text[] textComponents = go.GetComponentsInChildren <Text>();

            SetTeamColourOnText(killerTeam, textComponents[0]);
            textComponents[0].text = killerName;
            SetTeamColourOnText(victimTeam, textComponents[2]);
            textComponents[2].text = victimName;

            AddToLogList(go);
        }
Example #6
0
        private void UpdateScore(IAIBase.ETeam team, int score)
        {
            switch (team)
            {
            case IAIBase.ETeam.TEAM_BLUE:
                blueTeamScore.text = score.ToString();
                return;

            case IAIBase.ETeam.TEAM_RED:
                redTeamScore.text = score.ToString();
                return;

            default:
                return;
            }
        }
Example #7
0
        private void SetTeamColourOnText(IAIBase.ETeam playerTeam, Text textComponent)
        {
            switch (playerTeam)
            {
            case IAIBase.ETeam.TEAM_RED:
                textComponent.color = Color.red;
                break;

            case IAIBase.ETeam.TEAM_BLUE:
                textComponent.color = Color.blue;
                break;

            default:
                textComponent.color = Color.white;
                break;
            }
        }
Example #8
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               SpawnNPC
    /////////////////////////////////////////////////////////////////////////////
    public static void SpawnNPC(IAIBase.ETeam eTeam, IAIBase.ENPCType eType)
    {
        foreach (GameObject goObject in m_liSpawnPoints)
        {
            CSpawner cSpawner = goObject.GetComponent <CSpawner>();

            if (cSpawner.SpawnerType != ESpawnerType.TYPE_NPC)
            {
                continue;
            }

            if (cSpawner.Team == eTeam && true == cSpawner.CanSpawn)
            {
                cSpawner.Spawn(NPCResource.GetObjectByType(eTeam, eType));
                break;
            }
        }
    }
Example #9
0
        public void Enable(string killerName, IAIBase.ETeam killerTeam)
        {
            deathBanner.SetActive(true);

            switch (killerTeam)
            {
            case IAIBase.ETeam.TEAM_RED:
                playerName.color = Color.red;
                break;

            case IAIBase.ETeam.TEAM_BLUE:
                playerName.color = Color.blue;
                break;

            default:
                playerName.color = Color.white;
                break;
            }
            playerName.text = killerName;
            StartCoroutine(Countdown());
        }
Example #10
0
        private IAIBase.ETeam GetTeamForNextClient(out int teamOrder)
        {
            int redCount  = registeredClients.Count(c => c.ClientTeam == IAIBase.ETeam.TEAM_RED);
            int blueCount = registeredClients.Count(c => c.ClientTeam == IAIBase.ETeam.TEAM_BLUE);

            IAIBase.ETeam team = redCount <= blueCount ? IAIBase.ETeam.TEAM_RED : IAIBase.ETeam.TEAM_BLUE;
            switch (team)
            {
            case IAIBase.ETeam.TEAM_RED:
                teamOrder = redCount;
                break;

            case IAIBase.ETeam.TEAM_BLUE:
                teamOrder = blueCount;
                break;

            default:
                teamOrder = 0;
                break;
            }
            return(team);
        }
Example #11
0
        public bool RegisterClient(RegisterClient registerMessage, out IAIBase.ETeam team, out int teamOrder)
        {
            if (registeredClients.Count < Constants.GAME_MAX_PLAYERS)
            {
                team = GetTeamForNextClient(out teamOrder);

                ClientDataOnServer client = new ClientDataOnServer(registerMessage.User, registerMessage.Profile, registerMessage.NetworkPlayer, team);
                registeredClients.Add(client);

                if (OnClientRegistered != null)
                {
                    OnClientRegistered();
                }

                return(true);
            }
            else
            {
                Debug.LogError("Maximum number of players reached, cannot register");
                team      = IAIBase.ETeam.TEAM_NONE;
                teamOrder = -1;
                return(false);
            }
        }
Example #12
0
 public IEnumerable <ClientDataOnServer> GetTeam(IAIBase.ETeam teamColour)
 {
     return(registeredClients.Where(c => c.ClientTeam == teamColour));
 }
Example #13
0
    /////////////////////////////////////////////////////////////////////////////
    /// Function:               GetObjectByType
    /////////////////////////////////////////////////////////////////////////////
    public GameObject GetObjectByType(IAIBase.ETeam eTeam, IAIBase.ENPCType eType)
    {
        bool bMatchFound = false;

        if (eTeam == IAIBase.ETeam.TEAM_BLUE)
        {
            UpdateBlueTeamObjects();

            foreach (GameObject goObject in m_liBlueTeamNPCs)
            {
                switch (eType)
                {
                case IAIBase.ENPCType.TYPE_DRONE:

                    CDroneAI cDrone = goObject.GetComponent <CDroneAI>();
                    if (null == cDrone)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_HEALER:
                    break;

                case IAIBase.ENPCType.TYPE_TANK:

                    CTankAI cTank = goObject.GetComponent <CTankAI>();
                    if (null == cTank)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_WARRIOR:

                    CWarriorAI cWarrior = goObject.GetComponent <CWarriorAI>();
                    if (null == cWarrior)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;
                }

                if (true == bMatchFound)
                {
                    return(goObject);
                }
            }
        }
        else if (eTeam == IAIBase.ETeam.TEAM_RED)
        {
            UpdateRedTeamObjects();

            foreach (GameObject goObject in m_liRedTeamNPCs)
            {
                switch (eType)
                {
                case IAIBase.ENPCType.TYPE_DRONE:

                    CDroneAI cDrone = goObject.GetComponent <CDroneAI>();
                    if (null == cDrone)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_HEALER:
                    break;

                case IAIBase.ENPCType.TYPE_TANK:

                    CTankAI cTank = goObject.GetComponent <CTankAI>();
                    if (null == cTank)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;

                case IAIBase.ENPCType.TYPE_WARRIOR:

                    CWarriorAI cWarrior = goObject.GetComponent <CWarriorAI>();
                    if (null == cWarrior)
                    {
                        continue;
                    }

                    bMatchFound = true;

                    break;
                }

                if (true == bMatchFound)
                {
                    return(goObject);
                }
            }
        }

        return(null);
    }
Example #14
0
 public void UpdateTeamDetails(IAIBase.ETeam team, int teamOrder)
 {
     this.team      = team;
     this.teamOrder = teamOrder;
 }
        private void OnCollisionEnter(Collision cCollision)
        {
            // Only react on server and results will be send to client when processed
            if (Network.isServer)
            {
                // Get a handle on the gameObject with which we collided.
                GameObject goObject = cCollision.gameObject;

                // Check if we collided with a base
                if (goObject.tag == Tags.TAG_BASE)
                {
                    ClientDataOnServer client = serverManager.RegisteredClients.First(c => c.NetworkPlayer == networkView.owner);

                    if (goObject.name == Names.NAME_RED_BASE && client.ClientTeam == IAIBase.ETeam.TEAM_RED)
                    {
                        CollidedWithBase(client);
                    }
                    else if (goObject.name == Names.NAME_BLUE_BASE && client.ClientTeam == IAIBase.ETeam.TEAM_BLUE)
                    {
                        CollidedWithBase(client);
                    }
                }

                // Depending on the name of the object, react accordingly.
                switch (goObject.tag)
                {
                case Tags.TAG_WEAPON:

                    // Get the name and team of the attacker using its projectile.
                    CProjectile cProjectile = goObject.GetComponent <CProjectile>();

                    if (null == cProjectile.Instantiator.gameObject)
                    {
                        return;
                    }

                    //// Set the name.
                    string        strAttackerName = "";
                    IAIBase.ETeam eTeam           = IAIBase.ETeam.TEAM_NONE;

                    // Check if attacker is another client
                    GameObject       goAttacker = cProjectile.Instantiator;
                    PlayerController aPC        = goAttacker.GetComponent <PlayerController>();
                    if (aPC != null)
                    {
                        ClientDataOnServer cd = serverManager.RegisteredClients.First(c => c.NetworkPlayer == aPC.networkView.owner);
                        strAttackerName = cd.Profile.DisplayName;
                        eTeam           = cd.ClientTeam;
                    }
                    else     // attacker is an AI
                    {
                        strAttackerName = "AI";
                        //// Find the team using the attacker's name.
                        if (strAttackerName == Names.NAME_AI_DRONE_BLUE + "(Clone)")
                        {
                            eTeam = IAIBase.ETeam.TEAM_BLUE;
                        }

                        else if (strAttackerName == Names.NAME_AI_DRONE_RED + "(Clone)")
                        {
                            eTeam = IAIBase.ETeam.TEAM_RED;
                        }
                    }

                    serverManager.SendGameMessage(new PlayerTakenDamage()
                    {
                        Player = networkView.owner, PlayerPosition = transform.position, Damage = (int)cProjectile.Damage, Attacker = strAttackerName, AttackerTeam = eTeam
                    });

                    break;
                }
            }
        }
        public void SendClientRegistration(NetworkPlayer player, IAIBase.ETeam team, int teamOrder)
        {
            int teamInt = (int)team;

            networkView.RPC("RPCSendClientRegistrationData", player, teamInt, teamOrder);
        }