예제 #1
0
    //选取操作函数
    public void choose_operation()
    { //改变选定英雄动画to选定待定在状态。
        if (selected_hero)
        {
            selected_hero.GetComponent <HeroController>().AnimationPlayState(1);
        }
        this.gameObject.GetComponent <UIController>().operation_panel.SetActive(true);
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Input.GetMouseButtonDown(0) && Physics.Raycast(ray, out hit))
        {
            if (player_side == Player_side.player1 && hit.transform.tag == "Player1_hero")
            {
                selected_hero = hit.transform.gameObject;
                mainCamera.GetComponent <CameraController>().cameraMove(selected_hero.transform.position, 2.0f);
            }
            else if (player_side == Player_side.player2 && hit.transform.tag == "Player2_hero")
            {
                selected_hero = hit.transform.gameObject;
                mainCamera.GetComponent <CameraController>().cameraMove(selected_hero.transform.position, 2.0f);
            }
            else if (hit.transform.tag != "Operation_panle" && !HitTestUI())
            {
                selected_hero.GetComponent <HeroController>().AnimationPlayState(0);
                game_process  = Game_process.Choose_hero;
                selected_hero = null;           //置空选定英雄
                mainCamera.GetComponent <CameraController>().CameraPosReset();
                print("返回选取英雄阶段");
            }
        }
    }
예제 #2
0
 //等待函数
 void wait()
 {
     //当是自己的回合时,跳转到选择英雄阶段,否则禁用UI和GameManager的操作。
     if (networkPlayer == whosRound)
     {
         game_process = Game_process.Choose_hero;
     }
     else
     {
         allPanel.SetActive(false);
     }
 }
예제 #3
0
    //等待函数
    void wait()
    {
        ////当是自己的回合时,跳转到选择英雄阶段,否则禁用UI和GameController的操作。
        //if (networkPlayer == whosRound)
        //{
        game_process = Game_process.Choose_hero;
        //}
        //else
        //{
        //    allPanel.SetActive(false);

        //}
    }
예제 #4
0
    //选取英雄函数
    public void choose_hero()
    {
        if (selected_hero != null)
        {
            selected_hero.GetComponent <HeroController>().AnimationPlayState(0);
            selected_hero = null;
            mainCamera.GetComponent <CameraController>().CameraPosReset();
        }
        allPanel.SetActive(true);
        this.gameObject.GetComponent <UIController>().getAttackPower.SetActive(false);
        this.gameObject.GetComponent <UIController>().operation_panel.SetActive(false);
        Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
        RaycastHit hit;

        if (Input.GetMouseButtonDown(0) && Physics.Raycast(ray, out hit) && (hit.transform.tag == "Player1_hero" || hit.transform.tag == "Player2_hero"))
        {
            if (hit.transform.gameObject.GetComponent <HeroController>().is_attacked)
            {
                print("该英雄已经行动完毕");
            }
            else
            {
                selecteEffect.GetComponent <AudioSource>().Play();
                if (player_side == Player_side.player1)
                {
                    if (hit.transform.tag == "Player1_hero")
                    {
                        selected_hero = hit.transform.gameObject;
                        //camMover.Follow(selected_hero.transform);
                        mainCamera.GetComponent <CameraController>().cameraMove(selected_hero.transform.position, 2.0f);
                        print("你选的是玩家1的英雄");
                        print("可移动格数:" + Convert.ToInt32(waterPower / selected_hero.gameObject.GetComponent <HeroController>().run_power));
                        game_process = Game_process.Choose_operation;
                    }
                }
                else
                {
                    if (hit.transform.tag == "Player2_hero")
                    {
                        selected_hero = hit.transform.gameObject;
                        mainCamera.GetComponent <CameraController>().cameraMove(selected_hero.transform.position, 2.0f);
                        print("你选的是玩家2的英雄");
                        game_process = Game_process.Choose_operation;
                    }
                }
            }
        }
    }
예제 #5
0
 //攻击函数
 public void getAttackAngel()
 {
     if (selected_hero.GetComponent <HeroController>().is_attacked == false)
     {
         selected_hero.GetComponent <HeroController>().ShowAttackAngel();
         if (Input.GetMouseButtonDown(0))
         {
             selected_hero.GetComponent <HeroController>().attackForwardRspeed = 0;
             angleY = selected_hero.GetComponent <HeroController>().attackForward.transform.eulerAngles.y;
             attackForwardEulerAngles = selected_hero.GetComponent <HeroController>().attackForward.transform.eulerAngles;
             string heroName = selected_hero.name.Substring(0, selected_hero.tag.Length - 1 - 6);//-6 = (clone)
             if (heroName == "Sword")
             {
                 //剑士直接攻击
                 if (GameController.player_side == GameController.Player_side.player1)
                 {
                     selected_hero.GetComponent <HeroController>().Chop("Team2", attackForwardEulerAngles);
                     selected_hero.transform.eulerAngles = new Vector3(0, attackForwardEulerAngles.y, 0);//英雄转向箭头方向
                     selected_hero.GetComponent <HeroController>().AnimationPlayState(3);
                     selected_hero.GetComponent <HeroController>().attackAudioPlay();
                 }
                 else if (GameController.player_side == GameController.Player_side.player2)
                 {
                     selected_hero.GetComponent <HeroController>().Chop("Team1", attackForwardEulerAngles);
                     selected_hero.transform.eulerAngles = new Vector3(0, attackForwardEulerAngles.y + 180.0f, 0);//英雄转向箭头方向
                     selected_hero.GetComponent <HeroController>().AnimationPlayState(3);
                     selected_hero.GetComponent <HeroController>().attackAudioPlay();
                 }
                 selected_hero.GetComponent <HeroController>().HideAttackAngel();//隐藏攻击显示的范围
                 selected_hero.GetComponent <HeroController>().is_attacked = true;
                 //HeroTurnToFront();//英雄转向对面
                 game_process = Game_process.Choose_hero;
             }
             else
             {
                 //其它英雄出现蓄力槽
                 game_process = Game_process.GetAttackPower;
             }
         }
     }
 }
예제 #6
0
 void MoveToNode()
 {
     if (pointi < pathArray.Count)
     {
         iTween.MoveTo(selected_hero, iTween.Hash(
                           "position", wayPoints[pointi],
                           //"path", wayPoints,
                           "time", 0.2f,
                           "easetype", "linear",
                           "movetopath", true,
                           "looktarget", wayPoints[pointi],
                           "oncomplete", "MoveToNode",
                           "oncompletetarget", this.gameObject
                           ));
         pointi++;
         mainCamera.GetComponent <CameraController>().cameraMove(selected_hero.transform.position, 0.2f);
     }
     else
     {//英雄转向对面
         HeroTurnToFront();
         game_process = Game_process.Choose_operation;
     }
 }
예제 #7
0
    //移动函数
    public void move()
    {
        if (!selected_hero.gameObject.GetComponent <HeroController>().is_moved)
        {
            //GridManager.instance.ClearAllObstacle();//清除障碍物
            GridManager.instance.findObstacleAndCalculateWaterPower();//刷新障碍物
            //显示可移动范围
            Node heroNode = new Node(selected_hero.transform.position);
            distance = AStar.checkDistance(heroNode, (int)(waterPower / selected_hero.gameObject.GetComponent <HeroController>().run_power));
            for (int i = 0; i < distance.Count; i++)
            {
                int        row     = GridManager.instance.GetRow(GridManager.instance.GetGridIndex(((Node)distance[i]).position)) + 1;
                int        col     = GridManager.instance.GetColumn(GridManager.instance.GetGridIndex(((Node)distance[i]).position)) + 1;
                GameObject theCube = GameObject.Find("Cube " + row + col);
                theCube.gameObject.GetComponent <MeshRenderer>().enabled = true;
            }
            //射线
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Input.GetMouseButtonDown(0) && Physics.Raycast(ray, out hit))
            {
                print(1);
                //目标位置gameobject类型
                goal_position = hit.transform.gameObject;
                //目标位置node类型
                Node goalNode = new Node(goal_position.transform.position);
                //if (hit.transform.tag != "Obstacle")
                if (!GridManager.instance.IsObstacle(GridManager.instance.CalculateAtNodes(goalNode)))
                {
                    print(2);
                    int moveDistance = FindPathAndReturnDistance();
                    if (moveDistance * selected_hero.gameObject.GetComponent <HeroController>().run_power > waterPower)
                    {
                        print("圣水不足");
                        game_process = Game_process.Choose_operation;
                    }
                    else
                    {
                        print(3);
                        selected_hero.GetComponent <HeroController>().AnimationPlayState(3);
                        //开始移动
                        MoveToNode();

                        print("选择位置成功");
                        //camMover.Follow(goal_position.transform);
                        selected_hero.gameObject.GetComponent <HeroController>().is_moved = true;
                        waterPower -= moveDistance * selected_hero.gameObject.GetComponent <HeroController>().run_power;
                    }
                    //取消移动显示范围
                    for (int i = 0; i < distance.Count; i++)
                    {
                        int        row     = GridManager.instance.GetRow(GridManager.instance.GetGridIndex(((Node)distance[i]).position)) + 1;
                        int        col     = GridManager.instance.GetColumn(GridManager.instance.GetGridIndex(((Node)distance[i]).position)) + 1;
                        GameObject theCube = GameObject.Find("Cube " + row + col);
                        theCube.gameObject.GetComponent <MeshRenderer>().enabled = false;
                    }
                }
                //爆炸点
                else
                {
                    print("该单元格为障碍物,无法到达!");
                    //取消攻击显示范围
                    for (int i = 0; i < distance.Count; i++)
                    {
                        int        row     = GridManager.instance.GetRow(GridManager.instance.GetGridIndex(((Node)distance[i]).position)) + 1;
                        int        col     = GridManager.instance.GetColumn(GridManager.instance.GetGridIndex(((Node)distance[i]).position)) + 1;
                        GameObject theCube = GameObject.Find("Cube " + row + col);
                        theCube.gameObject.GetComponent <MeshRenderer>().enabled = false;
                    }
                    game_process = Game_process.Choose_operation;
                }
            }
        }
    }