示例#1
0
    private void CreateField()
    {
        var wNum = weight / cubeObj.transform.localScale.x;
        var hNum = hight / cubeObj.transform.localScale.x;

        for (float i = (-weight / 2); i <= (weight / 2); i++)
        {
            for (float j = (-hight / 2); j <= (hight / 2); j++)
            {
                GameObject obj = Instantiate(cubeObj, new Vector3(i, 0, j), Quaternion.identity);
                blockList.Add(obj.GetComponent <Block>());
            }
        }
        var delta = cubeObj.transform.localScale.x;
        var wall0 = Instantiate(ResourcesMng.ResourcesLoad("Hole"), new Vector3(0, 0, hight / 2 + delta), Quaternion.identity);

        wall0.GetComponent <BoxCollider>().size = new Vector3(weight + cubeObj.transform.localScale.x, 1, 1);
        wall0.gameObject.tag = "Wall";
        var wall1 = Instantiate(ResourcesMng.ResourcesLoad("Hole"), new Vector3(0, 0, -(hight / 2 + delta)), Quaternion.identity);

        wall1.GetComponent <BoxCollider>().size = new Vector3(weight + cubeObj.transform.localScale.x, 1, 1);
        wall1.gameObject.tag = "Wall";
        var wall2 = Instantiate(ResourcesMng.ResourcesLoad("Hole"), new Vector3(weight / 2 + delta, 0, 0), Quaternion.identity);

        wall2.GetComponent <BoxCollider>().size = new Vector3(1, 1, hight + cubeObj.transform.localScale.x);
        wall2.gameObject.tag = "Wall";
        var wall3 = Instantiate(ResourcesMng.ResourcesLoad("Hole"), new Vector3(-(weight / 2 + delta), 0, 0), Quaternion.identity);

        wall3.GetComponent <BoxCollider>().size = new Vector3(1, 1, hight + cubeObj.transform.localScale.x);
        wall3.gameObject.tag = "Wall";
    }
示例#2
0
    public void CharacterRegister(string p1Name, string p2Name)
    {
        GameObject chara1 = Instantiate(ResourcesMng.ResourcesLoad("BlockMans/" + p1Name),
                                        startPoints[0], Quaternion.identity);

        chara1.AddComponent <Player>();
        chara1.GetComponent <Player>().SetControllerNum(1);
        playerCameras[0].Init(chara1.GetComponent <Player>());
        chara1.GetComponent <BlockMan>().Init();
        GameObject chara2 = Instantiate(ResourcesMng.ResourcesLoad("BlockMans/" + p2Name),
                                        startPoints[2], Quaternion.identity);

        chara2.AddComponent <Player>();
        chara2.GetComponent <Player>().SetControllerNum(2);
        playerCameras[1].Init(chara2.GetComponent <Player>());
        chara2.GetComponent <BlockMan>().Init();
        foreach (GameObject charaObj in GameObject.FindGameObjectsWithTag("Player"))
        {
            allCharacters.Add(charaObj.GetComponent <CharacterBase>());
            savedCharacterSize += 1;
        }
        playerCameras[0].CameraStartAction();
        playerCameras[1].CameraStartAction();
        Invoke("GameStart", 2f);
    }
示例#3
0
    public void CharacterRegister(string name)
    {
        GameObject chara1 = Instantiate(ResourcesMng.ResourcesLoad("BlockMans/" + name),
                                        startPoints[0], Quaternion.identity);

        chara1.AddComponent <Player>();
        chara1.GetComponent <Player>().SetControllerNum(0);
        playerCameras[0].Init(chara1.GetComponent <Player>());
        chara1.GetComponent <BlockMan>().Init();
        for (int i = 0; i < allBlockMans.Count; i++)
        {
            if (allBlockMans[i].name == name)
            {
                allBlockMans.Remove(allBlockMans[i]);
            }
        }
        AllBlockManShuffle();
        GameObject chara2 = Instantiate(allBlockMans[0],
                                        startPoints[2], Quaternion.identity);

        chara2.AddComponent <CharacterAI>();
        chara2.GetComponent <CharacterAI>().Init();
        chara2.GetComponent <BlockMan>().Init();
        foreach (GameObject charaObj in GameObject.FindGameObjectsWithTag("Player"))
        {
            allCharacters.Add(charaObj.GetComponent <CharacterBase>());
            savedCharacterSize += 1;
        }
        playerCameras[0].CameraStartAction();
        Invoke("GameStart", 2f);
    }
示例#4
0
    // Update is called once per frame
    void Update()
    {
        if (trigger != isOver)
        {
            trigger = true;
            GetComponent <AudioSource>().PlayOneShot(ResourcesMng.AudioClipLoad("Voice/TapT1576374544351"));
        }

        if (score < mainUI.score)
        {
            score += Time.deltaTime * scoreChangeSpeed;
        }
        else
        {
            score  = mainUI.score;
            isOver = true;
            nextText.SetActive(true);
        }
        finalScoreText.text = "Score : " + ((int)score).ToString();

        if (Input.GetMouseButtonDown(0) && isOver && mainUI.fadeActionNum == 0)
        {
            mainUI.fadeActionNum = 1;
        }
    }
示例#5
0
    public void CreateHole(Block target)
    {
        blockList.Remove(target);
        var holeObj = Instantiate <GameObject>(ResourcesMng.ResourcesLoad("Hole"), target.transform.position, Quaternion.identity);

        holes.Add(holeObj);
        Debug.Log("CreateHole");
    }
示例#6
0
    private void CtrlUI()
    {
        if (Input.GetMouseButtonDown(0) && tapGUI == null)
        {
            tapGUI = Instantiate(ResourcesMng.ResourcesLoad("TAP_1"), Vector3.zero, Quaternion.identity);
        }

        if (tapGUI != null)
        {
            Vector3 tapPosition = Input.mousePosition;
            tapPosition.z             = 10f;
            tapGUI.transform.position = Camera.main.ScreenToWorldPoint(tapPosition);
        }

        if (tapGUI != null && Input.GetMouseButtonUp(0))
        {
            Destroy(tapGUI.gameObject);
            tapGUI = null;
        }
    }
示例#7
0
    private void KeyCtrl()
    {
        if (Input.GetMouseButtonDown(0))
        {
            if (isCoolDown)
            {
                return;
            }
            Vector3 tapPosition = Input.mousePosition;
            tapPosition.z = 10;
            if (level <= allSprites.Count)
            {
                level++;
            }
            flashObj.SetActive(false);
            if (canFusion)
            {
                GameObject tapObj = Instantiate <GameObject>(ResourcesMng.ResourcesLoad("Tap_yes"), Vector3.zero, Quaternion.identity);
                tapObj.transform.position = Camera.main.ScreenToWorldPoint(tapPosition);
                if (GetComponent <AudioSource>() != null)
                {
                    GetComponent <AudioSource>().PlayOneShot(ResourcesMng.AudioClipLoad("SE/good-job-se"));
                }
                mainUI.Good();
                canFusion = false;
            }

            else
            {
                GameObject tapObj = Instantiate <GameObject>(ResourcesMng.ResourcesLoad("Tap_no"), Vector3.zero, Quaternion.identity);
                tapObj.transform.position = Camera.main.ScreenToWorldPoint(tapPosition);
                if (GetComponent <AudioSource>() != null)
                {
                    GetComponent <AudioSource>().PlayOneShot(ResourcesMng.AudioClipLoad("SE/miss"));
                }
                mainUI.Bad();
            }
            StartCoroutine(CoolDown());
        }
    }
    public void CollectBlock(float period)
    {
        if (status == Status.Attack || status == Status.Damage)
        {
            changeBlockCount = 0;
            return;
        }
        if (MyBlockNum <= 0)
        {
            changeBlockCount = 0;
            status           = Status.Normal;
            return;
        }
        if (status != Status.Collect)
        {
            collectBlockCount = 0;
            status            = Status.Collect;
            var stageMng = GameObject.Find("StageMng").GetComponent <StageMng>();
            targetBlock = FurthestBlock(stageMng);
            targetBlock.MarkSwitch(true);
            var efe = Instantiate(ResourcesMng.ResourcesLoad("CubeEffect"), targetBlock.transform.position, Quaternion.identity);
            efe.GetComponent <BlockEffect>().Init(this, color);
            var attackObj = new GameObject();
            attackObj.AddComponent <AttackObj>();
            myAttack = attackObj.GetComponent <AttackObj>();
            myAttack.Init(this);
        }
        else
        {
            if (collectBlockCount < period)
            {
                collectBlockCount += Time.deltaTime;
            }
            else
            {
                if (myAttack.CollectNum < maxCollectNum)
                {
                    if (targetBlock.isStepOn == false && targetBlock.whos == this)
                    {
                        myAttack.BlockRegister(targetBlock);
                        targetBlock.MarkSwitch(false);
                        MyBlockNum--;
                    }

                    var stageMng = GameObject.Find("StageMng").GetComponent <StageMng>();
                    targetBlock = FurthestBlock(stageMng);
                    targetBlock.MarkSwitch(true);
                    var efe = Instantiate(ResourcesMng.ResourcesLoad("CubeEffect"), targetBlock.transform.position, Quaternion.identity);
                    efe.GetComponent <BlockEffect>().Init(this, color);
                }
                else
                {
                    if (targetBlock != null)
                    {
                        targetBlock.MarkSwitch(false);
                        targetBlock = null;
                    }
                }
                collectBlockCount = 0;
            }
        }
    }