コード例 #1
0
    void CollideWithOther(GameObject data)
    {
        //Only care about collisions with a flag base.
        if (data.tag == "FlagBase")
        {
            //If it's not being carried, wait until a player touched it to do anything.
            if (Carrying == null)
            {
                return;
            }

            //If it's not this flag's base, and the base is the carrying player's base,
            //   and he is able to capture at the moment, then this flag was captured.
            FlagBaseBehavior flBB = data.GetComponent <FlagBaseBehavior>();
            if (flBB.Team != Team &&
                flBB.Team == Carrying.ActorData.Team &&
                (flBB.Flag.AtHome || !ctfRules.FlagAtHomeToScore))
            {
                WorldConstants.Creator.CreateFloatingTextsForPlayers(WorldConstants.Creator.FourMessages(WorldConstants.ActorConsts.FlagCapturedMessages, takenBy, Team),
                                                                     st => st.ActorData.Team == Carrying.ActorData.Team,
                                                                     WorldConstants.Creator.CreateFlagFloatingText);
                WorldConstants.CrowdCheering.CreateCrowdCheer(CrowdCheers.Events.FlagCaptured);

                if (ctfRules.FlagRespawnDelay > 0.0f)
                {
                    RemoveFlag();
                }
                else
                {
                    ResetFlag(false);
                }
            }
        }
    }
コード例 #2
0
    //TODO: "Don't be a dick" griefing timer for if the flag carrier isn't really moving ("hurt/throw" the player -- with lots of pain taken -- and make him drop the flag).

    public void SetData(FlagBaseBehavior flagBase, Color team)
    {
        Team     = team;
        FlagBase = flagBase;
        renderer.material.SetColor("_TeamCol", Team);
    }
コード例 #3
0
    void OtherCollision(int index)
    {
        GameObject other = ColManager.Others[index];

        if (other.tag == "Powerup")
        {
            OwnerStats.PowerupsCollected += 1;
        }

        else if (other.tag == "Flag")
        {
            FlagBehavior flB = other.GetComponent <FlagBehavior>();

            //If the flag is being carried, don't do anything.
            if (flB.Carrying != null)
            {
                return;
            }
            //If the flag is from the same team, it might have been returned.
            if (flB.Team == ActorData.Team)
            {
                if (!flB.AtHome && Manager.MatchRules.CTF.TouchFlagToReturn)
                {
                    OwnerStats.FlagsReturned += 1;
                }
                return;
            }
            //If this actor is already carrying, don't do anything.
            if (OwnerStats.CarryingFlag)
            {
                return;
            }
            //If this actor can't pick up flags, don't do anything.
            if (!Manager.MatchRules.EnemiesArePeopleToo && !IsPlayer)
            {
                return;
            }
            //If this actor is hurt, don't do anything.
            if (CurrentState is HurtState)
            {
                return;
            }

            tookFlag = true;
        }

        else if (other.tag == "Waypoint")
        {
            //Don't bother doing anything on the player side.
        }

        else if (other.tag == "FlagBase")
        {
            //If the player isn't carrying a flag, stop.
            if (!OwnerStats.CarryingFlag)
            {
                return;
            }

            FlagBaseBehavior flBB = other.GetComponent <FlagBaseBehavior>();

            //If it's not this actor's base, then ignore it.
            if (!flBB.Team.Equals(ActorData.Team))
            {
                return;
            }

            //If this actor's flag isn't at home and it has to be at home to score, ignore the base.
            FlagBehavior beh = Manager.FlagsByTeam[ActorData.Team].GetComponent <FlagBehavior>();
            if (Manager.MatchRules.CTF.FlagAtHomeToScore && !beh.AtHome)
            {
                return;
            }

            //Update the stats.
            OwnerStats.FlagsCaptured += 1;
            OwnerStats.CarryingFlag   = false;
        }
    }