Example #1
0
        private void MakeAttack(Transform tf, float h, float r, float d, bool muti = false)
        {
            RaycastHit[] hits = Physics.BoxCastAll(
                tf.position + Vector3.up * h * 0.5f,
                new Vector3(r, h, r),
                -tf.forward,
                Quaternion.identity,
                WeaponInfo.AttackRange
                );

            List <CharacterBehaviour> chList = new List <CharacterBehaviour>();

            for (int i = 0; i < hits.Length; i++)
            {
                EnemyBehaviour en = hits[i].transform.GetComponent <EnemyBehaviour>();

                if (en && !chList.Contains(en) && (chList.Count == 0 || muti))
                {
                    en.Hurt(d, tf);
                    chList.Add(en);
                }

                Rigidbody rig = hits[i].transform.GetComponent <Rigidbody>();
                if (rig)
                {
                    rig.AddExplosionForce(250f, tf.position, 2.5f);
                }
            }

            chList = null;

            DemoStage.PlaySound((int)Random.Range(8f, 10.99f), 0.25f);
        }
Example #2
0
		void Awake () {
			Main = this;
			SpawnRange = new Vector2(MainGround.localScale.x * 0.45f, MainGround.localScale.z * 0.45f);
			LightColor = MainLight.color;
			Audio = GetComponent<AudioSource>();
			GameOverUI.gameObject.SetActive(true);
		}
Example #3
0
        public void BossHurt(float damage, Transform tf)
        {
            transform.localScale = Vector3.one * 2f;

            Vector3 pos = (transform.position - tf.position).normalized * 0.2f;

            transform.Translate(pos.x + Random.Range(-0.1f, 0.1f), 0f, pos.z + Random.Range(-0.1f, 0.1f));

            if (DemoStage.Main.bossDamageImmune)
            {
                damage = 0;
                // DemoStage.Main.life--;
            }

            HP -= damage;
            if (HP <= 0)
            {
                Die(tf);
            }

            // -xx
            GameObject o = new GameObject("-x");

            o.transform.position = transform.position + Vector3.up * Mathf.Lerp(4f, 2f, HP / MaxHP);
            o.transform.rotation = Camera.main.transform.rotation;
            TextMesh tm = o.AddComponent <TextMesh>();

            tm.text          = damage.ToString("00");
            tm.characterSize = 0.3f;
            tm.color         = new Color(0.9f, 0.3f, 0.3f, 1f);
            Destroy(o, 1f);

            if (!DemoStage.Main.bossDamageImmune)
            {
                int len = Random.Range(6, 14);
                for (int i = 0; i < len; i++)
                {
                    Blood(tf, BloodCube);
                    if (i < len * 0.3f)
                    {
                        Blood(tf, RedBloodCube);
                    }
                }
            }

            LastHurtTime = Time.time;

            //SFX
            if (DemoStage.Main.bossDamageImmune)
            {
                DemoStage.PlaySound(8);
            }
            else
            {
                DemoStage.PlaySound((int)Random.Range(2f, 6.99f));
            }
        }
Example #4
0
        public void Die(Transform tf)
        {
            if (!Alive)
            {
                return;
            }

            Alive = false;
            Destroy(gameObject);

            if (DemoStage.Playing)
            {
                GameObject o = Instantiate <GameObject>(RagDoll.gameObject);
                o.transform.position = transform.position;
                o.transform.rotation = transform.rotation;
                o.transform.Rotate(new Vector3(Random.Range(-20f, 20f), Random.Range(0f, 40f), Random.Range(-20f, 20f)));

                Rigidbody rig = o.GetComponent <Rigidbody>();
                if (rig)
                {
                    rig.AddExplosionForce(10000f, tf.position, 100f);
                }

                Collider[] cs = o.GetComponentsInChildren <Collider>(true);

                for (int i = 0; i < cs.Length; i++)
                {
                    Destroy(cs[i], 5f);
                }

                Destroy(o, 10f);

                int len = Random.Range(28, 40);
                for (int i = 0; i < len; i++)
                {
                    Blood(tf, BloodCube);
                    if (i < len * 0.6f)
                    {
                        Blood(tf, RedBloodCube);
                    }
                }
                DemoStage.CurrentEnemyNum--;
                DemoStage.Main.FreshBar();
                DemoStage.AddKillNum();
                CameraBehaviour.CameraShake();
                DemoStage.PlaySound(1);
                DemoStage.Main.Invoke("PlayDieoutSound", 0.6f);
            }
        }
Example #5
0
        public void Die(Transform tf)
        {
            if (!Alive)
            {
                return;
            }

            Alive = false;
            Destroy(gameObject);

            if (DemoStage.Playing)
            {
                GameObject o = Instantiate <GameObject>(RagDoll.gameObject);
                o.transform.position = transform.position;
                o.transform.rotation = transform.rotation;
                o.transform.Rotate(new Vector3(Random.Range(-20f, 20f), Random.Range(0f, 40f), Random.Range(-20f, 20f)));

                Rigidbody rig = o.GetComponent <Rigidbody>();
                if (rig)
                {
                    rig.AddExplosionForce(10000f, tf.position, 100f);
                }

                Collider[] cs = o.GetComponentsInChildren <Collider>(true);

                for (int i = 0; i < cs.Length; i++)
                {
                    Destroy(cs[i], 5f);
                }

                Destroy(o, 10f);

                int len = Random.Range(28, 40);
                for (int i = 0; i < len; i++)
                {
                    Blood(tf, BloodCube);
                    if (i < len * 0.6f)
                    {
                        Blood(tf, RedBloodCube);
                    }
                }
                if (DemoStage.Main.bossPlaying && !isBoss)
                {
                    if (DemoStage.Main.IsCorrect(sign))
                    {
                        DemoStage.Main.bossDamageImmune = false;
                    }
                }

//			DemoStage.Main.FreshBar2();

                CameraBehaviour.CameraShake();
                DemoStage.PlaySound(1);
                DemoStage.Main.Invoke("PlayDieoutSound", 0.6f);

                if (isBoss)
                {
                    DemoStage.numOfBoss--;
                }
                else
                {
                    if (DemoStage.Main.IsCorrect(sign))
                    {
                        DemoStage.Main.NextStage();
                    }
                    else
                    {
                        DemoStage.Main.UpdateMsg("Wrong! \n You're Damaged!!");
                        DemoStage.Main.Damage();
                    }
                }

                Destroy(EnemySign.gameObject);
            }
        }