コード例 #1
0
ファイル: FightManager.cs プロジェクト: yashgandhe666/RPG
    private void Start()
    {
        currentAttackerIndex        = 0;
        whoseAttackingTurn          = WhoseTurn.None;
        isFightStart                = false;
        delayTime                   = 1f;
        delayInAttackTimer          = delayTime;
        addEnemyButton              = CanvasUIHandler.Instance.FightUIPanel.transform.Find("AddButton").GetComponent <Button>();
        attackButton                = CanvasUIHandler.Instance.FightUIPanel.transform.Find("AttackButton").GetComponent <Button>();
        cancelButton                = CanvasUIHandler.Instance.FightUIPanel.transform.Find("NameAndIcon").Find("CancelButton").GetComponent <Button>();
        attackButton.interactable   = false;
        addEnemyButton.interactable = true;
        addEnemyButton.onClick.AddListener(AddEnemyOnScene);
        attackButton.onClick.AddListener(ArrangeAttackersInOrder);
        cancelButton.onClick.AddListener(CancelAttack);
        Enemy[] enemy = Resources.LoadAll <Enemy>("Prefabs/Characters/");
        foreach (var e in enemy)
        {
            enemiesPrefabs.Add(e.gameObject);
        }
        Debug.Log("enemies prefabs count : " + enemiesPrefabs.Count);

        foreach (Player item in GameManager.Instance.Players)
        {
            if (item.gameObject.activeSelf)
            {
                currentActivePlayers.Add(item);
            }
        }
    }
コード例 #2
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (roomInfo_ != null)
            {
                hash ^= RoomInfo.GetHashCode();
            }
            hash ^= cards_.GetHashCode();
            hash ^= playerInfos_.GetHashCode();
            if (RoomState != 0)
            {
                hash ^= RoomState.GetHashCode();
            }
            if (WhoseTurn != 0)
            {
                hash ^= WhoseTurn.GetHashCode();
            }
            if (LeftCardCount != 0)
            {
                hash ^= LeftCardCount.GetHashCode();
            }
            if (LeftTurnTime != 0F)
            {
                hash ^= LeftTurnTime.GetHashCode();
            }
            if (LastPlayedCardId != 0)
            {
                hash ^= LastPlayedCardId.GetHashCode();
            }
            return(hash);
        }
コード例 #3
0
    void SetTurn(WhoseTurn player)
    {
        currentPlayer = player;
        switch (player)
        {
        case WhoseTurn.p1:
            // Player manually inputs die roll.
            canReroll = true;
            break;

        case WhoseTurn.p2:
            StartCoroutine(RollDie());
            break;

        case WhoseTurn.p3:
            StartCoroutine(RollDie());
            break;

        case WhoseTurn.p4:
            StartCoroutine(RollDie());
            break;

        case WhoseTurn.end:
            StartCoroutine(PrepareEnd());
            break;
        }
    }
コード例 #4
0
ファイル: Dice.cs プロジェクト: TNathanCT/Unity-Games
    //Use a coroutine for the gameplay.
    private IEnumerator RollTheDice()
    {
        coroutineAllowed = false;
        int randomDiceSide = 0;

        for (int i = 0; i <= 20; i++)
        {
            //roll the dice twenty times and reveal a random side of the dice, while playing and audio.
            randomDiceSide = Random.Range(0, 6);
            rend.sprite    = diceSides[randomDiceSide];
            yield return(new WaitForSeconds(0.01f));

            GetComponent <AudioSource>().Play();
        }

        GameControl.diceSideThrown = randomDiceSide + 1;


        //This will setup the turns after throwing. If it's not 6, change the turn, if it is 6, play again
        if (randomDiceSide == 5)
        {
            if (turn == WhoseTurn.PLAYER)
            {
                GameControl.MovePlayer(1);
                yield return(new WaitForSeconds(3.5f));

                turn = WhoseTurn.PLAYER;
            }


            else if (turn == WhoseTurn.AI)
            {
                GameControl.MovePlayer(2);
                yield return(new WaitForSeconds(3.5f));

                turn = WhoseTurn.AI;
            }
            coroutineAllowed = true;
        }
        else
        {
            if (turn == WhoseTurn.PLAYER)
            {
                GameControl.MovePlayer(1);
                yield return(new WaitForSeconds(3.5f));

                turn = WhoseTurn.AI;
            }
            else if (turn == WhoseTurn.AI)
            {
                GameControl.MovePlayer(2);
                yield return(new WaitForSeconds(3.5f));

                turn = WhoseTurn.PLAYER;
            }
        }

        coroutineAllowed = true;
    }
コード例 #5
0
            public CharacterSet(int hitPoints, int damage)
            {
                Boss   = new Character(hitPoints, damage, 0, 0);
                Player = new Character(50, 0, 0, 500);

                // set to boss first, so first turn will switch to player
                WhoseTurn = WhoseTurn.BossTurn;
            }
コード例 #6
0
ファイル: Dice.cs プロジェクト: TNathanCT/Unity-Games
 private void Start()
 {
     //We want the player to start.
     turn = WhoseTurn.PLAYER;
     rend = GetComponent <SpriteRenderer>();
     //Where can we find the dice sprites?
     diceSides   = Resources.LoadAll <Sprite>("DiceSides/");
     rend.sprite = diceSides[5];
 }
コード例 #7
0
 public GameStatus MakeMove(Player player, int x, int y)
 {
     if (IsValid(x, y))
     {
         _board[x, y] = player.Id == Player1.Id ? "X" : "O";
         WhoseTurn    = WhoseTurn.Equals(Player1) ? Player2 : Player1;
         return(CheckWin());
     }
     return(GameStatus.InvalidMove);
 }
コード例 #8
0
ファイル: Attacks.cs プロジェクト: robinfriedmr/Chef
    private void Start()
    {
        _wt    = GetComponent <WhoseTurn>();
        moving = false;

        chefAttackMenu.SetActive(false);
        dGMoveMenu.SetActive(false);

        moveOffset = new Vector3(0.75f, 0, -0.1f);

        turnTakerStats = Object.FindObjectsOfType <TurnTakerStats>();
    }
コード例 #9
0
            public void DoNextTurn(bool partB)
            {
                WhoseTurn = WhoseTurn == WhoseTurn.PlayerTurn ? WhoseTurn.BossTurn : WhoseTurn.PlayerTurn;

                Player.ResetTurn();
                Boss.ResetTurn();

                if (partB && WhoseTurn == WhoseTurn.PlayerTurn)
                {
                    Player.HitPoints--;
                }
            }
コード例 #10
0
        public override int GetHashCode()
        {
            int hash = 1;

            if (State != 0)
            {
                hash ^= State.GetHashCode();
            }
            if (WhoseTurn != 0)
            {
                hash ^= WhoseTurn.GetHashCode();
            }
            if (LeftCardCount != 0)
            {
                hash ^= LeftCardCount.GetHashCode();
            }
            return(hash);
        }
コード例 #11
0
ファイル: FightManager.cs プロジェクト: yashgandhe666/RPG
    public IFighter WhoseTurnToAttack()
    {
        if (attackersInOrder.Count == 0)
        {
            whoseAttackingTurn = WhoseTurn.None;
            return(null);
        }

        currentAttackerIndex = (currentAttackerIndex + 1) % attackersInOrder.Count;

        IFighter fighter = attackersInOrder[currentAttackerIndex];

        if (fighter.typeOfFighter == TypeOfFighter.Player)
        {
            whoseAttackingTurn = WhoseTurn.Player;
        }
        else
        {
            whoseAttackingTurn = WhoseTurn.Enemy;
        }

        return(fighter);
    }