Unity game development complete project, a full set of code + resources

Project Introduction

A role-playing game developed by Unity3D, which is suitable for beginners to learn as a reference, and can also be used for graduation project, just unzip it and use it.

Resource link

RPG game “The Witcher” full set of code + resources

Introduction to resources

2 game scenes

6 types of character models

4 types of monster figures

20 types of weapon models

Particle Effects 50+

Equipment, Item Icons 56+

Several UI materials

Attack, walk, death and other animations

Game size

1.23g (compressed package 628m)

Game function design

The game is divided into 10 parts, namely game interface design, game map design, character design, monster system, game props design, backpack system, store system, combat system, mission system, and storage system.

Game interface design

Game Interface

main menu
Character Creation Interface
game interface
shop interface
task interface
Character property interface
backpack interface

Partial code display

Monster finite state machine implementation

 void StateUpdate()
    {
        //If the target exists and is not dead, switch the attack state
        if (target & amp; & amp; state != MonsterState. Death)
        {
            state = MonsterState. Attack;
        }
            switch (state)
        {
            //idle state
            case MonsterState. Idle:
                if (anim. isPlaying == false)
                {
                    int num = Random. Range(0, 10);
                    switch (num)
                    {
                        case 0:
                        case 1:
                        case 2:
                        case 3:
                        case 4:
                            anim. CrossFade("idle");
                            break;
                        case 5:
                        case 6:
                            anim.CrossFade("idle_lookaround");
                            break;
                        case 7:
                        case 8:
                           anim. CrossFade("roar");
                           break;
                        case 9:
                            state = MonsterState. Walk;
                            break;
                    }
                }
                break;
            //walking state
            case MonsterState. Walk:
                //If no walking animation is played
                if (anim. IsPlaying("walk") == false)
                {
                    int i = Random.Range(0, monsterManager.nextPos.Length);
                    nextPos = monsterManager.nextPos[i].position;
                    transform.LookAt(new Vector3(nextPos.x, transform.position.y, nextPos.z));
                }
                anim. CrossFade("walk");
                //If the walking animation is playing
                if (anim. IsPlaying("walk") == true)
                {
                    controller.SimpleMove(transform.forward * walkSpeed);
                    DistanceUpdate(nextPos);
                    if (distance < 0.5f)
                    {
                        anim. Stop();
                        state = MonsterState. Idle;
                    }
                }
                break;
            // chase state
            case MonsterState.Run:
                break;
            //Attack status
            case MonsterState. Attack:
                if (target)
                {
                    Attack();
                }
                else
                {
                    state = MonsterState. Idle;
                }
                
                break;
            //dead state
            case MonsterState. Death:
                break;
        }
    }

item logic

 public virtual void OnEndDrag(PointerEventData eventData)
    {
        if (currentGrid.name == "Destroy")
        {
            Destroy(gameObject);
        }
        //If the grid has more than 2 items
        if (transform. parent. transform. childCount > 1)
        {
            GameObject itemEx = transform.parent.transform.GetChild(0).gameObject;
            //if equipped
            if (itemEx. tag == Tags. Equipment)
            {
                itemEx.GetComponent<Equipment>().transform.SetParent(itemEx.GetComponent<Equipment>().currentGrid);
            }
            //if it's a potion
            else if (itemEx. tag == Tags. Potion)
            {
                itemEx.GetComponent<Potion>().transform.SetParent(itemEx.GetComponent<Potion>().currentGrid);
            }
            //if material
            else if (itemEx. tag == Tags. Material)
            {
                itemEx.GetComponent<ItemMaterial>().transform.SetParent(itemEx.GetComponent<ItemMaterial>().currentGrid);
            }
            itemEx.transform.localPosition = Vector3.zero;
        }
        ObjectsDialog.instance.ShowDlg(transform.position);
    }