Skip to content

Commit

Permalink
1.添加了一个历史记录窗口
Browse files Browse the repository at this point in the history
2.添加历史记录在Dialog计数器自动推进
3.Dialog新增设置文字大小API
4.引入jquery-ui库,用于复杂界面,(暂时没有使用)
5.Game.css重命名
6.FileSystem添加自定义更改换行判定符号功能,可以不用中文句号结尾,只需要设置新的判断符号即可(早晚得换成\n)
7.ImageEffect.js简化代码,改用for()现在必须手动设定图片效果的value
8.core.js代码清理,删除了一些废弃代码变量,更换注释格式
9.新增Dialog默认文字大小样式为25px,也可以手动更改
10.注释和删除调无用log -core.js中的计数器代码里面
11.新增文件夹-空游戏模板-tempz
12.test单元测试新增ImageEffect测试和json存入测试
note:
eval("var x=4")
可用于执行字符串里面的js方法
json不能存函数,但可以存对象
读取存档后,同步函数的功能未实现
  • Loading branch information
2439905184 committed Feb 2, 2021
1 parent 0c4d1c7 commit d962686
Show file tree
Hide file tree
Showing 33 changed files with 33,616 additions and 211 deletions.
Binary file added EasyAvgFrameWork_0.2.3.zip
Binary file not shown.
3 changes: 1 addition & 2 deletions fullExample/SaveLogic.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@ $(function() {
//初始化文件系统
var fileManager = new FileSystem()
function init()
{ // NOTE: 弃用代码
//var a = $("<img width='5%' src='img/k18.png' alt='存档截屏快照'>" + "<span>这是已经存在的存档</span>")
{
/*数据列表*/
var list=[]
/*遍历 获得数据*/
Expand Down
11 changes: 5 additions & 6 deletions fullExample/Scene/Game.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,12 @@
<script src="../../module/FileSystem.js"></script>
<script src="../../module/changeScene.js"></script>
<script src="../../module/ImageEffect.js"></script>
<script src="../../module/Animate.js"></script>
<script src="Logic.js"></script>
<!--内置button样式,如果不喜欢,可以自己建立css样式-->
<link rel="stylesheet" href="../css/button.css">
<link rel="stylesheet" href="../css/bgm.css">
<link rel="stylesheet" href="../css/Game.css">
<link rel="stylesheet" href="../css/historyView.css">
</head>
<body>

Expand All @@ -30,12 +31,10 @@ <h1> EasyAvgFramework </h1>
<button id="reload">刷新页面</button>
<button id="history">历史记录</button>
<button id="hideDialog">隐藏对话框</button>
<div style="display:none">
<!-- <button id="closeHistory">关闭</butotn> -->
<p class="historyView">历史记录 可能不好看,以后用开源库实现效果</p>
<p class="historyView">【小夜美】测试1</p>
<button id="clearAll">清空localStorage</button>
<ol id="HistoryPanel" style="display:none">
<!-- <p class="historyView">【小夜美】测试2</p> -->
</div>
</ol>
<h6> Copyright © 2020 小沙盒工作室&128hh. </h6>
</body>
</html>
153 changes: 84 additions & 69 deletions fullExample/Scene/Logic.js
Original file line number Diff line number Diff line change
@@ -1,139 +1,154 @@
// NOTE: 游戏主逻辑文本
$(function()
{
var Engine=new EasyAvg()
var file=new FileSystem()
//动画
var Anim=new AnimateEffect()

var historyText=[]
/*初始化图像特效模块*/
var Effect=new ImageEffect()
alert("请先点击开始按钮来播放背景音乐,由于浏览器安全设置,不能自动播放,点击人物,也能开始播放音乐")
function initUI()
{
$("#end").click(function()
{
changeScene("../index.html")
})
$("#start").click(function()
{
$("#bgm")[0].play()
})
$("#end").click(function()
{
changeScene("../index.html")
})
$("#loadGame").click(function()
{
changeScene("../save.html")

})
/*历史记录*/
$("#clearCookie").click(function()
{
$.removeCookie('runTimeIndex',{path:'/'})
})
$("#clearClicks").click(function()
{
console.clear()
console.warn("#清空计数器");
dialog.clearClicks()
})
$("#history").click(function()
{
// alert("历史记录!")
$("div").toggle()
$("#HistoryPanel").toggle()
var h=localStorage.getItem("historyText")
console.log("#读取历史文本");
// console.log(h.split("\n"))
var 文本=h.split("\n")
var len=h.split("\n").length

})
$("#reload").click(function()
{
location.reload()
})
$("#hideDialog").click(function()
{
dialog.toggle()
})
$("#clearAll").click(function()
{
file.clearAll()
})
}
initUI()
/*逻辑代码*/
var Engine=new EasyAvg()
// NOTE: 需要先创建背景
// Engine.showBgm()
Engine.setBgmVolume(0.5)
var bg=Engine.create_img("../img/bg.jpg","背景")
var dialog=Engine.create_Dialog()
var koyomi=Engine.create_img("../img/char.png","小夜美")
// Engine.showBgm()
Engine.setBgmVolume(0.5)

koyomi.css("margin-left","500px")
koyomi.css("margin-top","20px")
koyomi.css("position","relative")
koyomi.click(function()
{
alert("点击了人物,开始播放音乐")
$("#bgm")[0].play()
// Effect.setImageEffect(bg,Effect.blur)
// Effect.setImageEffectValue(koyomi,"60px")
// Effect.clearAllEffect(koyomi)
// alert("点击了人物,开始播放音乐")
// $("#bgm")[0].play()
//此方法不能放入函数列表,会被自动执行
koyomi.animate({right:'250px',opacity:'0.5'})
// koyomi.animate({opacity:'1'})
// Anim.setAnimate(koyomi,Anim.move_to_left)
// Anim.setAnimate(koyomi,Anim.move_to_right)
// koyomi.animate({right:'250px'})
})
var dialog=Engine.create_Dialog()
// NOTE: 从文本文件读取剧情
var chapter1=file.load_Plot_Text("../chapter/1.txt")
dialog.setContent(chapter1[0])
dialog.setDebugLog(true)
//定义人物图片变化,定义bgm变化
// BUG: 这个地方有小bug 顺序问题,
// dialog.setCustomActionAt(0,b)
Engine.create_BackroundImg(bg)
// dialog.changeImgAt(3,koyomi,"../img/k18.png")
$("#hideDialog").click(function()
{
dialog.toggle()
})
/*-----自定义函数------*/
var effect=function()
{
// alert("自定义事件1 背景模糊!")
Effect.setImageEffect(bg,Effect.blur)
Effect.setImageEffect(bg,Effect.blur,"20px")
}
var effect2=function()
{
Effect.setImageEffect(bg,Effect.invert)
Effect.setImageEffect(bg,Effect.invert,"100%")
}
var bright=function()
{
Effect.setImageEffect(koyomi,Effect.bright)
Effect.setImageEffect(koyomi,Effect.bright,"20%")
}
var gray=function()
{
// Effect.clearAllEffect(koyomi)
Effect.setImageEffect(koyomi,Effect.gray)
Effect.setImageEffect(koyomi,Effect.gray,"100%")
}
var clear=function()
{
Effect.clearAllEffect(bg)
Effect.clearAllEffect(koyomi)
}
//事件 bug了 修好了 core.js计数器判断和执行方式推倒 重写
// dialog.changeBgmAt(1,"../bgm/i72008_momoiro_cherry.ogg")
/*-------自定义函数----*/
// 设置文字大小
// dialog.setFontSize()
// NOTE: 更换角色没有过度效果 过于突然 以后优化图像效果
/*--自定义函数绑定---*/
var s=function()
{
Anim.setAnimate(koyomi,Anim.move_to_left)
}
dialog.changeImgAt(1,koyomi,"../img/k18.png")
// dialog.setCustomActionAt(2,koyomi,koyomi.animate({right:'250px',opacity:'0.5'}))
dialog.changeImgAt(2,koyomi,"../img/char.png")
/*更换角色*/
// NOTE: 更换角色没有过度效果 过于突然 以后优化图像效果
dialog.changeImgAt(5,koyomi,"../img/c03.png")
dialog.setCustomActionAt(14,effect)
//反色
// //反色
dialog.changeImgAt(15,koyomi,"../img/k20.png")
dialog.setCustomActionAt(15,effect2)
dialog.changeBgmAt(15,"../bgm/i71009_asia.ogg")
dialog.setCustomActionAt(17,bright)
dialog.setCustomActionAt(18,gray)
dialog.setCustomActionAt(19,clear)

/*恢复原图*/
dialog.changeImgAt(20,koyomi,"../img/char.png")
dialog.changeBgmAt(20,"../bgm/i71004_fresh.ogg")
/*--自定义函数绑定---*/

//添加ui
$("body").append(bg)
$("body").append(koyomi)
$("body").append(dialog)

// NOTE: 绑定按钮code 存档
function bindingButtonAction(dialog)
{
$("#clearCookie").click(function()
{
$.removeCookie('runTimeIndex',{path:'/'})
})
$("#clearClicks").click(function()
{
console.clear()
console.warn("#清空计数器");
dialog.clearClicks()
})
$("#reload").click(function()
{
location.reload()
})
$("#saveGame").click(function()
{
console.warn("##存档!");
//在跳转存档页面之前,先暂存游戏运行状态执行到哪一个句子的index
var index=dialog.getRuntimeIndex()
console.warn("#运行状态"+index);
$.cookie('runTimeIndex',index,{path:'/',secure:true})
//localStorage.setItem("test","test1ad3s1")
//file.save("runTimeIndex",index)
changeScene("../save.html")
})
}
bindingButtonAction(dialog)
//从文本文件读取剧情
// 存档
$("#saveGame").click(function()
{
console.warn("##存档!");
//在跳转存档页面之前,先暂存游戏运行状态执行到哪一个句子的index
var index=dialog.getRuntimeIndex()
console.warn("#运行状态"+index);
$.cookie('runTimeIndex',index,{path:'/',secure:true})
// var todoObj=JSON.stringify({"todoActionIndex":todoActionIndexArray,"functions":functionsList})
// localStorage.setItem("todoData",todoObj)
// changeScene("../save.html")
})

// bindingButtonAction(dialog)
})
12 changes: 0 additions & 12 deletions fullExample/css/Game.css

This file was deleted.

25 changes: 25 additions & 0 deletions fullExample/css/historyView.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
.historyView
{
border: solid;
border-radius: 5px;
background-color:#ACA772;
transition: background-color 0.2s;
margin-top:0px;
}
.historyView:hover
{
background-color: white;
}
/* 列表 */
#HistoryPanel
{
position: absolute;
margin-top: 100px;
margin-left: 200px;
z-index:1 ;
background-color:rgba(252,236,201,0.5) ;
width:800px;
height:600px;
overflow:scroll;
}
/* @androids7 你重写的代码使用什么逻辑来写 */
28 changes: 28 additions & 0 deletions module/Animate.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
function AnimateEffect()
{
console.log("#创建了动画模块");
var effects=["shake","move_to_left","move_to_right"]
this.shake="shake"
this.move_to_left="move_to_left"
this.move_to_right="move_to_right"
this.setAnimate=function(obj,effect)
{
// for(var i=0;i<effects.length;i++)
// {
// if(effect==effects[i])
// {
// obj.animate({effect:})
// }
// }
if(effect=="move_to_left")
{
obj.animate({right:'250px'})
}
if(effect=="move_to_right")
{
obj.animate({left:'250px'})
}
// obj.animate({right:'250px'})
}

}
7 changes: 6 additions & 1 deletion module/FileSystem.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// WARNING: 注意,必须要设置finishAction行为,不然会导致内部计数器一直累加,然后存档索引数据和剧情索引对不上去,就无法显示文本了
function FileSystem()
{
var custom_split_char=""
var debugMode=true
this.setDebugLog=function(bool)
{
Expand All @@ -14,7 +15,6 @@ function FileSystem()
debugMode=false
}
}
// var plot_text=[]
/*读取localStorage*/
this.load=function(key)
{
Expand Down Expand Up @@ -52,6 +52,11 @@ function FileSystem()
return Array(t1)

}
/*让用户自定义剧情解析器的换号判断符号*/
this.set_plot_split_char=function(str)
{
custom_split_char=str
}
/*清空所欲存档*/
this.clearAll=function()
{
Expand Down
Loading

0 comments on commit d962686

Please sign in to comment.