Esempio n. 1
0
    void WaitForArrowOut()
    {
        Vector3 pos = general.transform.localPosition + posOffset;
        string  shenGuiLuanWuName = "";

        switch (step)
        {
        case 0:
            pos -= posOffset;
            shenGuiLuanWuName = shenGuiLuanWuName1;
            if (Mathf.Abs(general.transform.localPosition.x - enemyGeneral.transform.localPosition.x) < 200)
            {
                general.SetOnMagic(5);

                enemyGeneral.OnDamage(20, -1, false);
            }
            else
            {
                Invoke("WaitForMagicOver", 0.5f);
            }
            break;

        case 1:
            shenGuiLuanWuName = shenGuiLuanWuName2;
            general.SetOnMagic(4);
            enemyGeneral.OnDamage(10, -1, false);
            break;

        case 2:
            shenGuiLuanWuName = shenGuiLuanWuName3;
            general.SetOnMagic(5);
            enemyGeneral.OnDamage(10, -1, false);
            break;

        case 3:
            shenGuiLuanWuName = shenGuiLuanWuName2;
            general.SetOnMagic(4);
            enemyGeneral.OnDamage(10, -1, false);
            break;

        case 4:
            shenGuiLuanWuName = shenGuiLuanWuName4;

            Invoke("WaitForMagicOver", 0.5f);
            break;
        }

        GameObject go = InstantiateOneGO(shenGuiLuanWuName, pos, scale, WarSceneController.manEulerAngles);

        go.GetComponent <MagicShenGuiLuanWuAct>().SetInfo(speed);

        InstantiateOneGO(explodeName, enemyGeneral.transform.localPosition, Vector3.one, Vector3.zero);

        step++;
    }
    IEnumerator ShowLightningStroke()
    {
        for (int i = 0; i < soliderHit.Count; i++)
        {
            soliderHit[i].OnDamage(-1, (WarSceneController.Direction)Random.Range(0, 2));

            GameObject go = (GameObject)Instantiate(Resources.Load(explodeName));
            go.transform.parent        = transform;
            go.transform.localPosition = soliderHit[i].transform.localPosition;
        }

        if (hitGeneral)
        {
            gCtrl.OnDamage(MagicController.Instance.GetMagicAttack(), -1, false);

            GameObject go = (GameObject)Instantiate(Resources.Load(explodeName));
            go.transform.parent        = transform;
            go.transform.localPosition = gCtrl.transform.localPosition;
        }

        for (int i = 0; i < listLightning.Count; i++)
        {
            listLightning[i].SetActive(true);
            if (i % 3 == 0)
            {
                yield return(new WaitForSeconds(0.1f));
            }
        }

        Invoke("WaitForMagicOver", 1f);
    }
Esempio n. 3
0
    IEnumerator ShowStones()
    {
        yield return(new WaitForSeconds(0.3f));

        gCtrl.OnDamage(MagicController.Instance.GetMagicAttack(), -1, false);

        for (int i = 0; i < listStones.Count; i++)
        {
            listStones[i].SetActive(true);

            GameObject go = (GameObject)Instantiate(Resources.Load(explodeName));
            go.transform.parent        = transform;
            go.transform.localPosition = listStones[i].transform.localPosition;

            Rect region = new Rect();
            region.x      = listStones[i].transform.localPosition.x - 60;
            region.y      = listStones[i].transform.localPosition.y - 60;
            region.width  = 120;
            region.height = 120;

            warCtrl.OnMagicHitChecking(side, 0, region, false);

            yield return(new WaitForSeconds(0.2f));
        }

        Invoke("WaitForMagicOver", 1);
    }
Esempio n. 4
0
    bool CheckDamage(WhichSide side, int gDamage, int gType, int type, Direction dir, int xS, int xE, int yPos, bool isFire)
    {
        int x = 0;
        int y = 0;

        if (side == WhichSide.Right)
        {
            for (int i = 0; i < leftSoliders.Count; i++)
            {
                x = leftSoliders[i].GetLocationX();
                y = leftSoliders[i].GetLocationY();
                if (y == yPos && x >= xS && x <= xE)
                {
                    leftSoliders[i].OnDamage(type, dir, isFire);
                }
            }

            x = GetLocationPositionX(leftGeneral.transform.localPosition.x);
            y = GetLocationPositionY(leftGeneral.transform.localPosition.y);

            if (y == yPos && x >= xS && x <= xE)
            {
                leftGeneral.OnDamage(gDamage, gType, isFire);
            }
        }
        else
        {
            for (int i = 0; i < rightSoliders.Count; i++)
            {
                x = rightSoliders[i].GetLocationX();
                y = rightSoliders[i].GetLocationY();
                if (y == yPos && x >= xS && x <= xE)
                {
                    rightSoliders[i].OnDamage(type, dir, isFire);
                }
            }

            x = GetLocationPositionX(rightGeneral.transform.localPosition.x);
            y = GetLocationPositionY(rightGeneral.transform.localPosition.y);
            if (y == yPos && x >= xS && x <= xE)
            {
                rightGeneral.OnDamage(gDamage, gType, isFire);
            }
        }

        return(false);
    }
Esempio n. 5
0
    IEnumerator ShowLightningStroke()
    {
        gCtrl.OnDamage(MagicManager.Instance.GetMagicDataInfo(15).ATTACK, -1, false);

        for (int i = 0; i < listLightning.Count; i++)
        {
            listLightning[i].SetActive(true);
            yield return(new WaitForSeconds(0.1f));
        }
        for (int i = 0; i < 5; i++)
        {
            GameObject go = (GameObject)Instantiate(Resources.Load(explodeName));
            go.transform.parent = transform;
            Vector3 pos = gCtrl.transform.localPosition;
            pos.x += Random.Range(-20, 20);
            pos.z += Random.Range(-20, 20);
            go.transform.localPosition = pos;
        }

        Invoke("WaitForMagicOver", 1f);
    }
Esempio n. 6
0
    // Update is called once per frame
    void Update()
    {
        if (state == 1)
        {
            Vector3 pos = arrow.transform.localPosition;
            pos.x += speed * Time.deltaTime;
            arrow.transform.localPosition = pos;

            if ((side == WarSceneController.WhichSide.Left && pos.x > enemyGeneral.transform.localPosition.x) ||
                (side == WarSceneController.WhichSide.Right && pos.x < enemyGeneral.transform.localPosition.x))
            {
                state = 0;
                Destroy(arrow);
                StartCoroutine(ShowArrowExplode());

                enemyGeneral.OnDamage(MagicController.Instance.GetMagicAttack(), -1, false);
            }
            else
            {
                warCtrl.SetCameraPosition(new Vector3(pos.x, -30, 0));
            }
        }
    }
Esempio n. 7
0
    // Update is called once per frame
    void Update()
    {
        timeTick += Time.deltaTime;
        if (timeTick < 0.5f)
        {
            if (side == WarSceneController.WhichSide.Left)
            {
                this.transform.localPosition += speedLeft * Time.deltaTime;
            }
            else
            {
                this.transform.localPosition += speedRight * Time.deltaTime;
            }
        }
        else
        {
            if (soliderCtrl != null)
            {
                soliderCtrl.OnDamage(-1, (WarSceneController.Direction)Random.Range(0, 2), isWithFire);
            }
            else if (generalCtrl != null)
            {
                int damage;
                if (!isWithFire)
                {
                    damage = MagicManager.Instance.GetMagicDataInfo(1).ATTACK;
                }
                else
                {
                    damage = MagicManager.Instance.GetMagicDataInfo(27).ATTACK;
                }
                generalCtrl.OnDamage(damage, -1, isWithFire);
            }

            Destroy(this.gameObject);
        }
    }
Esempio n. 8
0
    // Update is called once per frame
    void Update()
    {
        float deltaPos = speed * Time.deltaTime;

        if (state == 1)
        {
            cameraPos = new Vector3(cameraPos.x + deltaPos, cameraPos.y, 0);

            for (int i = 0; i < listMoon.Count; i++)
            {
                Vector3 pos = listMoon[i].transform.localPosition;
                pos.x += deltaPos;
                listMoon[i].transform.localPosition = pos;
            }

            if ((side == WarSceneController.WhichSide.Left && cameraPos.x > enemyGeneral.transform.localPosition.x) ||
                (side == WarSceneController.WhichSide.Right && cameraPos.x < enemyGeneral.transform.localPosition.x))
            {
                state = 2;
                Invoke("WaitForMagicOver", 1);

                enemyGeneral.OnDamage(MagicController.Instance.GetMagicAttack(), -1, false);
                listMoon[0].SetActive(false);

                for (int i = 1; i < listMoon.Count; i++)
                {
                    Rect region = new Rect();
                    if (side == WarSceneController.WhichSide.Left)
                    {
                        region.x = listMoon[i].transform.localPosition.x - 20;
                    }
                    else
                    {
                        region.x = listMoon[i].transform.localPosition.x - 180;
                    }
                    region.y      = listMoon[i].transform.localPosition.y - 15;
                    region.width  = 200;
                    region.height = 30;
                    warCtrl.OnMagicHitChecking(side, 0, region, false);
                }

                StartCoroutine(ShowArrowExplode());
            }
            else
            {
                warCtrl.SetCameraPosition(cameraPos);

                for (int i = 0; i < listMoon.Count; i++)
                {
                    Rect region = new Rect();
                    region.x      = listMoon[i].transform.localPosition.x;
                    region.y      = listMoon[i].transform.localPosition.y - 15;
                    region.width  = 20;
                    region.height = 30;
                    warCtrl.OnMagicHitChecking(side, 0, region, false);
                }
            }
        }
        else if (state == 2)
        {
            for (int i = 0; i < listMoon.Count; i++)
            {
                Vector3 pos = listMoon[i].transform.localPosition;
                pos.x += deltaPos;
                listMoon[i].transform.localPosition = pos;
            }
        }
    }
Esempio n. 9
0
    // Update is called once per frame
    void Update()
    {
        float deltaPos = speed * Time.deltaTime;

        if (state == 1)
        {
            for (int i = 0; i < listMan.Count; i++)
            {
                if (!listMan[i].activeSelf)
                {
                    break;
                }

                Vector3 pos = listMan[i].transform.localPosition;
                pos.x += deltaPos;
                listMan[i].transform.localPosition = pos;
            }

            cameraPos = new Vector3(listMan[4].transform.localPosition.x, -30, 0);

            if ((side == WarSceneController.WhichSide.Left && cameraPos.x > enemyGeneral.transform.localPosition.x) ||
                (side == WarSceneController.WhichSide.Right && cameraPos.x < enemyGeneral.transform.localPosition.x))
            {
                state = 2;
                Invoke("WaitForMagicOver", 1);

                listMan[0].SetActive(false);
                enemyGeneral.OnDamage(MagicManager.Instance.GetMagicDataInfo(40).ATTACK, -1, false);

                Rect region = new Rect();
                if (side == WarSceneController.WhichSide.Left)
                {
                    region.x = listMan[0].transform.localPosition.x - 20;
                }
                else
                {
                    region.x = listMan[0].transform.localPosition.x - 180;
                }
                region.y      = listMan[0].transform.localPosition.y - 20;
                region.width  = 200;
                region.height = 40;
                warCtrl.OnMagicHitChecking(side, 0, region, false);

                StartCoroutine(ShowArrowExplode());
            }
            else
            {
                warCtrl.SetCameraPosition(cameraPos);

                Rect region = new Rect();
                region.x      = listMan[0].transform.localPosition.x;
                region.y      = listMan[0].transform.localPosition.y - 20;
                region.width  = 20;
                region.height = 40;
                warCtrl.OnMagicHitChecking(side, 0, region, false);
            }
        }
        else if (state == 2)
        {
            for (int i = 0; i < listMan.Count; i++)
            {
                Vector3 pos = listMan[i].transform.localPosition;
                pos.x += deltaPos;
                listMan[i].transform.localPosition = pos;
            }
        }
    }