Beispiel #1
0
        public void ResetGame()
        {
            // Reset
            while (PlanetManager.GetInstance().planets.Count > 0)
            {
                GameObject planet = PlanetManager.GetInstance().planets[0];
                PlanetManager.GetInstance().HidePlanet(planet);
            }

            while (ItemManager.GetInstance().meteorolites.Count > 0)
            {
                GameObject meteorolite = ItemManager.GetInstance().meteorolites[0];
                ItemManager.GetInstance().HideMeteorolite(meteorolite);
            }

            while (EnemyManager.GetInstance().enemys.Count > 0)
            {
                GameObject enemy = EnemyManager.GetInstance().enemys[0];
                EnemyManager.GetInstance().HideEnemy(enemy);
            }

            GetEarthEntity().Reset();
            UIManager.GetInstance().Show("Page_GameHUD");
            InitScene();
        }
Beispiel #2
0
 private void OnDestroy()
 {
     // 销毁
     EventManager.GetInstance().Final();
     UIManager.GetInstance().Final();
     SceneManager.GetInstance().Final();
     PlanetManager.GetInstance().Final();
     ControlManager.GetInstance().Final();
     EnemyManager.GetInstance().Final();
     EffectManager.GetInstance().Final();
     AudioManager.GetInstance().Final();
     ItemManager.GetInstance().Final();
 }
Beispiel #3
0
        void Start()
        {
            // Init Manager
            EventManager.GetInstance().Init();
            UIManager.GetInstance().Init();
            SceneManager.GetInstance().Init();
            PlanetManager.GetInstance().Init();
            ControlManager.GetInstance().Init();
            EnemyManager.GetInstance().Init();
            EffectManager.GetInstance().Init();
            AudioManager.GetInstance().Init();
            ItemManager.GetInstance().Init();

            UIManager.GetInstance().Show("Page_MainMenu");
        }
Beispiel #4
0
        public void SetPlanets()
        {
            List <GameObject> releasePlanets = new List <GameObject>();

            for (int i = 0; i < PlanetManager.GetInstance().planets.Count; ++i)
            {
                GameObject planet = PlanetManager.GetInstance().planets[i];
                if (Math.Abs(GetEarthEntity().GetPosition().y - planet.transform.position.y) > 50)
                {
                    releasePlanets.Add(planet);
                }
            }

            for (int i = 0; i < releasePlanets.Count; ++i)
            {
                PlanetManager.GetInstance().HidePlanet(releasePlanets[i]);
            }

            curVelocity = GetEarthVelocity();

            int L = 0;
            int R = 2;

            if (prePlanetPos.x - GetEarthEntity().GetPosition().x > 0)
            {
                L -= 2;
            }
            else
            {
                R += 2;
            }
            int   flag = UnityEngine.Random.Range(L, R);
            float posX = UnityEngine.Random.Range(MinPawnX, MaxPawnX);

            posX = flag < 1 ? -posX : posX;
            float posY = UnityEngine.Random.Range(MinPawnY, MaxPawnY);

            Vector2 posOffset = new Vector2(posX, posY);
            Vector2 planetPos = GetEarthEntity().GetPosition() + posOffset;

            if (planetPos.y - prePlanetPos.y < 5)
            {
                return;
            }
            PlanetManager.GetInstance().ShowPlanet(planetPos);
            prePlanetPos = planetPos;
        }
Beispiel #5
0
        void Update()
        {
            if (Input.GetKeyDown(KeyCode.Space))
            {
                OnApplySheil();
            }

            for (int n = 0; n < 3; n++)
            {
                if (ForceState[n].bAdd)
                {
                    CurEnergy = Mathf.Max(0, CurEnergy - DeltaEnergy);
                    ForceState[n].FireObj.localScale = Vector3.Lerp(ForceState[n].FireObj.localScale,
                                                                    new Vector3(FireScale, FireScale, FireScale), Time.deltaTime);

                    if (CurEnergy <= 0)
                    {
                        ForceState[n].TargetForce        = 0;
                        ForceState[n].FireObj.localScale = Vector3.Lerp(ForceState[n].FireObj.localScale,
                                                                        Vector3.one, Time.deltaTime);
                    }
                }
                ForceState[n].FireObj.localScale = Vector3.Lerp(ForceState[n].FireObj.localScale,
                                                                ForceState[n].TargetForce > 0 ?
                                                                new Vector3(FireScale, FireScale, FireScale) :
                                                                Vector3.one, Time.deltaTime);
                ForceState[n].CurForce = Mathf.Lerp(ForceState[n].CurForce, ForceState[n].TargetForce, Time.deltaTime);
                if (ForceState[n].TargetForce <= 0)
                {
                    Vector2 v = thisRb2D.velocity;
                    v.Normalize();
                    thisRb2D.velocity = Vector2.Lerp(thisRb2D.velocity, v * BaseSpeed, Time.deltaTime);
                }
            }

            if (ForceState[1].bAdd)
            {
                Vector2 sideDir = Utility.Vector2Rotate(transform.up, SideDirectionRadius);
                sideDir.Normalize();
                thisRb2D.AddForce(sideDir * ForceState[1].CurForce);
            }
            else if (ForceState[2].bAdd)
            {
                Vector2 psideDir = Utility.Vector2Rotate(transform.up, -SideDirectionRadius);
                psideDir.Normalize();
                thisRb2D.AddForce(psideDir * ForceState[2].CurForce);
            }
            else if (ForceState[0].bAdd)
            {
                thisRb2D.AddForce(new Vector2(this.transform.up.x, this.transform.up.y) * ForceState[0].CurForce);
            }
            else
            {
                CurEnergy = Mathf.Lerp(CurEnergy, MaxEnergy, Time.deltaTime * DeltaEnergy);
            }

            //获取引力
            if (bWithSheil)
            {
                CurSheilTime -= Time.deltaTime;
                if (CurSheilTime <= 0)
                {
                    CurSheilTime = 0;
                    bWithSheil   = false;
                    SheilObj.SetActive(false);
                }
            }
            else
            {
                Vector2 force = PlanetManager.GetInstance().GetPlanetsForce(transform.position, thisRb2D.mass);
                thisRb2D.AddForce(force);

                CurSheilCoolTime = Mathf.Min(CurSheilCoolTime + Time.deltaTime, SheilCoolDownTime);
            }


            Vector2 vec = thisRb2D.velocity;

            vec.Normalize();
            vec *= MaxSpeed;
            if (thisRb2D.velocity.magnitude > MaxSpeed)
            {
                thisRb2D.velocity = vec;
            }
        }
Beispiel #6
0
 void Start()
 {
     PlanetManager.GetInstance().ShowPlanet(GetPosition() + new Vector2(100, 300));
     SheilObj = transform.Find("Sheil").gameObject;
     Reset();
 }