Exemplo n.º 1
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_);
        }
Exemplo n.º 2
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_);
                }
            }
        }
Exemplo n.º 3
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);
            }
        }