PlayerSave.PlayerSave C# (CSharp) Method

PlayerSave() public method

public PlayerSave ( GameObject go, string pathPlayer, bool isServer ) : System.Collections.Generic
go GameObject
pathPlayer string
isServer bool
return System.Collections.Generic
    public PlayerSave(GameObject go, string pathPlayer, bool isServer)
    {
        this.namePlayer = go.GetComponent<Social_HUD>().PlayerName;
        this.path = pathPlayer + namePlayer;
        this.player = go;

        if (File.Exists(this.path))
        {
            string[] save = File.ReadAllLines(this.path);
            string[] properties = save[0].Split('|');

            this.x = float.Parse(properties[0]);
            this.y = float.Parse(properties[1]);
            this.life = float.Parse(properties[2]);
            this.hunger = float.Parse(properties[3]);
            this.thirst = float.Parse(properties[4]);
            this.speed = float.Parse(properties[5]);
            this.cdSpeed = float.Parse(properties[6]);
            this.jump = float.Parse(properties[7]);
            this.cdJump = float.Parse(properties[8]);
            this.regen = float.Parse(properties[9]);
            this.cdRegen = float.Parse(properties[10]);
            this.poison = float.Parse(properties[11]);
            this.cdPoison = float.Parse(properties[12]);
            this.tutoProgress = int.Parse(properties[13]);

            this.inventory = save[1];
            string[] social = save[2].Split('|');
            this.isOp = bool.Parse(social[0]) || isServer;
            this.team = (Team)uint.Parse(social[1]);
        }
        else
        {
            Vector3 newPos = new Vector3(Random.Range(-10f, 10f), 7, Random.Range(-10f, 10f));
            while (!Graph.isValidPosition(newPos))
                newPos = new Vector3(Random.Range(-10f, 10f), 7, Random.Range(-10f, 10f));
            this.x = newPos.x;
            this.y = newPos.z;
            this.life = 100;
            this.hunger = 100;
            this.thirst = 100;
            this.speed = 0;
            this.cdSpeed = 0;
            this.jump = 0;
            this.cdJump = 0;
            this.regen = 0;
            this.cdRegen = 0;
            this.poison = 0;
            this.cdPoison = 0;
            this.tutoProgress = 0;
            this.inventory = "";
            this.isOp = isServer;

            // Choisir une equipe
            if (GameObject.Find("Map").GetComponent<Save>().IsCoop)
                this.team = Team.Blue;
            else
            {
                int blue = 0;
                int red = 0;
                foreach (GameObject p in GameObject.FindGameObjectsWithTag("Player"))
                {
                    if (p.GetComponent<Social_HUD>().Team == Team.Blue)
                        blue++;
                    else if (p.GetComponent<Social_HUD>().Team == Team.Red)
                        red++;
                }
                if (blue > red)
                    this.team = Team.Red;
                else
                    this.team = Team.Blue;
            }
        }
    }