Пример #1
0
 // Start is called before the first frame update
 void Start()
 {
     animator        = GetComponent <Animator>();
     photonGM        = GameObject.Find("PhotonGM").GetComponent <photonGmaeManager>();
     playerName.text = photonView.Owner.NickName;
     if (photonView.IsMine)
     {
         cameraFlow        = GameObject.Find("Main Camera").GetComponent <CameraFlow>();
         cameraFlow.target = gameObject;
         if (photonGM.isSubuerver)
         {
             thisplayer.tag = "Subuerver";
         }
         else
         {
             if (photonGM.anemyTag == "A")
             {
                 thisplayer.tag = "A";
             }
             if (photonGM.anemyTag == "B")
             {
                 thisplayer.tag = "B";
             }
         }
     }
     agent       = this.GetComponent <NavMeshAgent>();
     PlayerKinds = playerKinds.stop;
     StartCoroutine(this.State());
 }
Пример #2
0
 protected override void checkLifeTime()
 {
     lifeTime += Time.fixedDeltaTime;
     if (lifeTime > 25 && !CameraFlow.inScreenView(transform.position, 0.1f))
     {
         dumpObject();
     }
     //null
 }
Пример #3
0
    void Start()
    {
        //获取存储数据.
        gemcount = PlayerPrefs.GetInt("gem", 0);

        m_Transform  = gameObject.GetComponent <Transform> ();
        m_position   = m_Transform.position;
        m_MapManager = GameObject.Find("MapManager").GetComponent <MapManager> ();
        m_UIMaganer  = GameObject.Find("UI Root").GetComponent <UIManager> ();
        m_CameraFlow = GameObject.Find("Main Camera").GetComponent <CameraFlow> ();
    }
Пример #4
0
    IEnumerator shift()
    {
        while (true)
        {
            yield return(new WaitForSeconds(.25f));

            float m = transform.position.y + bounds * .5f - CameraFlow.getScreenMinBorderY();
            if (m < 0)
            {
                transform.position += Vector3.up * bounds * 2f;
            }
        }
    }
Пример #5
0
    IEnumerator CheckDestroy()
    {
        int sc = 0;

        cycles = (int)(Random.value * 20f) + 10;
        if (isBoss)
        {
            cycles += 20;
        }
        while (Vector2.Distance(transform.position, CameraFlow.position) < 100)
        {
            if (transform.position.y < CameraFlow.getScreenMinBorderY())
            {
                break;
            }
            sc++;
            if (sc > 7)
            {
                speed *= 0.75f;
                sc     = 0;
            }

            if (Random.value < repositionChance)
            {
                if (Random.value > 0.92)
                {
                    behaviorType = 0;
                    Range        = Random.Range(6f, 12f);
                    AdRange      = Range * .05f + 1f;
                    shootRange   = Random.Range(Range * 1.5f, Range * 2.5f);
                    fleeRange    = Range * 0.5f * Random.value;
                }
                stayPos = CameraFlow.randomScreenPos();
            }

            if (healthPercent < 0.9f)
            {
                cycles--;
                if (cycles < 0 && Random.value > 0.6)
                {
                    speed       += 3;
                    stayPos      = Vector2.down * 100 + Vector2.right * (Random.value - 0.5f) * 200;
                    behaviorType = 1;
                    Range        = 1;
                }
            }

            yield return(new WaitForSeconds(1f));
        }
        destroySelf();
    }
Пример #6
0
    IEnumerator spawnLoop()
    {
        while (true)
        {
            yield return(new WaitForSeconds(spawnRate));

            float c = ((avgMeteors - meteorHolder.live) * chance);
            if (c < chance)
            {
                c = chance;
            }
            liveM = meteorHolder.live;
            if (Random.value < c)
            {
                Missle  meteor     = MissleSpawner.instance.getReusable(prefab);
                Vector2 spawnPoint = CameraFlow.outSideScreen(MathHelper.DegreeToVector2(Random.value * 360));
                meteor.transform.position = spawnPoint;
                meteor.calculateProperties();
            }
        }
    }
Пример #7
0
    protected virtual void onDestroy()
    {
        if (destroyed)
        {
            return;
        }

        foreach (UnitLife unit in collidedUnits)
        {
            unit.ApplyDamage(damage);
        }
        if (!CameraFlow.inScreenView(transform.position, 0.01f))
        {
            return;
        }
        Transform exp = ParticleSpawner.instance.getReusable(exploshion).transform;

        exp.position = transform.position + Vector3.one * Random.Range(0, 0.1f);
        destroyed    = true;
        //dumpObject();
    }
Пример #8
0
 protected virtual bool dumpCondition()
 {
     return(CameraFlow.inScreenView(transform.position, 0.20f));
 }
Пример #9
0
    void Start()
    {
        Enemies++;
        life       = GetComponent <UnitLife>();
        target     = PlayerController.player;
        fireSystem = GetComponent <FireSystem>();

        float maxPowerLevel = RandomEnemies.maxDifficulty;
        float powerLevel    = maxPowerLevel;

        if (Random.value < RandomEnemies.BossChance)
        {
            powerLevel *= 10f;
            RandomEnemies.BossChance = 0;
            isBoss = true;
            //AudioManager.playOnce(AudioManager.instance.bossIsCommingClip);
            AudioManager.playRepeatedEffect(AudioManager.instance.bossIsCommingClip, 6, 2, 1);
        }
        else
        {
            powerLevel = maxPowerLevel * (Random.value + 2) * 0.05f;
            float reducePower = maxPowerLevel * (Random.value + 2) * 0.05f;
            if (powerLevel > reducePower)
            {
                powerLevel = reducePower;
            }
        }

        repositionChance = Random.value * 0.1f;

        camRatio            = Random.value * 0.5f;
        fireSystem.camRatio = camRatio;

        difficulty = fireSystem.RandomValues(powerLevel);

        float vv = (difficulty / RandomEnemies.maxDifficulty);
        float Rv = 0.75f + .15f * vv;

        life.life = (difficulty * 2) + 35;
        life.life = Mathf.Clamp(life.life, RandomEnemies.maxDifficulty + 35, RandomEnemies.maxDifficulty * 20);
        maxLife   = life.life;

        float scale = Rv < 2.5f ? Rv : 2.5f;

        transform.localScale = scale * Vector3.one;

        goldDrop = difficulty * 3 + 5;
        if (goldDrop > RandomEnemies.maxDifficulty * 10)
        {
            goldDrop *= 0.25f + Random.value * 0.75f;
        }

        rotationSpeed = 2;
        behaviorType  = 1;
        Range         = 0;
        fleeRange     = 0;



        speed = Random.value * 4f + 1;

        if (vv < 1 || Random.value > 0.85)
        {
            if (Random.value > 0.7)
            {
                behaviorType = 0;
                Range        = Random.Range(6f, 12f);
                AdRange      = Range * .05f + 1f;
                shootRange   = Random.Range(Range * 1.5f, Range * 2.5f);
                fleeRange    = Range * 0.5f * Random.value;
            }
            else
            {
                suicider = Random.value > vv * 4f ? true : false;
                if (suicider)
                {
                    if (Random.value > .5f)
                    {
                        difficulty *= .5f;

                        Range = 0;
                        speed = 3.25f / Rv;
                        speed = Mathf.Clamp(speed, 2.5f, 5f);

                        StartCoroutine(DestroySelf(7.5f));

                        rotationSpeed = 6f;
                        life.life    *= 0.75f;
                        camRatio      = 0;
                    }
                }
            }
        }

        StartCoroutine(damageColliding());

        stayPos = CameraFlow.randomScreenPos();
        RandomEnemies.liveDifficulty += difficulty;

        StartCoroutine(CheckDestroy());

        life.onGetHitCallback += onGethit;
    }