Beispiel #1
0
        public void update(float dt, double update_time, ref MyTransform parent_transform)
        {
            if (MyCollider.getHitOpponentForEnemy(collider_) != MyCollider.Type.None)
            {
                rigidbody_.addTorque(MyRandom.Range(-20f, 20f),
                                     MyRandom.Range(-20f, 20f),
                                     MyRandom.Range(-20f, 20f));
            }
            if (lock_target_.isHitted())
            {
                rigidbody_.addTorque(MyRandom.Range(-200f, 200f),
                                     MyRandom.Range(-200f, 200f),
                                     MyRandom.Range(-200f, 200f));
                lock_target_.clearLock();
                Explosion.Instance.spawn(ref lock_target_.updated_position_, update_time);
                Hahen.Instance.spawn(ref lock_target_.updated_position_, update_time);
                Shockwave.Instance.spawn(ref lock_target_.updated_position_, update_time);
                SystemManager.Instance.registSound(DrawBuffer.SE.Explosion);
            }
            rigidbody_.addSpringTorque(ref parent_transform.rotation_, 30f /* torque_level */);
            var pos = parent_transform.transformPosition(ref locator_);

            rigidbody_.transform_.position_ = pos;
            rigidbody_.update(dt);
            MyCollider.updateEnemy(collider_, ref rigidbody_.transform_.position_);
            lock_target_.update();
        }
Beispiel #2
0
        IEnumerator loop()
        {
            replay_manager_.startRecording((double)Time.time);
            for (var i = 0; i < 7; ++i)
            {
                MyTransform tfm = new MyTransform();
                tfm.position_ = new Vector3(i, 0f, 0f);
                try {
                    replay_manager_.update((double)i, ref tfm, false /* is_fire_button_pressed */);
                } catch (System.Exception e) {
                    Debug.LogError(e);
                }
            }
            replay_manager_.stopRecording();

            yield return(null);

            replay_manager_.startPlaying((double)Time.time, null /* player */);
            for (var i = 0; i < 24; ++i)
            {
                MyTransform tfm = new MyTransform();
                try {
                    bool is_fire_button_pressed = false;
                    replay_manager_.getFrameData((double)(i - 2) * 0.33333, ref tfm, ref is_fire_button_pressed);
                } catch (System.Exception e) {
                    Debug.LogError(e);
                }
                Debug.LogFormat("{0}:pos_x:{1}", (double)(i - 2) * 0.33333, tfm.position_.x);
            }
            replay_manager_.stopPlaying(null /* player */);
            yield return(null);
        }
 public void setPositionAndRotation(ref MyTransform tfm)
 {
     transform_.setPositionAndRotation(ref tfm);
     velocity_       = CV.Vector3Zero;
     acceleration_   = CV.Vector3Zero;
     r_velocity_     = CV.Vector3Zero;
     r_acceleration_ = CV.Vector3Zero;
 }
Beispiel #4
0
        public MyTransform add(ref Vector3 offset)
        {
            var transform = new MyTransform();

            transform.position_ = transformPosition(ref offset);
            transform.rotation_ = rotation_;
            return(transform);
        }
Beispiel #5
0
        public void reset(ref MyTransform parent_transform)
        {
            var pos = parent_transform.transformPosition(ref locator_);

            rigidbody_.transform_.position_ = pos;
            rigidbody_.transform_.rotation_ = parent_transform.rotation_;
            rigidbody_.velocity_            = CV.Vector3Zero;
            rigidbody_.r_velocity_          = CV.Vector3Zero;
        }
 public void regist(ref MyTransform transform, Type type)
 {
     object_buffer_[object_num_].set(ref transform, type);
     ++object_num_;
     if (object_num_ > OBJECT_MAX) {
     Debug.LogError("EXCEED Enemy POOL!");
     Debug.Assert(false);
     }
 }
Beispiel #7
0
 public void regist(ref MyTransform transform, Type type)
 {
     object_buffer_[object_num_].set(ref transform, type);
     ++object_num_;
     if (object_num_ > OBJECT_MAX)
     {
         Debug.LogError("EXCEED Enemy POOL!");
         Debug.Assert(false);
     }
 }
 public void regist(ref MyTransform transform, Type type, int versatile_data = 0)
 {
     object_buffer_[object_num_].set(ref transform, type, versatile_data);
     ++object_num_;
     if (object_num_ > OBJECT_MAX)
     {
         Debug.LogError("EXCEED Fighter POOL!");
         Debug.Assert(false);
     }
 }
Beispiel #9
0
 public void renderUpdate(int front, ref MyTransform head_transform, ref DrawBuffer draw_buffer)
 {
     for (var i = 0; i < nodes_.Length; ++i)
     {
         nodes_[i].renderUpdate(front, ref draw_buffer);
     }
     // if (is_charging_) {
     //  var offset = new Vector3(0, 0, 2.5f);
     //  lightball_.renderUpdate(front, ref head_transform, ref offset);
     // }
 }
Beispiel #10
0
        private void internal_update_for_replay(float dt, double update_time)
        {
            MyTransform transform = new MyTransform();
            bool        success   = replay_manager_.getFrameData(update_time, ref transform, ref fire_button_);

            if (!success)
            {
                SystemManager.Instance.restart();
            }
            rigidbody_.transform_ = transform;
            update_attack(update_time, true /* replay */);
            update_collision(update_time);
        }
Beispiel #11
0
 public void reset(ref MyTransform head_transform)
 {
     for (var i = 0; i < nodes_.Length; ++i)
     {
         if (i == 0)
         {
             nodes_[i].reset(ref head_transform);
         }
         else
         {
             nodes_[i].reset(ref nodes_[i - 1].rigidbody_.transform_);
         }
     }
 }
        IEnumerator loop()
        {
            MyTransform transform = new MyTransform();

            transform.init();
            transform.position_ = new Vector3(1, 1, 1);
            var offset = new Vector3(0, 0, 5);

            for (;;)
            {
                lightball_.update(1f / 60f /* dt */);
                lightball_.renderUpdate(0 /* front */, ref transform, ref offset);
                yield return(null);
            }
        }
Beispiel #13
0
 public void update(float dt, double update_time, ref MyTransform head_transform)
 {
     for (var i = 0; i < nodes_.Length; ++i)
     {
         if (i == 0)
         {
             nodes_[i].update(dt, update_time, ref head_transform);
         }
         else
         {
             nodes_[i].update(dt, update_time, ref nodes_[i - 1].rigidbody_.transform_);
         }
     }
     lightball_.update(dt);
 }
Beispiel #14
0
 public void renderUpdate(int front, ref MyTransform transform, ref Vector3 offset)
 {
     {
         var pos = transform.transformPosition(ref offset);
         Beam.Instance.renderUpdate(front,
                                    beam_id_,
                                    ref pos,
                                    ref pos);
     }
     for (var i = 0; i < beam_id_list_.Length; ++i)
     {
         var dir0 = offset + normal_list_[i] * phase_list_[i] * 2f;
         var pos0 = transform.transformPosition(ref dir0);
         var dir1 = offset + normal_list_[i] * (phase_list_[i] + 0.1f) * 2f;
         var pos1 = transform.transformPosition(ref dir1);
         Beam.Instance.renderUpdate(front,
                                    beam_id_list_[i],
                                    ref pos0,
                                    ref pos1);
     }
 }
Beispiel #15
0
        public void update(double update_time,
                           ref MyTransform player_transform,
                           bool is_fire_button_pressed)
        {
            /* during pause, this function won't be executed. */

            if (is_recording_)
            {
                frames_[frame_index_].game_time_ = (float)(update_time - start_time_);
                frames_[frame_index_].player_transform_.position_ = player_transform.position_;
                frames_[frame_index_].player_transform_.rotation_ = player_transform.rotation_;
                frames_[frame_index_].is_fire_button_pressed_     = is_fire_button_pressed;
                // Debug.LogFormat("record:{0},{1}",
                //              frames_[frame_index_].game_time_,
                //              frames_[frame_index_].player_transform_);
                ++frame_index_;
                if (frame_index_ >= MAX_FRAMES)
                {
                    Debug.LogError("exceeded replay buffer");
                    is_recording_ = false;
                }
            }
        }
Beispiel #16
0
        /**
         * @return whether next frame is available. 'false' means you should stop the replay at this frame.
         */
        public bool getFrameData(double update_time, ref MyTransform transform, ref bool is_fire_button_pressed)
        {
            double game_time = update_time - start_time_;
            int    max       = recorded_frame_number_;
            int    index     = search(game_time, 0, max);
            int    index_a   = index;

            if (index_a >= max)
            {
                index_a = max - 1;
            }
            int index_b = index + 1;

            if (index_b >= max)
            {
                index_b = max - 1;
            }

            double game_time_a = frames_[index_a].game_time_;
            double game_time_b = frames_[index_b].game_time_;
            double diff        = game_time_b - game_time_a;
            float  ratio       = (float)((game_time - game_time_a) / diff);

            transform.position_ = Vector3.Lerp(frames_[index_a].player_transform_.position_,
                                               frames_[index_b].player_transform_.position_,
                                               ratio);
            transform.rotation_ = Quaternion.Slerp(frames_[index_a].player_transform_.rotation_,
                                                   frames_[index_b].player_transform_.rotation_,
                                                   ratio);

            bool is_fire_button_pressed_a = frames_[index_a].is_fire_button_pressed_;
            bool is_fire_button_pressed_b = frames_[index_b].is_fire_button_pressed_;

            is_fire_button_pressed = ratio < 0.5f ? is_fire_button_pressed_a : is_fire_button_pressed_b;
            return(index + 1 < max);
        }
Beispiel #17
0
 public void set(ref MyTransform transform, Type type)
 {
     transform_ = transform;
     type_      = type;
 }
Beispiel #18
0
 public void registPlayer(ref MyTransform transform, ref Vector3 arm_offset)
 {
     player_transform_  = transform;
     player_arm_offset_ = arm_offset;
 }
Beispiel #19
0
 public void setPositionAndRotation(ref MyTransform tfm)
 {
     position_ = tfm.position_;
     rotation_ = tfm.rotation_;
     update();
 }
 public void set(ref MyTransform transform, Type type, int versatile_data)
 {
     transform_      = transform;
     type_           = type;
     versatile_data_ = versatile_data;
 }
 public void set(ref MyTransform transform, Type type)
 {
     transform_ = transform;
     type_ = type;
 }
 public void registCamera(ref MyTransform transform)
 {
     camera_transform_ = transform;
 }
 public void registCamera(ref MyTransform transform)
 {
     camera_transform_ = transform;
 }
 public void registPlayer(ref MyTransform transform)
 {
     player_transform_ = transform;
 }
Beispiel #25
0
 public virtual void init(ref MyTransform transform)
 {
     init();
     rigidbody_.transform_ = transform;
 }
Beispiel #26
0
 public virtual void init(ref MyTransform transform)
 {
     init();
     rigidbody_.transform_ = transform;
 }
Beispiel #27
0
 public void registPlayer(ref MyTransform transform)
 {
     player_transform_ = transform;
 }