Beispiel #1
0
    // Update is called once per frame
    void Update()
    {
        /*
         * if (Input.GetKeyDown(KeyCode.S))
         * {
         *  StartCoroutine(Getcard(2));
         * }
         */

        /****文本标记维护****/
        //cardHeapCountText = GameObject.Find("cardHeap").GetComponent<Text>();
        if (!!cardHeapCountText)
        {
            cardHeapCountText.text = CardHeapList.Count.ToString();
        }

        if (!!cardHeapCountText)
        {
            distanceText.text = "距离:" + playerSelf.GetComponent <effect_self>().Distance().ToString();
        }

        /***弃牌阶段侦听***/
        if (myState == GameStageSate.DisCardWait && CardList.Count <= 2)
        {
            ButtonDisable();
            myState = GameStageSate.EnemyPrepare;
            //break;
        }

        App();
    }
Beispiel #2
0
    public float posOffset = 2.2f; //卡片偏移



    void Awake()
    {
        CardNames    = GetCardNames();
        CardHeapList = CardNames;
        //Debug.Log(cardNames.Join(","));

        myState = GameStageSate.begin;//置为开始阶段;
    }
Beispiel #3
0
    //获得卡牌即摸牌
    public IEnumerator Getcard(int Num)
    {
        //进入发牌阶段
        //cardManagerState = CardManagerStates.DealCards;

        //显示牌堆
        //heapPos.gameObject.SetActive(true);

        //从牌堆中取出制定数量的牌,
        //维护牌堆列表
        //播放相应动画
        DestroyAllCards();

        CardHeapNum = CardHeapList.Count();
        for (int i = CardHeapNum - 1; i >= CardHeapNum - Num; i--)
        {
            string cardName = CardHeapList[i];

            //给当前玩家发一张牌
            //playerSelf.GetComponent<player>().AddCard(cardName);
            AddCard(cardName);
            CardHeapList.RemoveAt(i);


            var cover = Instantiate(coverPrefab, heapPos.position, Quaternion.identity, heapPos.parent.transform);
            //cover.GetComponent<RectTransform>().position = heapPos.position;//暂时的处理方法
            cover.GetComponent <RectTransform>().localScale = Vector3.one;
            covers.Add(cover);
            iTween.MoveTo(cover, playerHeapPos.position, 0.3f);

            yield return(new WaitForSeconds(1 / dealCardSpeed));
        }

        //隐藏牌堆
        //heapPos.gameObject.SetActive(false);
        //playerHeapPos.gameObject.SetActive(false);

        //动画结束,进入叫牌阶段
        yield return(new WaitForSeconds(1f));

        covers.ForEach(Destroy);
        covers.Clear();


        //显示玩家手牌
        if (playerSelf != null)
        {
            //playerSelf.GetComponent<player>().GenerateAllCards();
            GenerateAllCards(true);
        }
        //cardManagerState = CardManagerStates.Bid;

        //摸牌后进入准备阶段
        myState = GameStageSate.playerPrepare;
    }
Beispiel #4
0
    public IEnumerator JumpEnemy()
    {
        for (int i = 0; i < 2; i++)
        {
            iTween.MoveTo(enmey, enmey.transform.position + Vector3.up * 32f, 0.4f);
            //iTween.MoveTo(enmey, enmey.transform.position + Vector3.up * 10f, 0.2f);
            yield return(new WaitForSeconds(0.1f));

            //iTween.MoveTo(enmey, enmey.transform.position - Vector3.up * 10f, 0.2f);

            iTween.MoveTo(enmey, enmey.transform.position - Vector3.up * 32f, 0.4f);
            yield return(new WaitForSeconds(0.1f));
        }
        myState = GameStageSate.EnemyEnd;
    }
Beispiel #5
0
    /*
     * GameObject card01;
     * //public Transform card01;//意图表示第一张牌的位置
     *
     * //public Transform card02;
     *
     * public GameObject cardsprefab;
     *
     * public float thedistance=45;//两张牌的距离
     */

    // Use this for initialization
    void Start()
    {
        /******预制件加载***********/
        prefab      = (GameObject)Resources.Load("prefab/cardPrefab");
        coverPrefab = (GameObject)Resources.Load("prefab/coverPrefab");

        /********对象加载******/
        playerSelf = GameObject.Find("self");
        enmey      = GameObject.Find("Enemy");
        btnPanel   = GameObject.Find("BtnPanel");
        //ensureBtn = GameObject.Find("UseCardBtn");
        gameFunc      = GameObject.Find("GameManager");
        dataManager   = GameObject.Find("DataManager");
        RecordManager = GameObject.Find("RecordManager");

        /************位置加载**************/
        //originPos1 = GameObject.Find("CardPanel").GetComponent<RectTransform>();
        heapRectTrans      = GameObject.Find("cardHeap").GetComponent <RectTransform>();
        CardPanelRectTrans = GameObject.Find("CardPanel").GetComponent <RectTransform>();

        /*********文本组件加载*********/
        cardHeapCountText  = GameObject.Find("cardHeapText").GetComponent <Text>();
        gameStageStateText = GameObject.Find("GameStageText").GetComponent <Text>();
        distanceText       = GameObject.Find("DistanceText").GetComponent <Text>();
        roundCountText     = GameObject.Find("RoundCountText").GetComponent <Text>();

        /*
         * GameObject card = (GameObject)Resources.Load("prefab/cardPre");
         * card01 = Instantiate(card);
         *
         * Debug.Log("create sucess!");
         * GameObject mUICanvas = GameObject.Find("CardPanel");
         * card01.transform.parent = mUICanvas.transform;
         * CardList.Add(card01);
         */

        //OnTestClick();

        //初始化
        CardNames    = GetCardNames();
        CardHeapList = CardNames;
        //Debug.Log(cardNames.Join(","));

        myState = GameStageSate.begin;//置为开始阶段;

        //隐藏不必要按键
        ButtonDisable();
    }
Beispiel #6
0
 public void LoadState()
 {
     Debug.Log("执行LoadState");
     myState = myState = GameStageSate.playerAction;
     Debug.Log("执行完毕");
 }
Beispiel #7
0
    /// <summary>
    /// 发牌
    /// </summary>
    //获得卡牌即摸牌
    public IEnumerator DealCard(int Num, int flag = 2)
    {
        //yield return OtherCoroutine();

        float speed = 1f;


        //从牌堆中取出制定数量的牌,
        //维护牌堆列表
        //播放相应动画
        // DestroyAllCards();
        if (Num > CardHeapList.Count)
        {
            ShuffleCards();
        }


        //记录摸牌前牌数
        int cardnum_before = CardList.Count;

        Debug.Log(cardnum_before);

        //重新计算每张牌的偏移
        offsetX = CardPanelRectTrans.rect.width / (CardList.Count() + Num);

        offsetX = Mathf.Min(offsetX, prefabWidth);


        int card_index = 0;

        //按新的偏移调整之前的牌
        for (; card_index < cardnum_before; card_index++)
        {
            var targetPos = CardPanelRectTrans.position + Vector3.right * offsetX * card_index;
            cards[card_index].transform.SetAsLastSibling();
            iTween.MoveTo(cards[card_index], targetPos, speed);
            yield return(new WaitForSeconds(1 / dealCardSpeed));
        }

        //Debug.Log(offsetX); Debug.Log("offsetX00000");

        //从牌堆中取牌
        CardHeapNum = CardHeapList.Count();
        for (int i = CardHeapNum - 1; i >= CardHeapNum - Num; i--)
        {
            string cardName = CardHeapList[i];

            //给当前玩家发一张牌
            //playerSelf.GetComponent<player>().AddCard(cardName);
            AddCard(cardName);
            CardHeapList.RemoveAt(i);
        }

        //动画摸牌起点
        var startPos = heapRectTrans.position;

        //新加入牌的位置调整
        for (; card_index < CardList.Count(); card_index++)
        {
            speed = 1f;
            //生成卡牌
            var card = Instantiate(prefab, startPos, Quaternion.identity, CardPanelRectTrans.transform); // TODO: need to fix
            card.GetComponent <RectTransform>().position   = startPos;                                   //暂时的处理方法
            card.GetComponent <RectTransform>().localScale = Vector3.one * 0.5f;
            card.GetComponent <card>().InitImage(CardList[card_index], dataManager.GetComponent <DataManager>().Search(CardList[card_index]));

            //移动和放大
            //offsetX = card.GetComponent<RectTransform>().rect.width;// * posOffset;
            var targetPos = CardPanelRectTrans.position + Vector3.right * offsetX * card_index;
            card.transform.SetAsLastSibling();
            //Debug.Log(offsetX);
            //Debug.Log("offsetX11111");
            //动画移动
            iTween.MoveTo(card, targetPos, speed);
            card.GetComponent <RectTransform>().localScale = Vector3.one * 1f;
            card.transform.parent.SetParent(CardPanelRectTrans.transform);
            cards.Add(card);

            yield return(new WaitForSeconds(1 / dealCardSpeed));
        }



        //隐藏牌堆
        //heapRectTrans.gameObject.SetActive(false);
        //CardPanelRectTrans.gameObject.SetActive(false);

        //动画结束,进入叫牌阶段
        yield return(new WaitForSeconds(0.5f));

        //covers.ForEach(Destroy);
        //covers.Clear();


        //显示玩家手牌

        /*
         * if (playerSelf != null)
         * {
         *  //playerSelf.GetComponent<player>().GenerateAllCards();
         *  GenerateAllCards(true);
         * }
         */
        //cardManagerState = CardManagerStates.Bid;

        //摸牌后检查牌堆是否该洗牌
        if (CardHeapList.Count == 0)
        {
            ShuffleCards();
        }

        //摸牌后进入准备阶段
        if (flag == 0)
        {
            myState = GameStageSate.playerPrepare;
        }
        else if (flag == 1)
        {
            myState = GameStageSate.playerGetCard;
        }
    }
Beispiel #8
0
    public void App()
    {
        /****游戏阶段逻辑顺序****/
        /************* 游戏准备阶段*****************/
        if (myState == GameStageSate.begin)
        {
            if (main.LoadData)
            {
                Debug.Log("开始读档");
                if (RecordManager.GetComponent <OperateRecord>().ReadDataRecord())
                {
                    return;
                }
                else
                {
                    myState = GameStageSate.AllWait;
                }
                Debug.Log("读档完毕");
            }
            myState = GameStageSate.AllWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "游戏开始";
            }


            OnBegin();//牌的处理函数
            //myState = GameStageSate.playerGetCard; 在DealCard 函数结尾
        }

        /****************己方回合****************/

        else if (myState == GameStageSate.playerGetCard)
        {
            myState = GameStageSate.AllWait;

            Debug.Log("state" + playerSelf.GetComponent <effect_self>().state);
            gameFunc.GetComponent <gameManager>().state_judge();
            //UI刷新待加入
            round += 1;
            roundCountText.text = "第" + round.ToString() + "回合"; //回合数文本刷新

            if (!!gameStageStateText)                            //游戏阶段文本刷新
            {
                gameStageStateText.text = "摸牌阶段";
            }
            //行动力刷新
            playerSelf.GetComponent <effect_self>().IncreaseMoveEnergy(1);

            //洗牌
            if (CardHeapList.Count < 2)
            {
                ShuffleCards();
            }
            StartCoroutine(Getcard(2, 1));//摸牌
            //myState = GameStageSate.playerPrepare; 在GetCard 函数结尾
        }
        else if (myState == GameStageSate.playerPrepare)
        {
            myState = GameStageSate.AllWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "准备阶段";
            }
            //TODO:状态调整
            myState = GameStageSate.playerAction; //待加入到函数结尾
        }
        else if (myState == GameStageSate.playerAction)
        {
            myState = GameStageSate.Wait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "行动阶段";
            }


            ButtonEnable(); //显示按钮
                            //进行众多卡牌操作


            //TODO:增加结束按钮来进入下一阶段
            //myState = GameStageSate.playerEnd  加入到结束按钮中  finish  *****not work*****
        }
        else if (myState == GameStageSate.playerEnd)
        {
            myState = GameStageSate.DisCardWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "结束阶段";
            }

            ButtonForDiscard();
            //弃牌 待加入  即使用牌直到牌等于两张
            //TODO:写一个弃牌函数  弃牌函数结尾进入下一阶段敌人准备阶段

            //ButtonDisable();
            //myState = GameStageSate.EnemyPrepare; //待加入到函数结尾
        }

        /*****************敌人回合*********************/
        else if (myState == GameStageSate.EnemyPrepare)
        {
            myState = GameStageSate.AllWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "敌方回合";
            }

            myState = GameStageSate.EnemyAction; //待加入到函数结尾
        }
        else if (myState == GameStageSate.EnemyAction)
        {
            myState = GameStageSate.AllWait;

            /**************TODO:增加敌人动作演示*****************/
            if (playerHealth == 1)
            {
                gameFunc.GetComponent <gameManager>().boss1_func();
            }
            else
            {
                gameFunc.GetComponent <gameManager>().boss2_func();
            }
            playerSelf.GetComponent <effect_self>().TakeDamage(3);
            //playerSelf.GetComponent<effect_self>().AddselfBlood(-1);

            //StartCoroutine(JumpEnemy());
            /*****************************/
            myState = GameStageSate.EnemyEnd; //加入到jump函数结尾
        }
        else if (myState == GameStageSate.EnemyEnd)
        {
            myState = GameStageSate.AllWait;

            myState = GameStageSate.playerGetCard;//待加入到函数结尾
        }
    }
Beispiel #9
0
    public void App()
    {
        /****游戏阶段逻辑顺序****/
        /************* 游戏准备阶段*****************/
        if (myState == GameStageSate.begin)
        {
            myState = GameStageSate.AllWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "游戏开始";
            }


            OnBegin();//牌的处理函数
            //myState = GameStageSate.playerGetCard; 在DealCard 函数结尾
        }

        /****************己方回合****************/

        else if (myState == GameStageSate.playerGetCard)
        {
            myState = GameStageSate.AllWait;

            //UI刷新待加入
            round += 1;
            roundCountText.text = "第" + round.ToString() + "回合"; //回合数文本刷新

            if (!!gameStageStateText)                            //游戏阶段文本刷新
            {
                gameStageStateText.text = "摸牌阶段";
            }
            //行动力刷新
            playerSelf.GetComponent <effect_self>().IncreaseMoveEnergy(1);

            //洗牌
            if (CardHeapList.Count < 2)
            {
                ShuffleCards();
            }
            StartCoroutine(Getcard(2));//摸牌
            //myState = GameStageSate.playerPrepare; 在GetCard 函数结尾
        }
        else if (myState == GameStageSate.playerPrepare)
        {
            myState = GameStageSate.AllWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "准备阶段";
            }
            //TODO:状态调整
            myState = GameStageSate.playerAction; //待加入到函数结尾
        }
        else if (myState == GameStageSate.playerAction)
        {
            myState = GameStageSate.Wait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "行动阶段";
            }


            ButtonEnable(); //显示按钮
                            //进行众多卡牌操作


            //TODO:增加结束按钮来进入下一阶段
            //myState = GameStageSate.playerEnd  加入到结束按钮中  finish  *****not work*****
        }
        else if (myState == GameStageSate.playerEnd)
        {
            myState = GameStageSate.DisCardWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "结束阶段";
            }

            ButtonForDiscard();
            //弃牌 待加入  即使用牌直到牌等于两张
            //TODO:写一个弃牌函数  弃牌函数结尾进入下一阶段敌人准备阶段

            //ButtonDisable();
            //myState = GameStageSate.EnemyPrepare; //待加入到函数结尾
        }

        /*****************敌人回合*********************/
        else if (myState == GameStageSate.EnemyPrepare)
        {
            myState = GameStageSate.AllWait;
            //UI刷新待加入
            if (!!gameStageStateText)//游戏阶段文本刷新
            {
                gameStageStateText.text = "敌方回合";
            }

            myState = GameStageSate.EnemyAction; //待加入到函数结尾
        }
        else if (myState == GameStageSate.EnemyAction)
        {
            myState = GameStageSate.AllWait;

            /**************TODO:增加敌人动作演示*****************/
            playerSelf.GetComponent <effect_self>().TakeDamage(1);
            playerSelf.GetComponent <effect_self>().AddselfBlood(-1);

            StartCoroutine(JumpEnemy());
            /*****************************/
            //myState = GameStageSate.EnemyEnd; //加入到jump函数结尾
        }
        else if (myState == GameStageSate.EnemyEnd)
        {
            myState = GameStageSate.AllWait;

            myState = GameStageSate.playerGetCard;//待加入到函数结尾
        }
    }