第一人称<ReactiveTarget >

本文介绍了一个Unity脚本,用于实现游戏对象被击中后的反应效果,包括角色状态改变、旋转动画及销毁等。该脚本通过挂载到目标对象上,能够在受到攻击时调用方法改变AI敌人的存活状态,并启动协程处理死亡动画。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

using UnityEngine;
using System.Collections;

public class ReactiveTarget : MonoBehaviour {

    // Use this for initialization
    void Start () {

    }

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

    }

    public void ReactiveToHit(){
        AI enemyMove=GetComponent<AI>();
        //Fenshu fenshu=GetComponent<Fenshu>();
        if(enemyMove!=null){

            enemyMove.setAlive(false);
            //fenshu.setCount();
        }
        StartCoroutine(Die());
    }

    private IEnumerator Die(){
        this.transform.Rotate(90,0,0);
        yield return new WaitForSeconds(1.5f);
        Destroy(this.gameObject);
    }
}
<!-- 添加分支申请页面 --> <template> <a-card class="ab-root"> <a-tooltip :title="$t('global.back')"> <div class="ab-4" @click="back"> <SvgIcon name="back" class="default-svg-icon-large ab-2"></SvgIcon> </div> </a-tooltip> <a-row type="flex" justify="start" align="middle" style="margin-bottom: 20px;"> <a-row type="flex" justify="start" align="middle" class="ab-1"> <div>电子流单号</div> <div>BC20250804edcbadh2</div> </a-row> </a-row> <a-steps current="1" label-placement="vertical"> <a-step title="未提交"></a-step> <a-step title="CIE审核"></a-step> <a-step title="创建中"></a-step> <a-step title="创建成功"></a-step> </a-steps> <a-divider /> <a-row type="flex" justify="start" align="middle" class="ab-1"> <div>范围</div> </a-row> <a-divider /> <a-space align="center" class="ab-5"> <a-space align="center"> <span>按分支</span> <a-select v-model:value="filterParams.branch" style="width: 250px;" placeholder="分支名" ></a-select> </a-space> <a-space align="center"> <span>按自定义组</span> <a-select v-model:value="filterParams.group" style="width: 250px;" placeholder="分支名" ></a-select> </a-space> <a-space align="center"> <span>按组织</span> <a-select v-model:value="filterParams.organization" style="width: 250px;" placeholder="分支名" ></a-select> </a-space> </a-space> <div class="ab-6"></div> <a-space align="center" class="ab-5"> <span>已选择:</span> <a-tag color="#666666">CANN/acl</a-tag> <a-tag color="#666666">CANN/ops/math/dev</a-tag> </a-space> <div class="ab-6"></div> <a-space align="center" class="ab-5"> <span>全选</span> <a-checkbox></a-checkbox> <div class="ab-3"></div> <a-input-search placeholder="输入仓名搜索"></a-input-search> </a-space> <div class="ab-6"></div> <div class="ab-5"> <a-checkbox-group v-model:value="rangeModel"> <a-checkbox v-for="(item, index) in allRanges" :key="index" :value="item"> {{ item }} </a-checkbox> </a-checkbox-group> </div> <a-divider /> <a-row type="flex" justify="start" align="middle" class="ab-1"> <div>分支信息</div> </a-row> <a-divider /> <a-form :label-col="{ span: 2 }" :wrapper-col="{ span: 21 }" class="ab-7"> <a-form-item> <template #label> <SvgIcon name="red_star" class="red-star"></SvgIcon> <span>分支名称</span> </template> <a-input v-model:value="branchInfoForm.name" placeholder="请输入分支名" style="width: 40vw;"> </a-input> </a-form-item> <a-form-item> <template #label> <SvgIcon name="red_star" class="red-star"></SvgIcon> <span>黄区映射分支</span> </template> <a-radio-group v-model:value="branchInfoForm.does_map"> <a-radio :value="true">是</a-radio> <a-radio :value="false">否</a-radio> </a-radio-group> </a-form-item> <a-form-item> <template #label> <SvgIcon name="red_star" class="red-star"></SvgIcon> <span>分支Owner</span> </template> <a-input v-model:value="branchInfoForm.name" placeholder="请输入Owner" style="width: 40vw;"> </a-input> </a-form-item> <a-form-item> <template #label> <SvgIcon name="red_star" class="red-star"></SvgIcon> <span>保护分支</span> </template> <a-radio-group v-model:value="branchInfoForm.does_protected"> <a-radio :value="true">是</a-radio> <a-radio :value="false">否</a-radio> </a-radio-group> </a-form-item> <a-form-item> <template #label> <SvgIcon name="red_star" class="red-star"></SvgIcon> <span>有效期</span> </template> <a-radio-group v-model:value="branchInfoForm.valid_date"> <a-radio-button value="半年">半年</a-radio-button> <a-radio-button value="一年">一年</a-radio-button> <a-radio-button value="二年">二年</a-radio-button> </a-radio-group> </a-form-item> <a-form-item> <template #label> <SvgIcon name="red_star" class="red-star"></SvgIcon> <span>会议纪要</span> </template> <a-upload name="file" :show-upload-list="false" > <a-button type="primary">上传附件</a-button> </a-upload> </a-form-item> </a-form> <a-divider /> <a-row type="flex" justify="start" align="middle" class="ab-1"> <div>历史状态</div> </a-row> <a-divider /> </a-card> </template> <script lang="ts" setup> import { defineOptions } from 'unplugin-vue-define-options/macros'; import { ref, reactive, defineExpose } from 'vue'; import i18n from '@/locales'; defineOptions({ name: 'AddBranch' }); const visible = ref<boolean>(false); const allRanges = ref<any[]>(['CANN/acl', 'CANN/ops-math-dev', 'CANN/ops-base-dev']); const rangeModel = ref<any[]>([]); const emit = defineEmits(['back']); const filterParams = reactive<any>({ branch: undefined, group: undefined, organization: undefined }); const branchInfoForm = reactive<any>({ name: undefined, does_map: false, owner: undefined, does_protected: false, valid_date: undefined, file: undefined }); function show() { document.title = i18n.global.t('branch_manage.add_branch_modal'); } function back() { emit('back'); } defineExpose({ show }); </script> <style lang="less"> .ab-root { min-height: 80vh; padding: 10px; position: relative; .ant-divider-horizontal { margin: 16px 0; } } .ab-1 { margin-left: 15px; font-size: 16px; font-weight: bold; height: 40px; } .ab-2 { margin: 0 10px 0 10px; position: relative; top: -3px; cursor: pointer; } .ab-3 { margin: 0 10px; width: 2px; background: #cccccc; height: 15px; } .ab-4 { position: absolute; right: 20px; top: 10px; } .ab-5 { padding-left: 15px; } .ab-6 { height: 20px; width: 100%; } .ab-7 { .ant-form-item-label { font-weight: bold; } } .ab-8 { } .ab-0 { } .red-star { width: 0.8em; height: 0.8em; margin-left: 3px; vertical-align: 0.2em!important; } </style>
最新发布
08-13
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值