Пример #1
0
    string DoEntityCmd(int id, string funcName, string[] args)
    {
        Pathea.PeEntity entity = Pathea.EntityMgr.Instance.Get(id);
        if (null == entity)
        {
            return("can't find entity by id:" + id);
        }

        switch (funcName)
        {
        case "servant":
            Pathea.NpcCmpt npcCmpt = entity.GetCmpt <Pathea.NpcCmpt>();
            if (npcCmpt == null)
            {
                return("no NpcCmpt.");
            }

            Pathea.ServantLeaderCmpt leader = Pathea.PeCreature.Instance.mainPlayer.GetCmpt <Pathea.ServantLeaderCmpt>();
            if (leader == null)
            {
                return("no ServantLeaderCmpt");
            }

            leader.AddServant(npcCmpt);
            npcCmpt.SetServantLeader(leader);
            return("ok");

        case "start_skill":
            int targetId;
            if (!int.TryParse(args[0], out targetId))
            {
                return("get target id failed");
            }
            Pathea.PeEntity      targetEntity = Pathea.EntityMgr.Instance.Get(targetId);
            Pathea.SkAliveEntity skillCmpt    = targetEntity.GetCmpt <Pathea.SkAliveEntity>();
            if (null == skillCmpt)
            {
                return("target have no SkillCmpt");
            }
            int skillId;
            if (!int.TryParse(args[1], out skillId))
            {
                return("get skill id failed");
            }
            skillCmpt.StartSkill(skillCmpt, skillId);
            return("ok");

        case "Kill":
            Pathea.PeEntity killEntity = Pathea.EntityMgr.Instance.Get(id);
            if (killEntity == null)
            {
                return("get entity failed with id : " + id);
            }
            killEntity.SetAttribute(Pathea.AttribType.Hp, 0.0f, false);
            return("ok");

        //case "SetBool":
        //    string animationName = args[0];
        //    bool value;
        //    if (!bool.TryParse(args[1], out value))
        //    {
        //        return "get value failed";
        //    }

        //    entity.SetBool(animationName, value);
        //    return "ok";
        default:
            return("not implementd cmd");
        }
    }