[add] first

This commit is contained in:
2023-02-22 09:50:51 +08:00
commit 6260e95bc8
9053 changed files with 4492644 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
import { _decorator, Component, Node, geometry, PhysicsSystem, v3, Line, Vec3, Graphics, ParticleSystem, CurveRange } from 'cc';
import { UtilVec3 } from '../util/util';
const { ccclass, property } = _decorator;
@ccclass('FxActorFallPoint')
export class FxActorFallPoint extends Component {
_ray: geometry.Ray = new geometry.Ray();
_height = 0;
_line: Node;
_fxHit: Node;
_hitPos: Vec3;
@property(ParticleSystem)
particle_high_light:ParticleSystem = null
@property
rate_high_light = 1.0;
start () {
this._line = this.node.getChildByName('line');
this._fxHit = this.node.getChildByName('hitpoint');
this._hitPos = v3(0, 0, 0);
this._ray.d.x = 0;
this._ray.d.y = -1;
this._ray.d.z = 0;
}
update (deltaTime: number) {
this.detectPoint();
}
detectPoint () {
UtilVec3.copy(this._ray.o, this.node.worldPosition);
if (PhysicsSystem.instance.raycastClosest(this._ray)) {
var res = PhysicsSystem.instance.raycastClosestResult;
this._height = this.node.worldPosition.y - res.hitPoint.y;
UtilVec3.copy(this._hitPos, res.hitPoint);
this._hitPos.y += 0.05;
this.particle_high_light.startSpeed.constant = this._height * this.rate_high_light;//this._curverange;
} else {
this._height = 0;
}
const isShow = this._height > 0.3;
this._line.active = isShow;
this._fxHit.active = isShow;
this._line.setScale(1, this._height * 3, 1);
this._fxHit.setWorldPosition(this._hitPos);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "079ff04e-7b20-4edd-a306-d6093f01c159",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,30 @@
import { _decorator, Component, ParticleSystem } from 'cc';
const { ccclass, property } = _decorator;
@ccclass('FxAutoRemove')
export class FxAutoRemove extends Component {
@property
delayTime = 0.5;
start () {
const particles = this.node?.getComponentsInChildren(ParticleSystem);
for (let i = 0; i < particles.length; i++) {
particles[i].play();
}
}
update (deltaTime: number) {
this.delayTime -= deltaTime;
if (this.delayTime < 0) {
deltaTime = 9999;
this.node.destroy();
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "9a13d435-82fd-4fcc-8d3f-99a72a2c927f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,29 @@
import { _decorator, Component, Node, ParticleSystem, resources } from 'cc';
import { fun } from '../util/fun';
const { ccclass, property } = _decorator;
@ccclass('FxBase')
export class FxBase extends Component {
@property
destroyTime = 3;
particles:ParticleSystem[] | undefined;
start() {
this.particles = this.node?.getComponentsInChildren(ParticleSystem);
}
play() {
for (let i = 0; i < this.particles!.length; i++) {
const particle = this.particles![i];
particle.stop();
particle.play();
}
}
remove() {
fun.delay(()=>{
this.node.destroy()
}, this.destroyTime);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "a337d6ef-89ab-47cf-8048-818eadc95c39",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,69 @@
import { _decorator, Component, Node, ParticleSystem } from 'cc';
import { fun } from '../util/fun';
const { ccclass, property } = _decorator;
@ccclass('FxGroup')
export class FxGroup extends Component {
_particles:ParticleSystem[] | undefined;
_loop:boolean = true;
@property
delayTime = 3;
start() {
this._particles = this.node.getComponentsInChildren(ParticleSystem);
this.node.on('setDestroy', this.setDestroy, this);
this.play(true);
if (this._particles === undefined || this._particles.length <= 0) {
throw new Error(`This node ${this.node.name} can not find particles.`);
}
}
onDestroy() {
this.node.off('setDestroy', this.setDestroy, this);
}
setLoop(value:boolean) {
for(let i = 0; i < this._particles!.length; i++) {
this._particles![i].loop = value;
}
this._loop = value
}
setEnable(value:boolean) {
for(let i = 0; i < this._particles!.length; i++) {
this._particles![i].enabled = value;
}
}
stop(value:boolean) {
for(let i = 0; i < this._particles!.length; i++) {
this._particles![i].stop();
}
}
play(value:boolean) {
for(let i = 0; i < this._particles!.length; i++) {
this._particles![i].play();
}
}
setDestroy() {
this.setLoop(false);
fun.delay(()=>{
this.node?.destroy();
}, this.delayTime);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "67c81aa2-b02a-48b9-97b6-02513b3110d3",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,13 @@
import { _decorator, Component, Node } from 'cc';
import { fx } from './fx';
const { ccclass, property } = _decorator;
@ccclass('FxInit')
export class FxInit extends Component {
start() {
fx.init(this.node);
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "ed45ebcd-e5c8-4766-8aef-d345b20daa14",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,53 @@
import { _decorator, Node, ParticleSystem, sys, Vec3 } from 'cc';
import { Res } from '../res/res';
import { ResCache } from '../res/res-cache';
import { UtilNode } from '../util/util';
import { FxBase } from './fx-base';
const { ccclass, property } = _decorator;
let close_blood_fx = true;
@ccclass('fx')
export class fx {
public static node: Node;
public static init (node: Node) {
this.node = node;
}
public static on (name: string, pos: Vec3) {
if (sys.platform == sys.Platform.IOS && name.includes('fx_hit')) {
return;
}
if (close_blood_fx)
if (name == 'fx_hit_body') return;
var prefab = ResCache.Instance.getPrefab(name);
var newFx = Res.inst(prefab, this.node, pos);
}
public static play (node: Node, name: string) {
const fxNode = UtilNode.find(node, name);
const fx = fxNode.getComponent(FxBase);
fx?.play();
}
public static playLoop (node: Node, name: string, isLoop: boolean) {
const pNode = UtilNode.find(this.node, name);
var particles = pNode?.getComponentsInChildren(ParticleSystem);
if (particles === undefined) {
console.warn(` effect can not find ${name}`);
return;
}
for (let i = 0; i < particles.length; i++) {
let p = particles[i];
p.loop = isLoop;
if (isLoop) p.play();
}
}
}

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "0114d130-3813-432b-9297-04290671d82f",
"files": [],
"subMetas": {},
"userData": {}
}

View File

@@ -0,0 +1,72 @@
import { _decorator, Component, Node, SphereLight} from 'cc';
const { ccclass, property } = _decorator;
/**
* Predefined variables
* Name = light_flash
* DateTime = Wed Jan 12 2022 18:59:08 GMT+0800 (China Standard Time)
* Author = canvas
* FileBasename = light-flash.ts
* FileBasenameNoExtension = light-flash
* URL = db://assets/scripts/core/effect/light-flash.ts
* ManualUrl = https://docs.cocos.com/creator/3.4/manual/en/
*
*/
@ccclass('light_flash')
export class light_flash extends Component {
// [1]
// dummy = '';
// [2]
// @property
// serializableDummy = 0;
_light: SphereLight = null;
_curLuminance: number = 0;
_range: number = 0;
_time: number = 0;
@property
min: number = 1;
@property
range: number = 0.5;
@property
speed: number = 10;
start () {
// [3]
this._light = this.getComponent(SphereLight);
this._curLuminance = this.min;
}
update (deltaTime: number) {
// [4]
/*
this._curLuminance = this._curLuminance + deltaTime * this.speed;
if (this._curLuminance > this.max || this._curLuminance < this.min) {
this.speed *= -1;
}
this._light.luminance = this._curLuminance;
*/
this._time = this._time + deltaTime * this.speed;
this._range = Math.sin(this._time) * this.range + this.min;
this._light.range = this._range;
}
}
/**
* [1] Class member could be defined like this.
* [2] Use `property` decorator if your want the member to be serializable.
* [3] Your initialization goes here.
* [4] Your update function goes here.
*
* Learn more about scripting: https://docs.cocos.com/creator/3.4/manual/en/scripting/
* Learn more about CCClass: https://docs.cocos.com/creator/3.4/manual/en/scripting/ccclass.html
* Learn more about life-cycle callbacks: https://docs.cocos.com/creator/3.4/manual/en/scripting/life-cycle-callbacks.html
*/

View File

@@ -0,0 +1,9 @@
{
"ver": "4.0.23",
"importer": "typescript",
"imported": true,
"uuid": "471dcc40-3f65-4d40-9708-331dfd1ccc19",
"files": [],
"subMetas": {},
"userData": {}
}