资源简介

Unity3D塔防游戏制作,包含已打包可试玩的游戏程序和Unity3D工程源码。试玩前请认真阅读游戏引导。

资源截图

代码片段和文件信息

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;

public class BuildManager : MonoBehaviour {

    public TurretData laserTurretData;
    public TurretData missileTurretData;
    public TurretData standardTurretData;

    private TurretData selectedTurretData;//当前选择的炮台(要建造的炮台)
    private MapCube selectedMapCube;//表示当前选择的炮台(当前场景中的游戏物体)

    public Text moneyText;
    public Animator moneyAnimator;
    public int money = 3000;

    public Gameobject upgradeCanvas;//升级按钮
    public Button buttonUpgrade;

    private Animator upgratedCanvasAnimator;//升级按钮状态机

    void ChangeMoney(int change=0)
    {
        money += change;
        moneyText.text = “¥“ + money;
    }

    private void Start()
    {
        upgratedCanvasAnimator = upgradeCanvas.GetComponent();        
    }

    private void Update()
    {
        if (Input.GetMouseButtonDown(0))//检测鼠标左键是否按下
        {
            if (EventSystem.current.IsPointerOverGameobject()==false)//检测鼠标是否点在UI上,使用鼠标时参数为空
            {
                //开发炮台的建造
                Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);//鼠标点转换为射线
                RaycastHit hit;
                bool isCollider = Physics.Raycast(ray out hit 1000 layerMask.GetMask(“MapCube“));
                if (isCollider)
                {
                    MapCube mapCube = hit.collider.GetComponent();
                    if (selectedTurretData != null && mapCube.turretGo == null)
                    {
                        //可以在当前位置创建炮台
                        if (money >= selectedTurretData.cost)
                        {
                            ChangeMoney(-selectedTurretData.cost);
                            mapCube.BuildTurret(selectedTurretData);

                        }
                        else
                        {
                            //提示金钱不足
                            moneyAnimator.SetTrigger(“Flicker“);
                        }
                    }
                    else if (mapCube.turretGo != null)
                    {
                        //升级处理 
                        //if (mapCube.isUpgraded)
                        //{
                        //    ShowUpgradeUI(mapCube.transform.positiontrue);
                        //}
                        //else
                        //{
                        //    ShowUpgradeUI(mapCube.transform.position false);
                        //}
                        if(mapCube==selectedMapCube&&upgradeCanvas.activeInHierarchy)
                        {
                            StartCoroutine(HideUpgradeUI());
                        }
                        else
                        {
                            ShowUpgradeUI(mapCube.transform.position mapCube.isUpgraded);
                        }
                        selectedMapCube 

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-09-08 15:37  Source\
     目录           0  2018-09-08 15:37  Source\.vs\
     目录           0  2018-09-08 15:37  Source\.vs\Tower Defense\
     目录           0  2018-09-08 15:37  Source\.vs\Tower Defense\v15\
     文件       97280  2018-08-06 09:12  Source\.vs\Tower Defense\v15\.suo
     目录           0  2018-09-08 15:37  Source\.vs\Tower Defense\v15\Server\
     目录           0  2018-09-08 15:37  Source\.vs\Tower Defense\v15\Server\sqlite3\
     文件           0  2018-04-22 22:52  Source\.vs\Tower Defense\v15\Server\sqlite3\db.lock
     文件      593920  2018-05-14 00:02  Source\.vs\Tower Defense\v15\Server\sqlite3\storage.ide
     目录           0  2018-09-08 15:37  Source\Assets\
     文件         191  2018-04-27 00:46  Source\Assets\Animations.meta
     目录           0  2018-09-08 15:37  Source\Assets\Animations\
     文件         191  2018-05-09 15:12  Source\Assets\Animations\Button.meta
     目录           0  2018-09-08 15:37  Source\Assets\Animations\Button\
     文件       15907  2018-05-13 20:19  Source\Assets\Animations\Button\button.controller
     文件         207  2018-05-13 20:05  Source\Assets\Animations\Button\button.controller.meta
     文件       16962  2018-05-09 15:42  Source\Assets\Animations\Button\ButtonUpgrade.controller
     文件         207  2018-05-09 15:12  Source\Assets\Animations\Button\ButtonUpgrade.controller.meta
     文件         191  2018-05-13 19:05  Source\Assets\Animations\End.meta
     目录           0  2018-09-08 15:37  Source\Assets\Animations\End\
     文件        1857  2018-05-13 19:10  Source\Assets\Animations\End\End.controller
     文件         207  2018-05-13 19:05  Source\Assets\Animations\End\End.controller.meta
     文件        9235  2018-05-13 20:19  Source\Assets\Animations\End\show.anim
     文件         207  2018-05-13 19:05  Source\Assets\Animations\End\show.anim.meta
     文件         191  2018-05-13 20:55  Source\Assets\Animations\GameMenu.meta
     目录           0  2018-09-08 15:37  Source\Assets\Animations\GameMenu\
     文件        4499  2018-05-13 21:03  Source\Assets\Animations\GameMenu\rotate.anim
     文件         207  2018-05-13 20:55  Source\Assets\Animations\GameMenu\rotate.anim.meta
     文件        1862  2018-05-13 21:03  Source\Assets\Animations\GameMenu\Turret.controller
     文件         207  2018-05-13 20:55  Source\Assets\Animations\GameMenu\Turret.controller.meta
     文件         191  2018-04-27 00:46  Source\Assets\Animations\Money.meta
............此处省略1844个文件信息

评论

共有 条评论