示例#1
0
 void Start()
 {
     number_of_box          = CreateGameBoard.Height * CreateGameBoard.Width;
     player1_score          = 0;
     player2_score          = 0;
     player3_score          = 0;
     player1_textfield.text = "Blue Player Score: " + player1_score;
     player2_textfield.text = "Red Player Score: " + player2_score;
     player3_textfield.text = "Green Player Score: " + player3_score;
     player4_textfield.text = "Yellow Player Score: " + player4_score;
     if (Random.Range(0f, 1f) <= 0.25f)
     {
         playerTurn = player_struct.player1;
     }
     else if (Random.Range(0f, 1f) > 0.25f && Random.Range(0f, 1f) <= 0.5f)
     {
         playerTurn = player_struct.player2;
     }
     else if (Random.Range(0f, 1f) > 0.5f && Random.Range(0f, 1f) <= 0.75f)
     {
         playerTurn = player_struct.player3;
     }
     else
     {
         playerTurn = player_struct.player4;
     }
 }
示例#2
0
 void Start()
 {
     number_of_box          = CreateGameBoard.Height * CreateGameBoard.Width;
     player1_score          = 0;
     player2_score          = 0;
     player1_textfield.text = "Blue Player Score: " + player1_score;
     player2_textfield.text = "Red Player Score: " + player2_score;
     if (Random.Range(0f, 1f) < 0.5f)
     {
         playerTurn = player_struct.player1;
     }
     else
     {
         playerTurn = player_struct.player2;
     }
 }
示例#3
0
    void Update()
    {
        if (Input.GetMouseButtonDown(0))
        {
            bool         is_empty_vertical   = false;
            bool         is_empty_horizontal = false;
            bool         extra_turn          = false;
            float        xCor   = Camera.main.ScreenToWorldPoint(Input.mousePosition).x;
            float        yCor   = Camera.main.ScreenToWorldPoint(Input.mousePosition).y;
            Vector2      origin = new Vector2(xCor, yCor);
            RaycastHit2D hit    = Physics2D.Raycast(origin, Vector2.zero, 0);
            if (hit.collider != null)
            {
                is_empty_vertical   = hit.transform.gameObject.tag.Equals("empty vertical");
                is_empty_horizontal = hit.transform.gameObject.tag.Equals("empty horizontal");
                if (is_empty_vertical || is_empty_horizontal)
                {
                    int x_index = 0;
                    int y_index = 0;
                    for (int y = 0; y <= CreateGameBoard.Height; y++)
                    {
                        for (int x = 0; x <= CreateGameBoard.Width; x++)
                        {
                            if (y != CreateGameBoard.Height && hit.transform == CreateGameBoard.vertical_line[x, y])
                            {
                                x_index = x;
                                y_index = y;
                            }
                            else
                            if (x != CreateGameBoard.Width && hit.transform == CreateGameBoard.horizontal_line[x, y])
                            {
                                x_index = x;
                                y_index = y;
                            }
                        }
                    }


                    //  P1



                    if (this.playerTurn == player_struct.player1)
                    {
                        if (is_empty_horizontal)
                        {
                            hit.transform.gameObject.GetComponent <SpriteRenderer>().sprite = Spirite_playerHorizontal;
                            hit.transform.tag = "is play";
                            if (y_index != 0)
                            {
                                if (Check_Top(x_index, y_index))
                                {
                                    player1_score++;
                                    player1_textfield.text = "Blue Player Score: " + player1_score;
                                    CreateGameBoard.box_transform[x_index, y_index - 1].GetComponent <SpriteRenderer>().sprite = Spirite_playerBox;
                                    CreateGameBoard.box_transform[x_index, y_index - 1].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                            if (y_index != CreateGameBoard.Height)
                            {
                                if (Check_Bottom(x_index, y_index))
                                {
                                    player1_score++;
                                    player1_textfield.text = "Blue Player Score: " + player1_score;
                                    CreateGameBoard.box_transform[x_index, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_playerBox;
                                    CreateGameBoard.box_transform[x_index, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                        }
                        else
                        if (is_empty_vertical)
                        {
                            hit.transform.gameObject.GetComponent <SpriteRenderer>().sprite = Spirite_playerVertical;
                            hit.transform.tag = "is play";
                            if (x_index != 0)
                            {
                                if (Check_Left(x_index, y_index))
                                {
                                    player1_score++;
                                    player1_textfield.text = "Blue Player Score: " + player1_score;
                                    CreateGameBoard.box_transform[x_index - 1, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_playerBox;
                                    CreateGameBoard.box_transform[x_index - 1, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                            if (x_index != CreateGameBoard.Width)
                            {
                                if (Check_Right(x_index, y_index))
                                {
                                    player1_score++;
                                    player1_textfield.text = "Blue Player Score: " + player1_score;
                                    CreateGameBoard.box_transform[x_index, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_playerBox;
                                    CreateGameBoard.box_transform[x_index, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                        }
                        if (!extra_turn)
                        {
                            playerTurn = player_struct.player2;
                        }
                    }



                    //P2



                    else if (this.playerTurn == player_struct.player2)
                    {
                        if (is_empty_horizontal)
                        {
                            hit.transform.gameObject.GetComponent <SpriteRenderer>().sprite = Spirite_player2Horizontal;
                            hit.transform.tag = "is play";
                            if (y_index != 0)
                            {
                                if (Check_Top(x_index, y_index))
                                {
                                    player2_score++;
                                    player2_textfield.text = "Red Player Score: " + player2_score;
                                    CreateGameBoard.box_transform[x_index, y_index - 1].GetComponent <SpriteRenderer>().sprite = Spirite_player2Box;
                                    CreateGameBoard.box_transform[x_index, y_index - 1].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                            if (y_index != CreateGameBoard.Height)
                            {
                                if (Check_Bottom(x_index, y_index))
                                {
                                    player2_score++;
                                    player2_textfield.text = "Red Player Score: " + player2_score;
                                    CreateGameBoard.box_transform[x_index, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_player2Box;
                                    CreateGameBoard.box_transform[x_index, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                        }
                        else
                        if (is_empty_vertical)
                        {
                            hit.transform.gameObject.GetComponent <SpriteRenderer>().sprite = Spirite_player2Vertical;
                            hit.transform.tag = "is play";
                            if (x_index != 0)
                            {
                                if (Check_Left(x_index, y_index))
                                {
                                    player2_score++;
                                    player2_textfield.text = "Red Player Score: " + player2_score;
                                    CreateGameBoard.box_transform[x_index - 1, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_player2Box;
                                    CreateGameBoard.box_transform[x_index - 1, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                            if (x_index != CreateGameBoard.Width)
                            {
                                if (Check_Right(x_index, y_index))
                                {
                                    player2_score++;
                                    player2_textfield.text = "Red Player Score: " + player2_score;
                                    CreateGameBoard.box_transform[x_index, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_player2Box;
                                    CreateGameBoard.box_transform[x_index, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                        }
                        if (!extra_turn)
                        {
                            playerTurn = player_struct.player3;
                        }
                    }



                    //P3



                    else if (this.playerTurn == player_struct.player3)
                    {
                        if (is_empty_horizontal)
                        {
                            hit.transform.gameObject.GetComponent <SpriteRenderer>().sprite = Spirite_player3Horizontal;
                            hit.transform.tag = "is play";
                            if (y_index != 0)
                            {
                                if (Check_Top(x_index, y_index))
                                {
                                    player3_score++;
                                    player3_textfield.text = "Green Player Score: " + player3_score;
                                    CreateGameBoard.box_transform[x_index, y_index - 1].GetComponent <SpriteRenderer>().sprite = Spirite_player3Box;
                                    CreateGameBoard.box_transform[x_index, y_index - 1].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                            if (y_index != CreateGameBoard.Height)
                            {
                                if (Check_Bottom(x_index, y_index))
                                {
                                    player3_score++;
                                    player3_textfield.text = "Green Player Score: " + player3_score;
                                    CreateGameBoard.box_transform[x_index, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_player3Box;
                                    CreateGameBoard.box_transform[x_index, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                        }
                        else
                        if (is_empty_vertical)
                        {
                            hit.transform.gameObject.GetComponent <SpriteRenderer>().sprite = Spirite_player3Vertical;
                            hit.transform.tag = "is play";
                            if (x_index != 0)
                            {
                                if (Check_Left(x_index, y_index))
                                {
                                    player3_score++;
                                    player3_textfield.text = "Green Player Score: " + player3_score;
                                    CreateGameBoard.box_transform[x_index - 1, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_player3Box;
                                    CreateGameBoard.box_transform[x_index - 1, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                            if (x_index != CreateGameBoard.Width)
                            {
                                if (Check_Right(x_index, y_index))
                                {
                                    player3_score++;
                                    player3_textfield.text = "Green Player Score: " + player3_score;
                                    CreateGameBoard.box_transform[x_index, y_index].GetComponent <SpriteRenderer>().sprite = Spirite_player3Box;
                                    CreateGameBoard.box_transform[x_index, y_index].tag = "mark box";
                                    extra_turn = true;
                                }
                            }
                        }
                        if (!extra_turn)
                        {
                            playerTurn = player_struct.player1;
                        }
                    }
                }
            }
        }
        if (player1_score + player2_score + player3_score == number_of_box)
        {
            if ((player1_score == player2_score) && (player1_score == player3_score))
            {
                winner_textfield.text = "GAME DRAW";
            }
            else
            {
                if ((player1_score > player2_score) && (player1_score > player3_score))
                {
                    winner_textfield.text = "BLUE PLAYER WIN";
                }
                else if ((player2_score > player1_score) && (player2_score > player3_score))
                {
                    winner_textfield.text = "RED PLAYER WIN";
                }
                else
                {
                    winner_textfield.text = "GREEN PLAYER WIN";
                }
            }
        }
    }
示例#4
0
    /*
     *
     * void scratchmarks(long x,long y,long n,char s,char p)
     * {
     *  long i, ni;
     *
     *  ni = n/5;
     *  for(i=ni;i >= 0;i--)
     *  {
     *      overwritesprite(x-2,y,SCRATCH+4,s,0,0);
     *      x += Engine.tilesizx[SCRATCH+4]-1;
     *  }
     *
     *  ni = n%5;
     *  if(ni) overwritesprite(x,y,SCRATCH+ni-1,s,p,0);
     * }
     */
    public static void displayinventory(player_struct p)
    {
        int   n;
        short j;
        short xoff;
        short y;

        j = xoff = 0;

        n = (short)(((p.jetpack_amount > 0) ? 1 : 0) << 3);
        if ((n & 8) != 0)
        {
            j++;
        }
        n |= ((p.scuba_amount > 0) ? 1 : 0) << 5;
        if ((n & 32) != 0)
        {
            j++;
        }
        n |= ((p.steroids_amount > 0) ? 1 : 0) << 1;
        if ((n & 2) != 0)
        {
            j++;
        }
        n |= ((p.holoduke_amount > 0) ? 1 : 0) << 2;
        if ((n & 4) != 0)
        {
            j++;
        }
        n |= ((p.firstaid_amount > 0) ? 1 : 0);
        if ((n & 1) != 0)
        {
            j++;
        }
        n |= ((p.heat_amount > 0) ? 1 : 0) << 4;
        if ((n & 16) != 0)
        {
            j++;
        }
        n |= ((p.boot_amount > 0) ? 1 : 0) << 6;
        if ((n & 64) != 0)
        {
            j++;
        }

        xoff = (short)(160 - (j * 11));

        j = 0;

        if (ud.screen_size > 4)
        {
            y = 154;
        }
        else
        {
            y = 172;
        }

        if (ud.screen_size == 4)
        {
            if (ud.multimode > 1)
            {
                xoff += 56;
            }
            else
            {
                xoff += 65;
            }
        }

        while (j <= 9)
        {
            if ((n & (1 << j)) != 0)
            {
                switch (n & (1 << j))
                {
                case 1:
                    Engine.rotatesprite(xoff << 16, y << 16, 65536, 0, DefineConstants.FIRSTAID_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;

                case 2:
                    Engine.rotatesprite((xoff + 1) << 16, y << 16, 65536, 0, DefineConstants.STEROIDS_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;

                case 4:
                    Engine.rotatesprite((xoff + 2) << 16, y << 16, 65536, 0, DefineConstants.HOLODUKE_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;

                case 8:
                    Engine.rotatesprite(xoff << 16, y << 16, 65536, 0, DefineConstants.JETPACK_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;

                case 16:
                    Engine.rotatesprite(xoff << 16, y << 16, 65536, 0, DefineConstants.HEAT_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;

                case 32:
                    Engine.rotatesprite(xoff << 16, y << 16, 65536, 0, DefineConstants.AIRTANK_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;

                case 64:
                    Engine.rotatesprite(xoff << 16, (y - 1) << 16, 65536, 0, DefineConstants.BOOT_ICON, 0, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                    break;
                }

                xoff += 22;

                if (p.inven_icon == j + 1)
                {
                    Engine.rotatesprite((xoff - 2) << 16, (y + 19) << 16, 65536, 1024, DefineConstants.ARROW, -32, 0, 2 + 16, Engine._device.windowx1, Engine._device.windowy1, Engine._device.windowx2, Engine._device.windowy2);
                }
            }

            j++;
        }
    }
示例#5
0
    //REPLACE FULLY
    public static void weapon_amounts(player_struct p, int x, int y, int u)
    {
        int cw;

        int[] temp_got_weapons  = new int[DefineConstants.MAX_WEAPONS];
        int[] temp_got_weapons2 = new int[DefineConstants.MAX_WEAPONS];
        for (int i = 0; i < temp_got_weapons.Length; i++)
        {
            if (p.gotweapon[i])
            {
                temp_got_weapons[i]  = 1;
                temp_got_weapons2[i] = 0;
            }
            else
            {
                temp_got_weapons[i]  = 0;
                temp_got_weapons2[i] = 1;
            }
        }

        cw = p.curr_weapon;

        if ((u & 4) != 0)
        {
            weaponnum999(DefineConstants.PISTOL_WEAPON, x, y, p.ammo_amount[DefineConstants.PISTOL_WEAPON], max_ammo_amount[DefineConstants.PISTOL_WEAPON], (char)(12 - 20 * ((cw == DefineConstants.PISTOL_WEAPON) ? 1 : 0)));
        }
        if ((u & 8) != 0)
        {
            weaponnum999(DefineConstants.SHOTGUN_WEAPON, x, y + 6, p.ammo_amount[DefineConstants.SHOTGUN_WEAPON], max_ammo_amount[DefineConstants.SHOTGUN_WEAPON], (char)((temp_got_weapons2[DefineConstants.SHOTGUN_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.SHOTGUN_WEAPON) ? 1 : 0)));
        }
        if ((u & 16) != 0)
        {
            weaponnum999(DefineConstants.CHAINGUN_WEAPON, x, y + 12, p.ammo_amount[DefineConstants.CHAINGUN_WEAPON], max_ammo_amount[DefineConstants.CHAINGUN_WEAPON], (char)((temp_got_weapons2[DefineConstants.CHAINGUN_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.CHAINGUN_WEAPON) ? 1 : 0)));
        }
        if ((u & 32) != 0)
        {
            weaponnum(DefineConstants.RPG_WEAPON, x + 39, y, p.ammo_amount[DefineConstants.RPG_WEAPON], max_ammo_amount[DefineConstants.RPG_WEAPON], (char)((temp_got_weapons2[DefineConstants.RPG_WEAPON] * 9) + 12 - 19 * ((cw == DefineConstants.RPG_WEAPON) ? 1 : 0)));
        }
        if ((u & 64) != 0)
        {
            int _ammo1 = p.ammo_amount[DefineConstants.HANDBOMB_WEAPON];
            if (_ammo1 == 0)
            {
                _ammo1 = temp_got_weapons2[DefineConstants.HANDBOMB_WEAPON];
            }


            weaponnum(DefineConstants.HANDBOMB_WEAPON, x + 39, y + 6, p.ammo_amount[DefineConstants.HANDBOMB_WEAPON], max_ammo_amount[DefineConstants.HANDBOMB_WEAPON], (_ammo1 * 9) + 12 - 19 * (((cw == DefineConstants.HANDBOMB_WEAPON) || (cw == DefineConstants.HANDREMOTE_WEAPON))  ? 1 : 0));
        }
        if ((u & 128) != 0)
        {
#if VOLUMEONE
            orderweaponnum(DefineConstants.SHRINKER_WEAPON, x + 39, y + 12, p.ammo_amount[DefineConstants.SHRINKER_WEAPON], max_ammo_amount[DefineConstants.SHRINKER_WEAPON], (temp_got_weapons2[DefineConstants.SHRINKER_WEAPON] * 9) + 12 - 18 * (cw == DefineConstants.SHRINKER_WEAPON));
#else
            if ((p.subweapon & (1 << DefineConstants.GROW_WEAPON)) != 0)
            {
                weaponnum(DefineConstants.SHRINKER_WEAPON, x + 39, y + 12, p.ammo_amount[DefineConstants.GROW_WEAPON], max_ammo_amount[DefineConstants.GROW_WEAPON], (temp_got_weapons2[DefineConstants.GROW_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.GROW_WEAPON) ? 1 : 0));
            }
            else
            {
                weaponnum(DefineConstants.SHRINKER_WEAPON, x + 39, y + 12, p.ammo_amount[DefineConstants.SHRINKER_WEAPON], max_ammo_amount[DefineConstants.SHRINKER_WEAPON], (temp_got_weapons2[DefineConstants.SHRINKER_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.SHRINKER_WEAPON) ? 1 : 0));
            }
#endif
        }
        if ((u & 256) != 0)
        {
#if VOLUMEONE
            orderweaponnum(DefineConstants.DEVISTATOR_WEAPON, x + 70, y, p.ammo_amount[DefineConstants.DEVISTATOR_WEAPON], max_ammo_amount[DefineConstants.DEVISTATOR_WEAPON], (temp_got_weapons2[DefineConstants.DEVISTATOR_WEAPON] * 9) + 12 - 18 * (cw == DefineConstants.DEVISTATOR_WEAPON));
#else
            weaponnum(DefineConstants.DEVISTATOR_WEAPON, x + 70, y, p.ammo_amount[DefineConstants.DEVISTATOR_WEAPON], max_ammo_amount[DefineConstants.DEVISTATOR_WEAPON], (temp_got_weapons2[DefineConstants.DEVISTATOR_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.DEVISTATOR_WEAPON) ? 1 : 0));
#endif
        }
        if ((u & 512) != 0)
        {
#if VOLUMEONE
            orderweaponnum(DefineConstants.TRIPBOMB_WEAPON, x + 70, y + 6, p.ammo_amount[DefineConstants.TRIPBOMB_WEAPON], max_ammo_amount[DefineConstants.TRIPBOMB_WEAPON], (temp_got_weapons2[DefineConstants.TRIPBOMB_WEAPON] * 9) + 12 - 18 * (cw == DefineConstants.TRIPBOMB_WEAPON));
#else
            weaponnum(DefineConstants.TRIPBOMB_WEAPON, x + 70, y + 6, p.ammo_amount[DefineConstants.TRIPBOMB_WEAPON], max_ammo_amount[DefineConstants.TRIPBOMB_WEAPON], (temp_got_weapons2[DefineConstants.TRIPBOMB_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.TRIPBOMB_WEAPON) ? 1 : 0));
#endif
        }

        if ((u & 65536) != 0)
        {
#if VOLUMEONE
            orderweaponnum(-1, x + 70, y + 12, p.ammo_amount[DefineConstants.FREEZE_WEAPON], max_ammo_amount[DefineConstants.FREEZE_WEAPON], (temp_got_weapons2[DefineConstants.FREEZE_WEAPON] * 9) + 12 - 18 * (cw == DefineConstants.FREEZE_WEAPON));
#else
            weaponnum(-1, x + 70, y + 12, p.ammo_amount[DefineConstants.FREEZE_WEAPON], max_ammo_amount[DefineConstants.FREEZE_WEAPON], (temp_got_weapons2[DefineConstants.FREEZE_WEAPON] * 9) + 12 - 18 * ((cw == DefineConstants.FREEZE_WEAPON) ? 1 : 0));
#endif
        }
    }