Esempio n. 1
0
        private void zako2_update(float dt, float flow_speed)
        {
            if (MyCollider.getHitOpponentForEnemy(collider_) != MyCollider.Type.None)
            {
                rigidbody_.addTorque(MyRandom.Range(-200f, 200f),
                                     MyRandom.Range(-200f, 200f),
                                     MyRandom.Range(-200f, 200f));
                life_ -= 20f;
            }
            if (lock_target_.isHitted())
            {
                rigidbody_.addTorque(MyRandom.Range(-200f, 200f),
                                     MyRandom.Range(-200f, 200f),
                                     MyRandom.Range(-200f, 200f));
                lock_target_.clearLock();
                life_ -= 100f;
            }
            if (life_ <= 0f && phase_ == Phase.Alive)
            {
                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);
                MyCollider.disableForEnemy(collider_);
                lock_target_.disable();
                phase_ = Phase.Dying;
            }

            rigidbody_.update(dt);
            MyCollider.updateEnemy(collider_, ref rigidbody_.transform_.position_);
            lock_target_.update();
        }
Esempio n. 2
0
        private void zako_update(float dt)
        {
            if (phase_ == Phase.Alive)
            {
                if (MyCollider.getHitOpponentForEnemy(collider_) != MyCollider.Type.None)
                {
                    float p = 100f;
                    rigidbody_.addTorque(MyRandom.Range(-p, p),
                                         MyRandom.Range(-p, p),
                                         MyRandom.Range(-p, p));
                    life_ -= MyCollider.getHitPowerForEnemy(collider_);

                    if (life_ <= 0f)
                    {
                        Explosion.Instance.spawn(ref rigidbody_.transform_.position_, update_time_);
                        Hahen.Instance.spawn(ref rigidbody_.transform_.position_, update_time_);
                        SystemManager.Instance.registSound(DrawBuffer.SE.Explosion);
                        MyCollider.disableForEnemy(collider_);
                        phase_ = Phase.Dying;
                    }
                    else
                    {
                        Vector3 pos;
                        MyCollider.getIntersectPointForEnemy(collider_, out pos);
                        Spark.Instance.spawn(ref pos, Spark.Type.Bullet, update_time_);
                    }
                }
            }
            rigidbody_.update(dt);
            MyCollider.updateEnemy(collider_, ref rigidbody_.transform_.position_);
            MyCollider.updateEnemyHoming(collider_homing_, ref rigidbody_.transform_.position_);
        }
Esempio n. 3
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();
        }
Esempio n. 4
0
        private void dragon_update(float dt)
        {
            if (MyCollider.getHitOpponentForEnemy(collider_) != MyCollider.Type.None)
            {
                float p = 100f;
                rigidbody_.addTorque(MyRandom.Range(-p, p),
                                     MyRandom.Range(-p, p),
                                     MyRandom.Range(-p, p));
                life_ -= 20f;
            }
            if (life_ <= 0f && phase_ == Phase.Alive)
            {
                MyCollider.disableForEnemy(collider_);
                phase_ = Phase.Dying;
            }

            rigidbody_.update(dt);
            MyCollider.updateEnemy(collider_, ref rigidbody_.transform_.position_);
            MyCollider.updateEnemyHoming(collider_homing_, ref rigidbody_.transform_.position_);
            // var head_transform = rigidbody_.transform_.add(ref HEAD_OFFSET);
            dragon_.update(dt, update_time_, ref rigidbody_);

            if (MyRandom.Probability(0.01f))
            {
                var head_pos = new Vector3(0f, 0f, 2f);
                var pos      = rigidbody_.transform_.transformPosition(ref head_pos);
                if (pos.y > 0f)
                {
                    EnemyLaser.create(ref pos, ref rigidbody_.transform_.rotation_, 40f /* speed */, update_time_);
                    SystemManager.Instance.registSound(DrawBuffer.SE.Laser);
                }
            }

            if (MyRandom.Probability(0.1f))
            {
                var pos = rigidbody_.transform_.position_;
                pos.x += MyRandom.Range(-1f, 1f);
                pos.z += MyRandom.Range(-1f, 1f);
                WaterSplash.Instance.spawn(ref pos,
                                           ref CV.Vector3Zero, update_time_ - 0.2f);
            }

            if (-1f < rigidbody_.transform_.position_.y && rigidbody_.transform_.position_.y < 1f)
            {
                WaterSurface.Instance.makeBump(ref rigidbody_.transform_.position_, -0.1f /* value */, 1f /* size */);
                if (MyRandom.Probability(0.1f))
                {
                    var wpos = rigidbody_.transform_.position_;
                    wpos.y = -2f;
                    var vel = new Vector3(0f, MyRandom.Range(5f, 8f), 0f);
                    WaterSplash.Instance.spawn(ref wpos, ref vel, update_time_);
                }
            }
        }
Esempio n. 5
0
        public override void update(float dt, float update_time)
        {
            update_time_ = update_time;
            if (enumerator_ != null)
            {
                enumerator_.MoveNext();
            }
            if (alive_)
            {
                if (MyCollider.getHitOpponentForEnemy(collider_) != MyCollider.Type.None)
                {
                    rigidbody_.addTorque(MyRandom.Range(-100f, 100f),
                                         MyRandom.Range(-100f, 100f),
                                         MyRandom.Range(-100f, 100f));
                    rigidbody_.addForceZ(-10000f);
                    Explosion.Instance.spawn(ref rigidbody_.transform_.position_, update_time);
                    Hahen.Instance.spawn(ref rigidbody_.transform_.position_, update_time);
                    SystemManager.Instance.registSound(DrawBuffer.SE.Explosion);
                    MyCollider.disableForEnemy(collider_);
                    lock_target_.disable();
                    phase_ = Phase.Dying;
                }
                if (lock_target_.isHitted())
                {
                    rigidbody_.addTorque(MyRandom.Range(-100f, 100f),
                                         MyRandom.Range(-100f, 100f),
                                         MyRandom.Range(-100f, 100f));
                    rigidbody_.addForceZ(-10000f);
                    lock_target_.clearLock();
                    Explosion.Instance.spawn(ref lock_target_.updated_position_, update_time);
                    Hahen.Instance.spawn(ref lock_target_.updated_position_, update_time);
                    SystemManager.Instance.registSound(DrawBuffer.SE.Explosion);
                    MyCollider.disableForEnemy(collider_);
                    lock_target_.disable();
                    phase_ = Phase.Dying;
                }

                rigidbody_.update(dt);
                MyCollider.updateEnemy(collider_, ref rigidbody_.transform_.position_);
                lock_target_.update();
            }
        }
Esempio n. 6
0
        public void update(float dt,
                           double update_time,
                           ref RigidbodyTransform grand_parent_rigidbody,
                           ref RigidbodyTransform parent_rigidbody,
                           ref RigidbodyTransform child_rigidbody,
                           bool head,
                           bool tail)
        {
#if false
            if (MyCollider.getHitOpponentForEnemy(collider_) != MyCollider.Type.None)
            {
                rigidbody_.addTorque(MyRandom.Range(-20f, 20f),
                                     MyRandom.Range(-20f, 20f),
                                     MyRandom.Range(-20f, 20f));
            }
            rigidbody_.addSpringTorque(ref parent_transform.rotation_, 10f /* torque_level */);
            rigidbody_.transform_.position_ = parent_transform.transformPosition(ref locator_);
            rigidbody_.update(dt);
#else
            if (head)
            {
                rigidbody_.updateVerlet(dt, 0.8f /* damper */);
            }
            else
            {
                rigidbody_.updateVerlet(dt, 0.8f /* damper */);
            }
            if (head)
            {
                var head_offset = new Vector3(0f, 0f, -3f);
                var pos         = parent_rigidbody.transform_.transformPosition(ref head_offset);
                rigidbody_.restrictPositionVerletFixed(ref pos, 0f /* length */);
            }
            else
            {
                rigidbody_.restrictPositionVerlet(ref grand_parent_rigidbody,
                                                  ref parent_rigidbody,
                                                  3f /* length */, 60f /* max_degree */);
            }
            if (!tail)
            {
                rigidbody_.solveRotationVerlet(ref parent_rigidbody, ref child_rigidbody);
            }
#endif
            MyCollider.updateEnemy(collider_, ref rigidbody_.transform_.position_);
            MyCollider.updateEnemyHoming(collider_homing_, ref rigidbody_.transform_.position_);

            if (-2f < rigidbody_.transform_.position_.y && rigidbody_.transform_.position_.y < 2f)
            {
                WaterSurface.Instance.makeBump(ref rigidbody_.transform_.position_, -0.025f /* value */, 1f /* size */);
                var wpos = rigidbody_.transform_.position_;
                wpos.y = -1.5f;
                var th  = MyRandom.Range(0f, Mathf.PI * 2f);
                var cos = Mathf.Cos(th);
                var sin = Mathf.Sin(th);
                wpos.x += cos * 1.25f;
                wpos.z += sin * 1.25f;
                var vel = new Vector3(cos * 0.8f,
                                      MyRandom.Range(5f, 8f),
                                      sin * 0.8f);
                WaterSplash.Instance.spawn(ref wpos, ref vel, update_time);
            }
            if (MyRandom.Probability(0.1f))
            {
                var pos = rigidbody_.transform_.position_;
                pos.x += MyRandom.Range(-1f, 1f);
                pos.z += MyRandom.Range(-1f, 1f);
                WaterSplash.Instance.spawn(ref pos,
                                           ref CV.Vector3Zero, update_time - 0.2f);
            }
        }