コード例 #1
0
        public override Tuple <Item[], int> GenerateLootItem(Mobile creature)
        {
            BaseBone bone = Activator.CreateInstance(m_BoneType) as BaseBone;

            if (bone == null)
            {
                throw new Exception(String.Format("Type {0} is not BaseBone or could not be instantiated.", m_BoneType));
            }

            int value = BaseValue;

            bone.BoneType = (BoneType)GetBonus();

            switch (bone.BoneType)
            {
            case BoneType.Preserved: value += 50; break;

            case BoneType.Ancient: value += 100; break;

            case BoneType.Fossilized: value += 250; break;

            case BoneType.Ethereal: value += 500; break;

            case BoneType.Demonic: value += 1500; break;
            }

            return(new Tuple <Item[], int>(new Item[] { bone }, value));
        }
コード例 #2
0
ファイル: PrixNPC.cs プロジェクト: jicomub/Temrael
        public static int SellResource(Type type)
        {
            object item = Activator.CreateInstance(type);

            if (item is BaseIngot)
            {
                BaseIngot ing = item as BaseIngot;

                switch (ing.Resource)
                {
                case CraftResource.Fer: return(1);

                case CraftResource.Cuivre: return(2);

                case CraftResource.Bronze: return(3);

                case CraftResource.Acier: return(5);

                case CraftResource.Argent: return(7);
                }
            }

            if (item is BaseBone)
            {
                BaseBone bone = item as BaseBone;

                switch (bone.Resource)
                {
                case CraftResource.RegularBones: return(1);

                case CraftResource.GobelinBones: return(2);

                case CraftResource.NordiqueBones: return(3);

                case CraftResource.ReptilienBones: return(5);

                case CraftResource.DesertiqueBones: return(7);
                }
            }

            if (item is BaseLeather)
            {
                BaseLeather leath = item as BaseLeather;

                switch (leath.Resource)
                {
                case CraftResource.RegularLeather: return(1);

                case CraftResource.LupusLeather: return(2);

                case CraftResource.NordiqueLeather: return(3);

                case CraftResource.ReptilienLeather: return(5);

                case CraftResource.DesertiqueLeather: return(7);
                }
            }

            if (item is BaseLog)
            {
                BaseLog board = item as BaseLog;

                switch (board.Resource)
                {
                case CraftResource.RegularWood: return(1);

                case CraftResource.PinWood: return(2);

                case CraftResource.CypresWood: return(5);
                }
            }

            if (item is BaseGem)
            {
                if (item is Coquillage)
                {
                    return(1);
                }
                if (item is Amber)
                {
                    return(2);
                }
                if (item is Citrine)
                {
                    return(3);
                }
                if (item is Tourmaline)
                {
                    return(5);
                }
                if (item is Amethyst)
                {
                    return(7);
                }
            }

            return(-1);
        }
コード例 #3
0
    //Load model from unity, map model bones to our bone structure and create a skeleton
    private void LoadModel()
    {
        //Clone the referenced mesh
        AnimatedMesh.mesh = ReferenceMesh.sharedMesh.CloneMesh();
        AnimatedMesh.GetComponent <Renderer>().materials = ReferenceMesh.GetComponent <Renderer>().materials;
        _vertices = new List <Vector3>(AnimatedMesh.mesh.vertices.Length);

        var basePoseVertices   = new Vector3[ReferenceMesh.sharedMesh.vertices.Length];
        var basePoseNormals    = new Vector3[ReferenceMesh.sharedMesh.normals.Length];
        var nameBoneDictionary = new Dictionary <string, BaseBone>();

        BaseBone[] boneArray = new BaseBone[0];
        var        vertexIdBoneWeightDictionary = new Dictionary <int, Dictionary <string, float> >();

        int[]   boneIndexArray  = new int[0];
        float[] boneWeightArray = new float[0];

        //Load vertices and normals for basePose
        Array.Copy(ReferenceMesh.sharedMesh.vertices, basePoseVertices, basePoseVertices.Length);
        Array.Copy(ReferenceMesh.sharedMesh.normals, basePoseNormals, basePoseNormals.Length);

        var bindPoses = new Matrix4x4[ReferenceMesh.sharedMesh.bindposes.Length];

        Array.Copy(ReferenceMesh.sharedMesh.bindposes, bindPoses, bindPoses.Length);

        //bones could for example be pulled from a SkinnedMeshRenderer
        boneArray = new BaseBone[ReferenceMesh.bones.Length];

        for (var i = 0; i < ReferenceMesh.bones.Length; i++)
        {
            var localPosition = bindPoses[i].inverse.GetColumn(3);
            var localRotation = bindPoses[i].inverse.rotation;

            if (i == 0)
            {
                boneArray[i] = new RootBone(localPosition, localRotation);
                ReferenceMesh.rootBone.name = "root";
                nameBoneDictionary.Add(ReferenceMesh.rootBone.name, boneArray[i]);
            }
            else
            {
                var parentIndex = -1;
                for (var j = 0; j < ReferenceMesh.bones.Length; j++)
                {
                    if (ReferenceMesh.bones[j] != ReferenceMesh.bones[i].parent)
                    {
                        continue;
                    }

                    parentIndex = j;
                    break;
                }
                localRotation = (ReferenceMesh.sharedMesh.bindposes[parentIndex] * ReferenceMesh.sharedMesh.bindposes[i].inverse).rotation;
                localPosition = (ReferenceMesh.sharedMesh.bindposes[parentIndex] * ReferenceMesh.sharedMesh.bindposes[i].inverse).GetColumn(3);
                boneArray[i]  = new Bone(localPosition, localRotation, ReferenceMesh.bones[i].parent.name);
                nameBoneDictionary.Add(ReferenceMesh.bones[i].name, boneArray[i]);
            }
        }

        //Unity BoneWeight class can assign up to four bones to each vertex, acessable via bone inicies
        var boneWeights = ReferenceMesh.sharedMesh.boneWeights;

        boneWeightArray = new float[basePoseVertices.Length * 4];
        boneIndexArray  = new int[basePoseVertices.Length * 4];
        for (var i = 0; i < basePoseVertices.Length; i++)
        {
            Dictionary <string, float> dic = new Dictionary <string, float>();
            var name0 = ReferenceMesh.bones[boneWeights[i].boneIndex0].name;
            var name1 = ReferenceMesh.bones[boneWeights[i].boneIndex1].name;
            var name2 = ReferenceMesh.bones[boneWeights[i].boneIndex2].name;
            var name3 = ReferenceMesh.bones[boneWeights[i].boneIndex3].name;

            dic.Add(name0, boneWeights[i].weight0);
            if (!dic.ContainsKey(name1))
            {
                dic.Add(name1, boneWeights[i].weight1);
            }
            if (!dic.ContainsKey(name2))
            {
                dic.Add(name2, boneWeights[i].weight2);
            }
            if (!dic.ContainsKey(name3))
            {
                dic.Add(name3, boneWeights[i].weight3);
            }
            vertexIdBoneWeightDictionary.Add(i, dic);

            boneWeightArray[4 * i]     = boneWeights[i].weight0;
            boneWeightArray[4 * i + 1] = boneWeights[i].weight1;
            boneWeightArray[4 * i + 2] = boneWeights[i].weight2;
            boneWeightArray[4 * i + 3] = boneWeights[i].weight3;
            boneIndexArray[4 * i]      = boneWeights[i].boneIndex0;
            boneIndexArray[4 * i + 1]  = boneWeights[i].boneIndex1;
            boneIndexArray[4 * i + 2]  = boneWeights[i].boneIndex2;
            boneIndexArray[4 * i + 3]  = boneWeights[i].boneIndex3;
        }

        //Create a skeleton
        Skeleton = new Skeleton(nameBoneDictionary, vertexIdBoneWeightDictionary, basePoseVertices, basePoseNormals, boneArray, boneIndexArray, boneWeightArray);

        //Deactivate template
        ReferenceMesh.gameObject.SetActive(false);
    }