Exemplo n.º 1
0
        public bool IsLater(DateTime time, string name, int index, DateTime date)
        {
            if (is_offday(date.Day))
            {
                return(false);
            }

            TimeSpan start    = new TimeSpan(time.Hour, time.Minute, time.Second);
            TimeSpan span     = new TimeSpan(9, 35, 0);
            TimeSpan span_tmp = new TimeSpan(10, 0, 5);

            if (index == 0)
            {
                return(start > span);
            }
            else
            {
                player_info info = dic_all_player[name];
                bool        t    = info.date_info[index - 1].is_workday && info.date_info[index - 1].is_allowance;
                if (t)
                {
                    return(start > span_tmp);
                }
                else
                {
                    return(start > span);
                }
            }
        }
Exemplo n.º 2
0
 public FSMState(AIController aiCtrl)
 {
     this.aiCtrl       = aiCtrl;
     this.timer        = aiCtrl.wanderTimer;
     this.wanderRadius = aiCtrl.wanderRadius;
     this.p            = aiCtrl.p;
 }
Exemplo n.º 3
0
 public void avoid(player_info player) //回避
 {
     if (player.delendurance(2))
     {
         player.Isavoid = true;
     }
 }
Exemplo n.º 4
0
    public void Init()
    {
#if CWSDK
        CWSdkPubmeth.GetSdk.Init();
#endif

        GameObject plan   = GameObject.Find("Plane");
        Vector3    length = plan.GetComponent <MeshFilter>().mesh.bounds.size;
        xlength = length.x * plan.transform.lossyScale.x;
        ylength = length.z * plan.transform.lossyScale.z;
        Debug.Log($"地图的尺寸为  x:{xlength}  y:{ylength}");


        m_main  = GameObject.Find("Main Camera").GetComponent <Camera>();
        npcroot = GameObject.Find("NPC_Root");
        UIMgr.Instance.Init(GameObject.Find("UIRoot"), GameObject.Find("HUD"));


        player_info info = new player_info();
        info.ID      = 0;
        info.m_name  = "tony";
        info.m_level = 9;
        info.m_pos   = Vector3.zero;
        info.m_res   = "Teddy";
        info.m_HP    = 2000;
        info.m_MP    = 1000;
        info.m_hpMax = 2000;
        info.m_mpMax = 2000;

        //===技能解析读取   已取出单独解析
        //info.skillList =

        m_plyer = new HostPlayer(info);
        m_plyer.CreateObj(MonsterType.Null);
        JoyStickMgr.Instance.SetJoyArg(m_main, m_plyer);
        JoyStickMgr.Instance.JoyActive = true;

        CreateIns();

        MsgCenter.Instance.AddListener("AutoMove", (notify) =>
        {
            this.AutoMoveByInsId((int)notify.data[0], (Vector3)notify.data[1]);
        });

        MsgCenter.Instance.AddListener("AddBuff", (notify) =>
        {
            int insid    = (int)notify.data[0];
            int buffid   = (int)notify.data[1];
            ObjectBase p = m_insDic[insid];
            if (p is PlayerObj)
            {
                BuffSystem.Instance.AddBuff(p as PlayerObj, buffid);
            }
        });

        MsgCenter.Instance.AddListener("ReMoveBuff", (notify) =>
        {
        });
    }
Exemplo n.º 5
0
 public void s_defend(player_info player, int addnum)//防御
 {
     if (player.delendurance(2))
     {
         player.adddefence(addnum);
     }
     p_anima.SetTrigger("HorAtk");
 }
Exemplo n.º 6
0
    private void OnTriggerEnter(Collider other)
    {
        player_info player = other.GetComponent <player_info>();

        if (player != null)
        {
            player.Hurt(damage);
        }
        Destroy(this.gameObject);
    }
Exemplo n.º 7
0
        private void listView1_SelectedIndexChanged(object sender, EventArgs e)
        {
            if (this.listView1.SelectedItems.Count > 0)
            {
                this.groupBox1.Text = this.listView1.SelectedItems[0].Text;

                player_info info = dic_all_player[this.listView1.SelectedItems[0].Text];
                InitPlayerDetail(info);
            }
        }
Exemplo n.º 8
0
 public void s_heal(player_info player, int addnum)//加血
 {
     if (player.delendurance(3))
     {
         if (player.Health <= player.Maxhp)
         {
             int num = player.Maxhp - addnum;
             player.addhp(num);
         }
     }
 }
Exemplo n.º 9
0
    void Start()
    {
        string scenename = SceneManager.GetActiveScene().name; // get current loaded scene and get parent of pills

        versionnumber    = "pre alpha 0.5";
        versiontext.text = versionnumber;

        if (scenename == "Main Menu")
        {
            currentparent = BackgroundAnimation.Instance.menupills;
        }
        else
        {
            currentparent = GameManager.Instance.pillsparent;
        }

        jsonString          = GetJsonDataByPlatform("/MenuJson/classic_levels_info.json", "read");
        classic_levels_info = JsonHelper.FromJson <levels_info>(jsonString);

        jsonString         = GetJsonDataByPlatform("/MenuJson/custom_levels_info.json", "read");
        custom_levels_info = JsonHelper.FromJson <levels_info>(jsonString);

        jsonString  = GetJsonDataByPlatform("/MenuJson/player_info.json", "read");
        player_data = JsonUtility.FromJson <player_info>(jsonString);

        audiomixer.SetFloat("MasterVol", player_data.masterslider);
        audiomixer.SetFloat("MusicVol", player_data.musicslider);
        audiomixer.SetFloat("FxVol", player_data.fxslider);

        Tooltips(0);

        //if back from editor preview load editor gameobjects
        if (player_data.editorback)
        {
            canvas.GetChild(0).gameObject.SetActive(false);
            backgroundpills.SetActive(false);
            editorpills.SetActive(true);
            canvas.GetChild(2).gameObject.SetActive(true);

            player_data.editorback = false;
            SavePlayerData();
        }
    }
Exemplo n.º 10
0
 public HostPlayer(player_info info) : base(info)
 {
     m_insID     = info.ID;
     m_modelPath = info.m_res;
 }
Exemplo n.º 11
0
        static void MovementCalculator(ref player_info playerList, int roll, char movement)
        {
            switch (movement.ToString().ToLower()) //check our movement direction
            {
                case "n":
                    playerList.yCoordinates = playerList.yCoordinates - roll; //if north, move up by roll amount

                    if (playerList.yCoordinates < 0) //if we go off the board
                    {
                        playerList.yCoordinates = playerList.yCoordinates + 8; //wrap around to (y + roll) - 8
                    }
                    break;
                case "s": //check if we're moving south
                    playerList.yCoordinates = playerList.yCoordinates + roll; //if so, move down on the y axis by roll

                    if (playerList.yCoordinates > 7)
                    {
                        playerList.yCoordinates = playerList.yCoordinates - 8; //wrap around to (y - roll) + 8 if we go off the board
                    }
                    break;
                case "e":
                    playerList.xCoordinates = playerList.xCoordinates + roll; //if we go east, move up the x axis by roll

                    if (playerList.xCoordinates > 7)
                    {
                        playerList.xCoordinates = playerList.xCoordinates - 8; //wrap to (x + roll) - 8 if we go off the x axis
                    }
                    break;
                case "w":
                    playerList.xCoordinates = playerList.xCoordinates - roll; //if we move west, go down the x axis by roll amount

                    if (playerList.xCoordinates < 0)
                    {
                        playerList.xCoordinates = playerList.xCoordinates + 8; //wrap to (x - roll) + 8 if we fall off the board
                    }
                    break;
            }
        }
Exemplo n.º 12
0
 static bool FindAWinner(player_info[] playerList, ref List<int> winnerIndex)
 {
     for (int i = 0; i < playerList.Length; i++) //loop through our structure
     {
         if (playerList[i].playerStash >= 6) //if a player has a stash of equal or more than 6
         {
             winnerIndex.Add(i); //add them to the winner's list
         }
     }
     if (winnerIndex.Count == 0) //if there's no one in the list
     {
         return false; //no one won
     }
     else //if there is
     {
         return true; //someone won
     }
 }
Exemplo n.º 13
0
        static bool CollisionDetector(player_info[] playerList, int currentIndex, ref List<int> detectedPlayer)
        {
            for (int i = 0; i < playerList.Length; i++) //loop through our array
            {
                if (i == currentIndex) //check we're not on the current player
                {
                    continue; //if so, skip this iteration
                }
                else
                {
                    if (playerList[i].xCoordinates == playerList[currentIndex].xCoordinates) //check the x co-ordinates between the two players match
                    {
                        if (playerList[i].yCoordinates == playerList[currentIndex].yCoordinates) //if so, check that the y co-ordinates match
                        {
                            detectedPlayer.Add(i); //if so, move our loop iteration into our list
                        }
                    }
                }
            }

            if (detectedPlayer.Count == 0)
            {
                return false; //return that there were no collisions
            }
            else
            {
                return true; //return that there was a collision
            }
        }
Exemplo n.º 14
0
        static int CheeseHead(player_info[] playerList)
        {
            string CheeseFace; //initialise the method variables
            bool found = false;
            int playerIndex = 0;

            do //make one big outer loop
            {
                Console.WriteLine("Who has the head which looks most like a block of cheese? "); //ask who goes first
                CheeseFace = Console.ReadLine(); //read in the input

                for (int i = 0; i < playerList.Length; i++) //loop through array
                {
                    if (playerList[i].playerName.ToLower() == CheeseFace.ToLower()) //check if the input exists in the array
                    {
                        playerIndex = i; //move it over to our catch variable
                        found = true; //set found to true
                    }
                }

                if (found == false) //check if the input was invalid
                {
                    Console.WriteLine("Error, player not found! " + Environment.NewLine); //throw error
                    continue; //restart outer loop
                }
            } while (found == false);

            return playerIndex; //return the index of the player
        }
Exemplo n.º 15
0
 static bool[,] CheeseCollector(ref bool[,] board, ref player_info playerDetails)
 {
     if (board[playerDetails.xCoordinates, playerDetails.yCoordinates] == false) //check if we've landed on an empty square
     {
         Console.WriteLine("There is no cheese on this space.");
         Console.WriteLine("You do not collect any cheese this turn. "); //tell them it's empty
         return board; //return an unedited board
     }
     else //if there's cheese on this board
     {
         Console.WriteLine("There is a cheese on this space."); //tell them
         playerDetails.playerStash = playerDetails.playerStash + 1; //move the player stash up by one
         board[playerDetails.xCoordinates, playerDetails.yCoordinates] = false; //set the position to empty
         Console.WriteLine("You collect the cheese and have a new stash counter of " + playerDetails.playerStash); //tell them their new stash amount
         return board; //return our edited board
     }
 }
Exemplo n.º 16
0
 public void send_info(player_info pi)
 {
     send_message(Custom_msg_type.SET_PLAYER_INFO, "", "", -1, format_data(pi), false, large: true);
 }
Exemplo n.º 17
0
        static player_info[] PlayerCollection(ref player_info[] playerData, ref int numberOfPlayers)
        {
            for (int i = 0; i < 100000000; i++) //start loop for handling exceptions
            {
                Console.WriteLine("How many players are there? ");
                try //attempt to execute this code
                {
                    numberOfPlayers = int.Parse(Console.ReadLine());
                }
                catch (System.FormatException) //when a user inputs an incorrect data, do this to stop the system from crashing
                {
                    Console.WriteLine("That's not a number!"); //throw error
                    Console.WriteLine(Environment.NewLine); //render a new line
                    continue; //restart chunk
                }

                if (numberOfPlayers < 0) //check user hasn't entered a negative value
                {
                    Console.WriteLine("Please input a number between 2 and 4!" + Environment.NewLine);
                    continue;
                }
                else if (numberOfPlayers == 0) //check user hasn't set input to 0
                {
                    Console.WriteLine("Please input a number between 2 and 4!" + Environment.NewLine);
                    continue;
                }
                else if (numberOfPlayers == 1) //check user hasn't set input to 1
                {
                    Console.WriteLine("Please input a number between 2 and 4!");
                    Console.WriteLine(Environment.NewLine);
                    continue;
                }
                else if (numberOfPlayers > 4) //check there aren't too many players
                {
                    Console.WriteLine("Please input a number between 2 and 4!", Environment.NewLine);
                    continue;
                }
                else
                {
                    break; //exit out of the loop when the inputs are valid
                }
            }

            playerData = new player_info[numberOfPlayers]; //make a new structure for the number of players
            string colourCatcher;
            for (int i = 0; i < playerData.Length; i = i + 1) //loop around and get player info
            {
                bool broken = false;

                Console.WriteLine("Player " + (i + 1)); //write which player we are collecting info for
                playerData[i].playerID = i; //write ID based on index
                Console.WriteLine("What is your name? ");
                playerData[i].playerName = Console.ReadLine();
                Console.WriteLine("What colour would you like to be? You can pick from: Red, Blue, Green, Yellow"); //ask for colour selection
                colourCatcher = Console.ReadLine();

                if (colourCatcher.ToLower() == "red" || colourCatcher.ToLower() == "blue" || colourCatcher.ToLower() == "green" || colourCatcher.ToLower() == "yellow")
                //ensure we got a valid input
                {

                    for (int j = 0; j < i; j++) //nest a new loop
                    {
                        if (playerData[j].playerColour.ToString() == colourCatcher.ToLower()) //check selected colour hasn't been picked
                        {
                            Console.WriteLine("Selected colour is unavailable, please pick again!");
                            broken = true; //set a break variable to true if so
                            break; //break out of nested loop
                        }

                    }

                    if (broken == true) //check if we broke out of the nested loop
                    {
                        i = i - 1; //move the index back one
                        continue; //restart
                    }
                    else
                    {
                        playerData[i].playerColour = (player_colour)Enum.Parse(typeof(player_colour), colourCatcher, true); //messy code, but here we check if our Colour Catcher matches an Enum state, then put the state it matches into our structure.
                    }
                    Console.WriteLine("Player details saved!");
                    Console.WriteLine(Environment.NewLine);
                }
                else
                {
                    Console.WriteLine("Due to printing issues, the colours selected are unavailable, please try again!");
                    i = i - 1; //move index one back
                    continue; //restart our loop
                }

            }

            return playerData;
        }
Exemplo n.º 18
0
        static player_info[] PlayerResetter(ref player_info[] playerInfo)
        {
            if (playerInfo.Length == 2) //check if we have 2 players
            {
                playerInfo[0].xCoordinates = 0;
                playerInfo[0].yCoordinates = 0;
                playerInfo[0].playerStash = 0;
                //place them at opposite board ends
                playerInfo[1].xCoordinates = 7;
                playerInfo[1].yCoordinates = 7;
                playerInfo[1].playerStash = 0;
            }
            else if (playerInfo.Length == 3) //check if we have 3 players
            {
                playerInfo[0].xCoordinates = 0;
                playerInfo[0].yCoordinates = 0;
                playerInfo[0].playerStash = 0;
                //place them in an L shape across the board
                playerInfo[1].xCoordinates = 7;
                playerInfo[1].yCoordinates = 0;
                playerInfo[1].playerStash = 0;

                playerInfo[2].xCoordinates = 0;
                playerInfo[2].yCoordinates = 7;
                playerInfo[2].playerStash = 0;
            }
            else
            {
                playerInfo[0].xCoordinates = 0;
                playerInfo[0].yCoordinates = 0;
                playerInfo[0].playerStash = 0;
                //place all four players in the corners of the board
                playerInfo[1].xCoordinates = 7;
                playerInfo[1].yCoordinates = 0;
                playerInfo[1].playerStash = 0;

                playerInfo[2].xCoordinates = 7;
                playerInfo[2].yCoordinates = 7;
                playerInfo[2].playerStash = 0;

                playerInfo[3].xCoordinates = 0;
                playerInfo[3].yCoordinates = 7;
                playerInfo[3].playerStash = 0;
            }
            return playerInfo;
        }
Exemplo n.º 19
0
        private void InitPlayerDetail(player_info info)
        {
            this.listView2.Clear();
            int[]    width = { 30, 50, 80, 80, 50, 60, 60, 60 };
            string[] tip   = { "天", "星期几", "上班", "下班", "休息", "打卡", "餐补", "迟到" };
            for (int i = 0; i < 8; i++)
            {
                ColumnHeader ch = new ColumnHeader();
                ch.Text      = tip[i];
                ch.Width     = width[i];
                ch.TextAlign = System.Windows.Forms.HorizontalAlignment.Center;
                this.listView2.Columns.Add(ch);
            }

            this.listView2.BeginUpdate();

            int count_allowance = 0;
            int count_later     = 0;
            int count_not_sign  = 0;

            for (int i = 0; i < info.date_info.Count; i++)
            {
                player_info.time_info t_info = info.date_info[i];

                ListViewItem lvi = new ListViewItem();
                //lvi.ImageIndex = i;
                lvi.Text = (i + 1).ToString();

                lvi.SubItems.Add(Week(t_info.date));


                TimeSpan start     = new TimeSpan(t_info.time_start.Hour, t_info.time_start.Minute, t_info.time_start.Second);
                string   str_start = "";

                //--1
                if (start != TimeSpan.Zero)
                {
                    str_start = start.ToString();
                }
                lvi.SubItems.Add(str_start);

                //--2
                TimeSpan end     = new TimeSpan(t_info.time_end.Hour, t_info.time_end.Minute, t_info.time_end.Second);
                string   str_end = "";
                if (end != TimeSpan.Zero)
                {
                    str_end = end.ToString();
                }
                lvi.SubItems.Add(str_end);

                //--3
                if (is_offday(t_info.date.Day))
                {
                    lvi.SubItems.Add("休息日");
                }
                else
                {
                    lvi.SubItems.Add("");
                }

                //--4
                if (t_info.is_not_sing > 0)
                {
                    count_not_sign += t_info.is_not_sing;
                    lvi.SubItems.Add("卡x " + count_not_sign);
                }
                else
                {
                    lvi.SubItems.Add("");
                }

                //--5
                if (t_info.is_allowance)
                {
                    count_allowance += 1;
                    lvi.SubItems.Add("补x " + count_allowance);
                }
                else
                {
                    lvi.SubItems.Add("");
                }

                //--6
                if (t_info.is_later)
                {
                    count_later += 1;
                    lvi.SubItems.Add("迟x " + count_later);
                }
                else if (t_info.is_deduction_later)
                {
                    lvi.SubItems.Add("抵扣");
                }
                else
                {
                    lvi.SubItems.Add("");
                }

                this.listView2.Items.Add(lvi);
            }
            this.listView2.EndUpdate();
        }
Exemplo n.º 20
0
        static void BattleSystemTest(ref player_info[] playerData, int activePlayer, int targetPlayer, ref bool[,] cheeseData)
        {
            bool lostBattle = false; //initialise our variables
            int cheeseChange;
            int activeRoll = ReadDice(); //active player rolls the dice
            Console.WriteLine("Player " + (activePlayer + 1) + " rolled a " + activeRoll);
            int targetRoll = ReadDice(); //target rolls the dice
            Console.WriteLine("Player " + (targetPlayer + 1) + " rolled a " + targetRoll);
            cheeseChange = BattleLogic(playerRoll: activeRoll, opponentRoll: targetRoll, larger: ref lostBattle); //run the method which runs through the logic of the battle
            if (lostBattle == true) //if the player lost the battle, switch over the victor in the decision making
            {
                int temp = activePlayer;
                activePlayer = targetPlayer;
                targetPlayer = temp;
            }

            switch (cheeseChange)
            {
                case -2: //check if it was a poor win
                    {
                        Console.WriteLine("Poor win! Surrender a cheese to your target!");
                        if (playerData[activePlayer].playerStash == 0) //check the loser has cheese to give
                        {
                            Console.WriteLine("No cheese to be given! You escape this time!"); //if not spit out an error
                            break;
                        }
                        else
                        { //if so, fork over cheese
                            playerData[activePlayer].playerStash = playerData[activePlayer].playerStash - 1;
                            playerData[targetPlayer].playerStash = playerData[targetPlayer].playerStash + 1;
                            Console.WriteLine("Player " + (activePlayer + 1) + "'s new stash amount: " + playerData[activePlayer].playerStash);
                            Console.WriteLine("Player " + (targetPlayer + 1) + "'s new stash amount: " + playerData[targetPlayer].playerStash); //print new stash amounts
                            break; //exit out of the switch
                        }
                    }
                case -1: //check if it was an honorable defeat
                    {
                        int selectedMove;

                        Console.WriteLine("Honorable defeat! Player " + (targetPlayer + 1) + " must move to any of these adjacent spaces:");
                        Console.WriteLine("1. " + (playerData[targetPlayer].xCoordinates) + ", " + (playerData[targetPlayer].yCoordinates + 1));
                        Console.WriteLine("2. " + (playerData[targetPlayer].xCoordinates) + ", " + (playerData[targetPlayer].yCoordinates - 1));
                        Console.WriteLine("3. " + (playerData[targetPlayer].xCoordinates + 1) + ", " + (playerData[targetPlayer].yCoordinates)); //print the available moves
                        Console.WriteLine("4. " + (playerData[targetPlayer].xCoordinates - 1) + ", " + (playerData[targetPlayer].yCoordinates));
                        for (int i = 0; i < 1; i++)
                        {
                            Console.WriteLine("Please select move 1, 2, 3 or 4");
                            try
                            {
                                selectedMove = int.Parse(Console.ReadLine()); //attempt to get an integer input
                            }
                            catch (System.FormatException) //catch any exceptions
                            {
                                Console.WriteLine("Invalid format, please try again! " + Environment.NewLine); //throw an error if nessecary
                                i--; //restart the loop
                                continue;
                            }
                            if (selectedMove == 1) //check if we're moving north
                            {
                                MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("s")); //move the player down
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>();
                                occupied = CollisionDetector(playerList: playerData, currentIndex: targetPlayer, detectedPlayer: ref playersOccupying); //check for a collision
                                if (occupied == true) //if we have a collision
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine); //inform the player
                                    MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("n")); //move them up one
                                    i--; //restart the loop
                                    continue;
                                }
                                else
                                {
                                    break; //exit out of the loop
                                }
                            }
                            else if (selectedMove == 2) //if we're moving south
                            {
                                MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("n")); //move them up one
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>();
                                occupied = CollisionDetector(playerList: playerData, currentIndex: targetPlayer, detectedPlayer: ref playersOccupying); //check collisions
                                if (occupied == true) //if we have a collision
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("s")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 3) //if we're moving east
                            {
                                MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("e")); //move them right
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>();
                                occupied = CollisionDetector(playerList: playerData, currentIndex: targetPlayer, detectedPlayer: ref playersOccupying); //check the space isn't occupied
                                if (occupied == true) //if it is
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("w")); //move them back and try restart the loop
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 4) //check we're moving them west
                            {
                                MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("w")); //move them west
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check if we collide with anyone in their western position
                                occupied = CollisionDetector(playerList: playerData, currentIndex: targetPlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we do
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[targetPlayer], roll: 1, movement: char.Parse("e")); //tell them the space is invalid and restart
                                    i--;
                                    continue;
                                }
                                else //if not
                                {
                                    break;
                                }
                            }
                            else //if the input is invalid
                            {
                                Console.WriteLine("Invalid move selected! Please try again!" + Environment.NewLine); //throw an error
                                i--; //restart the loop
                                continue;
                            }
                        }
                        cheeseData = CheeseCollector(board: ref cheeseData, playerDetails: ref playerData[targetPlayer]); //check if there's any cheese on the new space
                        break; //break out of the switch
                    }
                case 0: //check if we have a solid victory
                    {
                        int selectedMove;

                        Console.WriteLine("Solid victory! Player " + (activePlayer + 1) + " must move to any of these adjacent spaces:"); //inform the player of available moves
                        Console.WriteLine("1. " + (playerData[activePlayer].xCoordinates) + ", " + (playerData[activePlayer].yCoordinates + 1));
                        Console.WriteLine("2. " + (playerData[activePlayer].xCoordinates) + ", " + (playerData[activePlayer].yCoordinates - 1));
                        Console.WriteLine("3. " + (playerData[activePlayer].xCoordinates + 1) + ", " + (playerData[activePlayer].yCoordinates));
                        Console.WriteLine("4. " + (playerData[activePlayer].xCoordinates - 1) + ", " + (playerData[activePlayer].yCoordinates));
                        for (int i = 0; i < 1; i++)
                        {
                            Console.WriteLine("Please select move 1, 2, 3 or 4");
                            try
                            {
                                selectedMove = int.Parse(Console.ReadLine()); //check for integer input
                            }
                            catch (System.FormatException)
                            {
                                Console.WriteLine("Invalid format, please try again! " + Environment.NewLine); //throw an error and restart the loop if we don't get one
                                i--;
                                continue;
                            }
                            if (selectedMove == 1) //if we're moving north
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("s")); //move the user south
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("n"));
                                    i--; //move them back and restart the loop
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 2) //if they're moving south
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("n")); //move them north
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check if we have a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we have a collision
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("s")); //move them back and try again
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 3) //if we're moving east
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("e")); //move them east
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("w")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else //if we don't
                                {

                                    break;
                                }
                            }
                            else if (selectedMove == 4) //if we're moving west
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("w")); //move them west
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("e")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else //if our input isn't valid
                            {
                                Console.WriteLine("Invalid move selected! Please try again!" + Environment.NewLine);
                                i--; //throw an error and restart
                                continue;
                            }
                        }
                        cheeseData = CheeseCollector(board: ref cheeseData, playerDetails: ref playerData[activePlayer]); //collect any cheese on the new position
                        break; //exit the switch case
                    }
                case 1:
                    {
                        int selectedMove;

                        Console.WriteLine("Glorious victory!");
                        if (playerData[targetPlayer].playerStash < 1)
                        {
                            Console.WriteLine("Player " + (targetPlayer + 1) + " is unable to give you any cheese, he escapes this time!");
                        }
                        else
                        {
                            playerData[activePlayer].playerStash++;
                            playerData[targetPlayer].playerStash--;
                            Console.WriteLine("Player " + (activePlayer + 1) + "'s new stash amount: " + playerData[activePlayer].playerStash);
                            Console.WriteLine("Player " + (targetPlayer + 1) + "'s new stash amount: " + playerData[targetPlayer].playerStash);
                        }
                        Console.WriteLine("Now Player " + (activePlayer + 1) + "must move to any of these co-ordinates: ");
                        Console.WriteLine("1. " + (playerData[activePlayer].xCoordinates) + ", " + (playerData[activePlayer].yCoordinates + 1));
                        Console.WriteLine("2. " + (playerData[activePlayer].xCoordinates) + ", " + (playerData[activePlayer].yCoordinates - 1));
                        Console.WriteLine("3. " + (playerData[activePlayer].xCoordinates + 1) + ", " + (playerData[activePlayer].yCoordinates));
                        Console.WriteLine("4. " + (playerData[activePlayer].xCoordinates - 1) + ", " + (playerData[activePlayer].yCoordinates));
                        for (int i = 0; i < 1; i++)
                        {
                            Console.WriteLine("Please select move 1, 2, 3 or 4");
                            try
                            {
                                selectedMove = int.Parse(Console.ReadLine());
                            }
                            catch (System.FormatException)
                            {
                                Console.WriteLine("Invalid format, please try again! " + Environment.NewLine);
                                i--;
                                continue;
                            }
                            if (selectedMove == 1) //if we're moving north
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("s")); //move the user south
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("n"));
                                    i--; //move them back and restart the loop
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 2) //if they're moving south
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("n")); //move them north
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check if we have a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we have a collision
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("s")); //move them back and try again
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 3) //if we're moving east
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("e")); //move them east
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("w")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else //if we don't
                                {

                                    break;
                                }
                            }
                            else if (selectedMove == 4) //if we're moving west
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("w")); //move them west
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("e")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else //if our input isn't valid
                            {
                                Console.WriteLine("Invalid move selected! Please try again!" + Environment.NewLine);
                                i--; //throw an error and restart
                                continue;
                            }
                        }
                        cheeseData = CheeseCollector(board: ref cheeseData, playerDetails: ref playerData[activePlayer]); //check if there's cheese on the new space
                        break; //break out of the case switch
                    }
                case 2:
                    {
                        int selectedMove;

                        Console.WriteLine("Infamous victory!");
                        if (playerData[targetPlayer].playerStash < 2)
                        {
                            Console.WriteLine("Player " + (targetPlayer + 1) + " is unable to give you any cheese, he escapes this time!");
                        }
                        else
                        {
                            playerData[activePlayer].playerStash = playerData[activePlayer].playerStash + 2;
                            playerData[targetPlayer].playerStash = playerData[targetPlayer].playerStash - 2;
                            Console.WriteLine("Player " + (activePlayer + 1) + "'s new stash amount: " + playerData[activePlayer].playerStash);
                            Console.WriteLine("Player " + (targetPlayer + 1) + "'s new stash amount: " + playerData[targetPlayer].playerStash);
                        }
                        Console.WriteLine("Now Player " + (activePlayer + 1) + "must move to any of these co-ordinates: ");
                        Console.WriteLine("1. " + (playerData[activePlayer].xCoordinates) + ", " + (playerData[activePlayer].yCoordinates + 1));
                        Console.WriteLine("2. " + (playerData[activePlayer].xCoordinates) + ", " + (playerData[activePlayer].yCoordinates - 1));
                        Console.WriteLine("3. " + (playerData[activePlayer].xCoordinates + 1) + ", " + (playerData[activePlayer].yCoordinates));
                        Console.WriteLine("4. " + (playerData[activePlayer].xCoordinates - 1) + ", " + (playerData[activePlayer].yCoordinates));
                        for (int i = 0; i < 1; i++)
                        {
                            Console.WriteLine("Please select move 1, 2, 3 or 4");
                            try
                            {
                                selectedMove = int.Parse(Console.ReadLine());
                            }
                            catch (System.FormatException)
                            {
                                Console.WriteLine("Invalid format, please try again! " + Environment.NewLine);
                                i--;
                                continue;
                            }
                            if (selectedMove == 1) //if we're moving north
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("s")); //move the user south
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("n"));
                                    i--; //move them back and restart the loop
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 2) //if they're moving south
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("n")); //move them south
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check if we have a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we have a collision
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("s")); //move them back and try again
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else if (selectedMove == 3) //if we're moving east
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("e")); //move them east
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("w")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else //if we don't
                                {

                                    break;
                                }
                            }
                            else if (selectedMove == 4) //if we're moving west
                            {
                                MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("w")); //move them west
                                bool occupied = false;
                                List<int> playersOccupying = new List<int>(); //check for a collision
                                occupied = CollisionDetector(playerList: playerData, currentIndex: activePlayer, detectedPlayer: ref playersOccupying);
                                if (occupied == true) //if we get one
                                {
                                    Console.WriteLine("Space is already occupied, please try again! " + Environment.NewLine);
                                    MovementCalculator(playerList: ref playerData[activePlayer], roll: 1, movement: char.Parse("e")); //move them back and restart
                                    i--;
                                    continue;
                                }
                                else
                                {
                                    break;
                                }
                            }
                            else //if our input isn't valid
                            {
                                Console.WriteLine("Invalid move selected! Please try again!" + Environment.NewLine);
                                i--; //throw an error and restart
                                continue;
                            }
                        }
                        cheeseData = CheeseCollector(board: ref cheeseData, playerDetails: ref playerData[activePlayer]); //check if there's cheese in the new position
                        break; //break out of the case switch
                    }
            }
        }
 void Start()
 {
     player = GameObject.FindGameObjectWithTag("Player");
     play   = player.GetComponent <player_info>();
 }
Exemplo n.º 22
0
 public PlayerObj(player_info info)
 {
     m_info = info;
 }