// Use this for initialization
    void Start()
    {
        startScale    = transform.localScale;
        startposition = transform.position;
        AttackPhase   = 0;
        nowHP         = _HP;
        enemyHpbar    = GetComponent <EnemyHpbar>();
        enemyHpbar.SetBarValue(_HP, nowHP);
        patrolType                 = 0;
        playerObject               = GameObject.FindGameObjectWithTag("Player");
        playerController           = playerObject.GetComponent <PlayerController>();
        targetPosition             = _AttackPosition.transform.position;
        _collisionDisplacePosition = transform.position.x - _WaitPosition.transform.position.x;


        _AttackPosition.transform.parent = null;
        _AttackPosition.SetActive(false);
        _WaitPosition.transform.parent = null;
        _WaitPosition.SetActive(false);

        animator    = GetComponent <Animator>();
        Model       = this.FindCubismModel();
        rb          = GetComponent <Rigidbody2D>();
        cameraShake = GameObject.Find("Main Camera").GetComponent <CameraShake>();

        int i = 0;

        foreach (var skl in _sickle)
        {
            attackEffect[i++] = skl.transform.GetChild(0).gameObject;
            attackEffect[i++] = skl.transform.GetChild(1).gameObject;
        }
        cubismRender = GetComponent <CubismRenderController>();
    }
        public static void SetLive2DCubism3CVVTuberSettings_Koharu()
        {
            GameObject koharu = GameObject.Find("Koharu");

            if (koharu != null)
            {
                CubismModel live2DCubism3Model = koharu.GetComponent <CubismModel> ();

                Animator animator = koharu.GetComponent <Animator>();


                CubismRenderController cubisumRenderController = koharu.GetComponent <CubismRenderController>();
                Undo.RecordObject(cubisumRenderController, "Set CubismSortingMode.BackToFrontOrder to cubisumRenderController.SortingMode");
                cubisumRenderController.SortingMode = CubismSortingMode.BackToFrontOrder;
                EditorUtility.SetDirty(cubisumRenderController);
                foreach (var renderer in cubisumRenderController.Renderers)
                {
                    EditorUtility.SetDirty(renderer);
                    // HACK Get mesh renderer directly.
                    EditorUtility.SetDirty(renderer.GetComponent <MeshRenderer>());
                }


                Undo.RecordObject(animator, "Set AnimatorControlle to animator.runtimeAnimatorController");
                animator.runtimeAnimatorController = Resources.Load <RuntimeAnimatorController>("Animation/Koharu_Animation");
                EditorUtility.SetDirty(animator);


                Live2DCubism3HeadRotationController headRotationController = FindObjectOfType <Live2DCubism3HeadRotationController> ();
                if (headRotationController != null)
                {
                    Undo.RecordObject(headRotationController, "Set live2DCubism3Model to headRotationController.target");
                    headRotationController.target = live2DCubism3Model;

                    EditorUtility.SetDirty(headRotationController);
                }

                Live2DCubism3FaceAnimationController faceAnimationController = FindObjectOfType <Live2DCubism3FaceAnimationController> ();
                if (faceAnimationController != null)
                {
                    Undo.RecordObject(faceAnimationController, "Set live2DCubism3Model to faceAnimationController.live2DCubism3Model");
                    faceAnimationController.live2DCubism3Model = live2DCubism3Model;

                    EditorUtility.SetDirty(faceAnimationController);
                }

                Live2DCubism3KeyInputExpressionController keyInputExpressionController = FindObjectOfType <Live2DCubism3KeyInputExpressionController>();
                if (keyInputExpressionController != null)
                {
                    Undo.RecordObject(keyInputExpressionController, "Set Animator to keyInputExpressionController.target");
                    keyInputExpressionController.target = animator;

                    EditorUtility.SetDirty(keyInputExpressionController);
                }
            }
            else
            {
                Debug.LogError("There is no \"Live2DCubism3Model_Koharu\" prefab in the scene. Please add \"Live2DCubism3Model_Koharu\" prefab to the scene.");
            }
        }
    // Use this for initialization
    void Start()
    {
        startScale          = transform.localScale;
        startPosition       = transform.position;
        startRotation       = transform.rotation.eulerAngles;
        Start_Rotation_Z    = transform.rotation.eulerAngles.z;
        PatrolPointPosition = new Vector3[_PatrolPoint.Length];
        for (int i = 0; i < _PatrolPoint.Length; i++)
        {
            PatrolPointPosition[i] = _PatrolPoint[i].gameObject.transform.position;
        }
        _waitPosition.SetActive(false);
        //_PatrolPoint[PointCount].SetActive(true);               //最初のパトロールポイントのアクティブをtrueにする
        //Point_Position = PatrolPointPosition[PointCount];       //最初のパトロールポイントの座標を格納
        AttackPhase      = 0;
        Count            = 0;
        nowHP            = _HP;
        playerObject     = GameObject.FindGameObjectWithTag("Player");
        playerController = playerObject.GetComponent <PlayerController>();
        waitingPosition  = gameObject.transform.position;
        waitingRotion    = gameObject.transform.eulerAngles;

        enemyHpbar = GetComponent <EnemyHpbar>();
        enemyHpbar.SetBarValue(_HP, nowHP);
        targetPosition = PatrolPointPosition[PointCount];
        rb             = GetComponent <Rigidbody2D>();
        var count = transform.childCount - 1;

        for (int i = count; i > count - _childNullCount; i--)
        {
            transform.GetChild(i).gameObject.SetActive(false);
            transform.GetChild(i).transform.parent = null;
        }

        attackEffect = transform.GetChild(0).GetChild(0).gameObject;

        animator = GetComponent <Animator>();
        int z = (int)Start_Rotation_Z;

        switch (z)
        {
        case 0:
        case 90:
            _directionChange = false;
            break;

        case 180:
        case 270:
            _directionChange = true;
            break;
        }

        Direction(playerObject.transform.position);

        cubismRender = GetComponent <CubismRenderController>();
    }
Exemple #4
0
 private void Awake()
 {
     if (!_isTruePopEffect)
     {
         enabled = false;
         return;
     }
     enemy_ChildSpiderAnimTest = GetComponent <Enemy_ChildSpiderAnimTest>();
     cubismRender = GetComponent <CubismRenderController>();
     enemyHpbar   = GetComponent <EnemyHpbar>();
     rb           = GetComponent <Rigidbody2D>();
 }
Exemple #5
0
        protected virtual void Awake()
        {
            animator         = GetComponent <Animator>();
            RenderController = GetComponent <CubismRenderController>();
            lookController   = GetComponent <CubismLookController>();
            mouthController  = GetComponent <CubismMouthController>();

            CubismModel = RenderController.FindCubismModel();

            if (controlLook)
            {
                lookTarget = new GameObject("LookTarget").AddComponent <CubismLookTargetBehaviour>();
                lookTarget.transform.SetParent(transform, false);
                lookController.Center = transform;
                lookController.Target = lookTarget;
            }
        }
Exemple #6
0
    // Use this for initialization
    void Start()
    {
        startPosition       = transform.position;
        startScale          = transform.localScale;
        PatrolPointPosition = new Vector3[_PatrolPoint.Length];
        for (int i = 0; i < _PatrolPoint.Length; i++)
        {
            PatrolPointPosition[i] = _PatrolPoint[i].gameObject.transform.position;
            _PatrolPoint[i].SetActive(false);
        }
        Point_Position = PatrolPointPosition[PointCount];     //最初のパトロールポイントの座標を格納
        movetype       = 2;

        AttackPhase = 0;
        Count       = 0;
        nowHP       = _HP;

        if (Point_Position.x <= gameObject.transform.position.x)
        {
            _direction      = -1; //左
            directionChange = false;
            gameObject.transform.localScale = new Vector2(gameObject.transform.localScale.x, gameObject.transform.localScale.y);
        }
        else
        {
            _direction      = 1; //右
            directionChange = true;
            gameObject.transform.localScale = new Vector2(-gameObject.transform.localScale.x, gameObject.transform.localScale.y);
        }
        enemyHpbar = GetComponent <EnemyHpbar>();
        enemyHpbar.SetBarValue(_HP, nowHP);
        playerObject         = GameObject.FindGameObjectWithTag("Player");
        playerController     = playerObject.GetComponent <PlayerController>();
        AttackObject.enabled = false;


        animator = GetComponent <Animator>();

        cubismRender = GetComponent <CubismRenderController>();
    }
Exemple #7
0
    // Use this for initialization
    void Start()
    {
        startPosition = transform.position;
        startScale    = transform.localScale;
        startTracking_cancellationPo = _tracking_cancellation.transform.position;
        PointA_Position = transform.GetChild(0).gameObject.transform.position;
        PointB_Position = transform.GetChild(1).gameObject.transform.position;
        transform.GetChild(0).gameObject.SetActive(false);
        transform.GetChild(1).gameObject.SetActive(false);
        AttackPhase         = 0;
        Count               = 0;
        nowHP               = _HP;
        directionChangeFlag = false;
        if (_directionChange)
        {
            _direction = 1;
            gameObject.transform.localScale = new Vector2(-gameObject.transform.localScale.x, gameObject.transform.localScale.y);
        }
        else
        {
            _direction = -1;
            gameObject.transform.localScale = new Vector2(gameObject.transform.localScale.x, gameObject.transform.localScale.y);
        }
        enemyHpbar = GetComponent <EnemyHpbar>();
        enemyHpbar.SetBarValue(_HP, nowHP);
        patrolType       = 0;
        playerObject     = GameObject.FindGameObjectWithTag("Player");
        playerController = playerObject.GetComponent <PlayerController>();

        animator     = GetComponent <Animator>();
        Model        = this.FindCubismModel();
        cubismRender = GetComponent <CubismRenderController>();
        _tracking_cancellation.transform.parent = null;
        if (!_tracking_cancellationflag)
        {
            _tracking_cancellation.SetActive(false);
        }
    }
Exemple #8
0
        public CubismModel GetModelFromName(string name, GameObject parent)
        {
            try
            {
                string ModelPath = Application.streamingAssetsPath + "../../../Data/live2d/" + name + ".model3.json";
                //Debug.Log(ModelPath);
                if (System.IO.File.Exists(ModelPath))
                {
                    var ModelFullName = ModelPath;
                    var model3Json    = CubismModel3Json.LoadAtPath(ModelFullName, BuiltinLoadAssetAtPath);
                    var motions       = model3Json.FileReferences.Motions.Motions;
                    var model         = model3Json.ToModel(true);
                    var Scale         = 40f;
                    model.gameObject.transform.localScale += new Vector3(Scale, Scale);
                    CubismRenderController cubisumRenderController = model.GetComponent <CubismRenderController>();
                    cubisumRenderController.SortingMode = CubismSortingMode.BackToFrontOrder;

                    //处理动画(Motion)
                    Animation animation      = model.gameObject.AddComponent <Animation>();
                    var       animationClips = new ArrayList();
                    var       modelD         = Path.GetDirectoryName(ModelPath);
                    if (motions != null)
                    {
                        for (var i = 0; i < motions.Length; ++i)
                        {
                            for (var j = 0; j < motions[i].Length; ++j)
                            {
                                string            MotionPath        = modelD + "/" + motions[i][j].File;
                                CubismMotion3Json cubismMotion3Json = CubismMotion3Json.LoadFrom(File.ReadAllText(MotionPath));
                                AnimationClip     animationClip     = cubismMotion3Json.ToAnimationClip(new AnimationClip
                                {
                                    legacy = true
                                }, false, false, false, null);
                                var motionName = motions[i][j].File.Substring(0, motions[i][j].File.Length - 13);
                                animationClip.name = motionName;
                                animation.AddClip(animationClip, animationClip.name);
                                animationClips.Add(animationClip.name);
                                //animation.Blend(animationClip.name);
                            }
                        }
                    }

                    //处理姿势
                    var pose3Json = model3Json.Pose3Json;
                    if (pose3Json != null)
                    {
                        var groups = pose3Json.Groups;
                        var parts  = model.Parts;
                        for (var groupIndex = 0; groupIndex < groups.Length; ++groupIndex)
                        {
                            var group = groups[groupIndex];
                            if (group == null)
                            {
                                continue;
                            }

                            for (var partIndex = 0; partIndex < group.Length; ++partIndex)
                            {
                                var part = parts.FindById(group[partIndex].Id);

                                if (part == null)
                                {
                                    continue;
                                }

                                var posePart = part.gameObject.GetComponent <CubismPosePart>();

                                if (posePart == null)
                                {
                                    posePart = part.gameObject.AddComponent <CubismPosePart>();
                                }

                                posePart.GroupIndex = groupIndex;
                                posePart.PartIndex  = partIndex;
                                posePart.Link       = group[partIndex].Link;
                            }
                        }
                        model.GetComponent <CubismPoseController>().Refresh();
                    }

                    //+1
                    model.name = model.name + "(" + Globle.ModelNum.ToString() + ")";
                    Globle.ModelNum++;
                    Globle.ModelList.Add(model.gameObject);

                    var modelController = model.gameObject.AddComponent <Live2DModelController>();
                    modelController.DisplayName    = model.name;
                    modelController.ModelPath      = modelD;
                    modelController.Animation      = animation;
                    modelController.animationClips = animationClips;

                    model.transform.SetParent(parent.transform);
                    model.gameObject.transform.localPosition = new Vector3(0, 0, 0);
                    return(model);
                }
                else
                {
                    throw new Exception(Globle.LangController.GetLang("LOG.FileUnisset"));
                }
            }
            catch (Exception err)
            {
                Globle.AddDataLog("Main", Globle.LangController.GetLang("LOG.ModelAddationException", err.Message));
            }
            return(null);
        }
Exemple #9
0
 protected override void Init()
 {
     base.Init();
     _model            = _curPlayerAnim.gameObject.FindCubismModel();
     _renderController = _model.gameObject.GetComponent <CubismRenderController>();
 }