Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
N
new_taobao
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
wildfirecode13
new_taobao
Commits
229b0962
Commit
229b0962
authored
Sep 27, 2020
by
spc
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
modified: project/src/canvas/game/src/Main.ts
parent
d7c920e0
Changes
5
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
327 additions
and
218 deletions
+327
-218
Main.ts
project/src/canvas/game/src/Main.ts
+1
-1
CircleItem.ts
project/src/canvas/game/src/xiaoxiaole/CircleItem.ts
+25
-6
Lattice.ts
project/src/canvas/game/src/xiaoxiaole/Lattice.ts
+0
-189
ObjectPool.ts
project/src/canvas/game/src/xiaoxiaole/ObjectPool.ts
+28
-0
XxlScene.ts
project/src/canvas/game/src/xiaoxiaole/XxlScene.ts
+273
-22
No files found.
project/src/canvas/game/src/Main.ts
View file @
229b0962
...
...
@@ -125,7 +125,7 @@ export class Main {
console
.
log
(
'resloadingList 加载完毕'
)
this
.
loadImageTextures
(
resCanvasList
).
then
(
res
=>
{
changeScene
(
OpenAni
)
changeScene
(
XxlScene
)
})
// XxlScene
...
...
project/src/canvas/game/src/xiaoxiaole/CircleItem.ts
View file @
229b0962
...
...
@@ -16,27 +16,46 @@ export default class CircleItem extends FYGE.Sprite {
type
:
number
circleRes
=
[
'2a747211-0210-4215-86a2-a6955b37c45b'
,
'7d1ec658-9371-4d52-b4d7-e75d04037daf'
,
'6a1345f6-969c-4969-8bfb-f4de637df34d'
,
'2e12a9ec-46be-487f-a9cd-550dd0af3746'
]
point
:
point
index
:
number
nnnn
:
number
constructor
(
type
:
number
,
point
:
point
)
{
constructor
(
type
:
number
,
point
:
point
,
index
:
number
)
{
super
();
this
.
type
=
type
this
.
point
=
point
this
.
x
=
this
.
point
.
x
this
.
y
=
this
.
point
.
y
this
.
point
=
{
x
:
point
.
x
+
39
,
y
:
point
.
y
+
39
}
this
.
x
=
point
.
x
this
.
y
=
point
.
y
this
.
index
=
index
this
.
texture
=
RES
.
getRes
(
resCanvasList
[
this
.
circleRes
[
type
]].
url
);
}
toBig
()
{
this
.
scaleX
=
1.3
this
.
scaleY
=
1.3
console
.
log
(
"变大"
)
this
.
scaleX
=
1.1
this
.
scaleY
=
1.1
}
toNormal
()
{
this
.
scaleY
=
this
.
scaleX
=
1
}
changeConfig
(
type
:
number
,
point
:
point
,
index
:
number
)
{
this
.
type
=
type
this
.
point
=
{
x
:
point
.
x
+
39
,
y
:
point
.
y
+
39
}
this
.
x
=
point
.
x
this
.
y
=
point
.
y
this
.
index
=
index
this
.
texture
=
RES
.
getRes
(
resCanvasList
[
this
.
circleRes
[
type
]].
url
);
}
}
project/src/canvas/game/src/xiaoxiaole/Lattice.ts
deleted
100644 → 0
View file @
d7c920e0
import
{
layers
}
from
"../../module/views/layers"
;
/**
* 右移偶数行
*/
export
const
hexIndices
=
[
3
,
9
,
10
,
14
,
15
,
16
,
17
,
18
,
19
,
20
,
21
,
22
,
23
,
24
,
25
,
26
,
29
,
30
,
31
,
32
,
33
,
35
,
36
,
37
,
38
,
39
,
40
,
42
,
43
,
44
,
45
,
46
,
47
,
48
,
51
,
52
,
59
]
export
class
Lattice
{
private
_element
:
Element
;
get
element
():
Element
{
return
this
.
_element
}
set
element
(
value
:
Element
)
{
if
(
value
)
{
value
.
index
=
this
.
index
;
// value.row = this.row;
// value.column = this.column;
}
this
.
_element
=
value
}
/**
* 索引
*/
index
:
number
/**
* 行
*/
row
:
number
;
/**
* 列
*/
col
:
number
/**
* 是否生成口
*/
isGenerate
:
boolean
;
/**
*
* @param index 索引
*/
constructor
(
index
:
number
)
{
this
.
index
=
index
;
this
.
element
=
null
;
this
.
isGenerate
=
false
;
}
/**
* 重置,貌似用不着,没有地方回收过格子,以后需要额外回收ice,door,element
* @param index 索引
*/
reset
(
index
:
number
)
{
this
.
index
=
index
;
// var rc = Tool.indexToRc(index);
// this.row = rc[0];
// this.column = rc[1];
this
.
element
=
null
;
this
.
isGenerate
=
false
;
}
}
class
Element
extends
FYGE
.
Container
{
index
:
number
lat
:
Lattice
}
const
offsetX
=
100
;
const
offsetY
=
100
;
/**
* 格子半径
*/
const
radius
=
100
;
export
const
ROW_NUM
=
9
;
export
const
COL_NUM
=
7
;
/**
* row和col转换到index的hashMap
*/
const
rcToIndexMap
=
{};
/**
* index到row和col的hashMap
*/
const
indexToRcMap
:
[
number
,
number
][]
=
[];
/**
* 行列位置,记录每个格子中心点的位置吧
*/
const
rowColPositions
=
{};
/**
* 索引位置
*/
const
indexPositions
:
[
number
,
number
][]
=
[];
const
halfSq3
=
Math
.
sqrt
(
3
)
/
2
;
/**
* 初始化数据
* 提前的缓存数据,千万别修改,因为给出的数据都没有深拷贝过
*/
(
function
init
()
{
for
(
var
i
=
0
;
i
<
ROW_NUM
;
i
++
)
{
for
(
var
j
=
0
;
j
<
COL_NUM
;
j
++
)
{
rcToIndexMap
[
""
+
i
+
j
]
=
i
*
COL_NUM
+
j
;
indexToRcMap
[
i
*
COL_NUM
+
j
]
=
[
i
,
j
];
var
x
=
offsetX
+
(
i
&
1
)
*
radius
/
2
+
j
*
radius
;
var
y
=
offsetY
+
i
*
halfSq3
*
radius
rowColPositions
[
""
+
i
+
j
]
=
[
x
,
y
];
indexPositions
[
i
*
COL_NUM
+
j
]
=
[
x
,
y
];
}
}
})()
/**
* row和col获得index值
* @param row
* @param col
*/
export
function
rcToIndex
(
row
:
number
,
col
:
number
):
number
{
var
key
=
""
+
row
+
col
;
return
rcToIndexMap
[
key
]
}
/**
* index获得row和col,返回的是数组,0是row,1是col
* @param index
*/
export
function
indexToRc
(
index
:
number
):
number
[]
{
return
indexToRcMap
[
index
]
}
/**
* 根据row,col得到位置信息
* @param row
* @param col
* @return 类似数组[111,222],0是x坐标,1是y坐标
*/
export
function
getPositionByRc
(
row
:
number
,
col
:
number
):
number
[]
{
var
key
=
""
+
row
+
col
;
return
rowColPositions
[
key
]
}
/**
* 根据index得到位置信息
* @param index
* @return 类似数组[111,222],0是x坐标,1是y坐标
*/
export
function
getPositionByIndex
(
index
:
number
):
number
[]
{
return
indexPositions
[
index
]
}
var
con
=
layers
.
addChild
(
new
FYGE
.
Container
())
// init();
for
(
var
i
=
0
;
i
<
ROW_NUM
*
COL_NUM
;
i
++
)
{
if
(
hexIndices
.
indexOf
(
i
)
==-
1
)
continue
var
p
=
getPositionByIndex
(
i
)
con
.
addChild
(
new
FYGE
.
Graphics
())
.
beginFill
(
0xff0000
)
.
drawCircle
(
p
[
0
],
p
[
1
],
45
)
.
endFill
();
}
project/src/canvas/game/src/xiaoxiaole/ObjectPool.ts
0 → 100644
View file @
229b0962
import
CircleItem
from
"./CircleItem"
declare
interface
point
{
x
:
number
;
y
:
number
;
}
export
class
ObjectPool
{
_circleItemPool
:
CircleItem
[]
=
[]
getItem
(
type
:
number
,
ponit
:
point
,
index
:
number
):
CircleItem
{
// console.log(this._circleItemPool.length)
let
co
=
this
.
_circleItemPool
.
shift
()
if
(
co
)
{
co
.
changeConfig
(
type
,
ponit
,
index
)
}
return
co
||
new
CircleItem
(
type
,
ponit
,
index
)
}
putItem
(
co
:
CircleItem
)
{
if
(
co
.
parent
)
{
co
.
parent
.
removeChild
(
co
)
}
this
.
_circleItemPool
.
push
(
co
)
}
}
\ No newline at end of file
project/src/canvas/game/src/xiaoxiaole/XxlScene.ts
View file @
229b0962
This diff is collapsed.
Click to expand it.
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment