Пример #1
0
    public void JoinTeam(TEAM_TYPE team)
    {
        NetworkPlayer np            = Scene.Players[LocalPeer].gameObject.GetComponent <NetworkPlayer>();
        int           playersInTeam = Teams[team].PlayerCount;

        if ((MaxPlayers / 2.0f) > playersInTeam)
        {
            np.JoinTeam(team);
        }
        else
        {
            Debug.Log(team + " is already full");
        }
    }
Пример #2
0
    public TEAM_TYPE GetOpposingTeam(TEAM_TYPE team)
    {
        switch (team)
        {
        case TEAM_TYPE.TEAM_1:
            return(TEAM_TYPE.TEAM_2);

        case TEAM_TYPE.TEAM_2:
            return(TEAM_TYPE.TEAM_1);

        case TEAM_TYPE.TEAM_SPECTATOR:
            return(TEAM_TYPE.TEAM_SPECTATOR);

        default:
            return(TEAM_TYPE.UNASSIGNED);
        }
    }
Пример #3
0
        //---------------------------------------------------
        // searchAliveTeam
        //---------------------------------------------------
        CharacterModel.Data searchAliveTeam(TEAM_TYPE type)
        {
            List <CharacterModel.Data> list = GetTeamCharacterDataList(type);

            CharacterModel.Data retData = null;

            foreach (CharacterModel.Data data in list)
            {
                if (data.Hp > 0)
                {
                    retData = data;
                    break;
                }
            }

            return(retData);
        }
Пример #4
0
        //---------------------------------------------------
        // GetLowHpCharacterData
        //---------------------------------------------------
        CharacterModel.Data GetLowHpCharacterData(TEAM_TYPE type)
        {
            List <CharacterModel.Data> list = GetTeamCharacterDataList(type);

            CharacterModel.Data retData = null;
            float hp = 0;

            foreach (CharacterModel.Data data in list)
            {
                if (hp < data.Hp)
                {
                    retData = data;
                }
            }

            return(retData);
        }
Пример #5
0
 public override void OnTriggerEnter(Collider collider)
 {
     if (MatchSystem.instance)
     {
         if (collider.gameObject == MatchSystem.instance.Ball && MatchSystem.instance.MatchStarted)
         {
             if (MatchSystem.instance.Ball.GetComponent <NetworkIdentity>().Owner&& !MatchSystem.instance.hasScored)
             {
                 TEAM_TYPE teamThatScored = MatchSystem.instance.GetOpposingTeam(Team);
                 MatchSystem.instance.OnGoal(teamThatScored);
                 if (teamThatScored == MatchSystem.instance.LocalChad.gameObject.GetComponent <NetworkPlayer>().Team.TeamType)
                 {
                     MatchSystem.instance.LocalChad.gameObject.GetComponent <NetworkPlayer>().GoalsScored += 1;
                 }
                 else
                 {
                     MatchSystem.instance.LocalChad.gameObject.GetComponent <NetworkPlayer>().Owngoal += 1;
                 }
             }
             StartCoroutine(EmitSparkForDuration(5.0f));
         }
     }
 }
Пример #6
0
    // this function will be called upon powerup use / collision after trown
    public override void OnActivate()
    {
        //Make sure powerups can only be activated once!
        if (activated)
        {
            return;
        }
        activated = true;
        // boom particles, Gustav do your magic, sprinkla lite magic till boisen


        ChadControls localChad = MatchSystem.instance.LocalChad;

        TEAM_TYPE playerTeam      = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject);
        TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(localChad.gameObject);

        if (localChad && otherPlayerTeam != playerTeam)
        {
            float distance = Vector3.Distance(localChad.transform.position, transform.position);
            if (distance < ExplosionRadius)
            {
                Vector3 forceDir = localChad.transform.position - transform.position;
                forceDir.Normalize();
                forceDir.y += 3.0f;

                float   distForce          = ExplosionRadius - distance;
                Vector3 force              = forceDir * ExplosionForce * distForce;
                Ragdoll.ImpactParams param = new Ragdoll.ImpactParams(gameObject.transform.position, force, 0.0f);
                param.bodyPartFactor[(int)Ragdoll.BODYPART.SPINE] = 0.88f;
                localChad.ActivateRagdoll(2.0f, param);
                AnnouncerSoundManager.Instance.Announce(ANNOUNCEMENT_TYPE.EXPLODED);
            }
        }

        Explosion();
    }
    public override void OnRead(NetDataReader reader, bool initialState)
    {
        HatIndex     = reader.GetInt();
        PlayerName   = reader.GetString();
        ReadyToStart = reader.GetBool();
        HasTackled   = reader.GetInt();
        Owngoal      = reader.GetInt();
        GoalsScored  = reader.GetInt();
        shirtNumber  = reader.GetString();
        TEAM_TYPE teamType = (TEAM_TYPE)reader.GetInt();
        Team      newTeam  = MatchSystem.instance.FindTeam(teamType);

        if (Team != newTeam)
        {
            JoinTeam(newTeam);
        }
        if (initialState)
        {
            if (teamType == TEAM_TYPE.TEAM_1 || teamType == TEAM_TYPE.TEAM_2)
            {
                gameObject.SetActive(true);
            }
        }
    }
    private IEnumerator BlastingMusic()
    {
        //List<ChadControls> affectedChads = new List<ChadControls>();

        if (_Note1 && _Note2)
        {
            _Note1.Emit = true;
            _Note2.Emit = true;
        }
        if (GramophoneClip)
        {
            GramophoneClip.Play();
        }

        // Start blasting
        ChadControls localChad = MatchSystem.instance.LocalChad;

        TEAM_TYPE playerTeam      = MatchSystem.instance.GetPlayerTeam(ObjectOwner.gameObject);
        TEAM_TYPE otherPlayerTeam = MatchSystem.instance.GetPlayerTeam(localChad.gameObject);

        while (_Timer < _DanceDuration)
        {
            _Timer += Time.DeltaTime;

            if (localChad)
            {
                float distance = Vector3.Distance(localChad.transform.position, transform.position);
                if (distance < ExplosionRadius && localChad.State != ChadControls.STATE.RAGDOLL && localChad.State != ChadControls.STATE.DANCING)
                {
                    localChad.Direction            = Vector3.Zero;
                    localChad.rBody.LinearVelocity = new Vector3(0, localChad.rBody.LinearVelocity.y, 0);;
                    localChad.CurrentVelocity      = Vector2.Zero;
                    localChad.State = ChadControls.STATE.DANCING;
                    ChadHud.Instance.DeactivateAimHUD();
                    localChad.ChargeTime = 0;
                    //affectedChads.Add(localChad);
                }
                else if (distance > ExplosionRadius && localChad.State == ChadControls.STATE.DANCING)
                {
                    //foreach (var player in affectedChads)
                    //{
                    //    if (player == localChad)
                    //    {
                    //        localChad.State = ChadControls.STATE.CHADING;
                    //        affectedChads.Remove(player); // buggy?
                    //    }
                    //}
                    localChad.State = ChadControls.STATE.CHADING;
                }
            }

            yield return(null);
        }
        GramophoneClip.Stop();

        // Reset all dancing Chads, the party is over
        //foreach (var player in affectedChads)
        //{
        //    if (player == localChad && localChad.State == ChadControls.STATE.DANCING)
        //    {
        //        localChad.State = ChadControls.STATE.CHADING;
        //        //affectedChads.Remove(player); // buggy?
        //    }
        //}
        if (localChad.State == ChadControls.STATE.DANCING)
        {
            localChad.State = ChadControls.STATE.CHADING;
        }
        //affectedChads.Clear();
        Explosion();
    }