Exemple #1
0
    private bool CheckKillAll(GrowthTriggerStep step)
    {
        if (step == null)
        {
            return(false);
        }

        bool allDie = true;

        for (int i = 0; i < cacheIdKillAll.Count; ++i)
        {
            ObjectBase obj = mScene.FindObject((uint)cacheIdKillAll[i]);
            if (obj == null)
            {
                cacheIdRemove.Add(cacheIdKillAll[i]);
            }
            else
            {
                allDie = false;
            }
        }

        if (allDie)
        {
            cacheIdKillAll.Clear();
        }

        foreach (uint id in cacheIdRemove)
        {
            cacheIdKillAll.Remove(id);
        }
        cacheIdRemove.Clear();

        return(allDie);
    }
Exemple #2
0
    private void DoNext(int next)
    {
        if (mScene == null)
        {
            return;
        }

        GrowthTriggerStep step = steps[next] as GrowthTriggerStep;

        if (step == null || step.objs.Count <= 0)
        {
            return;
        }

        slowCreateIds = (ArrayList)step.objs.Clone();

        step.curTime      = 0;
        step.curSpaceTime = 0;
        step.curRepeat++;
    }
Exemple #3
0
    override public void Update(uint elapsed)
    {
        if (!IsRunning())
        {
            return;
        }

        if (mScene == null)
        {
            return;
        }

        if (mCurStep < 0)
        {
            DoNext(++mCurStep);
            return;
        }

        //步骤执行完
        if (mCurStep >= steps.Count)
        {
            return;
        }

        GrowthTriggerStep step = steps[mCurStep] as GrowthTriggerStep;

        if (step == null)
        {
            return;
        }

        if (doSlowCreate(step.killAll))
        {
            return;
        }

        if (step.killAll && !CheckKillAll(step))
        {
            return;
        }

        int spacetime = (int)elapsed;

        if (step.curRepeat < step.repeat || step.repeat < 0)
        {
            step.curSpaceTime += spacetime;
            if (step.curSpaceTime > step.spacetime)
            {
                DoNext(mCurStep);
            }
            else
            {
                return;
            }
        }

        step.curTime += spacetime;

        if (step.curTime < step.time)
        {
            return;
        }

        ++mCurStep;
        if (mCurStep >= steps.Count)
        {
            Stop();
            mScene.OnTriggerFinish(this.name);
            mScene.OnGrowthTriggerFinish(this.name);
            return;
        }

        DoNext(mCurStep);
    }
    // 解析NpcGrowth
    private void ParseNpcGrowth(XmlNode node)
    {
        GrowthTrigger trigger = new GrowthTrigger(mScene);

        trigger.name = node.Attributes["name"].Value;
        XmlNodeList nodeList = node.ChildNodes;

        for (int i = 0; i < nodeList.Count; ++i)
        {
            XmlNode childNode = nodeList[i];
            if (childNode != null && childNode.Name == "Step")
            {
                GrowthTriggerStep step = new GrowthTriggerStep();
                int ka = System.Convert.ToInt32(childNode.Attributes["killAll"].Value);
                step.killAll = (ka != 0);
                step.time    = System.Convert.ToInt32(childNode.Attributes["time"].Value);

                if (childNode.Attributes["repeat"] != null && childNode.Attributes["spacetime"] != null)
                {
                    step.repeat    = System.Convert.ToInt32(childNode.Attributes["repeat"].Value);
                    step.spacetime = System.Convert.ToInt32(childNode.Attributes["spacetime"].Value);
                }

                XmlNodeList stepList = childNode.ChildNodes;
                for (int j = 0; j < stepList.Count; ++j)
                {
                    XmlNode stepNode = stepList[j];

                    if (stepNode != null && stepNode.Name == "Growth")
                    {
                        GrowthTriggerInfo info       = null;
                        string            growthtype = stepNode.Attributes["type"].Value;
                        if (growthtype.Equals("PICK"))
                        {
                            info = new PickGrowthTriggerInfo();
                            (info as PickGrowthTriggerInfo).picktype = System.Convert.ToInt32(stepNode.Attributes["picktype"].Value);
                            (info as PickGrowthTriggerInfo).content  = System.Convert.ToInt32(stepNode.Attributes["content"].Value);
                        }
                        else if (growthtype.Equals("BUILD"))
                        {
                            info = new BuildGrowthTriggerInfo();
                            (info as BuildGrowthTriggerInfo).barrier = System.Convert.ToInt32(stepNode.Attributes["barrier"].Value);
                        }
                        else
                        {
                            info = new GrowthTriggerInfo();
                        }

                        info.type  = growthtype;
                        info.resId = System.Convert.ToInt32(stepNode.Attributes["resId"].Value);
                        info.x     = System.Convert.ToSingle(stepNode.Attributes["x"].Value);
                        info.z     = System.Convert.ToSingle(stepNode.Attributes["z"].Value);
                        info.dir   = System.Convert.ToSingle(stepNode.Attributes["dir"].Value) * Mathf.Deg2Rad;

                        if (stepNode.Attributes["talkid"] != null)
                        {
                            info.talkID = System.Convert.ToInt32(stepNode.Attributes["talkid"].Value);
                        }

                        if (stepNode.Attributes["name"] != null)
                        {
                            info.alias = stepNode.Attributes["name"].Value;
                        }

                        step.objs.Add(info);
                    }
                }
                trigger.steps.Add(step);
            }
        }

        mTriggers.Add(trigger.name, trigger);
    }