예제 #1
0
파일: Arena.cs 프로젝트: justi1jc/FPS
    /* Spawns a player from a prefab at a random spawnpoint. */
    protected void SpawnPlayer(
        string prefabName,
        int id,
        int faction,
        Transform trans = null
        )
    {
        GameObject pref = (GameObject)Resources.Load(
            "Prefabs/" + prefabName,
            typeof(GameObject)
            );

        if (trans == null)
        {
            trans = GetSpawnTransform(faction);
        }
        if (trans == null)
        {
            print("Invalid transform for faction " + faction);
            return;
        }
        Vector3    pos = trans.position;
        Quaternion rot = trans.rotation;
        GameObject go  = (GameObject)GameObject.Instantiate(
            pref,
            pos,
            rot
            );
        Actor actor = go.GetComponent <Actor>();

        if (actor != null)
        {
            actor.stats.faction = faction;
            players.Add(actor);
            if (kit != "NONE")
            {
                Kit k = Session.session.GetKit(kit);
                if (k != null)
                {
                    k.ApplyKit(ref actor);
                }
            }
            if (id != -1)
            {
                actor.id = id;
                if (teams)
                {
                    actor.stats.faction = factions[id];
                    if (factions[id] == StatHandler.REDTEAM)
                    {
                        Kit.ApplyToClothes("Equipment/Shirt", ref actor, true, 1f, 0f, 0f, 1f);
                    }
                    else
                    {
                        Kit.ApplyToClothes("Equipment/Shirt", ref actor, true, 0f, 0f, 1f, 1f);
                    }
                }
                else
                {
                    actor.stats.faction = StatHandler.FERAL;
                }
                Kit.ApplyToClothes("Equipment/Pants", ref actor, true, 0f, 0f, 0f, 1f);
            }
        }
    }