idle

从 xlsx 读取翻译后的文本,对比旧的 XML 替换翻译,生成翻译后的 XML

记录:

using libxl;
using System.Collections.Generic;
using System.Xml.Linq;

namespace Test
{
    class Program
    {
        static void Main(string[] args)
        {
            var textData = new Dictionary<string, string>();
            var doc = XDocument.Load("Old.xml");
            foreach (var item in doc.Root.Descendants("text"))
            {
                textData[item.Attribute("t").Value] = item.Attribute("value").Value;
            }
            var dic = new Dictionary<string, string>();
            Book book = new XmlBook();
            book.load("new.xlsx");
            var sheet = book.getSheet(0);

            for (int i = 0; i < 4886; i++)
            {
                var a1 = sheet.readStr(i, 0);
                var a2 = sheet.readStr(i, 1);
                dic[a1] = a2;
            }

            var newXml = new XElement("GameTextSet");
            foreach (var node in textData)
            {
                string str;
                if (dic.TryGetValue(node.Value, out str)){}
                else if (dic.TryGetValue(node.Value.Trim(), out str)){}
                else
                    str = node.Value + "   没有翻译";

                newXml.Add(new XElement("text", new XAttribute("t", node.Key), new XAttribute("value", str)));
            }
            newXml.Save("New.xml");
        }
    }
}

还是回来写代码了

毫无准备的情况下成了游戏 lua 脚本,然后就写了自己的第一段代码。

	-- begin 加速表现
	local tBuilderDate = GetBuilderDataMgr():GetBuilderList()  -- 获取建筑的数据
	for i, v in ipairs(tBuilderDate) do
		if v.nSpeedTime ~= nil and v.nSpeedTime > 0  then 
			local id = v.idBuild
			local SpeedFlag = false
			if tSpeedID ~= nil then  --begin 防止重复添加光效
				for j,k in ipairs(tSpeedID) do
					if k.idBuild == id then
					SpeedFlag = true
					break
					end
				end
			end	 --end 防止重复添加光效
			local oBuiler = g_sPlayerManager:getBuilder(v.idBuild)	--处理光效
			if SpeedFlag == false and  oBuiler then
				SpeedEffectID = oBuiler:getModel():addEffect("heroLottery", -1, -1) --添加光效
				v.nSpeedTime = v.idBuild * 10  --临时测试数据,服务器上的数值太大不便测试
				local tSpeedInfoInfo = {idBuild = v.idBuild, nSpeedTime = v.nSpeedTime, FormatTime = nil, SpeedEffectID = SpeedEffectID}
				table.insert(tSpeedID, tSpeedInfoInfo) --tSpeedID 初始为空,是 tSpeedInfoInfo 的集合
				g_sEventManager:registerTimeoutEvent(1000, true, "SpeedBuilder_ProgressBar_Callback")	--计时器回调 参数 间隔时间,是否循环,回调函数名
			end
		end
	end	
	--end 加速表现

类似这种,一写就是半年多(去年打的草稿,现在翻出来),接着又是 C#。这一年多来过得比以往感觉都快,两点一线式的生活,上班-加班-下班。

最近因为工作遇到,再去看了一下 Bezier 曲线,发现网上广为流传的一段代码貌似有问题

using UnityEngine; 

[System.Serializable] 
public class Bezier : System.Object
 
{
 
    public Vector3 p0;
 
    public Vector3 p1;
 
    public Vector3 p2;
 
    public Vector3 p3;
 
    public float ti = 0f;
 
    private Vector3 b0 = Vector3.zero;
 
    private Vector3 b1 = Vector3.zero;
 
    private Vector3 b2 = Vector3.zero;
 
    private Vector3 b3 = Vector3.zero;
 
    private float Ax;
 
    private float Ay;
 
    private float Az;
 
    private float Bx;
 
    private float By;
 
    private float Bz;
 
    private float Cx;
 
    private float Cy;
 
    private float Cz;
 
    // Init function v0 = 1st point, v1 = handle of the 1st point , v2 = handle of the 2nd point, v3 = 2nd point
 
    // handle1 = v0 + v1
 
    // handle2 = v3 + v2
 
    public Bezier( Vector3 v0, Vector3 v1, Vector3 v2, Vector3 v3 )
 
    {
 
        this.p0 = v0;
 
        this.p1 = v1;
 
        this.p2 = v2;
 
        this.p3 = v3;
 
    }
 
    // 0.0 >= t <= 1.0
 
    public Vector3 GetPointAtTime( float t )
 
    {
 
        this.CheckConstant();
 
        float t2 = t * t;
 
        float t3 = t * t * t;
 
        float x = this.Ax * t3 + this.Bx * t2 + this.Cx * t + p0.x;
 
        float y = this.Ay * t3 + this.By * t2 + this.Cy * t + p0.y;
 
        float z = this.Az * t3 + this.Bz * t2 + this.Cz * t + p0.z;
 
        return new Vector3( x, y, z );
 
    }
 
    private void SetConstant()
 
    {
 
        this.Cx = 3f * ( ( this.p0.x + this.p1.x ) - this.p0.x );
 
        this.Bx = 3f * ( ( this.p3.x + this.p2.x ) - ( this.p0.x + this.p1.x ) ) - this.Cx;
 
        this.Ax = this.p3.x - this.p0.x - this.Cx - this.Bx;
 
        this.Cy = 3f * ( ( this.p0.y + this.p1.y ) - this.p0.y );
 
        this.By = 3f * ( ( this.p3.y + this.p2.y ) - ( this.p0.y + this.p1.y ) ) - this.Cy;
 
        this.Ay = this.p3.y - this.p0.y - this.Cy - this.By;
 
        this.Cz = 3f * ( ( this.p0.z + this.p1.z ) - this.p0.z );
 
        this.Bz = 3f * ( ( this.p3.z + this.p2.z ) - ( this.p0.z + this.p1.z ) ) - this.Cz;
 
        this.Az = this.p3.z - this.p0.z - this.Cz - this.Bz;
 
    }
 
    // Check if p0, p1, p2 or p3 have changed
 
    private void CheckConstant()
 
    {
 
        if( this.p0 != this.b0 || this.p1 != this.b1 || this.p2 != this.b2 || this.p3 != this.b3 )
 
        {
 
            this.SetConstant();
 
            this.b0 = this.p0;
 
            this.b1 = this.p1;
 
            this.b2 = this.p2;
 
            this.b3 = this.p3;
 
        }
 
    }
 
}

不知作者处于何种目的考虑 SetConstant 中那些可以化简的式子一个都没化简,而且写的非常绕,例如 

this.Cx = 3f * ( ( this.p0.x + this.p1.x ) - this.p0.x );

不能化简成如下结果?

 this.Cx = 3f *this.p1.x;

不过好像大家都不在意这些,这段代码网上到处可见,也用得“好好的”。

自己化简了下,应该可以写成下面这样。

Func<Vector3, Vector3, Vector3, Vector3, Func<float, Vector3>> GetBezierPoint = (a, b, c, d) => t => a + (-3 * a + 3 * b) * t + (3 * a - 6 * b + 3 * c) * t * t + (-a + 3 * b - 3 * c + d) * t * t * t;

一年总结(一)

离职手续正在办理中,第一份工作就要结束了。尽管我很珍惜这份工作,可公司、领导太过分!一年多来先后做了三个项目,现在还是三个项目同时在做。懒人一个,平时没时间、没心情写总结。就要走了闲来无聊,写点东西打发时间。

PTN 传输、WLAN、7750 路由器,一年多来做的都是粗活没什么技术含量。在 WLAN 上面花的时间比较多,总结就从这个开始吧。

继续阅读

TSS-5C 配置

printenv
set ipaddr 169.254.1.1  #配置 5C 临时 LAN IP
set serverip 169.254.1.2 # 指定 TFPT 服务器 IP
saveenv  #保存配置
nand erase  # 清空缓存区
tftp 0x350000 TSS5CAPP.bin #上传软件到缓存区,存储起始地址位:0x350000 。
nand write.jffs2 0x350000 0 0x3555413
boot  
 
id:alu   psw:alu123$
telnet 127.0.0.1 3083
act-user::ALUTSS:::Alu_1234;   #登录 ALUTSS ,PSW:Alu_1234
SET-SID:::::NINGHUAXXX;        #设置 SID
ed-lan:::C000:::LANIP=169-254-1-1,LANMASK=255-255-255-0,LANGW=169-254-1-2;   #设置 LAN IP
rtrv-lan:::;   #检查 LAN IP 地址
RTRV-PRMTR-NE;

-----------------------------------------------------------------------------------

TSS5CAPP.bin  好像是一个修改过的 Red Hat




Host by is-Programmer.com | Power by Chito 1.3.3 beta | © 2007 LinuxGem | Design by Matthew "Agent Spork" McGee