国产精品天干天干,亚洲毛片在线,日韩gay小鲜肉啪啪18禁,女同Gay自慰喷水

歡迎光臨散文網(wǎng) 會(huì)員登陸 & 注冊(cè)

史上最全Unity3D教程

2022-07-05 08:50 作者:屑貓貓耳  | 我要投稿

c#代碼

p140

EnemyMotor

using System.Collections;

using System.Collections.Generic;

using Unity.VisualScripting;

using UnityEngine;

using UnityEngine.SocialPlatforms;

/// <summary>

/// 敵人馬達(dá)器,提供移動(dòng)、旋轉(zhuǎn)、尋路功能

/// </summary>

public class EnemyMotor : MonoBehaviour

{

??private Vector3 startingPoint;

??private Vector3 destination;

??private WayLine wayLine;

??private Vector3[] points;

??private EnemySpawn enemySpawn;

??private bool isMove;

??public float nextTime;

??private int i = 0;

??/// <summary>

??/// 前行

??/// </summary>

??public void MovementForward()

??{

????this.transform.Translate(0, 0, (float)0.02);

??}


??/// <summary>

??/// 注視旋轉(zhuǎn)

??/// </summary>

??/// <param name="targetPoint">需要注視的目標(biāo)點(diǎn)</param>

??public void targetPoint(Vector3 targetPoint)

??{

????this.transform.LookAt(targetPoint);

??}

??/// <summary>

??/// 尋路,沿路線移動(dòng)

??/// </summary>

??/// <returns></returns>

??public bool Pathfinding()

??{

????targetPoint(points[i]);

????MovementForward();

????//你可以試試==0,會(huì)發(fā)生什么

????if (Vector3.Distance(this.transform.position, points[i]) <=0.02)

??????i++;

????if (i >= 4)

??????return false;

????else

??????return true;

??}

??// Start is called before the first frame update

??void Start()

??{

????isMove=true;

????startingPoint = this.transform.position;

????nextTime = 1;

????enemySpawn =Object.FindObjectOfType<EnemySpawn>();

????wayLine = enemySpawn.FingWayLine();

????points = wayLine.GetWayPoints();

??}


??// Update is called once per frame

??void Update()

??{

????if (isMove)

????{

??????isMove = Pathfinding();

????}

??}

}


using System;

using System.Collections;

using System.Collections.Generic;

using System.Drawing;

using System.Reflection;

using UnityEngine;

/// <summary>

/// 敵人生成器

/// </summary>

public class EnemySpawn : MonoBehaviour

{

??private WayLine[] wayLines;

??private System.Random random;

??private int firstNum;

??private int finallyNum;

??public int nextTime;

??// Start is called before the first frame update

??//private Vector3 point;

??//private Vector3[] points;

??//private WayLine wayLine;

??void Start()

??{

????//wayLine=FingWayLine();

????//points = wayLine.Points;

????//for (int i = 0; i < points.Length; i++)

????//{

????//point = points[i];

????//Debug.Log(point);

????//}

??}

??/// <summary>

??/// 找路線,沒(méi)做不重復(fù)

??/// </summary>

??public WayLine FingWayLine()

??{

????wayLines = this.transform.GetComponentsInChildren<WayLine>();

????random = new System.Random();

????firstNum = 0;

????finallyNum = wayLines.Length;

????int usedNum = random.Next(firstNum, finallyNum);

????wayLines[usedNum].IsUseable = false;

????Debug.Log(wayLines[usedNum]);

????//if (usedNum == firstNum)

??????//firstNum += 1;

????//else if (usedNum == finallyNum)

??????//finallyNum -= 1;

????return wayLines[usedNum];

??}

}


using System;

using System.Collections;

using System.Collections.Generic;

using System.Drawing;

using UnityEngine;

/// <summary>

/// 路線類

/// </summary>

public class WayLine : MonoBehaviour

{

??private Vector3[] Points;

??public bool IsUseable;

??private Transform[] PointsTF;

??private Vector3[] newPoints;

??// Start is called before the first frame update

??void Start()

??{

????PointsTF = this.transform.GetComponentsInChildren<Transform>();

????Points = new Vector3[PointsTF.Length];

????newPoints = new Vector3[PointsTF.Length - 1];

????IsUseable=true;

??}

??/// <summary>

??/// 找路點(diǎn)

??/// </summary>

??/// <returns>Vector3[] 路點(diǎn)數(shù)組</returns>

??public Vector3[] GetWayPoints()

??{

????for (int i = 0; i < PointsTF.Length; i++)

????{

??????Points[i] = PointsTF[i].position;??

????}

????for (int i = 0; i < newPoints.Length; i++)

????{

??????newPoints[i] = Points[i + 1];

????}

????return newPoints;

??}



敵人可以用Cube代替


史上最全Unity3D教程的評(píng)論 (共 條)

分享到微博請(qǐng)遵守國(guó)家法律
宕昌县| 册亨县| 阿巴嘎旗| 沙湾县| 苗栗市| 视频| 大悟县| 南溪县| 临海市| 泾阳县| 鸡东县| 宜兰市| 张北县| 伊宁市| 新竹市| 始兴县| 奈曼旗| 买车| 蕲春县| 金寨县| 拜城县| 钟山县| 达州市| 陕西省| 天全县| 古丈县| 肥西县| 宁化县| 平江县| 新巴尔虎左旗| 耒阳市| 南汇区| 南和县| 江华| 华宁县| 连州市| 连南| 贵南县| 永春县| 禹州市| 湖口县|