Example #1
0
    /// <summary>
    /// 获取新生对象
    /// </summary>
    /// <returns></returns>
    private GameObject GetNewGameObject(PairedIndex <OrganIndex> pairedOrganIndex)
    {
        GameObject cloneObject = GameObject.Instantiate(pairedOrganIndex.CurIndex.Belong);

        /*
         * 因枝干顶点已经调整完毕
         * 故可用后一关键帧中枝干所指的顶点索引确定前一关键帧顶点的位置
         */
        Vector3 position = TreeModel.GetBranchTopCenter(m_PreGameObjects[0], pairedOrganIndex.CurIndex.From);

        foreach (GameObject _subObject in GameObjectOperation.GetGameObjects(cloneObject))
        {
            if (!GameObjectValidate.HavaVertices(_subObject))
            {
                continue;
            }

            Vector3[] vertices = GameObjectOperation.GetVertices(_subObject);

            //该对象所有顶点均为该位置
            CopyVertices(_subObject.transform.InverseTransformPoint(position), vertices);
            GameObjectOperation.UpdateMeshInfo(_subObject, vertices);
        }

        //设置阈值为0
        GameObjectOperation.SetThreshold(cloneObject, 0);

        return(cloneObject);
    }
Example #2
0
    public double InsectSim(double insectIntake)
    {
        /*
         * 当该叶片的最低被啃食比例小于细胞纹理的最低被啃食比例时
         * 说明该比例无或者存在一定的问题
         * 因此将该比例设置为细胞纹理的最低被啃食比例
         */
        if (LimitRatio < CelluarTex.LimitRatio)
        {
            LimitRatio = CelluarTex.LimitRatio;

            /*
             * 调整最低被啃食比例
             * 减少重复感
             */
            LimitRatio += (0.8 - LimitRatio) * RandomNumer.Double();
        }

        /*
         * 叶片当前最大可被进食量
         * 用于计算当前实际被进食量
         */
        double maxInsectIntake = (InsectedRatio - LimitRatio) * LeafArea_Uninsected;

        /*
         * 若该叶片已经老去
         * 则不会被并病虫啃食
         * 若还未老去,则根据叶片最大被进食量计算实际被进食量
         * 当最大可被进食量不大于0时,说明无可被进食部分,因此实际被进食量为0
         * 当最大可被进食量大于当前病虫进食量,则说明该叶片满足病虫进食需求,因此实际进食量为病虫进食量
         * 当最大可被进食量大于0并且小于当前病虫进食量,则说明该叶片有被进食,但无法满足病虫进食需求
         * 因此最大可被进食量均被进食,故实际进食量为最大可被进食量
         */
        double actualInsectIntake = Age >= MaizeParams.LEAF_MAX_DEVELOPMENT_AGE ? 0 :
                                    maxInsectIntake <= 0 ? 0 :
                                    maxInsectIntake >= insectIntake ? insectIntake : maxInsectIntake;

        //根据实际进食量计算叶片的面积
        LeafArea -= actualInsectIntake;

        int threshold;

        //设置纹理
        GameObjectOperation.SetTexture(Belong, GetWormholeTex(actualInsectIntake, out threshold));

        //设置阈值
        GameObjectOperation.SetThreshold(Belong, threshold);

        //返回剩余的病虫进食量
        return(insectIntake - actualInsectIntake);
    }