Пример #1
0
        // Use this for initialization
        void Start()
        {
            playerNum = this.transform.parent.name[this.transform.parent.name.Length - 1];
            GameObject[] players = GameObject.FindGameObjectsWithTag("Player");
            GameObject   player  = players[0];

            foreach (GameObject _player in players)
            {
                if (_player.name[_player.name.Length - 1] == (char)playerNum)
                {
                    player = _player;
                    break;
                }
            }
            playerNum -= 48;
            pc         = player.GetComponent <PlayerController>();
            profile    = pc.getProfile();
            var model = Profile.Models[playerNum];

            close = model.keys[PlayerAction.Interaction].ToString();
            if (close.StartsWith("Keyboard"))
            {
                close = close.Substring(8);

                deblock = model.keys[PlayerAction.Submit].ToString().Substring(8);

                howTo = model.keys[PlayerAction.ChangeTorch].ToString();
                howTo = howTo.Substring(8);

                skillKeys = new string[] { model.keys[PlayerAction.Skill1].ToString().Substring(8),
                                           model.keys[PlayerAction.Skill2].ToString().Substring(8),
                                           model.keys[PlayerAction.Skill3].ToString().Substring(8),
                                           model.keys[PlayerAction.Skill4].ToString().Substring(8) };

                browseKeys = new string[] { model.keys[PlayerAction.Left].ToString().Substring(8),
                                            model.keys[PlayerAction.Up].ToString().Substring(8),
                                            model.keys[PlayerAction.Down].ToString().Substring(8),
                                            model.keys[PlayerAction.Right].ToString().Substring(8) };

                removeSelectedSkill = model.keys[PlayerAction.Attack].ToString().Substring(8);
            }
            if (close.StartsWith("Gamepad"))
            {
                close = close.Substring(7);

                deblock = model.keys[PlayerAction.Submit].ToString().Substring(7);
                howTo   = model.keys[PlayerAction.ChangeTorch].ToString();
                howTo   = howTo.Substring(7);

                skillKeys = new string[] { model.keys[PlayerAction.Skill1].ToString().Substring(7),
                                           model.keys[PlayerAction.Skill2].ToString().Substring(7),
                                           model.keys[PlayerAction.Skill3].ToString().Substring(7),
                                           model.keys[PlayerAction.Skill4].ToString().Substring(7) };

                browseKeys = new string[] { model.keys[PlayerAction.Left].ToString().Substring(7),
                                            model.keys[PlayerAction.Up].ToString().Substring(7),
                                            model.keys[PlayerAction.Down].ToString().Substring(7),
                                            model.keys[PlayerAction.Right].ToString().Substring(7) };

                removeSelectedSkill = model.keys[PlayerAction.Attack].ToString().Substring(7);
            }

            // Display the how to description
            setHowToDescription();


            // Set already selected skills sprites
            GeneralData.Skill[] selectedSkills = GeneralData.GetCurrentSkills(playerNum);

            // SKillsSelected (4th child of the inventory)
            Transform selectedSkillsPanel = this.transform.parent.GetChild(3);

            for (int i = 0; i < 4; i++)
            {
                if (selectedSkills[i] != null)
                {
                    Transform skillSlot = selectedSkillsPanel.GetChild(i);
                    skillSlot.GetChild(1).GetComponent <Image>().sprite = Resources.Load <Sprite>(selectedSkills[i].spritePath);
                    if (!skillSlot.transform.GetChild(1).GetComponent <Image>().enabled)
                    {
                        skillSlot.transform.GetChild(1).GetComponent <Image>().enabled = true;
                    }
                    skillSlot.tag = selectedSkills[i].name;
                }
            }
        }