mirror of
https://github.com/MartinKral/Slash-The-Hordes
synced 2025-10-09 08:36:14 +00:00
Initial
This commit is contained in:
12
assets/Media.meta
Normal file
12
assets/Media.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "fae64031-d2c9-4dfe-b230-aa8b831c487b",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
12
assets/Media/Animation.meta
Normal file
12
assets/Media/Animation.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "28f1b0a2-fc2d-4d13-b2a4-1a63eff3374f",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
12
assets/Media/Animation/Weapon.meta
Normal file
12
assets/Media/Animation/Weapon.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "e0f63227-3d3c-4059-bd11-cc0ca8fe2cf9",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
203
assets/Media/Animation/WeaponSwing.anim
Normal file
203
assets/Media/Animation/WeaponSwing.anim
Normal file
@@ -0,0 +1,203 @@
|
||||
[
|
||||
{
|
||||
"__type__": "cc.AnimationClip",
|
||||
"_name": "WeaponSwing",
|
||||
"_objFlags": 0,
|
||||
"__editorExtras__": {
|
||||
"embeddedPlayerGroups": []
|
||||
},
|
||||
"_native": "",
|
||||
"sample": 60,
|
||||
"speed": 1,
|
||||
"wrapMode": 1,
|
||||
"enableTrsBlending": false,
|
||||
"_duration": 0.31666666666666665,
|
||||
"_hash": 500763545,
|
||||
"_tracks": [
|
||||
{
|
||||
"__id__": 1
|
||||
}
|
||||
],
|
||||
"_exoticAnimation": null,
|
||||
"_events": [],
|
||||
"_embeddedPlayers": []
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.VectorTrack",
|
||||
"_binding": {
|
||||
"__type__": "cc.animation.TrackBinding",
|
||||
"path": {
|
||||
"__id__": 2
|
||||
}
|
||||
},
|
||||
"_channels": [
|
||||
{
|
||||
"__id__": 3
|
||||
},
|
||||
{
|
||||
"__id__": 5
|
||||
},
|
||||
{
|
||||
"__id__": 7
|
||||
},
|
||||
{
|
||||
"__id__": 9
|
||||
}
|
||||
],
|
||||
"_nComponents": 3
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.TrackPath",
|
||||
"_paths": [
|
||||
"eulerAngles"
|
||||
]
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 4
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [
|
||||
0,
|
||||
0.31666666666666665
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 6
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [
|
||||
0,
|
||||
0.31666666666666665
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 8
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [
|
||||
0,
|
||||
0.31666666666666665
|
||||
],
|
||||
"_values": [
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 0,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealKeyframeValue",
|
||||
"interpolationMode": 0,
|
||||
"tangentWeightMode": 0,
|
||||
"value": 90,
|
||||
"rightTangent": 0,
|
||||
"rightTangentWeight": 1,
|
||||
"leftTangent": 0,
|
||||
"leftTangentWeight": 1,
|
||||
"easingMethod": 0,
|
||||
"__editorExtras__": {
|
||||
"tangentMode": 0
|
||||
}
|
||||
}
|
||||
],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
},
|
||||
{
|
||||
"__type__": "cc.animation.Channel",
|
||||
"_curve": {
|
||||
"__id__": 10
|
||||
}
|
||||
},
|
||||
{
|
||||
"__type__": "cc.RealCurve",
|
||||
"_times": [],
|
||||
"_values": [],
|
||||
"preExtrapolation": 1,
|
||||
"postExtrapolation": 1
|
||||
}
|
||||
]
|
13
assets/Media/Animation/WeaponSwing.anim.meta
Normal file
13
assets/Media/Animation/WeaponSwing.anim.meta
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"ver": "2.0.3",
|
||||
"importer": "animation-clip",
|
||||
"imported": true,
|
||||
"uuid": "5022a9c8-7d40-4759-a10c-ce914b4b3fec",
|
||||
"files": [
|
||||
".cconb"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"name": "WeaponSwing"
|
||||
}
|
||||
}
|
12
assets/Scenes.meta
Normal file
12
assets/Scenes.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "633f1a26-e6a5-47bf-a5aa-0d4d35202468",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
1391
assets/Scenes/scene.scene
Normal file
1391
assets/Scenes/scene.scene
Normal file
File diff suppressed because it is too large
Load Diff
11
assets/Scenes/scene.scene.meta
Normal file
11
assets/Scenes/scene.scene.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
{
|
||||
"ver": "1.1.40",
|
||||
"importer": "scene",
|
||||
"imported": true,
|
||||
"uuid": "cffa5b19-2043-4cef-8221-1a10ab7a2c1f",
|
||||
"files": [
|
||||
".json"
|
||||
],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
12
assets/Scripts.meta
Normal file
12
assets/Scripts.meta
Normal file
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"ver": "1.1.0",
|
||||
"importer": "directory",
|
||||
"imported": true,
|
||||
"uuid": "f5d8d5db-417b-40f1-b7d8-86bd1cb1369c",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {
|
||||
"compressionType": {},
|
||||
"isRemoteBundle": {}
|
||||
}
|
||||
}
|
20
assets/Scripts/GameBootstrapper.ts
Normal file
20
assets/Scripts/GameBootstrapper.ts
Normal file
@@ -0,0 +1,20 @@
|
||||
import { Component, _decorator } from "cc";
|
||||
import { Player } from "./Player";
|
||||
import { VirtualJoystic } from "./VirtualJoystic";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("GameBootstrapper")
|
||||
export class GameBootstrapper extends Component {
|
||||
@property(VirtualJoystic) private virtualJoystic: VirtualJoystic;
|
||||
@property(Player) private player: Player;
|
||||
@property(Number) private strikeDelay = 0;
|
||||
|
||||
public start(): void {
|
||||
this.virtualJoystic.init();
|
||||
this.player.init(this.virtualJoystic, this.strikeDelay);
|
||||
}
|
||||
|
||||
public update(deltaTime: number): void {
|
||||
this.player.gameTick(deltaTime);
|
||||
}
|
||||
}
|
9
assets/Scripts/GameBootstrapper.ts.meta
Normal file
9
assets/Scripts/GameBootstrapper.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "5faa9913-e167-4014-92de-7061e103e557",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
31
assets/Scripts/Player.ts
Normal file
31
assets/Scripts/Player.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import { Component, Vec2, Vec3, _decorator } from "cc";
|
||||
import { VirtualJoystic } from "./VirtualJoystic";
|
||||
import { Weapon } from "./Weapon";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("Player")
|
||||
export class Player extends Component {
|
||||
private virtualJoystic: VirtualJoystic;
|
||||
@property private speed = 0;
|
||||
|
||||
@property(Weapon) private weapon: Weapon;
|
||||
|
||||
public init(virtualJoystic: VirtualJoystic, strikeDelay: number): void {
|
||||
this.virtualJoystic = virtualJoystic;
|
||||
this.weapon.init(strikeDelay);
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number): void {
|
||||
const movement: Vec2 = this.virtualJoystic.getAxis();
|
||||
movement.x *= deltaTime * this.speed;
|
||||
movement.y *= deltaTime * this.speed;
|
||||
|
||||
const newPosition: Vec3 = this.node.worldPosition;
|
||||
newPosition.x += movement.x;
|
||||
newPosition.y += movement.y;
|
||||
|
||||
this.node.setWorldPosition(newPosition);
|
||||
|
||||
this.weapon.gameTick(deltaTime, movement);
|
||||
}
|
||||
}
|
9
assets/Scripts/Player.ts.meta
Normal file
9
assets/Scripts/Player.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "b570abb8-1bcd-4ef0-85e8-4d783531001d",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
79
assets/Scripts/VirtualJoystic.ts
Normal file
79
assets/Scripts/VirtualJoystic.ts
Normal file
@@ -0,0 +1,79 @@
|
||||
import { _decorator, Component, Node, Vec3, input, Input, EventMouse, Vec2, EventTouch } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("VirtualJoystic")
|
||||
export class VirtualJoystic extends Component {
|
||||
@property(Number) private maxDistance = 10;
|
||||
@property(Node) private knob: Node;
|
||||
|
||||
#isUsingJoystic = false;
|
||||
#defaultPosition: Vec2 = new Vec2();
|
||||
|
||||
public init(): void {
|
||||
input.on(Input.EventType.MOUSE_DOWN, this.activateMouseJoystic, this);
|
||||
input.on(Input.EventType.MOUSE_UP, this.deactivateJoystic, this);
|
||||
input.on(Input.EventType.MOUSE_MOVE, this.moveKnobMouse, this);
|
||||
|
||||
input.on(Input.EventType.TOUCH_START, this.activateTouchJoystic, this);
|
||||
input.on(Input.EventType.TOUCH_END, this.deactivateJoystic, this);
|
||||
input.on(Input.EventType.TOUCH_MOVE, this.moveKnobTouch, this);
|
||||
|
||||
this.deactivateJoystic();
|
||||
}
|
||||
|
||||
public getAxis(): Vec2 {
|
||||
if (this.#isUsingJoystic) {
|
||||
return new Vec2(this.knob.position.x / this.maxDistance, this.knob.position.y / this.maxDistance);
|
||||
} else {
|
||||
return new Vec2();
|
||||
}
|
||||
}
|
||||
|
||||
private activateTouchJoystic(e: EventTouch): void {
|
||||
this.activateJoystic(e.getUILocation());
|
||||
}
|
||||
|
||||
private activateMouseJoystic(e: EventMouse): void {
|
||||
this.activateJoystic(e.getUILocation());
|
||||
}
|
||||
|
||||
private activateJoystic(location: Vec2): void {
|
||||
this.#isUsingJoystic = true;
|
||||
this.node.active = true;
|
||||
this.#defaultPosition = location;
|
||||
|
||||
this.node.setWorldPosition(new Vec3(this.#defaultPosition.x, this.#defaultPosition.y, 0));
|
||||
this.knob.position = new Vec3();
|
||||
}
|
||||
|
||||
private deactivateJoystic(): void {
|
||||
this.#isUsingJoystic = false;
|
||||
this.node.active = false;
|
||||
}
|
||||
|
||||
private moveKnobTouch(e: EventTouch): void {
|
||||
this.moveKnob(e.getUILocation());
|
||||
}
|
||||
|
||||
private moveKnobMouse(e: EventMouse): void {
|
||||
this.moveKnob(e.getUILocation());
|
||||
}
|
||||
|
||||
private moveKnob(location: Vec2): void {
|
||||
if (!this.#isUsingJoystic) return;
|
||||
|
||||
const posDelta: Vec2 = location.subtract(this.#defaultPosition);
|
||||
let x: number = posDelta.x;
|
||||
let y: number = posDelta.y;
|
||||
|
||||
const length: number = Math.sqrt(posDelta.x ** 2 + posDelta.y ** 2);
|
||||
if (this.maxDistance < length) {
|
||||
const multiplier: number = this.maxDistance / length;
|
||||
|
||||
x *= multiplier;
|
||||
y *= multiplier;
|
||||
}
|
||||
|
||||
this.knob.position = new Vec3(x, y, 0);
|
||||
}
|
||||
}
|
9
assets/Scripts/VirtualJoystic.ts.meta
Normal file
9
assets/Scripts/VirtualJoystic.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "a51b28bc-4ef0-4324-97fc-44f964ce087a",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
35
assets/Scripts/Weapon.ts
Normal file
35
assets/Scripts/Weapon.ts
Normal file
@@ -0,0 +1,35 @@
|
||||
import { Animation, BoxCollider2D, Component, Contact2DType, Vec2, Vec3, _decorator } from "cc";
|
||||
const { ccclass, property } = _decorator;
|
||||
|
||||
@ccclass("Weapon")
|
||||
export class Weapon extends Component {
|
||||
@property(Animation) private weaponAnimation: Animation;
|
||||
@property(BoxCollider2D) private weaponCollider: BoxCollider2D;
|
||||
|
||||
private strikeDelay: number;
|
||||
private currentDelay = 0;
|
||||
|
||||
public init(strikeDelay: number): void {
|
||||
this.strikeDelay = strikeDelay;
|
||||
|
||||
this.weaponCollider.on(Contact2DType.BEGIN_CONTACT, () => {
|
||||
console.log("Begin Contact!");
|
||||
});
|
||||
}
|
||||
|
||||
public gameTick(deltaTime: number, movement: Vec2): void {
|
||||
this.currentDelay += deltaTime;
|
||||
if (this.strikeDelay <= this.currentDelay) {
|
||||
this.currentDelay = 0;
|
||||
this.strike(movement);
|
||||
}
|
||||
}
|
||||
|
||||
private strike(movement: Vec2): void {
|
||||
const direction: Vec2 = movement.normalize();
|
||||
const angle: number = (Math.atan2(direction.y, direction.x) * 180) / Math.PI;
|
||||
this.node.eulerAngles = new Vec3(0, 0, angle);
|
||||
|
||||
this.weaponAnimation.play("WeaponSwing");
|
||||
}
|
||||
}
|
9
assets/Scripts/Weapon.ts.meta
Normal file
9
assets/Scripts/Weapon.ts.meta
Normal file
@@ -0,0 +1,9 @@
|
||||
{
|
||||
"ver": "4.0.23",
|
||||
"importer": "typescript",
|
||||
"imported": true,
|
||||
"uuid": "2391b8b7-f9fa-42a8-b046-55ff57b07d02",
|
||||
"files": [],
|
||||
"subMetas": {},
|
||||
"userData": {}
|
||||
}
|
Reference in New Issue
Block a user