• 大小: 8.41MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-11-18
  • 语言: 其他
  • 标签: unity3d  

资源简介

unity3d跑酷游戏DEMO源码,可以用来入门学习。 有障碍物,可以跳跃。

资源截图

代码片段和文件信息

using UnityEngine;
using System.Collections;
using System.Collections.Generic;

public class GameManager : MonoBehaviour {
    // 生成障碍物点列表
    public List bornPosList = new List();
    // 道路列表
    public List roadList = new List();
    // 抵达点列表
    public List arrivePosList = new List();
    // 障碍物列表
    public Listject> objPrefabList = new Listject>();
    // 目前的障碍物
    Dictionaryject>> objDict = new Dictionaryject>>();
    public int roadDistance;
    public bool isEnd = false;
// Use this for initialization
void Start () {
        foreach(Transform road in roadList)
        {
            Listject> objList = new Listject>();
            objDict.Add(road.name objList);
        }
        initRoad(0);
        initRoad(1);
    }

// Update is called once per frame
void Update () {

}

    // 切出新的道路
    public void changeRoad(Transform arrivePos)
    {
        int index = arrivePosList.IndexOf(arrivePos);
        if(index >= 0)
        {
            int lastIndex = index - 1;
            if (lastIndex < 0)
                lastIndex = roadList.Count - 1;
            // 移动道路
            roadList[index].position = roadList[lastIndex].position + new Vector3(roadDistance 0 0);

            initRoad(index);
        }
        else
        {
            Debug.LogError(“arrivePos index is error“);
            return;
        }
    }

    void initRoad(int index)
    {
        
        string roadName = roadList[index].name;
        // 清空已有障碍物
        foreach(Gameobject obj in objDict[roadName])
        {
            Destroy(obj);
        }
        objDict[roadName].Clear();

        // 添加障碍物
        foreach(Transform pos in bornPosList[index])
        {
            Gameobject prefab = objPrefabList[Random.Range(0 objPrefabList.Count)];
            Vector3 eulerAngle = new Vector3(0 Random.Range(0 360) 0);
            Gameobject obj = Instantiate(prefab pos.position Quaternion.EulerAngles(eulerAngle)) as Gameobject;
            obj.tag = “Obstacle“;
            objDict[roadName].Add(obj);
        }
    }
}

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2016-04-08 03:18  RunningDemo\
     目录           0  2016-02-22 00:08  RunningDemo\.vs\
     目录           0  2016-02-22 00:08  RunningDemo\.vs\RunningDemo\
     目录           0  2016-02-22 01:04  RunningDemo\.vs\RunningDemo\v14\
     文件       44544  2016-04-08 02:50  RunningDemo\.vs\RunningDemo\v14\.suo
     目录           0  2016-04-07 23:39  RunningDemo\Assets\
     目录           0  2016-04-07 23:54  RunningDemo\Assets\Models\
     文件         192  2016-04-07 23:39  RunningDemo\Assets\Models.meta
     文件        8856  2016-04-07 23:54  RunningDemo\Assets\Models\character.controller
     文件         180  2016-04-07 23:42  RunningDemo\Assets\Models\character.controller.meta
     文件      896480  2013-06-20 04:08  RunningDemo\Assets\Models\character.fbx
     文件       12850  2016-04-07 23:39  RunningDemo\Assets\Models\character.fbx.meta
     目录           0  2016-04-07 23:39  RunningDemo\Assets\Models\Materials\
     文件         192  2016-04-07 23:39  RunningDemo\Assets\Models\Materials.meta
     文件        4260  2013-06-20 04:08  RunningDemo\Assets\Models\Materials\character_mat.mat
     文件         138  2016-04-07 23:39  RunningDemo\Assets\Models\Materials\character_mat.mat.meta
     目录           0  2016-04-07 23:39  RunningDemo\Assets\Models\Textures\
     文件         192  2016-04-07 23:39  RunningDemo\Assets\Models\Textures.meta
     文件     3145772  2013-06-20 04:08  RunningDemo\Assets\Models\Textures\character_color.tga
     文件        1166  2016-04-07 23:39  RunningDemo\Assets\Models\Textures\character_color.tga.meta
     文件     3145772  2013-06-20 04:08  RunningDemo\Assets\Models\Textures\character_normal.tga
     文件        1165  2016-04-07 23:39  RunningDemo\Assets\Models\Textures\character_normal.tga.meta
     目录           0  2016-04-08 02:49  RunningDemo\Assets\Scenes\
     文件         192  2016-02-21 22:30  RunningDemo\Assets\Scenes.meta
     文件       99824  2016-04-08 02:49  RunningDemo\Assets\Scenes\gameScene.unity
     文件         175  2016-02-21 22:38  RunningDemo\Assets\Scenes\gameScene.unity.meta
     目录           0  2016-04-08 02:48  RunningDemo\Assets\scripts\
     文件         192  2016-02-22 00:03  RunningDemo\Assets\scripts.meta
     文件        2327  2016-04-08 02:24  RunningDemo\Assets\scripts\GameManager.cs
     文件         263  2016-04-08 01:29  RunningDemo\Assets\scripts\GameManager.cs.meta
     文件        4551  2016-04-08 02:48  RunningDemo\Assets\scripts\moveController.cs
............此处省略1451个文件信息

评论

共有 条评论