示例#1
0
        void AddCharacterHandler(int npcId, App.Model.ActionType actionType, App.Model.Direction direction, int x, int y, bool isPlayer)
        {
            Debug.LogError("VScenarioMap AddCharacterHandler");
            Model.Character.MCharacter character = NpcCacher.Instance.GetFromNpc(npcId);
            character.StatusInit();
            character.action = actionType;
            GameObject obj = character.staticAvatar == 0 ? Instantiate(Global.characterPrefab) : Instantiate(Global.avatarPrefab);

            obj.transform.SetParent(characterLayer);
            obj.transform.localScale = Vector3.one * 0.6f;
            //float x = character.coordinate.x * 0.64f + 0.32f + (character.coordinate.y % 2 == 0 ? 0 : 0.32f);
            obj.transform.localPosition = new Vector3(x * 0.32f, -4.4f, 0);
            obj.SetActive(true);
            Avatar.VCharacterBase vCharacter = obj.GetComponent <Avatar.VCharacterBase>();
            vCharacter.UpdateView(character);
            vCharacter.direction = direction;
            Global.charactersManager.vCharacters.Add(vCharacter);
            if (isPlayer)
            {
                Global.charactersManager.mainVCharacter = vCharacter;
            }
        }
示例#2
0
文件: VMap.cs 项目: lufy001/Sgj-MZ
        private void SetCharacters()
        {
            object val = this.GetByPath("characters");

            if (val == null)
            {
                return;
            }
            List <Model.Character.MCharacter> characters = val as List <Model.Character.MCharacter>;

            for (int i = 0; i < characters.Count; i++)
            {
                Model.Character.MCharacter character = characters[i];
                Debug.LogError("character=" + character.name + "," + character.staticAvatar);
                GameObject obj = character.staticAvatar == 0 ? Instantiate(Global.characterPrefab) : Instantiate(Global.avatarPrefab);
                obj.transform.SetParent(characterLayer);
                obj.transform.localScale = Vector3.one * 0.6f;
                float x = character.coordinate.x * 0.64f + 0.32f + (character.coordinate.y % 2 == 0 ? 0 : 0.32f);
                obj.transform.localPosition = new Vector3(x, -character.coordinate.y * 0.64f - 0.32f, 0);
                Avatar.VCharacterBase vCharacter = obj.GetComponent <Avatar.VCharacterBase>();
                vCharacter.UpdateView(character);
                Global.charactersManager.vCharacters.Add(vCharacter);
            }
        }