Commit db2d8dc5 authored by haiyoucuv's avatar haiyoucuv

init

parent af43633d
...@@ -2751,13 +2751,13 @@ ...@@ -2751,13 +2751,13 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": -0.05 "z": 0
}, },
"_size": { "_size": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1.2, "x": 1.176,
"y": 1, "y": 1,
"z": 4 "z": 4.171
}, },
"_id": "" "_id": ""
}, },
...@@ -2843,7 +2843,7 @@ ...@@ -2843,7 +2843,7 @@
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
}, },
{ {
"__uuid__": "4d88ad28-d740-4f52-8b92-8b84bb1a8087@e114f", "__uuid__": "20730933-a375-49d7-9d0d-5ff3804cd768",
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
} }
], ],
...@@ -2978,7 +2978,7 @@ ...@@ -2978,7 +2978,7 @@
}, },
"_materials": [ "_materials": [
{ {
"__uuid__": "4d88ad28-d740-4f52-8b92-8b84bb1a8087@e114f", "__uuid__": "20730933-a375-49d7-9d0d-5ff3804cd768",
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
} }
], ],
......
...@@ -1638,13 +1638,13 @@ ...@@ -1638,13 +1638,13 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0.06 "z": 0
}, },
"_size": { "_size": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1.2, "x": 1.24,
"y": 1, "y": 1,
"z": 2.8 "z": 3.289
}, },
"_id": "" "_id": ""
}, },
...@@ -1724,7 +1724,7 @@ ...@@ -1724,7 +1724,7 @@
}, },
"_materials": [ "_materials": [
{ {
"__uuid__": "a6c4d563-2f30-4a18-9d91-80eff8639cac@ca88e", "__uuid__": "0d2472bd-75d4-4674-8107-8db3d902af00",
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
} }
], ],
......
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0.287 "z": 0.215
} }
}, },
{ {
...@@ -1886,13 +1886,13 @@ ...@@ -1886,13 +1886,13 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0.06 "z": 0
}, },
"_size": { "_size": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1.2, "x": 1.156,
"y": 1, "y": 1,
"z": 2.8 "z": 2.622
}, },
"_id": "" "_id": ""
}, },
......
...@@ -159,7 +159,7 @@ ...@@ -159,7 +159,7 @@
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 0, "x": 0,
"y": 0, "y": 0,
"z": 0.61 "z": 0.585
} }
}, },
{ {
...@@ -2162,9 +2162,9 @@ ...@@ -2162,9 +2162,9 @@
}, },
"_size": { "_size": {
"__type__": "cc.Vec3", "__type__": "cc.Vec3",
"x": 1.2, "x": 1.134,
"y": 1, "y": 1,
"z": 3.2 "z": 3.222
}, },
"_id": "" "_id": ""
}, },
...@@ -2250,7 +2250,7 @@ ...@@ -2250,7 +2250,7 @@
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
}, },
{ {
"__uuid__": "8e9c0e2b-bb1f-424d-bbe2-b63e83bea2db@e114f", "__uuid__": "bf332ea3-76ec-4a94-81d6-bb2928080508",
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
} }
], ],
...@@ -2385,7 +2385,7 @@ ...@@ -2385,7 +2385,7 @@
}, },
"_materials": [ "_materials": [
{ {
"__uuid__": "8e9c0e2b-bb1f-424d-bbe2-b63e83bea2db@e114f", "__uuid__": "bf332ea3-76ec-4a94-81d6-bb2928080508",
"__expectedType__": "cc.Material" "__expectedType__": "cc.Material"
} }
], ],
......
import { _decorator, color, Color, Component, Enum, find, Material, MeshRenderer, Node, tween, Vec3 } from 'cc'; import {
_decorator,
BoxCollider,
color,
Color,
Component,
Enum,
find,
Material,
MeshRenderer,
Node,
tween,
Vec3
} from 'cc';
import { CarColors, CarTypes } from '../CarColorsGlobalTypes'; import { CarColors, CarTypes } from '../CarColorsGlobalTypes';
import { RoleCarColorsComponent } from './RoleCarColorsComponent'; import { RoleCarColorsComponent } from './RoleCarColorsComponent';
import { CarColorsGlobalInstance } from '../CarColorsGlobalInstance'; import { CarColorsGlobalInstance } from '../CarColorsGlobalInstance';
...@@ -33,6 +46,9 @@ export class CarCarColorsComponent extends Component { ...@@ -33,6 +46,9 @@ export class CarCarColorsComponent extends Component {
@property(MeshRenderer) bodyMesh: MeshRenderer = null @property(MeshRenderer) bodyMesh: MeshRenderer = null
@property(MeshRenderer) top: MeshRenderer = null @property(MeshRenderer) top: MeshRenderer = null
get sitNum() {
return this.node.getChildByName("Seets").children.length;
}
halfLen: number = 2 halfLen: number = 2
...@@ -43,12 +59,7 @@ export class CarCarColorsComponent extends Component { ...@@ -43,12 +59,7 @@ export class CarCarColorsComponent extends Component {
onLoad() { onLoad() {
this.changeColor() this.changeColor()
if (this.carType === CarTypes.CAR8) { this.halfLen = this.getComponent(BoxCollider).size.z / 2;
this.halfLen = 1.6
} else if (this.carType === CarTypes.CAR6) {
this.halfLen = 1.4
}
this.roleNum = 0 this.roleNum = 0
this.isFull = false this.isFull = false
} }
...@@ -95,7 +106,7 @@ export class CarCarColorsComponent extends Component { ...@@ -95,7 +106,7 @@ export class CarCarColorsComponent extends Component {
this.tweenCount += 1 this.tweenCount += 1
this.roleNum += 1 this.roleNum += 1
this.isFull = this.roleNum >= this.node.getChildByName("Seets").children.length; this.isFull = this.roleNum >= this.sitNum;
return this.isFull return this.isFull
} }
......
...@@ -18,28 +18,20 @@ export class CarCarColorsSysterm extends Component { ...@@ -18,28 +18,20 @@ export class CarCarColorsSysterm extends Component {
checkBoxInter: number = 10 // 每10帧检测一次 checkBoxInter: number = 10 // 每10帧检测一次
addCar(node: Node) { addCar(node: Node) {
const carBoxCom = node.getComponent(CarBoxComponent) const carBoxCom = node.getComponent(CarBoxComponent);
if (carBoxCom) { if (carBoxCom) {
this.checkBoxInter = 10 this.checkBoxInter = 10;
this.carBoxMap.push(carBoxCom) this.carBoxMap.push(carBoxCom);
node.getChildByName("cars").children.forEach((car) => { node.getChildByName("cars").children.forEach((car) => {
car.active = false car.active = false;
this.addCar(car) this.addCar(car);
}) });
return return;
} }
this.activeCar.set(node.uuid, node) this.activeCar.set(node.uuid, node);
const color = node.getComponent(CarCarColorsComponent).carColor let { carColor, sitNum } = node.getComponent(CarCarColorsComponent);
const carType = node.getComponent(CarCarColorsComponent).carType for (; sitNum--;) {
let len = 10 this.carSeats.push(carColor);
if (carType === CarTypes.CAR8) {
len = 8
} else if (carType === CarTypes.CAR6) {
len = 6
}
for (; len--;) {
this.carSeats.push(color)
} }
} }
...@@ -58,52 +50,65 @@ export class CarCarColorsSysterm extends Component { ...@@ -58,52 +50,65 @@ export class CarCarColorsSysterm extends Component {
} }
refreshCar() { refreshCar() {
const cars = find("Scene/Levels").children[0].children const cars = find("Scene/Levels").children[0].children;
const car4s: { cars: Array<Node>, colors: Array<CarColors> } = {
cars: [],
colors: [],
};
const miniCars: { cars: Array<Node>, colors: Array<CarColors> } = { const miniCars: { cars: Array<Node>, colors: Array<CarColors> } = {
cars: [], cars: [],
colors: [] colors: [],
} };
const middleCars: { cars: Array<Node>, colors: Array<CarColors> } = { const middleCars: { cars: Array<Node>, colors: Array<CarColors> } = {
cars: [], cars: [],
colors: [] colors: [],
} };
const bigCars: { cars: Array<Node>, colors: Array<CarColors> } = { const bigCars: { cars: Array<Node>, colors: Array<CarColors> } = {
cars: [], cars: [],
colors: [] colors: [],
} };
cars.forEach(car => { cars.forEach(car => {
const carCom = car.getComponent(CarCarColorsComponent) const carCom = car.getComponent(CarCarColorsComponent);
if (!carCom) return if (!carCom) return;
if (carCom.carType === CarTypes.CAR4) {
car4s.cars.push(car);
car4s.colors.push(carCom.carColor);
return;
}
if (carCom.carType === CarTypes.CAR6) { if (carCom.carType === CarTypes.CAR6) {
miniCars.cars.push(car) miniCars.cars.push(car);
miniCars.colors.push(carCom.carColor) miniCars.colors.push(carCom.carColor);
return return;
} }
if (carCom.carType === CarTypes.CAR8) { if (carCom.carType === CarTypes.CAR8) {
middleCars.cars.push(car) middleCars.cars.push(car);
middleCars.colors.push(carCom.carColor) middleCars.colors.push(carCom.carColor);
return return;
} }
if (carCom.carType === CarTypes.CAR10) { if (carCom.carType === CarTypes.CAR10) {
bigCars.cars.push(car) bigCars.cars.push(car);
bigCars.colors.push(carCom.carColor) bigCars.colors.push(carCom.carColor);
return return;
} }
}) });
car4s.colors.sort(() => Math.random() - 0.5);
miniCars.colors.sort(() => Math.random() - 0.5); miniCars.colors.sort(() => Math.random() - 0.5);
middleCars.colors.sort(() => Math.random() - 0.5); middleCars.colors.sort(() => Math.random() - 0.5);
bigCars.colors.sort(() => Math.random() - 0.5); bigCars.colors.sort(() => Math.random() - 0.5);
car4s.cars.forEach((car, index) => {
car.getComponent(CarCarColorsComponent).carColor = car4s.colors[index];
});
miniCars.cars.forEach((car, index) => { miniCars.cars.forEach((car, index) => {
car.getComponent(CarCarColorsComponent).carColor = miniCars.colors[index] car.getComponent(CarCarColorsComponent).carColor = miniCars.colors[index];
}) });
middleCars.cars.forEach((car, index) => { middleCars.cars.forEach((car, index) => {
car.getComponent(CarCarColorsComponent).carColor = middleCars.colors[index] car.getComponent(CarCarColorsComponent).carColor = middleCars.colors[index];
}) });
bigCars.cars.forEach((car, index) => { bigCars.cars.forEach((car, index) => {
car.getComponent(CarCarColorsComponent).carColor = bigCars.colors[index] car.getComponent(CarCarColorsComponent).carColor = bigCars.colors[index];
}) });
} }
checkCarBox() { checkCarBox() {
......
...@@ -17,7 +17,7 @@ import { CarCarColorsComponent } from '../Components/CarCarColorsComponent'; ...@@ -17,7 +17,7 @@ import { CarCarColorsComponent } from '../Components/CarCarColorsComponent';
import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr"; import { AudioClipName, AudioMgr } from "db://assets/core/base/AudioMgr";
import { showPanel } from "db://assets/core/Module/UIFast"; import { showPanel } from "db://assets/core/Module/UIFast";
import { ReviewPanel } from "db://assets/Scripts/Panels/ReviewPanel"; import { ReviewPanel } from "db://assets/Scripts/Panels/ReviewPanel";
import { CarColors, CarTypes } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalTypes"; import { CarColors } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalTypes";
import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance"; import { CarColorsGlobalInstance } from "db://assets/Scripts/Scenes/MainGame/CarColorsGlobalInstance";
import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame"; import { MainGame } from "db://assets/Scripts/Scenes/MainGame/MainGame";
import gameStore from "db://assets/Scripts/store/gameStore"; import gameStore from "db://assets/Scripts/store/gameStore";
...@@ -90,14 +90,8 @@ export class RoleCarColorsSysterm extends Component { ...@@ -90,14 +90,8 @@ export class RoleCarColorsSysterm extends Component {
for(let i = cars.length; i--;){ for(let i = cars.length; i--;){
const car = cars[i] const car = cars[i]
const carComp = car.getComponent(CarCarColorsComponent) const carComp = car.getComponent(CarCarColorsComponent)
let num = 10 let num = carComp.sitNum;
if (carComp.carType === CarTypes.CAR8){
num = 8
}else if (carComp.carType === CarTypes.CAR6){
num = 6
}
num -= carComp.roleNum num -= carComp.roleNum
console.log(num)
for(;num--;){ for(;num--;){
// console.log(num) // console.log(num)
colors.push(carComp.carColor) colors.push(carComp.carColor)
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment