- 📢 Blog home page: https://blog.csdn.net/zhangay1998
- 📢 Welcome to praise 👍 Collection ⭐ Leaving a message. 📝 Please correct any errors!
- 📢 This article was originally written by little Y, who knocked the code blankly, and was first launched in CSDN 🙉
- 📢 The future is long, and it is worth our efforts to go to a better life ✨
- 🐳 Fishing expert
- 🎁 Game source code download
- 💬 summary
- 👑 Review area lottery book delivery

📢 preface
- Today, we bring you a replica of a classic game, a small game of fishing for mankind!
- The classic version of fishing experts should have played it ~ it feels like a generation of classic games!
- Remember before, I envy others that they can play this game on computers and mobile phones!
- Let's take a look at how this type of game is done today~
🐳 Fishing expert
Everyone is familiar with fishing experts. We all know how to play the game, but there is no more explanation
There are many kinds of online games. Let's take a look at the game effects shared in this article!
Due to the size of the picture, the dynamic picture looks more card. In fact, the game is very smooth! Just download the experience

🎄 Game pictures
Let's take a look at some screenshots in the game, including the screen at the beginning, the game and the end of the game
As follows:





🔔 Engineering analysis

- Animations: folder where animations are stored
- Background: store the background map of the game, etc
- Bullets: picture material for storing artillery shells
- Effect: store special effect materials
- Fish: material for storing all kinds of fish
- Fonts: store font material
- Other: some props material
- Prefabs: store all kinds of preforms, such as shells, fish and gold coins
- Scenes: Store Project scenes
- Scripts: store all scripts
- Sound: store various audio resources
- UI: store various interactive UI materials
Preforms are mainly UI elements in the game. Because this is a 2D game, the materials and preforms used in the UI are UI
There are only two scenes, because the game is very simple. There is only one start scene and game scene
There are more than ten scripts to control a running logic process of the game!
There are many sprite pictures, which will be constantly switched during the game to achieve a visual effect~

There are many animation controllers, mainly the actions of various fish!

A start scene and game scene

The soul of the game - the script code is as follows

There is also the audio folder, which mainly has many sound effects for playing different sounds in various situations

There are also gold coins and other materials in various games

This is the UI material used in the game

💦 Core code explanation
There are more than ten scripts for this project, but not many. The core is actually GameController, game controller and FishMaker fish maker
GameController game controller is a core controller responsible for game operation
Including various levels of Fort switching, the number of gold coins used, upgrading according to experience, firing shells and other core functions
//What gear of shells are used private int costIndex = 0; //The number of gold coins required for each shot and the damage caused private int[] oneShootCosts = { 5, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 200, 300, 400, 500, 600, 700, 800, 900, 1000 }; private string[] lvName = { "Novice", "introduction", "steel", "bronze", "silver", "gold", "platinum", "Diamonds", "master", "Master" }; //Experience level conversion formula: experience required for upgrading = 1000 + 200 * current level while (exp >= 1000 + 200 * lv) { exp = exp - (1000 + 200 * lv); lv++; lvUpTips.SetActive(true); lvUpTips.transform.Find("Text").GetComponent<Text>().text = lv.ToString(); StartCoroutine(lvUpTips.GetComponent<Ef_HideSelf>().HideSelf(0.6f)); AudioManager.Instance.PlayEffectSound(AudioManager.Instance.lvUpClip); Instantiate(lvEffect); } ///Fire shells void Fire() { GameObject[] useBullets = bullet5Gos; int bulletIndex; if (Input.GetMouseButtonDown(0) && EventSystem.current.IsPointerOverGameObject() == false) { if (gold - oneShootCosts[costIndex] >= 0) { switch (costIndex / 4) { case 0: useBullets = bullet1Gos; break; case 1: useBullets = bullet2Gos; break; case 2: useBullets = bullet3Gos; break; case 3: useBullets = bullet4Gos; break; case 4: useBullets = bullet5Gos; break; } bulletIndex = (lv % 10 >= 9) ? 9 : lv % 10; gold -= oneShootCosts[costIndex]; AudioManager.Instance.PlayEffectSound(AudioManager.Instance.fireClip); Instantiate(fireEffect); GameObject bullet = Instantiate(useBullets[bulletIndex]); bullet.transform.SetParent(bulletHolder, false); bullet.transform.position = gunGos[costIndex / 4].transform.Find("FirePos").transform.position; bullet.transform.rotation = gunGos[costIndex / 4].transform.Find("FirePos").transform.rotation; bullet.GetComponent<BulletAttr>().damage = oneShootCosts[costIndex]; bullet.AddComponent<Ef_AutoMove>().dir = Vector3.up; bullet.GetComponent<Ef_AutoMove>().speed = bullet.GetComponent<BulletAttr>().speed; } else { StartCoroutine(GoldNotEnough()); } } }
FishMaker fish maker controls the generation and walking track of various fish in the scene
This is also a key function of the game
void Start() { InvokeRepeating("MakeFishes", 0, waveGenWaitTime); } void MakeFishes() { int genPosIndex = Random.Range(0, genPositions.Length); int fishPreIndex = Random.Range(0, fishPrefabs.Length); int maxNum = fishPrefabs[fishPreIndex].GetComponent<FishAttr>().maxNum; int maxSpeed = fishPrefabs[fishPreIndex].GetComponent<FishAttr>().maxSpeed; int num = Random.Range((maxNum / 2) + 1, maxNum); int speed = Random.Range(maxSpeed / 2, maxSpeed); int moveType = Random.Range(0, 2); //0: go straight; 1: turn int angOffset; //Only straight walking takes effect. The inclination angle of straight walking int angSpeed; //Effective only for turning, angular speed of turning if (moveType == 0) { angOffset = Random.Range(-22, 22); StartCoroutine(GenStraightFish(genPosIndex, fishPreIndex, num, speed, angOffset)); } else { if (Random.Range(0, 2) == 0) //Whether to take negative angular velocity { angSpeed = Random.Range(-15, -9); } else { angSpeed = Random.Range(9, 15); } StartCoroutine(GenTrunFish(genPosIndex, fishPreIndex, num, speed, angSpeed)); } }
Other codes will not be explained one by one. Those who like this little game can download the source code project for entertainment
There are more than a dozen scripts in total, but they are still very playable! Small partners who like this type of game can download and study a wave by themselves!
🎁 Game source code download
The source code project download link of this fishing expert is here!
[fishing talent] games download
💬 summary
- This article shares the game source code of a classic series [fishing master] back to childhood, and briefly analyzes the game structure and code
- Just a simple analysis of the engineering structure and core script of this little game
- Interested partners can download the source code to experience!
- You can have a wave for three times. See you next time~