Beispiel #1
0
    /*###########
    #   SPAWN   #
    ###########*/

    public void spawnPlayer(string weapon, GameObject spawnPlace, string team)
    {
        GameObject player = PhotonNetwork.Instantiate("soldierPrefab", spawnPlace.transform.position, Quaternion.identity, 0);

        Debug.Log(player);

        //we set the soldier a child of the playerCreator and we set it alive
        player.transform.parent = transform;

        //We select the weapon slot in the right hand
        GameObject weapSlot = player.gameObject.transform.Find("Armature/Dos/Haut_Dos/Epaule_D/Bras_D/Avant_Bras_D/Main_D/Paume_D/Majeur_1_D/weaponSlot").gameObject;

        Debug.Log(weapSlot);

        //We spawn the weapon
        GameObject weaponSelec = PhotonNetwork.Instantiate(weapon, weapSlot.transform.position, Quaternion.identity, 0);


        shotScript shootingScript = weaponSelec.GetComponent <shotScript>();

        weaponSelec.transform.parent = weapSlot.transform;

        playerNetwork playerNet = player.GetComponent <playerNetwork>();

        //playerNet.enabled = true;
        playerNet.playerTeam = team;
        Debug.Log("Spawned player on team " + team);


        //GameObject soldier = player.gameObject.transform.Find("Soldier").gameObject;
    }
Beispiel #2
0
    public void initilize(Player player)
    {
        playerNetwork = player.getNetwork();
        this.player   = player;
        path          = "Assets/XML/SkillTree.json";
        jsonString    = File.ReadAllText(path);

        transform.SetParent(GameObject.Find("UI").transform.Find("SkillTree_UI"));

        Skill skills = JsonUtility.FromJson <Skill> (jsonString);

        potrait = Instantiate(skillTreeSlotPrefab);
        potrait.transform.SetParent(this.transform);
        potrait.transform.position = new Vector3(xRoot, yRoot, zRoot);
        onSkillUpgrade(potrait, potrait.GetComponent <SkillId>(), this.gameObject, null);

        foreach (Skill skill in skills.Potrait)
        {
            chooseType(currentIndex);
            currentIndex++;
            //Create parents
            GameObject inst = Instantiate(skillTreeSlotPrefab);
            inst.transform.SetParent(potrait.transform);
            createSkillObject(inst, skill);

            inst.transform.position = new Vector3(xRoot + (50 * xType), yRoot + (75 * yType), zRoot);

            onSkillUpgrade(inst, inst.GetComponent <SkillId>(), potrait, skill);

            if (hasSkillChildren(skill))
            {
                parseChildren(skill.children, skill);
            }
        }
    }
Beispiel #3
0
    /*###########
    #   DEATH   #
    ###########*/

    void checkDeath()
    {
        //We get the child transform ( the transform of the soldier )
        foreach (Transform child in transform)
        {
            if (child.name != "globalHUD" && child.name != "scoreBoardUI" && child.name != "InGameMenu" && child.name != "littleScoreBoardUI" && child.name != "PlayerHUD")
            {
                playerNetwork playSet = child.gameObject.GetComponent <playerNetwork>();

                if (playSet.health <= 0)
                {
                    //We get the id of the last shot
                    int killer = playSet.lastShot;

                    /*if(actualTeam=="Blue")
                     * {
                     *      addRedKill(killer);
                     *      this.photonView.RPC("addRedKill", PhotonTargets.All, killer);
                     * }
                     * else {
                     *      addBlueKill(killer);
                     *      this.photonView.RPC("addBlueKill", PhotonTargets.All, killer);
                     * }*/

                    //We trigger the respawn function by setting us non-alive
                    playSet.isAlive = false;
                    isAlive         = false;

                    scoreScript scoreMan = GetComponent <scoreScript>();
                    scoreMan.wasKilled = true;
                }
            }
        }
    }
Beispiel #4
0
    public override void OnStartLocalPlayer()
    {
        ClientScene.RegisterPrefab((GameObject)Resources.Load("Prefabs/Enemy"));
        ClientScene.RegisterPrefab((GameObject)Resources.Load("Particles/Hit"));
        ClientScene.RegisterPrefab((GameObject)Resources.Load("Particles/ImpactOnGround"));

        this.movement = GetComponent <PlayerMovement>();

        this.skillUi = GameObject.Find("Actionbar_UI").GetComponent <SkillUIManager>();
        this.skillUi.init(this);
        this.skillManager = GetComponent <SkillManager>();
        this.skillManager.init(this);

        UICanvas = GameObject.Find("UI");
        chat     = Tools.getChild(UICanvas, "Chat_UI").GetComponent <Chat>();
        network  = GetComponent <playerNetwork>();
        network.initialize(this);
        chat.setPlayer(this);
        camera         = Camera.main;
        this.inventory = this.GetComponent <Inventory> ();
        this.inventory.init(this);

        camera.GetComponent <MainCamera> ().player = this.gameObject;
        camera.GetComponent <MainCamera> ().setState((int)e_cameraStates.DEFAULT);
        for (int i = 0; i < prefabsToRegister.Length; i++)
        {
            //ClientScene.RegisterPrefab (prefabsToRegister [i]);
        }
    }
Beispiel #5
0
    /*###################
    #   RPC FUNCTIONS   #
    ###################*/

    //Kill the player
    void killPlayer()
    {
        foreach (Transform playChild in transform)
        {
            playerNetwork playerChild = playChild.GetComponent <playerNetwork>();
            playerChild.isAlive = false;
        }
    }
    // Update is called once per frame
    void Update()
    {
        //updateWeaponStats();

        //----------------------- SHOOTING
        if (actualAmmo > 0)
        {
            improvedShot();
        }
        else
        {
            if (!isReloading)
            {
                reloadCounter = 0f;
                isReloading   = true;
            }
            else
            {
                if (reloadCounter >= reloadTime)
                {
                    actualAmmo  = taille_chargeur;
                    isReloading = false;
                }
                else
                {
                    reloadCounter += Time.deltaTime;
                }
            }
        }


        //-----------------------------RECOIL REDUCING

        //Reducing the recoil through time if the player doesn't shoot
        if (recoilDecal >= 0.002f)        //We put a if so it doesn't go below zero
        {
            //The decal is 5% max ( 0.05f max )
            recoilDecal -= Time.deltaTime * 0.06f; //With this speed we lower the biggest recoil in one second
        }
        else                                       //If the recoil is very small we put it to zero instead of lowering it under zero
        {
            recoilDecal = 0f;
        }

        //--------------------- UPDATING TEAM

        //We get our team
        if (weapTeam != "Blue" || weapTeam != "Red")
        {
            //playerNetwork playNet = this.transform.parent.GetComponent<playerNetwork>();
            playerNetwork playNet = GetComponent <playerNetwork>();
            weapTeam = playNet.playerTeam;
        }
    }
 void Start()
 {
     player           = GetComponent <CharacterController>();
     PlayerNetwork    = GetComponent <playerNetwork>();
     GameController   = GameObject.Find("_GameController").GetComponent <GameController>();
     DodgeballManager = GameController.GetComponentInChildren <dodgeballManager>();
     isGrounded       = true;
     isJumping        = false;
     isDashing        = false;
     hasDodgeball     = false;
     Cursor.lockState = CursorLockMode.Locked;
     Cursor.visible   = (false);
 }
Beispiel #8
0
    public float otherSpellHeightOffset;  //100

    public void initilize(Player player)
    {
        playerNetwork = player.getNetwork();
        this.player   = player;
        path          = "Assets/XML/SkillTree.json";
        jsonString    = File.ReadAllText(path);

        GameObject UI = GameObject.Find("UI");

        transform.SetParent(UI.transform.Find("SkillTree_UI"));
        UI.GetComponent <UIReferences>().skillTreeReference = this.gameObject;

        Skill skills = JsonUtility.FromJson <Skill> (jsonString);

        potrait = Instantiate(skillTreeSlotPrefab);
        potrait.GetComponent <SkillId>().setSkillTree(this);
        potrait.transform.SetParent(this.transform);
        potrait.transform.position    = new Vector3(xRoot, yRoot, zRoot);
        potrait.transform.localScale += new Vector3(1, 1, 0);
        onSkillUpgrade(potrait, potrait.GetComponent <SkillId>(), this.gameObject, null);

        foreach (Skill skill in skills.Potrait)
        {
            chooseType(currentIndex);
            currentIndex++;
            //Create parents
            GameObject inst = Instantiate(skillTreeSlotPrefab);
            inst.GetComponent <SkillId>().setSkillTree(this);
            inst.transform.SetParent(potrait.transform);
            createSkillObject(inst, skill);

            masterSpellWidthOffset  = 35 * potrait.transform.localScale.x;
            masterSpellHeightOffset = 35 * potrait.transform.localScale.y;

            inst.transform.position = new Vector3(xRoot + (masterSpellWidthOffset * xType), yRoot + (masterSpellHeightOffset * yType), zRoot);
            createText(inst, false);

            onSkillUpgrade(inst, inst.GetComponent <SkillId>(), potrait, skill);

            if (hasSkillChildren(skill))
            {
                parseChildren(skill.children, skill, inst);
            }
        }
    }
    void sendMyID(string damAndID)
    {
        //We convert the string back to a tab using Split
        string[] damID = damAndID.Split(';');

        //We get his ID
        int shooterID = int.Parse(damID[1]);

        //We get his team
        string shooterTeam = damID[2];

        playerNetwork playNet = GetComponent <playerNetwork>();

        //If we're not on the same team, I take damage
        if (shooterTeam != playNet.playerTeam)
        {
            playNet.lastShot = shooterID;
        }
    }
    void attack(string damAndID)
    {
        //We convert the string back to a tab using Split
        string[] damID = damAndID.Split(';');

        //We convert these values into int
        int dam = int.Parse(damID[0]);
        //int shooterID = int.Parse(damID[1]);

        //We get his team
        string shooterTeam = damID[2];

        playerNetwork playNet = GetComponent <playerNetwork>();

        //If we're not on the same team, I take damage
        if (shooterTeam != playNet.playerTeam)
        {
            playNet.health -= dam;
        }
        //Debug.Log(shooterID.ToString());
        //We set the "last shot" value to the last guy who shot us
        //playNet.lastShot = shooterID;
    }
Beispiel #11
0
    // Update is called once per frame
    void Update()
    {
        actualHealth = 0;
        //We get the soldier transform
        foreach (Transform child in transform.root)
        {
            if (child.name != "globalHUD" && child.name != "scoreBoardUI" && child.name != "InGameMenu" && child.name != "littleScoreBoardUI" && child.name != "PlayerHUD")
            {
                playerNetwork playSet = child.gameObject.GetComponent <playerNetwork>();
                actualHealth = playSet.health;
            }
        }

        //We update its value on the title
        healthTitle     = transform.Find("HealthTitle");
        healthInfo      = healthTitle.gameObject.GetComponent <Text>();
        healthInfo.text = actualHealth.ToString();

        //We update its value on the slider
        healthSlider    = transform.Find("Slider");
        healthBar       = healthSlider.GetComponent <Slider>();
        healthBar.value = (float)actualHealth;
    }
Beispiel #12
0
    private void Awake()
    {
        Instance = this;

        NickName = "Player#" + Random.Range(1000, 9999);
    }
    /*---------------------------- UPDATE ----------------------------*/

    // Update is called once per frame
    void Update()
    {
        PhotonView photonView = PhotonView.Get(this);

        /*------------------------- VERIFYING SYNCHRONIZATION -------------*/
        //We check if we have the scores of everyone

        /*if(!isUpdated) //We're not updated
         * {
         *      if(updateCounter >= 2.0f)
         *      {
         *              int myID = photonView.owner.ID;
         *
         *              photonView.RPC("updateMe", PhotonTargets.MasterClient, null);
         *              updateCounter = 0f;
         *              Debug.Log("Requesting update");
         *      }
         *      else
         *      {
         *              updateCounter += Time.deltaTime;
         *      }
         * }
         *
         * /*----------------------------- WE UPDATE THE PLAYERS REGULARLY -----------*/
        if (PhotonNetwork.isMasterClient)
        {
            /*if(updateTimer >= 2.0f)
             * {
             *      string theTeamScores = blueScore + ";" + redScore;
             *      photonView.RPC("updateTeamScores", PhotonTargets.Others, theTeamScores);
             *      updateTimer = 0f;
             * }
             * else
             * {
             *      updateTimer += Time.deltaTime;
             * }*/

            if (pingUpdate >= 5.0f)
            {
                pingFunction();
                pingUpdate = 0f;
            }
            else
            {
                pingUpdate += Time.deltaTime;
            }
            pingTimer += Time.deltaTime;
        }

        /*--------------------------------------------------------------------*/

        //When our playerCreator is created we add ourself on the scoreboards
        playerSpawn playSpawn = GetComponent <playerSpawn>();


        //Managing the kills

        //We update the last shot each frame
        foreach (Transform child in transform)
        {
            if (child.name != "globalHUD" && child.name != "scoreBoardUI" && child.name != "InGameMenu" && child.name != "littleScoreBoardUI" && child.name != "PlayerHUD")
            {
                playerNetwork playSet = child.GetComponent <playerNetwork>();
                myLastShot = playSet.lastShot;
            }
        }

        //If we're killed we add the kill and update the score
        if (wasKilled)
        {
            PhotonPlayer    killer            = PhotonPlayer.Find(myLastShot);
            PunPlayerScores playerScoreScript = GetComponent <PunPlayerScores>();
            ScoreExtensions.AddScore(killer, 1);

            int myID = photonView.owner.ID;
            //photonView.RPC("addKill", killer, null);
            //photonView.RPC("addKill", PhotonTargets.All, myLastShot);

            if (myTeam == "Blue")
            {
                //photonView.RPC("addRedKill", PhotonTargets.All, myLastShot);
                //photonView.RPC("addRedKill", PhotonTargets.All, null);
                TeamExtensions.AddTeamScore("Red");
                //photonView.RPC("addBlueDeath", PhotonTargets.All, myID);
            }
            else
            {
                //photonView.RPC("addBlueKill", PhotonTargets.All, myLastShot);
                //photonView.RPC("addBlueKill", PhotonTargets.All, null);
                TeamExtensions.AddTeamScore("Blue");
                //photonView.RPC("addRedDeath", PhotonTargets.All, myID);
            }

            PhotonPlayer myPlayer = PhotonPlayer.Find(myID);
            //addDeath();
            DeathExtensions.AddDeath(myPlayer, 1);

            //KILLFEED
            TeamExtensions.AddKillFeed(myLastShot, myID);
            wasKilled = false;
        }

        /*--------------------------- SCOREBOARD ----------------------*/

        //We get the scoreboard object
        Transform scoreB = transform.Find("scoreBoardUI");

        //Drawing the score
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            drawTheScore = true;
        }
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            drawTheScore = false;
        }

        if (photonView.isMine)
        {
            if (drawTheScore || isMatchEnded)            //If the player press tab we activate the board
            {
                scoreB.gameObject.active = true;
            }
            else
            {
                scoreB.gameObject.active = false;
            }
        }
        else
        {
            scoreB.gameObject.active = false;
        }

        /*------------------------------ TIMER ------------------------*/

        //At the end of the match the masterclient stops it
        if (matchTimer <= 0f)
        {
            if (PhotonNetwork.isMasterClient)
            {
                photonView.RPC("stopMatch", PhotonTargets.All, null);
            }
        }
        else
        {
            matchTimer -= Time.deltaTime;

            //if(PhotonNetwork.isMasterClient)
            //updateMatchTimer();
        }
    }
Beispiel #14
0
 // Use this for initialization
 void Start()
 {
     PlayerNetwork = GetComponent <playerNetwork>();
 }
Beispiel #15
0
    /*---------------------------- UPDATE ----------------------------*/

    // Update is called once per frame
    void Update()
    {
        PhotonView photonView = PhotonView.Get(this);

        /*------------------------- VERIFYING SYNCHRONIZATION -------------*/
        //We check if we have the scores of everyone
        int numberOfScores = countPlayers();

        if (numberOfScores != PhotonNetwork.playerList.Length)        //We do not have all scores
        {
            if (updateCounter >= 2.0f)
            {
                int myID = photonView.owner.ID;

                photonView.RPC("updateMe", PhotonTargets.All, myID);
                updateCounter = 0f;
                Debug.Log("Requesting update");
            }
            else
            {
                updateCounter += Time.deltaTime;
            }
        }

        /*--------------------------------------------------------------------*/

        //When our playerCreator is created we add ourself on the scoreboards
        playerSpawn playSpawn = GetComponent <playerSpawn>();


        //While we're not on the scoreboard we try to be added
        if (addedOnBoard == false)
        {
            //We make a string out of our gamertag and playerID
            string myTag = PlayerPrefs.GetString("Gamertag");
            int    myID  = photonView.owner.ID;

            //If we have all the components we send the RPC
            if (myTeam == "Blue" || myTeam == "Red")
            {
                string tagTeamID = myID.ToString() + ";" + myTag + ";" + myTeam;

                if (PhotonNetwork.isMasterClient)
                {
                    photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID);
                }
                else
                {
                    photonView.RPC("addOnBoard", PhotonTargets.All, tagTeamID);
                    photonView.RPC("updateMe", PhotonTargets.All, myID);
                }

                /*if(photonView.isMine)
                 * {
                 *      addOnBoard(tagTeamID);
                 * }*/
                addedOnBoard = true;
            }
        }


        //Managing the kills

        //We update the last shot each frame
        foreach (Transform child in transform)
        {
            if (child.name != "globalHUD" && child.name != "scoreBoardUI" && child.name != "InGameMenu")
            {
                playerNetwork playSet = child.GetComponent <playerNetwork>();
                myLastShot = playSet.lastShot;
            }
        }

        //If we're killed we add the kill and update the score
        if (wasKilled)
        {
            int myID = photonView.owner.ID;
            if (myTeam == "Blue")
            {
                photonView.RPC("addRedKill", PhotonTargets.All, myLastShot);
                photonView.RPC("addBlueDeath", PhotonTargets.All, myID);
            }
            else
            {
                photonView.RPC("addBlueKill", PhotonTargets.All, myLastShot);
                photonView.RPC("addRedDeath", PhotonTargets.All, myID);
            }
            wasKilled = false;
        }

        /*--------------------------- SCOREBOARD ----------------------*/

        //We get the scoreboard object
        Transform scoreB = transform.Find("scoreBoardUI");

        //Drawing the score
        if (Input.GetKeyDown(KeyCode.Tab))
        {
            drawTheScore = true;
        }
        if (Input.GetKeyUp(KeyCode.Tab))
        {
            drawTheScore = false;
        }

        if (photonView.isMine)
        {
            if (drawTheScore)            //If the player press tab we activate the board
            {
                scoreB.gameObject.active = true;
            }
            else
            {
                scoreB.gameObject.active = false;
            }
        }
        else
        {
            scoreB.gameObject.active = false;
        }
    }
Beispiel #16
0
    public override void OnStartLocalPlayer()
    {
        if (!isLocalPlayer)
        {
            return;
        }
        commandManager = new CommandManager(this);
        for (int i = 0; i < prefabsToRegister.Length; i++)
        {
            ClientScene.RegisterPrefab(prefabsToRegister [i]);
        }
        ResourceStructure.initilize();

        /*
         * ClientScene.RegisterPrefab((GameObject)Resources.Load("Prefabs/Enemy"));
         * ClientScene.RegisterPrefab((GameObject)Resources.Load("Particles/Hit"));
         * ClientScene.RegisterPrefab((GameObject)Resources.Load("Particles/ImpactOnGround"));
         * ClientScene.RegisterPrefab(skillPrefab);
         * ClientScene.RegisterPrefab(skillEffectPrefab);*/
        //UI
        UICanvas      = GameObject.Find("UI");
        login         = Tools.findInactiveChild(UICanvas, "Login_UI").GetComponent <Login>();
        this.movement = GetComponent <PlayerMovement>();
        //skills
        this.skillUi = Tools.findInactiveChild(UICanvas, "Actionbar_UI").GetComponent <SkillUIManager>();
        this.skillUi.init(this);
        this.skillManager = GetComponent <SkillManager>();
        this.skillManager.init(this, getSkillUiManager());

        //this.skillTreeUi = GameObject.Find(this.skillTreeUi.name)

        //network
        network = GetComponent <playerNetwork>();
        network.initialize(this);

        this.skillTreeUi = Tools.getChild(UICanvas, this.skillTreeUi.name);

        //chat
        chat = Tools.getChild(UICanvas, "Chat_UI").GetComponent <Chat>();
        chat.setPlayer(this);

        //inventory
        this.inventory = this.GetComponent <Inventory> ();
        this.inventory.init(this);

        //equip
        equip = Tools.getChild(UICanvas, "Equipment_UI").GetComponent <EquipmentHandler>();
        equip.setEquipmentUI(Tools.getChild(UICanvas, "Equipment_UI"));
        equip.setPlayer(this);

        //camera
        camera = Camera.main;
        camera.GetComponent <MainCamera> ().player = this.gameObject;
        camera.GetComponent <MainCamera> ().setState((int)e_cameraStates.DEFAULT);

        //worlds
        worlds[0] = GameObject.Find("login_World");
        worlds[1] = GameObject.Find("World");


        //TempQuestUI
        GameObject tempQuestUI = Instantiate(this.quest_UI);

        this.questInformationData = tempQuestUI.GetComponentInChildren <QuestInformationData>();
        tempQuestUI.transform.SetParent(this.getUI().transform);
        tempQuestUI.transform.SetAsLastSibling();
        tempQuestUI.SetActive(false);
        questInformationObject = tempQuestUI;

        //QuestWrapper
        questWrapper = getUI().transform.GetChild(getUI().transform.childCount - 1).GetChild(1).GetChild(0).GetComponent <QuestWrapper>();

        //UIPlayer
        this.UIPlayer = Tools.findInactiveChild(UICanvas, "Footer_UI").GetComponent <UIPlayerHandler>();
        this.UIPlayer.setPlayer(this);
        this.UIPlayer.gameObject.SetActive(true);
        this.UIPlayer.updateInfo();

        this.UIActionBar = Tools.findInactiveChild(UICanvas, "Actionbar_UI");
        UIActionBar.SetActive(true);
        this.uiStats = Tools.findInactiveChild(UICanvas, "Stat_UI").GetComponent <UIStats>();
        uiStats.gameObject.SetActive(false);
        Debug.Log("STATS: " + this.stats.s_str);

        this.UIDeath = Tools.findInactiveChild(this.getUI(), "Death_UI");
        this.UIDeath.SetActive(true);
        this.UIDeath.GetComponent <GraveStone>().player = this;
        this.UIDeath.SetActive(false);

        //QuestManager
        this.npcController = GameObject.FindWithTag("NPCManager").GetComponent <NPCController>();
        npcController.initilize(this);

        identity = this.GetComponent <NetworkIdentity>();
        Debug.Log("INFO1!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
    }
Beispiel #17
0
    public void initilize(Player player)
    {
        playerNetwork = player.getNetwork();
        this.player   = player;

        GameObject UI                 = GameObject.Find("UI");
        GameObject skillTreeUI        = Tools.findInactiveChild(UI, "SkillTree_UI");
        GameObject panel              = Tools.findInactiveChild(skillTreeUI, "Panel");
        GameObject skillTreeContainer = Tools.findInactiveChild(UI, "SkillTreeContainer");

        this.spritesheet             = Resources.LoadAll <Sprite>("Sprites/SkillIcons/spritesheet");
        this.spritesheet_transparent = Resources.LoadAll <Sprite>("Sprites/SkillIcons/spritesheet_transparent");

        transform.SetParent(skillTreeUI.transform);
        this.UISkillStats = Tools.findInactiveChild(this.transform.parent.gameObject, "Panel").transform.Find("Stats_BG").gameObject;

        this.UISkillStatsWrapper = Tools.findInactiveChild(UISkillStats, "Wrapper");
        this.UISkillStatsPoints  = Tools.findInactiveChild(UISkillStats, "Points").GetComponent <Text>();
        this.UISkillStatsName    = Tools.findInactiveChild(UISkillStats, "Name").GetComponent <Text>();

        UISkillStatsRectTransform = this.UISkillStats.GetComponent <RectTransform>();

        //transform.SetParent(UI.transform.Find("SkillTree_UI").Find("Panel").Find("SkillTreeContainer"));
        Debug.Log("INTIILIZEDIDDDDDDD!!!!");
        UI.GetComponent <UIReferences>().skillTreeReference = this.gameObject;

        Skill skills = JsonManager.readJson <Skill>(e_Paths.JSON_SKILLTREE);

        Debug.Log("e_paths.jsonskilltree: " + JsonManager.getPath(e_Paths.JSON_SKILLTREE));
        Debug.Log("skills: " + skills);

        potrait = Instantiate(skillTreeSlotPrefab);
        Debug.Log("Is  this running? " + potrait);
        potrait.GetComponent <SkillId>().setSkillTree(this);
        potrait.transform.SetParent(this.transform);
        potrait.transform.position    = new Vector3(xRoot, yRoot, zRoot);
        potrait.transform.localScale += new Vector3(1, 1, 0);
        potrait.GetComponent <RectTransform>().sizeDelta = new Vector3(30, 35, 0);
        potrait.GetComponent <Image>().sprite            = spritesheet[0];
        onSkillUpgrade(potrait, potrait.GetComponent <SkillId>(), this.gameObject, null);

        foreach (Skill skill in skills.Potrait)
        {
            chooseType(currentIndex);
            currentIndex++;
            //Create parents
            GameObject inst    = Instantiate(skillTreeSlotPrefab);
            SkillId    skillId = inst.GetComponent <SkillId>();
            skillId.setSkillTree(this);
            skillsObjects.Add(skillId);
            inst.transform.SetParent(potrait.transform);
            createSkillObject(inst, skill);

            masterSpellWidthOffset  = 35 * potrait.transform.localScale.x;
            masterSpellHeightOffset = 35 * potrait.transform.localScale.y;

            inst.transform.position = new Vector3(xRoot + (masterSpellWidthOffset * xType), yRoot + (masterSpellHeightOffset * yType), zRoot);
            createText(inst, false);

            onSkillUpgrade(inst, skillId, potrait, skill);

            if (hasSkillChildren(skill))
            {
                parseChildren(skill.children, skill, inst);
            }
        }
    }