Exemple #1
0
    public void SetRightCannon(int id)
    {
        if (rightCannon != null)
        {
            ObjectsPool.PushObject(rightCannon.poolPath, rightCannon.gameObject);
        }
        string     poolPath = "Prefabs/Cannons/type_" + id.ToString() + "/right";
        GameObject cannon   = ObjectsPool.PullObject(poolPath);

        rightCannon               = cannon.GetComponent <Cannon> ();
        rightCannon.poolPath      = poolPath;
        cannon.transform.position = rightCannonTransform.position;

        string cannonKey = Cannon.rightBullet.ToString() + "_" + id.ToString();

        LevelController.instance.currentRightButtonKey = cannonKey;
        if (LevelController.instance.cannonButtonsStatus.ContainsKey(cannonKey))
        {
            LevelController.instance.cannonButtonsStatus [cannonKey] = true;
        }
        else
        {
            LevelController.instance.cannonButtonsStatus.Add(cannonKey, true);
        }
    }
 public void BulletTrigger(ExplodeObject expObj)
 {
     if (Cannon.CheckSuitability(expObj.objectType, bullet.bulletType))
     {
         expObj.MakeDamage(GetValueByState(bullet.damageHealthParams.damage, currentState));
         currentState += 1;
         if (currentState == 3)
         {
             ObjectsPool.PushObject(bullet.poolPath, bullet.gameObject);
         }
         else
         {
             triangle1Transform.localScale = new Vector3(
                 GetValueByState(triangle1Transform.localScale.x, currentState),
                 GetValueByState(triangle1Transform.localScale.y, currentState),
                 GetValueByState(triangle1Transform.localScale.z, currentState)
                 );
             triangle2Transform.localScale = new Vector3(
                 GetValueByState(triangle2Transform.localScale.x, currentState),
                 GetValueByState(triangle2Transform.localScale.y, currentState),
                 GetValueByState(triangle2Transform.localScale.z, currentState)
                 );
         }
     }
 }
Exemple #3
0
    public void SetInactive()
    {
        LevelController.instance.levelActive = false;
        isDead = true;
        ShipSpawner.instance.StopSpawn();

        /*foreach (ExplodeObject obj in ShipsController.instance.explodeObjects) {
         *      obj.DefaultDestroy ();
         * }*/
        Dictionary <int, ExplodeObject> expObjDict = new Dictionary <int, ExplodeObject> ();

        for (int i = 0; i < ShipsController.instance.explodeObjects.Count; i++)
        {
            expObjDict.Add(i, ShipsController.instance.explodeObjects[i]);
        }
        for (int i = 0; i < expObjDict.Count; i++)
        {
            expObjDict [i].DefaultDestroy();
        }
        //ShipsController.instance.explodeObjects.Clear ();

        List <Bullet> bulletObjects = new List <Bullet> (FindObjectsOfType <Bullet> ());

        foreach (Bullet bullObj in bulletObjects)
        {
            ObjectsPool.PushObject(bullObj.poolPath, bullObj.gameObject);
        }
        AudioController.instance.currentSong.Stop();
        //Advertising.TryShowInterstitial ();
    }
Exemple #4
0
    public void DefaultEndAction()
    {
        if (LevelController.instance.levelActive)
        {
            LevelController.instance.levelActive = false;
            ShipSpawner.instance.StopSpawn();
            Interface.interfaceSt.OpenWinWindow();
            Dictionary <int, ExplodeObject> expObjDict = new Dictionary <int, ExplodeObject> ();
            for (int i = 0; i < ShipsController.instance.explodeObjects.Count; i++)
            {
                expObjDict.Add(i, ShipsController.instance.explodeObjects[i]);
            }
            for (int i = 0; i < expObjDict.Count; i++)
            {
                expObjDict [i].DefaultDestroy();
            }


            List <Bullet> bulletObjects = new List <Bullet> (FindObjectsOfType <Bullet> ());
            foreach (Bullet bullObj in bulletObjects)
            {
                ObjectsPool.PushObject(bullObj.poolPath, bullObj.gameObject);
            }

            AudioController.instance.currentSong.Stop();
            //Advertising.TryShowInterstitial ();
        }
    }
Exemple #5
0
    void Update()
    {
        if (frameRate == 150)
        {
            frameRate = 0;
            if (!RectTransformUtility.RectangleContainsScreenPoint(
                    Interface.interfaceSt.screenArea,
                    Camera.main.WorldToScreenPoint(new Vector2(objectTransform.position.x, objectTransform.position.y)))
                )
            {
                //Timer destroyTimer = new Timer ();
                //destroyTimer.SetTimer (5f);

                //StartCoroutine (destroyTimer.ActionAfterTimer (() => {
                //	Debug.Log("aziz");
                ObjectsPool.PushObject(poolPath, this.gameObject);

                //}));
            }
        }
        else
        {
            frameRate += 1;
        }


        objectTransform.Translate(speed * Time.timeScale);
    }
Exemple #6
0
 public void DefaultDestroyWithPoints()
 {
     isActive = false;
     LevelController.instance.currentPoints += damageHealthParam.points;
     BattleInterface.instance.AddPointToStack(damageHealthParam.points);
     ObjectsPool.PushObject(poolPath, this.gameObject);
     RemoveFromExpObjList();
 }
Exemple #7
0
    public void BulletMineTrigger(ExplodeObject expObj)
    {
        if (Cannon.CheckSuitability(expObj.objectType, bullet.bulletType))
        {
            if (!explodeTimerActive)
            {
                explodeTimer.SetTimer(explodeTime);
                explodeTimerActive = true;
                StartCoroutine(explodeTimer.ActionAfterTimer(() => {
                    foreach (ExplodeObject obj in bullet.triggeredExplodeObject)
                    {
                        if (obj.gameObject.activeInHierarchy)
                        {
                            if (Cannon.CheckSuitability(obj.objectType, bullet.bulletType))
                            {
                                obj.MakeDamage(bullet.damageHealthParams.damage);
                            }
                        }
                    }

                    string effectPath = "";
                    if (isShutterMine)
                    {
                        effectPath = "Prefabs/Effects/bullet2ExplodeShatter";
                    }
                    else
                    {
                        effectPath = "Prefabs/Effects/bullet2Explode";
                    }
                    Vector3 bulletPosition       = bullet.transform.position;
                    GameObject effectObj         = ObjectsPool.PullObject(effectPath);
                    effectObj.transform.position = bulletPosition;
                    Effect effect   = effectObj.GetComponent <Effect> ();
                    effect.poolPath = effectPath;
                    effect.main.Play();
                    effect.DestoyOverTime(effect.main.main.duration);

                    if (isShutterMine)
                    {
                        string shatterPath = "Prefabs/Bullets/bullet2ShatterPart";
                        for (int i = 0; i < shattersCount; i++)
                        {
                            GameObject shatter = ObjectsPool.PullObject(shatterPath);
                            //Debug.Log(bullet.transform.position);
                            shatter.transform.position = bulletPosition;
                            Bullet sbullet             = shatter.GetComponent <Bullet> ();
                            sbullet.poolPath           = shatterPath;
                            sbullet.BulletAwake();
                            sbullet.bulletType = bullet.bulletType;
                        }
                    }

                    ObjectsPool.PushObject(bullet.poolPath, this.gameObject);
                }));
            }
        }
    }
Exemple #8
0
    public void DestoyOverTime(float time)
    {
        Timer lifeTimer = new Timer();

        lifeTimer.SetTimer(time);
        StartCoroutine(lifeTimer.ActionAfterTimer(() => {
            ObjectsPool.PushObject(poolPath, this.gameObject);
        }));
    }
Exemple #9
0
    public void StartEffect()
    {
        effect.Play();
        Timer effectTimer = new Timer();

        effectTimer.SetTimer(effect.clip.length);
        StartCoroutine(effectTimer.ActionAfterTimer(() => {
            effect.Stop();
            ObjectsPool.PushObject(poolPath, this.gameObject);
        }));
    }
Exemple #10
0
 public void DefaultBulletTrigger(ExplodeObject expObject)
 {
     if (Cannon.CheckSuitability(expObject.objectType, bulletType))
     {
         expObject.MakeDamage(damageHealthParams.damage);
     }
     foreach (ParticleSystem effect in effects)
     {
         effect.Stop();
     }
     ObjectsPool.PushObject(poolPath, this.gameObject);
 }
Exemple #11
0
 void OverscreenChecker()
 {
     if (withOverscreenChecker && startOverscreenCheckerTimer.TimeIsOver() && overscreenCheckerEnable)
     {
         if (frame == 60)
         {
             if (!RectTransformUtility.RectangleContainsScreenPoint(Interface.interfaceSt.screenArea,
                                                                    Camera.main.WorldToScreenPoint(gameObject.transform.position)))
             {
                 ObjectsPool.PushObject(poolPath, gameObject);
             }
             frame = 0;
         }
         else
         {
             frame += 1;
         }
     }
 }
Exemple #12
0
    void SetDead()
    {
        if (LevelController.instance.levelActive)
        {
            LevelController.instance.levelActive = false;
            isDead = true;
            ShipSpawner.instance.StopSpawn();
            Timer explodeTimer = new Timer();
            loseExplode.gameObject.SetActive(true);
            loseExplode.Play();
            AudioController.instance.loseExplode.Play();
            explodeTimer.SetTimer(loseExplode.main.duration);
            StartCoroutine(explodeTimer.ActionAfterTimer(() => {
                loseExplode.gameObject.SetActive(false);
                Interface.interfaceSt.OpenLoseWindow();

                /*foreach (ExplodeObject obj in ShipsController.instance.explodeObjects) {
                 *      obj.DefaultDestroy ();
                 * }
                 * ShipsController.instance.explodeObjects.Clear ();*/
                Dictionary <int, ExplodeObject> expObjDict = new Dictionary <int, ExplodeObject> ();
                for (int i = 0; i < ShipsController.instance.explodeObjects.Count; i++)
                {
                    expObjDict.Add(i, ShipsController.instance.explodeObjects[i]);
                }
                for (int i = 0; i < expObjDict.Count; i++)
                {
                    expObjDict [i].DefaultDestroy();
                }

                List <Bullet> bulletObjects = new List <Bullet> (FindObjectsOfType <Bullet> ());
                foreach (Bullet bullObj in bulletObjects)
                {
                    ObjectsPool.PushObject(bullObj.poolPath, bullObj.gameObject);
                }
                AudioController.instance.currentSong.Stop();
                //Advertising.TryShowInterstitial ();
            }));
        }
    }
Exemple #13
0
 public void DefaultDestroy()
 {
     isActive = false;
     ObjectsPool.PushObject(poolPath, this.gameObject);
     RemoveFromExpObjList();
 }