コード例 #1
0
ファイル: Enemy.cs プロジェクト: tianzhilanat2010/Rex-Game
        protected override void OnDeath()
        {
            DropSpawner dropSpawner = GetComponent <DropSpawner>();

            if (dropSpawner != null)
            {
                dropSpawner.DropObject();
            }
        }
コード例 #2
0
    public void Kill()
    {
        DropSpawner[] spawners   = FindObjectsOfType <DropSpawner>();
        DropSpawner   minSpawner = null;
        float         minDist    = 0;

        foreach (DropSpawner spawner in spawners)
        {
            float dist = (spawner.transform.position - transform.position).magnitude;
            if (minSpawner == null || minDist > dist)
            {
                minSpawner = spawner;
                minDist    = dist;
            }
        }

        if (minSpawner != null)
        {
            minSpawner.spawn();
        }
        isDying       = true;
        dyingTime     = 0f;
        RB2D.velocity = new Vector2(0, 0);
        animator.SetTrigger("ascend");

        Vector3 camTop = Camera.main.ViewportToWorldPoint(new Vector2(1, 1));

        targetAscendPosition = new Vector3(transform.position.x, camTop.y, transform.position.z);

        startAscendPosition = transform.position;

        RB2D.simulated = false;

        AudioSource audioSource = GetComponent <AudioSource>();

        if (audioSource == null)
        {
            audioSource = this.gameObject.AddComponent <AudioSource>();
        }

        AudioManager.instance.PlayAudio(audioSource, SFX.Ascend);
    }
コード例 #3
0
        protected override void OnDeath()
        {
            DropSpawner dropSpawner = GetComponent <DropSpawner>();

            if (dropSpawner != null)
            {
                GameObject drop      = dropSpawner.DropObject();
                RexObject  rexObject = drop.GetComponent <RexObject>();
                if (rexObject != null)
                {
                    float yPosition = transform.position.y;
                    if (slots.collider != null)
                    {
                        yPosition = slots.collider.bounds.max.y;
                        if (rexObject.slots.collider)
                        {
                            yPosition = slots.collider.bounds.max.y + rexObject.slots.collider.bounds.size.y * 0.5f;
                        }
                    }

                    rexObject.SetPosition(new Vector2(transform.position.x, yPosition));
                }
            }
        }
コード例 #4
0
 public void InjectDropSpawner(DropSpawner injectedDropSpawner)
 {
     dropSpawner = injectedDropSpawner;
 }
コード例 #5
0
 void Start()
 {
     Instance = this;
 }