当前位置:网站首页>Test questions (2)
Test questions (2)
2022-04-23 03:23:00 【C # primary advanced】
Programming questions
- Design game scenes
- The red capsule is the player ( The camera object is under the player object , Place the camera over the player's head )
- Automatic doors with blue and yellow doors
pos01、pos02 Is the clone location
- Design game strategies
- Use the horizontal and vertical keys on the keyboard (WSAD) Control player movement
- Press down B key , The blue automatic door disappears ,10 Seconds later, the automatic door is displayed again
- Game begins 3 Seconds later in position pos1 Random cloning around 3 A black cube ,5 Seconds later in position pos2 Random cloning around 5 A black cube ( Application process )
- When the player moves near the first batch of black cubes , Left click , Fire red bullets from the player's head , When the bullet hits the black cube , The black cube disappears , If it doesn't work, hit , Red Bullet 5 Seconds later, it will disappear
- When the player moves near the second batch of black cubes , Press once F Key to make a black cube disappear
- When the player moves to the Yellow automatic door , Press down Y key , The Yellow automatic door moves upward 8 rice ,10 Seconds later, it falls back to its original position
- When the player returns to the starting point , When you hit an air wall , The game appears 5 Second countdown
- Time is over. , The game end dialog box pops up , Click on “ restart ” Button , The game can start again
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class move : MonoBehaviour
{
Rigidbody r;
public float speed;
public GameObject blue;
public GameObject yellow;
public GameObject Enemy;
public GameObject En;
public GameObject txt;
GameObject[] Enemy1 = new GameObject[5];
int a = 0;
void Start()
{
r = GetComponent<Rigidbody>();
StartCoroutine(BB());
}
void Update()
{
float h = Input.GetAxis("Horizontal");
float v = Input.GetAxis("Vertical");
Vector3 pos = new Vector3(h, 0, v);
r.velocity = pos * speed;
StartCoroutine(AA());// Coroutine call
StartCoroutine(CC());
StartCoroutine(DD());
}
IEnumerator AA()// Press down B key , The blue automatic door disappears ,10 Seconds later, the automatic door is displayed again
{
if (Input.GetKeyDown("b"))
{
blue.SetActive(false);// Deactivation
yield return new WaitForSeconds(10f);
blue.SetActive(false);
}
}
IEnumerator BB()// Game begins 3 Seconds later in position pos1 Random cloning around 3 A black cube ,5 Seconds later in position pos2 Random cloning around 5 A black cube ( Application process )
{
yield return new WaitForSeconds(3f);
for (int i = 0; i < 3; i++)
{
float x = Random.Range(-43f, -32f);
float z = Random.Range(-44f, -30f);
Instantiate(Enemy, new Vector3(x, 1f, z), Quaternion.identity);
}
yield return new WaitForSeconds(5f);
for (int i = 0; i < 5; i++)
{
float x = Random.Range(-7f, -22f);
float z = Random.Range(-16f, -3f);
Enemy1[i] = Instantiate(En, new Vector3(x, 1f, z), Quaternion.identity);
}
}
IEnumerator DD()// When the player moves near the second batch of black cubes , Press once F Key to make a black cube disappear
{
yield return new WaitForSeconds(0);
if (Input.GetKeyDown("f"))
{
if (a < 5)
{
Destroy(Enemy1[a]);
a++;
}
}
}
IEnumerator CC()// When the player moves to the Yellow automatic door , Press down Y key , The Yellow automatic door moves upward 8 rice ,10 Seconds later, it falls back to its original position
{
if (Input.GetKeyDown("y"))
{
yellow.transform.Translate(Vector3.up * 8);
yield return new WaitForSeconds(10f);
yellow.transform.Translate(Vector3.down * 8);
}
}
void OnTriggerEnter(Collider other)// When the player returns to the starting point , When you hit an air wall
{
if (other.CompareTag("kongqi"))
{
txt.SetActive(true);// send Text Text uses
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class mo : MonoBehaviour {
public GameObject sq;
public Transform poss;
void Start () {
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("Fire1")) // When the player moves near the first batch of black cubes , Left click , Fire red bullets from the player's head
{
Instantiate(sq, poss.position, Quaternion.identity);
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class ZD : MonoBehaviour {
Rigidbody r;
public float a = 5;
void Start () {
r = GetComponent<Rigidbody>();
StartCoroutine("AA");
}
// Update is called once per frame
void Update () {
r.velocity = Vector3.forward * a;
}
void OnTriggerEnter(Collider other)//, When the bullet hits the black cube , The black cube disappears , If it doesn't work, hit , Red Bullet 5 Seconds later, it will disappear
{
if (other .CompareTag("EN"))
{
Destroy(other.gameObject);
}
}
IEnumerator AA()
{
yield return new WaitForSeconds(5f);
Destroy(this.gameObject);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class daojis : MonoBehaviour
{
public Text tap;
float t = 6f;
public GameObject text;
public GameObject Button;
void Update()//, The game appears 5 Second countdown
{
if (t>1)
{
tap.text = ((int)t).ToString();
}
else
{
text.SetActive(false);
Button.SetActive(true);
}
t -= Time.deltaTime;
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class cxkais : MonoBehaviour {
public void ReStart()// Time is over. , The game end dialog box pops up , Click on “ restart ” Button , The game can start again
{
SceneManager.LoadScene("game");
Time.timeScale = 1;// Game begins restart
}
}
I suggest you do it yourself first
The method doesn't have to be exactly like this Reference only “ His writing ” There's no big problem !
版权声明
本文为[C # primary advanced]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204220621093464.html
边栏推荐
- 2022g2 boiler stoker examination question bank and online simulation examination
- [untitled]
- There is no index in the database table. When inserting data, SQL statements are used to prevent repeated addition (Reprint)
- Configure automatic implementation of curd projects
- Improvement of ref and struct in C 11
- Problem C: Hanoi Tower III
- QT dynamic translation of Chinese and English languages
- Queue storage and circular queue
- Log4net is in Net core usage
- Ide-idea-problem
猜你喜欢
Node configuration environment CMD does not take effect
Use of ADB command [1]
LoadRunner - performance testing tool
全新的ORM框架——BeetlSQL介绍
可以接收多种数据类型参数——可变参数
Visual programming - Experiment 2
C WPF UI framework mahapps switching theme
General test technology [II] test method
When migrating tslib_ setup: No such file or directory、ts_ open: No such file or director
[Mysql] LEFT函数 | RIGHT函数
随机推荐
2022g2 boiler stoker examination question bank and online simulation examination
. NETCORE sets the API post mode, which can accept parameters directly in parentheses
[MySQL] left Function | Right Function
12.<tag-链表和常考点综合>-lt.234-回文链表
Test experience data
QT learning summary
2022 团体程序设计天梯赛 模拟赛 L2-4 哲哲打游戏 (25 分)
TCP three handshakes and four waves
Explanation keyword of MySQL
Generate QR code through zxing
《C语言程序设计》(谭浩强第五版) 第9章 用户自己建立数据类型 习题解析与答案
Flink real-time data warehouse project - Design and implementation of DWS layer
How to achieve centralized management, flexible and efficient CI / CD online seminar highlights sharing
File upload vulnerability summary and upload labs shooting range documentary
数据库表中不建索引,在插入数据时,通过sql语句防止重复添加(转载)
一文了解全面静态代码分析
C WPF UI framework mahapps switching theme
Problem C: realize Joseph Ring with linked list
Top 9 task management system in 2022
移植tslib时ts_setup: No such file or directory、ts_open: No such file or director