상속: MonoBehaviour
예제 #1
0
        public int AddBlockType(BlockController controller)
        {
            int index = Controllers.Count;

            if (index == ushort.MaxValue)
            {
                Debug.LogError("Too many block types!");
                return(-1);
            }

            if (Names.ContainsKey(controller.Name()))
            {
                Debug.LogError("Two blocks with the same name " + controller.Name() + " are defined!");
                return(-1);
            }

            Controllers.Add(controller);
            BlockOverride blockOverride = GetBlockOverride(controller.Name());

            if (blockOverride != null)
            {
                blockOverride.m_Controller = controller;
            }

            BlockOverrides.Add(blockOverride);

            Names.Add(controller.Name().ToLower().Replace(" ", ""), index);
            return(index);
        }
예제 #2
0
    public void BlockStateChanged(BlockController bc)
    {
        switch (bc.CurrentBlockState)
        {
        case BlockController.blocksState.Ingame:
            BlockController tempBlock = GetNextBlock(bc);
            if (tempBlock == null)
            {
                Debug.Log("Warning No next block found !");
            }
            else
            {
                //Debug.Log("next block found : "+tempBlock.gameObject.GetHashCode());
                tempBlock.CurrentBlockState = BlockController.blocksState.Approaching;
            }
            break;

        case BlockController.blocksState.Waiting:
            //Debug.Log (bc.gameObject.GetHashCode () + " " + bc.CurrentBlockState);
            bc.gameObject.SetActive(false);
            break;

        default: break;
        }
        //Debug.Log(bc.gameObject.GetHashCode() + " " + bc.CurrentBlockState);
    }
    private void DestroyAllTouchingBlocks()
    {
        Collider[] infos    = Physics.OverlapBox(transform.position, new Vector3(1f, 1.80f, 1f));
        float      waitTIme = Const.BLOCK_DESTROY_DELAY;

        foreach (var item in infos)
        {
            BlockController controller = item.GetComponent <BlockController>();
            if (!controller)
            {
                continue;
            }
            RaycastHit hitInfo;
            Physics.Raycast(transform.position, (controller.transform.position - transform.position).normalized, out hitInfo);
            if (hitInfo.collider && hitInfo.collider.GetComponent <BlockController>() != controller)
            {
                Debug.Log(hitInfo.collider.name + " != " + controller.name);
                continue;
            }
            else if (!hitInfo.collider)
            {
                continue;
            }
            if (controller.BlockColor == BlockColor && controller != this && controller.IsActive)
            {
                controller.Invoke("RemoveBlock", waitTIme);
            }
            waitTIme += Const.BLOCK_DESTROY_DELAY;
        }
    }
예제 #4
0
    public void DoppelMove(Vector3 direc)
    {
        MapPos nextPos = GetNextPos(nowPos, direc);

        nextObj = goMap[nextPos.floor, nextPos.x, nextPos.z];

        transform.localRotation = Quaternion.LookRotation(direc);
        animator.SetBool(key_walk, true);

        if (nextObj == null)
        {
            StartCoroutine(Move(direc));
            stayCnt = 0;
        }
        else
        {
            if (nextObj.tag.Contains("Movable"))
            {
                GameObject      moveBlock = goMap[nextPos.floor, nextPos.x, nextPos.z];
                BlockController b         = moveBlock.GetComponent <BlockController>();
                b.BlockMove(direc);
                if (goMap[nextPos.floor, nextPos.x, nextPos.z] == null)
                {
                    //ブロック移動後移動先が空いているなら == ブロックが動けたなら プレイヤーを動かす
                    StartCoroutine(Move(direc));
                    stayCnt = 0;
                }
            }
        }
        doppelPos[number] = nowPos;
    }
예제 #5
0
        public override void OnActivate(PlayerController caster)
        {
            //4-Blöcke hohes Hindernis, das anderen Spielern schadet und nicht zum Abspringen benutzt werden kann
            BlockController block = GameObject.Instantiate(barrierPrefab, new Vector3(caster.SpawnController.transform.position.x, 34, 0), Quaternion.identity, GameObject.Find("Gameplay/Cubes").transform).GetComponent <BlockController>();

            block.Caster = caster;
        }
예제 #6
0
 private void CallChangeBlockPrewiew(BlockController block)
 {
     if (ChangeBlockPrewiew != null)
     {
         ChangeBlockPrewiew(block.View);
     }
 }
예제 #7
0
    IEnumerator BuildingsInst(GameObject goInst, XmlClass buidings, int _id)
    {
        goInst = buidings.analyseGO(_id, (int)WhatBlockParse.Builings, prefabBuildings, avatarBuildings, infoBuildings, downbarBuildings, xmlDoc.text);
        goInst = Instantiate(goInst);
        goInst.transform.SetParent(parentGOBuildings);
        goInst.transform.localScale = new Vector3(1, 1, 1);

        BlockController blc = goInst.GetComponent <BlockController>();

        blc.SetBlockName();
        blc.SetAvatar();
        blc.SetBlockLevel(_id, WhatBlockParse.Builings);
        blc.SetTitle();
        blc.SetDesc();
        blc.SetPrices();
        blc.SetTimeToBuild();
        blc.SetRequairments(xmlDoc.text, WhatBlockParse.Builings);

        if (blc.blockId == 45)
        {
            blc.SetCapitolium();
        }

        upGradeBtnBuildings = goInst.transform.FindChild("DownBar").FindChild("UpgradeButton").GetComponent <Button>();
        upGradeBtnBuildings.onClick.AddListener(() => { UpGradeBuildResearchTech((int)WhatBlockParse.Builings); });
        yield return(null);
    }
        private bool AllowClickMoved(BlockController block)
        {
            int x = block.Position.X;
            int y = block.Position.Y;

            if (block.Side == Side.Left || block.Side == Side.Right)
            {
                for (int i = _borderGamePole; i < _weightGamePole - _borderGamePole; i++)
                {
                    if (_blocks[i, y] != null)
                    {
                        return(true);
                    }
                }
            }
            if (block.Side == Side.Up || block.Side == Side.Down)
            {
                for (int i = _borderGamePole; i < _heightGamePole - _borderGamePole; i++)
                {
                    if (_blocks[x, i] != null)
                    {
                        return(true);
                    }
                }
            }

            return(false);
        }
예제 #9
0
    private void Update()
    {
        if (isCombine)
        {
            if (combinedBlock != null && !isMove)
            {
                if (!combinedBlock.isMove)
                {
                    Combine();
                    BlockController blockController = GameObject.FindGameObjectWithTag("NumBlockManeger").GetComponent <BlockController>();
                    blockController.AddScore(blockNumber);
                }
            }
        }

        if (isMove)
        {
            float   speed   = blockMoveSpeed * Time.deltaTime;
            Vector3 current = transform.position;

            transform.position = Vector3.MoveTowards(current, targetPosition, speed);

            if (transform.position == targetPosition)
            {
                MoveEnd();
            }
        }
    }
예제 #10
0
 // Use this for initialization
 void Start() {
     GameObject game = GameObject.Find("Game");
     this.blockController = game.GetComponent<BlockController>();
     
     this.direction = Direction.Down;
     DropStart();
 }
예제 #11
0
    // Use this for initialization
    void Start()
    {
        b = gameObject.GetComponent <BlockController>();
        h = gameObject.GetComponent <HardObjectController>();
        g = gameObject.GetComponent <GoalBlockController>();
        if (gameObject.tag.Contains("Movable"))
        {
            objectTag  = 'b';
            lightColor = new Color(1, 1, 1, 0);
        }
        else if (gameObject.tag.Contains("Goal"))
        {
            objectTag  = 'g';
            lightColor = new Color(0.8f, 0.8f, 0.2f, 0);
        }

        rend = GetComponent <Renderer>();
        if (lightning)
        {
            currentColor = lightColor;
        }
        else
        {
            currentColor = new Color(0, 0, 0, 0);
        }
        rend.material.SetColor("_EmissionColor", currentColor);
    }
예제 #12
0
    private void Initialize()
    {
        TutorialDialogueController.dialogueTurn = 0;
        TutorialDialogueController.isClickable  = true;

        blockController     = FindObjectOfType <BlockController>();
        diceController      = FindObjectOfType <DiceController>();
        resetDiceController = FindObjectOfType <ResetDiceController>();

        // tutorialGuideCanvas = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.TUTORIAL_GUIDE_CANVAS);
        attackGage = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.ATTACK_GAGE);
        blocks     = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.BLOCKS);
        guideItem  = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.GUIDE_ITEM);
        turn       = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.TURN);
        toast      = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.TOAST);

        oval            = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.OVAL);
        outline         = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.OUTLINE);
        outlineDice     = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.OUTLINE_DICE);
        outlineCircle   = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.OUTLINE_CIRCLE);
        outlineRect     = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.OUTLINE_RECT);
        outlineFullRect = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.OUTLINE_FULL_RECT);
        indicateArrow   = GameObject.Find(Constants.TUTORIAL.GAME_OBJECT_NAME.INDICATE_ARROW);

        ToggleClickEventResetDiceScreen(false);
    }
예제 #13
0
    /// <summary>
    /// Adds a block type to the index and adds it's name to a dictionary for quick lookup
    /// </summary>
    /// <param name="controller">The controller object for this block</param>
    /// <returns>The index of the block</returns>
    public int AddBlockType(BlockController controller)
    {
        int index = controllers.Count;

        if (index == ushort.MaxValue)
        {
            Debug.LogError("Too many block types!");
            return -1;
        }

        if (names.ContainsKey(controller.Name()))
        {
            Debug.LogError("Two blocks with the name " + controller.Name() + " are defined");
        } 

        controllers.Add(controller);
        BlockOverride blockOverride = GetBlockOverride(controller.Name());
        if(blockOverride != null)
            blockOverride.controller = controller;

        blockOverrides.Add(blockOverride);

        names.Add(controller.Name().ToLower().Replace(" ", ""), index);
        return index;
    }
    // Update is called once per frame
    void Update()
    {
        //newBlock();
        if (player != null)
        {
            gameCamera.transform.position = new Vector3(player.transform.position.x, gameCamera.transform.position.y, gameCamera.transform.position.z);
            gameText.text = "Score: " + Mathf.Floor(player.transform.position.x);
        }
        else
        {
            gameText.text = "Press R to Restart";
        }



        while (player != null && blockPointer < player.transform.position.x + safeMargin)
        {
            int blockIndex = Random.Range(0, blockPrefab.Length);
            if (blockPointer <= 20)
            {
                blockIndex = 0;
            }
            GameObject blockObj = GameObject.Instantiate <GameObject>(blockPrefab[blockIndex]);
            blockObj.transform.SetParent(this.transform);
            BlockController block = blockObj.GetComponent <BlockController>();
            blockObj.transform.position = new Vector3(blockPointer + block.sizeX / 2, 0, 0);
            blockPointer += block.sizeX;
        }

        if (Input.GetKeyDown(KeyCode.R))
        {
            SceneManager.LoadScene(SceneManager.GetActiveScene().name);
        }
    }
예제 #15
0
 // So sanh vi tri 2 block
 bool CompareBlock(BlockController block1, BlockController block2)
 {
     if (block1.x == block2.x && block1.y == block2.y)
     {
         return(true);
     }
     return(false);
 }
예제 #16
0
 private void OnBlockDestroyed(BlockController block)
 {
     block.ClickMove -= OnClickMove;
     block.Move      -= OnMove;
     block.TryMove   -= OnBlockTryMove;
     block.Destroyed -= OnBlockDestroyed;
     block.View.MoveAnimator.EndAnimation -= MoveAnimator_EndAnimation;
 }
예제 #17
0
 private void AddBlock(BlockController block)
 {
     block.ClickMove += OnClickMove;
     block.Move      += OnMove;
     block.TryMove   += OnBlockTryMove;
     block.Destroyed += OnBlockDestroyed;
     block.View.MoveAnimator.EndAnimation += MoveAnimator_EndAnimation;
 }
 private void DestroyBlock(BlockController controller)
 {
     if (controller)
     {
         controller.HitBlock();
     }
     Destroy(gameObject);
 }
예제 #19
0
 private void updateActiveBlock(int newX, int newY)
 {
     activeTile.Active   = false;
     XIndexOfActiveBlock = newX;
     ZIndexOfActiveBlock = newY;
     activeTile          = tiles[XIndexOfActiveBlock, ZIndexOfActiveBlock];
     activeTile.Active   = true;
 }
예제 #20
0
 // Use this for initialization
 void Start()
 {
     this.transform.position = new Vector2(this.transform.position.x, startYPos);
     timeSpawn     = timeToGrow;
     _retroceso    = retroceso;
     _growFireTime = growFireTime + 3f;
     blocks        = GameObject.Find("Block").GetComponent <BlockController>();
 }
예제 #21
0
 private void RemoveBlockAndCheckWin(BlockController block)
 {
     activeBlocks.Remove(block);
     if (activeBlocks.Count == 0)
     {
         EventManager.TriggerEvent(EventType.ALL_BLOCKS_DESTROYED);
     }
 }
예제 #22
0
 private void Initialize()
 {
     levelLoader           = FindObjectOfType <LevelLoader>();
     newTutorialController = FindObjectOfType <NewTutorialController>();
     blockController       = FindObjectOfType <BlockController>();
     diceController        = FindObjectOfType <DiceController>();
     diceText = this.transform.Find(Constants.GAME_OBJECT_NAME.NUMBER_TEXT).GetComponent <Text>();
 }
        /// <summary>
        /// Gets the controller.
        /// </summary>
        /// <returns></returns>
        private BlockController GetController()
        {
            var controller = new BlockController(
                _mockFutureNhsContentHandler.Object,
                _mockFutureNhsBlockHandler.Object);

            return(controller);
        }
예제 #24
0
    IEnumerator RefreshBlock(BlockController _blc)
    {
        _blc.SetBlockLevel(_blc.blockId, ParseAll.WhatBlockParse.Technology);
        _blc.SetTitle();
        _blc.ClearRequairments();
        _blc.SetRequairments(LoginController.xmlDoc.text, ParseAll.WhatBlockParse.Technology);

        yield return(null);
    }
예제 #25
0
    public void OnBlockDestroyed(BlockController block)
    {
        allBlocks.Remove(block);

        if (allBlocks.Count == 0)
        {
            LevelCompleted();
        }
    }
예제 #26
0
 public void RemovedBlock(BlockController block, GameManager.PlayerIndex player)
 {
     if (spawnedBlocks.Contains(block))
     {
         spawnedBlocks.Remove(block);
         PlayerBlocks[player].Remove(block);
         Destroy(block.gameObject);
     }
 }
예제 #27
0
    private void OnTriggerEnter(Collider other)
    {
        BlockController block = other.GetComponentInParent <BlockController>();

        if (block != null)
        {
            block.Death(other.gameObject);
        }
    }
예제 #28
0
 public override void blockHit(BlockController block)
 {
     // Check if the player was allowed to hit the block
     if (block.challengeType == BlockController.ChallengeType.DoNotShoot)
     {
         gameController.pauseGame();
         uiController.challangeFail();
     }
 }
예제 #29
0
    void MakeBlock()
    {
        GameObject BlockRoot = (GameObject)GameObject.Instantiate(Resources.Load("Prefebs/Blocks/pfBlock_Root")) as GameObject;
        BlockRoot.name = "BlockRoot";
        BlockRoot.transform.parent = transform;
        BlockRoot.transform.position = transform.position;

        blockController = BlockRoot.GetComponent<BlockController>();
    }
예제 #30
0
    private void OnTriggerExit(Collider other)
    {
        BlockController otherBlock = other.GetComponent <BlockController>();

        if (otherBlock)
        {
            detectedBlocks.Remove(otherBlock);
        }
    }
예제 #31
0
    private void OnTriggerEnter(Collider other)
    {
        BlockController otherBlock = other.GetComponent <BlockController>();

        if (otherBlock && otherBlock.GetAttached() && otherBlock != owningBlock)
        {
            detectedBlocks.Add(otherBlock);
        }
    }
예제 #32
0
    IEnumerator RefreshBlock(BlockController _blc)
    {
        _blc.SetBlockLevel(_blc.blockId, ParseAll.WhatBlockParse.Technology);
        _blc.SetTitle();
        _blc.ClearRequairments();
        _blc.SetRequairments(LoginController.xmlDoc.text, ParseAll.WhatBlockParse.Technology);

        yield return null;
    }
예제 #33
0
 public static BlockController getBlockAt(int x, int y)
 {
     if (grid[x, y] != null)
     {
         BlockController block = grid[x, y].GetComponent <BlockController>();
         return(block);
     }
     return(null);
 }
예제 #34
0
    // Use this for initialization
    void Start()
    {
        GameObject game = GameObject.Find("Game");

        this.blockController = game.GetComponent <BlockController>();

        this.direction = Direction.Down;
        DropStart();
    }
예제 #35
0
    public int AddBlockType(BlockController controller)
    {
        int index = controllers.Count;

        if (index == ushort.MaxValue)
        {
            Debug.LogError("Too many block types!");
            return -1;
        }

        controllers.Add(controller);
        names.Add(controller.Name().ToLower().Replace(" ", ""), index);
        return index;
    }
예제 #36
0
    IEnumerator GetJson()
    {
        WWW www = new WWW("http://vg2.v-galaktike.ru/api/?class=user&method=getuser&token=" + MainResourcesController.userToken );
        yield return www;

        result = JSON.Parse(www.text);

        MainResourcesController.timeNow = result["now"].AsLong;

        if(MainResourcesController.buildingInProgress.Count != 0)
        {
            progressParrent.SetActive(true);

            buildsInProgress = new BuildingsInProgress(MainResourcesController.buildingInProgress[0].sysId,
                MainResourcesController.buildingInProgress[0].buildId,
                MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.timeNow,
                MainResourcesController.buildingInProgress[0].timeToEnd - MainResourcesController.buildingInProgress[0].startTimeBuild );

            thisBlc = blocksParrent.transform.FindChild("Building_prefab_" + buildsInProgress.buildId).GetComponent<BlockController>();

            queneName.text = thisBlc.title;
            queneAvatar.sprite = thisBlc.ava;
            goInstQuene = Instantiate(quenePrefab);
            goInstQuene.transform.SetParent(progressParrent.transform);
            goInstQuene.transform.localScale = new Vector3(1, 1, 1);

            QueneController qC = goInstQuene.GetComponent<QueneController>();
            qC.queneId = buildsInProgress.buildId;
            qC.timeToEndBuild = buildsInProgress.timeToEnd;
            qC.timeToEndTxt = goInstQuene.transform.FindChild("TimeValue_text").GetComponent<Text>();
            qC.parrentBuilding = progressParrent;
            qC.progress = goInstQuene.transform.FindChild("Bg_image").GetComponent<Image>();
            qC.progress.fillAmount = 1f - buildsInProgress.timeToEnd / buildsInProgress.startTimeBuild;
            qC.TickBuild();
        }
        else
        {
            progressParrent.SetActive(false);
        }

        yield return new WaitForSeconds(1f);
        loadingPanel.SetActive(false);
        scrnM.ShowCurrentPanel();
    }
예제 #37
0
    public IEnumerator SelectBlock(BlockController block, bool value)
    {
        if(!value)
        {
            blockA = null;
            yield return StartCoroutine(block.Select(false));
        }
        else
        {
            if(blockA == null)
            {
                blockA = block;

                yield return StartCoroutine(block.Select(true));
            }
            else if(blockB == null && isNeighbor(blockA.transform, block.transform))
            {
                blockB = block;

                yield return StartCoroutine(block.Select(true));

                yield return new WaitForSeconds(0.5f);

                Vector2 tempPos = blockA.transform.position;

                blockA.transform.position = blockB.transform.position;
                blockB.transform.position = tempPos;

                yield return StartCoroutine(blockA.Select(false));
                yield return StartCoroutine(blockB.Select(false));

                // Check for groups to remove
                removeGroup(blockA.transform, blockA.transform, 1);

                // shift blocks after removing groups
                shiftBlocks();

                blockA = blockB = null;
            }
        }
        yield return new WaitForSeconds (0);
    }
		public async Task Collect(CollectTask collectTask)
		{
			var blockFactory = new BlockFactory(collectTask);
			var blockController = new BlockController();
			blockController.Trace = DataCollector.Trace;
			blockFactory.Trace = DataCollector.Trace;

			// Create repo for write results
			var inputRepo = getRepository(collectTask.Input);
			var outputRepo = getRepository(collectTask.Output);

			var inputBufferBlock = blockFactory.InputBuffer();
			var bacthBlock = blockFactory.Batch<string>();
			var processBlock = blockFactory.Process();
			var outputBufferBlock = blockFactory.OutputBuffer();
			var outputBlock = blockFactory.WriteResults(outputRepo);

			blockController.LinkWithCompletion(inputBufferBlock, bacthBlock);
			blockController.LinkWithCompletion(bacthBlock, processBlock);
			blockController.LinkWithCompletion(processBlock, outputBufferBlock);
			blockController.LinkWithCompletion(outputBufferBlock, outputBlock);

			// Read data and send to blocks
			foreach (var item in inputRepo.GetInputData())
			{
				await inputBufferBlock.SendAsync(item);
				collectTask.AllItems++;

                if (collectTask.AllItems % 524288 == 0)
                    Thread.Sleep(TimeSpan.FromMinutes(15));

				if (collectTask.CancellationSource.IsCancellationRequested)
					break;
			}
			inputBufferBlock.Complete();

			await outputBlock.Completion;

			inputRepo.Dispose();
			outputRepo.Dispose();
		}
예제 #39
0
    public void UpGradeBuildResearch_confirm(BlockController _blc, int _whatBlock)
    {
        if (!MainResourcesController.buildingListIsFull)
        {
            popUpBuildResearch.SetActive(false);
            if ((_blc.titan_current <= MainResourcesController.main_titan_value) && (_blc.silicon_current <= MainResourcesController.main_silicone_value) && (_blc.antimatter_current <= MainResourcesController.main_antimatter_value))
            {
                if (_whatBlock == (int)WhatBlockParse.Builings)
                {
                    string json_query = "http://vg2.v-galaktike.ru/api/?class=planet&method=addbuilding&token=" +
                        MainResourcesController.userToken + "&system_id=" +
                        MainResourcesController.currentSystemID + "&element_id=" +
                        _blc.blockId + "&mode=add";

                    queneName.text = _blc.title;
                    queneAvatar.sprite = _blc.ava;

                    StartCoroutine(AddBuildings(json_query, _blc));
                }
            }
            else
            {
                Debug.Log("Need more resources");
                NoEnoughtMoney_Panel.SetActive(true);
            }
        }
        else
        {
            Debug.Log("Some buildings in progress please wait end build or use credit");
        }

        if (!MainResourcesController.researchListIsFull)
        {
            popUpBuildResearch.SetActive(false);
            if ((_blc.titan_current <= MainResourcesController.main_titan_value) && (_blc.silicon_current <= MainResourcesController.main_silicone_value) && (_blc.antimatter_current <= MainResourcesController.main_antimatter_value))
            {
                if (_whatBlock == (int)WhatBlockParse.Research)
                {
                    string json_query = "http://vg2.v-galaktike.ru/api/?class=planet&method=addresearch&token=" +
                        MainResourcesController.userToken + "&system_id=" +
                        MainResourcesController.currentSystemID + "&tech_id=" +
                        _blc.blockId + "&mode=add";

                    queneName.text = _blc.title;
                    queneAvatar.sprite = _blc.ava;

                    StartCoroutine(AddResearch(json_query, _blc));
                }
            }
            else
            {
                Debug.Log("Need more resources");
                NoEnoughtMoney_Panel.SetActive(true);
            }
        }

        if (_whatBlock == (int)WhatBlockParse.Weapon || _whatBlock == (int)WhatBlockParse.Defence)
        {
            popUpBuildResearch.SetActive(false);
            if ((_blc.titan_current <= MainResourcesController.main_titan_value) && (_blc.silicon_current <= MainResourcesController.main_silicone_value) && (_blc.antimatter_current <= MainResourcesController.main_antimatter_value))
            {
                if (_blc.blockId == 407 && !PlayerPrefs.HasKey("blockid407"))
                {
                    PlayerPrefs.SetInt("blockid407", 1);
                    countFromSlider = Int32.Parse((_blc.downBar.transform.FindChild("InputField").FindChild("Text").GetComponent<Text>().text));
                    string json_query = "http://vg2.v-galaktike.ru/api/?class=planet&method=addweapon&token=" + MainResourcesController.userToken +
                        "&system_id=" + MainResourcesController.currentSystemID +
                        "&element_id=" + _blc.blockId +
                        "&element_count=" + countFromSlider;

                    StartCoroutine(AddWeapon(json_query, _blc));
                }
                else if (_blc.blockId == 408 && !PlayerPrefs.HasKey("blockid408"))
                {
                    PlayerPrefs.SetInt("blockid408", 1);
                    countFromSlider = Int32.Parse((_blc.downBar.transform.FindChild("InputField").FindChild("Text").GetComponent<Text>().text));
                    string json_query = "http://vg2.v-galaktike.ru/api/?class=planet&method=addweapon&token=" + MainResourcesController.userToken +
                        "&system_id=" + MainResourcesController.currentSystemID +
                        "&element_id=" + _blc.blockId +
                        "&element_count=" + countFromSlider;

                    StartCoroutine(AddWeapon(json_query, _blc));
                }
                else if (_blc.blockId == 409 && !PlayerPrefs.HasKey("blockid409"))
                {
                    PlayerPrefs.SetInt("blockid409", 1);
                    countFromSlider = Int32.Parse((_blc.downBar.transform.FindChild("InputField").FindChild("Text").GetComponent<Text>().text));
                    string json_query = "http://vg2.v-galaktike.ru/api/?class=planet&method=addweapon&token=" + MainResourcesController.userToken +
                        "&system_id=" + MainResourcesController.currentSystemID +
                        "&element_id=" + _blc.blockId +
                        "&element_count=" + countFromSlider;

                    StartCoroutine(AddWeapon(json_query, _blc));
                }
                else
                {
                    countFromSlider = Int32.Parse((_blc.downBar.transform.FindChild("InputField").FindChild("Text").GetComponent<Text>().text));
                    string json_query = "http://vg2.v-galaktike.ru/api/?class=planet&method=addweapon&token=" + MainResourcesController.userToken +
                        "&system_id=" + MainResourcesController.currentSystemID +
                        "&element_id=" + _blc.blockId +
                        "&element_count=" + countFromSlider;

                    StartCoroutine(AddWeapon(json_query, _blc));
                }
            }
            else
            {
                Debug.Log("Need more resources");
                NoEnoughtMoney_Panel.SetActive(true);
            }
        }

        upGradeBRPopUp_confirm.onClick.RemoveAllListeners();
    }
예제 #40
0
		private void MoveTarget(BlockController target)
		{
			var posEnemy = _enemyController.transform.position;
			posEnemy.x = Mathf.Floor(posEnemy.x * 10) / 10;
			posEnemy.y = Mathf.Floor(posEnemy.y * 10) / 10;

			var posTarget = target.transform.position;
			posTarget.x = Mathf.Floor(posTarget.x * 10) / 10;
			posTarget.y = Mathf.Floor(posTarget.y * 10) / 10;

			if (posTarget.x > posEnemy.x)
				_enemyController.SetDirection(Direction.Right);
			else if (posTarget.x < posEnemy.x)
				_enemyController.SetDirection(Direction.Left);

			if (posTarget.y > posEnemy.y)
				_enemyController.SetDirection(Direction.Top);
			else if (posTarget.y < posEnemy.y)
				_enemyController.SetDirection(Direction.Bottom);
		}
예제 #41
0
 public void DisconnectWithBlock()
 {
     target = GameObject.Find("_DummyBlock");
     if (!target) return;
     control = target.GetComponent<BlockController>();
 }
예제 #42
0
 public void ConnectWithBlock()
 {
     target = GameObject.Find("block(new)");
     if (!target) return;
     control = target.GetComponent<BlockController>();
 }
예제 #43
0
        public Group(BlockController blockController) {
            this.id = ++nextId;

            this.blockController = blockController;
            this.blocks = new HashSet<Block>();
        }
예제 #44
0
 /// get component of the _DummyBlock to disconnect
 private void DisconnectWithBlock(object sender, EventArgs e)
 {
     GameObject target = GameObject.Find("_DummyBlock");
     if (!target) return;
     blockController = target.GetComponent<BlockController>();
 }
예제 #45
0
 void FindBLC(int _id)
 {
     if (_id >= 202 && _id <= 216)
     {
         foreach (var mm in ParseAll.allDoc)
         {
             if (docDefInProgress.elementId == mm.blockId)
             {
                 thisBlc = mm;
             }
         }
     }
     else
     {
         foreach (var mm in ParseAll.allDoc)
         {
             if (docDefInProgress.elementId == mm.blockId)
             {
                 thisBlc = mm;
             }
         }
     }
 }
예제 #46
0
    IEnumerator AddWeapon(string json_query, BlockController _blc)
    {
        WWW www = new WWW(json_query);
        yield return www;

        if (www.error == null)
        {
            var result = JSON.Parse(www.text);
            JSONNode system = result["system"];
            JSONNode docDefInProgress = result["system"]["weapon"];

            if (result["error"].Value != "")
            {
                Debug.Log("Json Doc Error id: " + result["error"].Value);
                yield break;
            }
            else
            {
                parrentQuene_d.gameObject.SetActive(true);

                MainResourcesController.main_titan_value = system["titan"].AsDouble;
                MainResourcesController.main_silicone_value = system["silicon"].AsDouble;
                MainResourcesController.main_antimatter_value = system["antimatter"].AsDouble;
                MainResourcesController.energy_used = system["energy_used"].AsInt;
                MainResourcesController.timeNow = result["now"].AsLong;
                MainResourcesController.weapone_update = system["weapon_update"].AsLong;

                MainResourcesController mrc = TopBlock.GetComponent<MainResourcesController>();
                mrc.ValOnTheirPlace();

                MainResourcesController.docDefInProgress.Clear();
                for (int i = 0; i < docDefInProgress.Count; i++)
                {
                    MainResourcesController.docDefInProgress.Add(new DocDefInProgress(
                        docDefInProgress[i]["system_id"].AsInt,
                        docDefInProgress[i]["element_id"].AsInt,
                        docDefInProgress[i]["count"].AsInt));
                }

                GameObject.Find("DocDef").GetComponent<DocOnEnabled>().StartThis();

                yield return null;
            }
        }
        else
        {
            errorWindow.SetActive(true);
            yield break;
        }
    }
예제 #47
0
 void Awake()
 {
     blockController = GameObject.FindGameObjectWithTag (Tags.gameController).GetComponent<BlockController> ();
 }
예제 #48
0
    public GameObject analyseGO(int _id,int _whatParse, GameObject _prefab, Image _avatar, Transform _inform, Transform _downBar, string _xmlDoc)
    {
        xmlDoc = _xmlDoc;

        Rname = _inform.FindChild("ResearchName_text").GetComponent<Text>();
        Rinfo = _inform.FindChild("ResearchInfo_text").GetComponent<Text>();

        if (_whatParse != 4)
        {
            resourcesBlock = _inform.FindChild("Resources").GetComponent<Transform>();

            metal = resourcesBlock.FindChild("Metal_image").FindChild("MetalValue_text").GetComponent<Text>();
            metalImg = resourcesBlock.FindChild("Metal_image").GetComponent<Image>();
            crystal = resourcesBlock.FindChild("Crystal_image").FindChild("CrystalValue_text").GetComponent<Text>();
            crystalImg = resourcesBlock.FindChild("Crystal_image").GetComponent<Image>();
            deuterium = resourcesBlock.FindChild("Deuterium_image").FindChild("Deuterium_text").GetComponent<Text>();
            deuteriumImg = resourcesBlock.FindChild("Deuterium_image").GetComponent<Image>();

            timeToBuild = _downBar.FindChild("TimerValue_text").GetComponent<Text>();
        }

        researchRequir = _inform.FindChild("ResearchRequirements_text").GetComponent<Text>();

        upGrade = _downBar.FindChild("UpgradeButton").GetComponent<Button>();

        ParseTexts(_id,_whatParse);

        blockContr = _prefab.GetComponent<BlockController>();
        blockContr.blockId = _id;
        blockContr.title = title;
        blockContr.description = desc;
        blockContr.ava = GetAvatar(_id);

        blockContr.requairmentsText = researchRequir;

        blockContr.rName = Rname;
        blockContr.rInfo = Rinfo;
        blockContr.avatar = _avatar;
        blockContr.upGradeBtn = upGrade;

        if (_whatParse != 4)
        {
            ParsePrices(_id);
            blockContr.titan = priceD["titan"];
            blockContr.silicon = priceD["silicon"];
            blockContr.antimatter = priceD["antimatter"];
            blockContr.energy = priceD["energy"];
            blockContr.factor = priceD["factor"];
            priceD.Clear();

            blockContr.titanText = metal;
            blockContr.titanImg = metalImg;
            blockContr.siliconText = crystal;
            blockContr.siliconImg = crystalImg;
            blockContr.antimatterText = deuterium;
            blockContr.antimatterImg = deuteriumImg;
            blockContr.timeToBuildText = timeToBuild;
        }

        return _prefab;
    }
예제 #49
0
 void ConnectWithBlock()
 {
     block = GameObject.Find("block");
     if (!block) return;
     blockController = block.GetComponent<BlockController>();
 }
예제 #50
0
    IEnumerator AddResearch(string json_query, BlockController _blc)
    {
        WWW www = new WWW(json_query);
        yield return www;

        if (www.error == null)
        {
            var result = JSON.Parse(www.text);
            JSONNode system = result["system"];
            JSONNode current_user = result["user"];
            JSONNode researchInProgress = current_user["tech"];

            MainResourcesController.researchListIsFull = true;

            if (result["error"].Value != "")
            {
                Debug.Log("Json Building Error id: " + result["error"].Value);
                yield break;
            }
            else
            {
                parrentQuene_r.gameObject.SetActive(true);

                MainResourcesController.main_titan_value = system["titan"].AsDouble;
                MainResourcesController.main_silicone_value = system["silicon"].AsDouble;
                MainResourcesController.main_antimatter_value = system["antimatter"].AsDouble;
                MainResourcesController.energy_used = system["energy_used"].AsInt;
                MainResourcesController.timeNow = result["now"].AsLong;

                MainResourcesController mrc = TopBlock.GetComponent<MainResourcesController>();
                mrc.ValOnTheirPlace();

                if (parrentQuene_r.transform.FindChild("ProgressElement(Clone)"))
                {
                    Destroy(parrentQuene_r.transform.FindChild("ProgressElement(Clone)").gameObject);
                }

                MainResourcesController.researchInProgress.Add(new ResearchInProgress(
                    researchInProgress["user_id"].AsInt,
                    researchInProgress["tech_id"].AsInt,
                    researchInProgress["tech_end"].AsLong,
                    researchInProgress["tech_start"].AsLong));

                goInstQuene_r = Instantiate(quenePrefab_r);
                goInstQuene_r.transform.SetParent(parrentQuene_r);
                goInstQuene_r.transform.localScale = new Vector3(1, 1, 1);

                QueneController qC = goInstQuene_r.GetComponent<QueneController>();
                qC.parrentBuilding = parentGOResearch.gameObject;
                qC.queneId = _blc.blockId;
                qC.timeToEndBuild = researchInProgress["tech_end"].AsLong - MainResourcesController.timeNow;  //_blc.timetoend
                qC.timeToEndTxt = goInstQuene_r.transform.FindChild("TimeValue_text").GetComponent<Text>();
                qC.progress = goInstQuene_r.transform.FindChild("Bg_image").GetComponent<Image>();
                qC.progress.fillAmount = 1f - _blc.timeToBuild / (MainResourcesController.researchInProgress[0].timeToEnd - MainResourcesController.researchInProgress[0].startTime);
                qC.TickResearch();
                yield break;
            }
        }
        else
        {
            Debug.Log(www.error);
            errorWindow.SetActive(true);
            yield break;
        }
    }