Example #1
0
    protected virtual void Start()
    {
        // See if we have a persistent state to load in.
        EnemyState state = null;

        if (LevelManager.Instance.CurrentInitialEnemyStates != null && LevelManager.Instance.CurrentInitialEnemyStates.TryGetValue(Id, out state))
        {
            CurrentHealth      = state.CurrentHealth;
            CurrentDirection   = state.CurrentDirection;
            _currentSpeed      = state.CurrentSpeed;
            transform.position = state.Pose.position;
            transform.rotation = state.Pose.rotation;
        }

        CurrentHealth   = _baseHealth;
        _currentSpeed   = _baseSpeed;
        _motionProvider = GetMotionProvider();
        _attackZone.SetDimensions(_attackZoneDimensions);
        EnemiesManager.Instance.AddSpawnedEnemy(this);

        // If the enemy was despawned, we need to despawn it.
        // It may seem odd that we are adding a spawned enym and then immediately despawining it,
        // but this is so that we can keep an id in the state map saying that it was despawned.
        if (state?.WasDespawned ?? false)
        {
            EnemiesManager.Instance.DespawnEnemy(this);
        }
    }
Example #2
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);

                OpenFileDialog ofd2 = new OpenFileDialog();
                ofd2.Filter = "vmdモーションファイル(*.vmd)|*.vmd";
                if (ofd2.ShowDialog() == DialogResult.OK)
                {
                    IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true);
                    model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay);
                }

                WorldSpace.AddResource(model);
                //②コントローラーフォームに対して読み込んだモデルを渡して表示します。
                Controller controller = new Controller(model);
                controller.Show();
            }
        }
Example #3
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);

                OpenFileDialog ofd2 = new OpenFileDialog();
                ofd2.Filter = "vmdモーションファイル(*.vmd)|*.vmd";
                if (ofd2.ShowDialog() == DialogResult.OK)
                {
                    IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true);
                    model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay);
                }
                WorldSpace.AddResource(model);
                //③ カメラモーションの選択ダイアログを表示し、選ばれたものをScreenContext.CameraMotionProviderに代入する。
                CameraControlSelector selector = new CameraControlSelector(model);
                selector.ShowDialog(this);
                ScreenContext.CameraMotionProvider = selector.ResultCameraMotionProvider;

                /*
                 * ScreenContext.CameraMotionProviderに代入されたインターフェースのUpdateCameraが毎回呼ばれることによりカメラを更新している。
                 * この変数の型はICameraMotionProviderのため、これを実装すればカメラの動きは容易に定義可能である。
                 */
            }
        }
Example #4
0
 /// <summary>
 ///     指定したモーションを再生する
 /// </summary>
 /// <param name="id">モーションのid</param>
 /// <param name="startFrame">最初のフレーム</param>
 /// <param name="setting">終了後の挙動</param>
 public void ApplyMotion(IMotionProvider motionProvider, int startFrame = 0,
                         ActionAfterMotion setting = ActionAfterMotion.Nothing)
 {
     if (CurrentMotionProvider != null)
     {
         CurrentMotionProvider.Stop();
     }
     motionProvider.Start(startFrame, setting);
     CurrentMotionProvider = motionProvider;
 }
Example #5
0
        private void loadMotion_Click(object sender, EventArgs e)
        {
            if (model == null)
            {
                return;
            }
            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "vmdモデルファイル(*.vmd)|*.vmd";
            if (ofd.ShowDialog(this) == DialogResult.OK)
            {
                IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd.FileName, false);
                model.MotionManager.ApplyMotion(motion);
            }
        }
Example #6
0
        public PlayerContext(GameContext context, int index)
        {
            Context = context;
            this.PlayerIndex = index;
            ViewForm = new PlayerViewForm(context.RenderContext);
            currentScene = new StartScreenScene(Context, this);
            ViewForm.Show();
            //TODO キャラクターのファクトリクラスの作成など
            PlayerModel = PMXModelWithPhysics.OpenLoad("mona-.pmx", context.RenderContext);
            runMotion = PlayerModel.MotionManager.AddMotionFromFile("run.vmd", false);
            PlayerModel.MotionManager.ApplyMotion(runMotion);
            EyeTextureRenderer = new OculusDisplayRenderer(context.RenderContext, context.GameWorld,0,context.OculusManager,this);

            ViewForm.WorldSpace.AddResource(EyeTextureRenderer);
            context.GameWorld.AddResource(PlayerModel);
        }
Example #7
0
        public PlayerContext(GameContext context, int index)
        {
            Context          = context;
            this.PlayerIndex = index;
            ViewForm         = new PlayerViewForm(context.RenderContext);
            currentScene     = new StartScreenScene(Context, this);
            ViewForm.Show();
            //TODO キャラクターのファクトリクラスの作成など
            PlayerModel = PMXModelWithPhysics.OpenLoad("mona-.pmx", context.RenderContext);
            runMotion   = PlayerModel.MotionManager.AddMotionFromFile("run.vmd", false);
            PlayerModel.MotionManager.ApplyMotion(runMotion);
            EyeTextureRenderer = new OculusDisplayRenderer(context.RenderContext, context.GameWorld, 0, context.OculusManager, this);

            ViewForm.WorldSpace.AddResource(EyeTextureRenderer);
            context.GameWorld.AddResource(PlayerModel);
        }
Example #8
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "pmx model file(*.pmx)|*.pmx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                MMDModel model = MMDModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);

                //OpenFileDialog to select vmd motion file
                OpenFileDialog ofd2 = new OpenFileDialog();
                ofd2.Filter = "vmd motion file(*.vmd)|*.vmd";
                if (ofd2.ShowDialog() == DialogResult.OK)
                {
                    //①Load motion file
                    IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true);
                    //You should add your motion file to the model you wanting to apply.
                    //IMotionProvider AddMotionFromFile(string fileName,bool ignoreParentBone);
                    //If you set true in secound argument to the method above,MMF will ignore root bones motion.
                    //For instance,you want to walk by your code and motion with motion file,motion file might move model coordinate.
                    //When MMF ignore parent bone,MMF will not move model coordinate by motion.

                    //②Apply motion to your PMX model
                    model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay);
                    //Secound argument:
                    //Start frame number
                    //Third argument:
                    //What MMF should do when motion playing is finished.
                    //If you want MMF to do nothing when motion playing is finished,you should set ActionAfterMotion.Nothing in third argument.

                    //Extra
                    //(1) How to stop motion?
                    //You can stop motion by using the code below.
                    //model.MotionManager.StopMotion();
                    //(2) What frame number is it playing?
                    //You can get form model.MotionManager.CurrentFrame.
                }
                WorldSpace.AddResource(model);
            }
        }
Example #9
0
        protected override void OnLoad(EventArgs e)
        {
            base.OnLoad(e);

            OpenFileDialog ofd = new OpenFileDialog();

            ofd.Filter = "pmxモデルファイル(*.pmx)|*.pmx";
            if (ofd.ShowDialog() == DialogResult.OK)
            {
                PMXModel model = PMXModelWithPhysics.OpenLoad(ofd.FileName, RenderContext);

                //Establishment of preclusion to load dialog
                OpenFileDialog ofd2 = new OpenFileDialog();
                ofd2.Filter = "vmdモーションファイル(*.vmd)|*.vmd";
                if (ofd2.ShowDialog() == DialogResult.OK)
                {
                    //OK if the return value of the dialog to model loading process

                    //①モーションファイルを読み込む
                    IMotionProvider motion = model.MotionManager.AddMotionFromFile(ofd2.FileName, true);
                    //Add the models for which you want to apply the motion Manager。
                    //IMotionProvider AddMotionFromFile(string ファイル名,bool すべての親ボーンを無視するかどうか);
                    //Walking motion as the second argument to ignore the motion of all parent bones when you want to programmatically specify the movement itself, the
                    //Move the entire model is in motion to prevent。

                    //②モーションファイルをモデルに対して適用する。
                    model.MotionManager.ApplyMotion(motion, 0, ActionAfterMotion.Replay);
                    //Whether or not the second argument, replaying plays frame numbers begin to play, and the third argument is。
                    //If you leave without replay is Yctionyftermotion..Nothingを指定する

                    //オマケ
                    //(1) モーションをとめるときは?
                    //model.MotionManager.StopMotion();と記述すれば止まります
                    //(2) 現在何フレーム目なの?
                    //model.MotionManager.CurrentFrameによって取得できます。
                }
                WorldSpace.AddResource(model);
            }
        }
Example #10
0
 protected virtual void Start()
 {
     _animator       = new ProjectileAnimator(GetComponent <Animator>());
     _rigidBody      = GetComponent <Rigidbody2D>();
     _motionProvider = GetMotionProvider();
 }
Example #11
0
        /// <summary>
        ///     名前とモーションファイルを指定して,モーションを読み込みます.
        /// </summary>
        /// <param name="name">モーション名.</param>
        /// <param name="path">ファイルのパス.</param>
        public void LoadMotion(string name, string path)
        {
            IMotionProvider motion = model.MotionManager.AddMotionFromFile(path, false);

            motions.Add(name, motion);
        }
Example #12
0
 public DynamicMotionProvider(IMotionProvider currentMotionProvider)
 {
     CurrentMotionProvider = currentMotionProvider;
 }
Example #13
0
 public AlertableMotionProvider(AlertZone alertZone, IMotionProvider alertMotionProvider, IMotionProvider unalertMotionProvider)
 {
     _alertZone            = alertZone;
     AlertMotionProvider   = alertMotionProvider;
     UnalertMotionProvider = unalertMotionProvider;
 }