コード例 #1
0
    // Update is called once per frame
    void Update()
    {
        if (isGameOver)
        {
            return;
        }

        for (int i = 0; i < transform.childCount; i++)
        {
            Transform child = transform.GetChild(i);
            if (child.childCount == 0)
            {
                Destroy(child.gameObject);
            }
        }

//        if (GameConstants.LEVEL_TO_LOAD != 0)
//        {
//            if (cameraYPos - 4*0.75 > Camera.main.transform.position.y)
//            {
//                Transform box = BoxPattern.getInstance().getRandomBoxPattern();
//                Transform boxObj = Instantiate(box, new Vector3(0, lastBoxPosition.y - 3f, 0), Quaternion.identity) as Transform;
//                boxObj.parent = transform;
//                boxObj.localPosition = new Vector3(0, lastBoxPosition.y - 3f, 0);
//                lastBoxPosition = boxObj.localPosition;
//                groundBox.localPosition = new Vector3(0, lastBoxPosition.y - 3f, 0);
//                addStarGameObject();
//                cameraYPos = Camera.main.transform.position.y;
//            }
//            return;
//        }

        //add new box below
//        if (transform.childCount <= 3)
//        {
//            Transform box = BoxPattern.getInstance().getRandomBoxPattern();
//            Transform boxObj = Instantiate(box, new Vector3(0, lastBoxPosition.y - 3f, 0), Quaternion.identity) as Transform;
//            boxObj.parent = transform;
//            boxObj.localPosition = new Vector3(0, lastBoxPosition.y - 3f, 0);
//            lastBoxPosition = boxObj.localPosition;
//            groundBox.localPosition = new Vector3(0, lastBoxPosition.y - 3f, 0);
//            addStarGameObject();
//        }

        if (cameraYPos - 4 * 0.75 > Camera.main.transform.position.y)// || transform.childCount <= 4)
        {
            if (GameConstants.LEVEL_TO_LOAD != 0 && boxCount <= levelData.boxList.Count)
            {
                Transform box = BoxPattern.getInstance().getBoxPatternNumber(boxCount);
                addNewBoxAtBottom(box);
                boxCount++;
            }
            else if (GameConstants.LEVEL_TO_LOAD == 0)
            {
                Transform box = BoxPattern.getInstance().getRandomBoxPattern();
                addNewBoxAtBottom(box);
                addStarGameObject(10);
            }
        }
    }
コード例 #2
0
    void initInfiniteGamePlay()
    {
        scorePanel.SetActive(true);
        levelStarsPanel.SetActive(false);

        for (int i = 0; i < 4; i++)
        {
            groundBox.localPosition = new Vector3(0, -3 * (i + 1), 0);

            Transform box    = BoxPattern.getInstance().getRandomBoxPattern();
            Transform boxObj = Instantiate(box, new Vector3(0, -3 * i, 0), Quaternion.identity) as Transform;
            boxObj.parent        = transform;
            boxObj.localPosition = new Vector3(0, -3 * i, 0);
            lastBoxPosition      = boxObj.localPosition;
        }
        addStarGameObject(10);
        updateScores(0, null);

        if (numOfStars >= 30)
        {
            popButtonGameObject.GetComponent <Image>().sprite = Resources.Load("PopStar", typeof(Sprite)) as Sprite;
            popButtonGameObject.SetActive(true);
        }
        else if (AdHandler.GetInstance().IsVideoAdAvailable())
        {
            popButtonGameObject.GetComponent <Image>().sprite = Resources.Load("PopVideo", typeof(Sprite)) as Sprite;
            popButtonGameObject.SetActive(true);
        }
        else
        {
            popButtonGameObject.SetActive(false);
        }
    }
コード例 #3
0
ファイル: BoxPattern.cs プロジェクト: umardev0/Six
    public static BoxPattern getInstance()
    {
        if (m_instance == null)
        {
            m_instance = GameObject.FindObjectOfType <BoxPattern>();
            DontDestroyOnLoad(m_instance.gameObject);
        }

        return(m_instance);
    }
コード例 #4
0
ファイル: BoxPattern.cs プロジェクト: umardev0/Six
 void Awake()
 {
     if (m_instance == null)
     {
         m_instance = this;
         DontDestroyOnLoad(this);
     }
     else
     {
         m_instance.count = 0;
         Destroy(gameObject);
     }
 }
コード例 #5
0
    void initLevel(int levelNum)
    {
        scorePanel.SetActive(false);
        levelStarsPanel.SetActive(true);
        levelData = LevelsReader.getInstance().getDataForLevel(levelNum);
        int boxListSize         = levelData.boxList.Count;
        int numberOfBoxesToDraw = 0;

        numberOfBoxesToDraw = boxListSize > 4 ? 4 : boxListSize;

        for (int i = 0; i < numberOfBoxesToDraw; i++)
        {
            groundBox.localPosition = new Vector3(0, -3 * (i + 1), 0);

            Transform box    = BoxPattern.getInstance().getBoxPatternNumber(levelData.boxList[i]);
            Transform boxObj = Instantiate(box, new Vector3(0, -3 * i, 0), Quaternion.identity) as Transform;
            boxObj.parent        = transform;
            boxObj.localPosition = new Vector3(0, -3 * i, 0);
            lastBoxPosition      = boxObj.localPosition;
            boxCount++;
        }
        starCount = levelData.stars;
        nextStart = 1;
        int nextStarBlocks = 0;

        for (int j = 0; j < levelData.starsList.Count; j++)
        {
            nextStarBlocks += levelData.starsList[j];
            if (j < levelData.stars)
            {
                continue;
            }
            addStarGameObject(nextStarBlocks * 4);
            nextStart = 1;
        }

        for (int j = 0; j < levelData.stars; j++)
        {
            Image starImg = levelStarsPanel.transform.GetChild(j).GetComponent <Image>();
            starImg.sprite = Resources.Load("GoldStar", typeof(Sprite)) as Sprite;
        }
    }
コード例 #6
0
    // Use this for initialization
    void Start()
    {
        polygonSetting();

        bestScore             = ZPlayerPrefs.GetInt(GameConstants.BESTSCORE_STRING, 0);
        numOfStars            = ZPlayerPrefs.GetInt(GameConstants.GLOBALSTARS_STRING, 0);
        currentScoreText.text = "" + currentScore;
        bestScoreText.text    = "" + bestScore;
        starText.text         = "" + numOfStars;

        cameraYPos = Camera.main.transform.position.y;
        Transform groundBoxPrefab = BoxPattern.getInstance().groundBoxPrefab;

        groundBox               = Instantiate(groundBoxPrefab, new Vector3(0, 0, 0), Quaternion.identity) as Transform;
        groundBox.parent        = transform;
        groundBox.localPosition = new Vector3(0, 0, 0);

        if (GameConstants.LEVEL_TO_LOAD == 0)
        {
            GameAnalytics.NewDesignEvent("InfiniteGamePlay");
            initInfiniteGamePlay();
        }
        else
        {
            GameAnalytics.NewDesignEvent("LevelGamePlay");
            initLevel(GameConstants.LEVEL_TO_LOAD);
        }

        if (AudioListener.volume == 0.0f)
        {
            Sprite temp = Resources.Load("sound_off", typeof(Sprite)) as Sprite;
            musicOn.GetComponent <Image>().overrideSprite = temp;             //Resources.Load ("DressingScene/Body/body"+id.ToString()+".png",typeof(Sprite)) as Sprite;
            //musicOn.GetComponent<UISprite>().spriteName = "SoundOn-button";
        }
        else
        {
            Sprite temp = Resources.Load("sound_on", typeof(Sprite)) as Sprite;
            musicOn.GetComponent <Image>().overrideSprite = temp;
            //musicOn.GetComponent<UISprite>().spriteName = "SoundOff-button";
        }
    }
コード例 #7
0
        public void Initialize()
        {
            gameOverPosition.X = 320;
            gameOverPosition.Y = 130;

            device = graphics.GraphicsDevice;

            gameState = new GameState();
            gameStart = new GameStart(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight);
            gameState.setState(GameState.state.Level);

            board  = new GameBoard(new Vector2(33, 25), new Vector2(device.PresentationParameters.BackBufferWidth, device.PresentationParameters.BackBufferHeight));
            darwin = new Darwin(board);

            String zombieString = "This a zombie,\n don't near him \nas a human!!";

            zombieMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, zombieString);

            String darwinString = "This is darwin,\n move with arrows, \n z to transform, \n a for actions";

            darwinMessage = new MessageBox(board.getPosition(12, 8).X, board.getPosition(10, 10).Y, darwinString);

            stairs = new Stairs(board);
            if (board.isGridPositionOpen(5, 18))
            {
                stairs.setGridPosition(5, 18);
            }

            // Initial starting position
            darwin.setGridPosition(6, 18);
            if (board.isGridPositionOpen(darwin))
            {
                board.setGridPositionOccupied(darwin.X, darwin.Y);
                darwin.setPosition(board.getPosition(darwin).X, board.getPosition(darwin).Y);
            }

            // Darwin's lag movement
            counterReady = counter = 5;

            zTime      = new ZombieTime(board);
            zTimeReset = new ZombieTime(board);

            setPotionPosition(27, 5);

            setBoxes();
            setBoxPattern();
            pattern = new BoxPattern(board, spotsForPattern);

            setVortexes();

            setWalls();

            snake  = new Snake(10, 9, 27, 5, 18, 5, board);
            snake2 = new Snake(8, 15, 27, 5, 18, 5, board);
            snake3 = new Snake(21, 9, 27, 5, 18, 5, board);
            snake4 = new Snake(21, 15, 27, 5, 18, 5, board);

            northZombie = new PyroZombie(15, 3, 25, 4, 3, 3, board);
            northZombie.setGridPosition(15, 3);
            northZombie.setCurrentPatrolPoint(new Vector2(27, 3));
            northZombie.setNextPatrolPoint(new Vector2(5, 3));

            southZombie = new PyroZombie(15, 20, 25, 4, 20, 20, board);
            southZombie.setGridPosition(15, 20);
            southZombie.setCurrentPatrolPoint(new Vector2(5, 20));
            southZombie.setNextPatrolPoint(new Vector2(27, 20));

            eastZombie = new PyroZombie(29, 11, 29, 29, 19, 4, board);
            eastZombie.setGridPosition(29, 11);
            eastZombie.setCurrentPatrolPoint(new Vector2(29, 17));
            eastZombie.setNextPatrolPoint(new Vector2(29, 6));

            westZombie = new PyroZombie(3, 11, 3, 3, 19, 4, board);
            westZombie.setGridPosition(3, 11);
            westZombie.setCurrentPatrolPoint(new Vector2(3, 5));
            westZombie.setNextPatrolPoint(new Vector2(3, 18));

            flames = new LinkedList <Flame>();
        }