Esempio n. 1
0
    private bool CreateNPC(ObjectBase obj, respond_msg_gm respond)
    {
        if (respond == null)
        {
            return(false);
        }

        if (obj == null)
        {
            return(false);
        }

        BaseScene scn = SceneManager.Instance.GetCurScene();

        if (scn == null)
        {
            return(false);
        }

        NpcInitParam initParam = new NpcInitParam();

        initParam.npc_res_id = System.Convert.ToInt32(respond.param1);
        initParam.init_pos   = obj.GetPosition();
        initParam.init_dir   = obj.GetDirection();

        return(scn.CreateSprite(initParam) != null);
    }
Esempio n. 2
0
    private bool CreateNPC(ObjectBase obj, ArrayList param)
    {
        if (param == null || param.Count != 1)
        {
            return(false);
        }

        if (obj == null)
        {
            return(false);
        }

        BaseScene scn = SceneManager.Instance.GetCurScene();

        if (scn == null)
        {
            return(false);
        }

        NpcInitParam initParam = new NpcInitParam();

        initParam.npc_res_id = System.Convert.ToInt32(param[0]);
        initParam.init_pos   = obj.GetPosition();
        initParam.init_dir   = obj.GetDirection();

        return(scn.CreateSprite(initParam) != null);
    }
Esempio n. 3
0
    private void CreateBoss(uint time)
    {
        NpcInitParam initParam = new NpcInitParam();

        initParam.npc_res_id = GameConfig.ZhaoCaiMaoId;
        initParam.init_pos   = new Vector3(GameConfig.ZhaoCaiMaoPosX, 0.0f, GameConfig.ZhaoCaiMaoPosY);
        initParam.init_pos.y = GetHeight(initParam.init_pos.x, initParam.init_pos.z);
        initParam.init_dir   = GameConfig.ZhaoCaiMaoDir;
        initParam.alias      = "zhaocaimao";
        mBoss = CreateSprite(initParam) as Npc;
    }
Esempio n. 4
0
    override public bool Init(ObjectInitParam param)
    {
        NpcInitParam npcParam = (NpcInitParam)param;

        if (!DataManager.NPCTable.ContainsKey(npcParam.npc_res_id))
        {
            return(false);
        }
        mRes        = DataManager.NPCTable[npcParam.npc_res_id] as NPCTableItem;
        mModelResID = mRes.model;

        if (!base.Init(param))
        {
            return(false);
        }

        mBattleUintAI = AIFactory.Instance.CreateAIObject(this, mRes.ai);
        if (mBattleUintAI == null)
        {
            return(false);
        }

        if (npcParam.talk_id >= 0)
        {
            mTalkID = npcParam.talk_id;
        }
        else
        {
            mTalkID = mRes.talkID;
        }

        InitTalk();

        SetLeague(mRes.league);

        mDestroyWaiting       = true;
        mMaxDisappearTime     = mRes.DisappearTime;
        mMaxWaitDisappearTime = mRes.WaitDisappearTime;

        mLifeTime = npcParam.lifeTime;

        mSummonerAttr = npcParam.summonerAttr;

        InitProperty();

        if (mRes.bossHpUnit < 0 && mRes.showHp)
        {
            mBloodNode = BloodUIManager.Instance.CreateBloodUI();
        }

        GetCrySound();
        return(true);
    }
Esempio n. 5
0
    private bool doSlowCreate(bool killAll)
    {
        if (slowCreateIds.Count < 1)
        {
            return(false);
        }

        GrowthTriggerInfo info = slowCreateIds[0] as GrowthTriggerInfo;

        if (info.type == "NPC")
        {
            NpcInitParam npcParam = new NpcInitParam();
            npcParam.npc_res_id = info.resId;
            float y = mScene.GetHeight(info.x, info.z);
            npcParam.init_pos = new Vector3(info.x, y, info.z);
            npcParam.init_dir = info.dir;
            npcParam.alias    = info.alias;
            npcParam.talk_id  = info.talkID;

            ObjectBase obj = mScene.CreateSprite(npcParam);
            if (obj == null)
            {
                GameDebug.LogError("创建Npc失败。npcId:" + info.resId);
                return(false);
            }

            if ("ghost" == info.alias)
            {
                mScene.GhostObjects().Add(info);
            }

            if (obj != null)
            {
                if (killAll)
                {
                    cacheIdKillAll.Add(obj.InstanceID);
                }
                else
                {
                    cacheId.Add(obj.InstanceID);
                }
            }
        }
        else if (info.type == "PICK")
        {
            PickGrowthTriggerInfo pickinfo = info as PickGrowthTriggerInfo;

            List <PickInitParam> paramList = new List <PickInitParam>();
            if (SceneObjManager.CreatePickInitParam((Pick.PickType)(System.Enum.Parse(typeof(Pick.PickType), pickinfo.picktype.ToString())),
                                                    pickinfo.resId, pickinfo.content, new Vector3(info.x, mScene.GetHeight(info.x, info.z), info.z), info.dir, out paramList, false,
                                                    Pick.FlyType.FLY_OUT, pickinfo.picktype != (int)Pick.PickType.SUPER_WEAPON))
            {
                foreach (PickInitParam param in paramList)
                {
                    param.init_pos.y = mScene.GetHeight(param.init_pos.x, param.init_pos.z);
                    param.alias      = info.alias;
                    ObjectBase obj = mScene.CreateSprite(param);
                    if (obj == null)
                    {
                        GameDebug.LogError("创建Pick失败。pickId:" + info.resId);
                        return(false);
                    }

                    if (obj != null)
                    {
                        if (killAll)
                        {
                            cacheIdKillAll.Add(obj.InstanceID);
                        }
                        else
                        {
                            cacheId.Add(obj.InstanceID);
                        }
                    }
                }
            }
        }
        else if (info.type == "BUILD")
        {
            BuildGrowthTriggerInfo buildinfo = info as BuildGrowthTriggerInfo;

            BuildInitParam buildParam = new BuildInitParam();
            buildParam.build_res_id = info.resId;
            float y = mScene.GetHeight(info.x, info.z);
            buildParam.init_pos      = new Vector3(info.x, y, info.z);
            buildParam.init_dir      = info.dir;
            buildParam.build_barrier = buildinfo.barrier > 0;
            buildParam.alias         = info.alias;

            ObjectBase obj = mScene.CreateSprite(buildParam);
            if (obj == null)
            {
                GameDebug.LogError("创建Building失败。buildId:" + info.resId);
                return(false);
            }

            if (obj != null)
            {
                if (killAll)
                {
                    cacheIdKillAll.Add(obj.InstanceID);
                }
                else
                {
                    cacheId.Add(obj.InstanceID);
                }
            }
        }
        else if (info.type == "PARTICLE")
        {
            Vector3 pos = new Vector3(info.x, mScene.GetHeight(info.x, info.z), info.z);
            mScene.CreateEffect(info.resId, Vector3.one, pos, info.dir, info.alias);
        }

        slowCreateIds.RemoveAt(0);

        if (slowCreateIds.Count < 1)
        {
            return(false);
        }

        return(true);
    }