Exemplo n.º 1
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get the type of object to spawn
            int spawnType = DropDownListValue.GetValue(heroKitObject, 0);

            // where are we spawning item? from pool or in scene?
            bool   usePool  = BoolValue.GetValue(heroKitObject, 1);
            string poolName = (usePool) ? StringFieldValue.GetValueA(heroKitObject, 2) : "";

            // debug string
            string debugSpawn = "";

            // get the object to spawn (1=hero object, 2=prefab)
            if (spawnType == 1)
            {
                HeroObject heroSpawn      = HeroObjectFieldValue.GetValueC(heroKitObject, 3);
                bool       debugHeroSpawn = BoolValue.GetValue(heroKitObject, 4);
                bool       dontSave       = BoolValue.GetValue(heroKitObject, 5);
                Vector3    position       = GetPosition();
                Quaternion rotation       = GetRotation();
                HeroKitDatabase.SpawnHeroKitObject(usePool, poolName, position, rotation, heroSpawn, debugHeroSpawn, dontSave);
                if (heroKitObject.debugHeroObject)
                {
                    debugSpawn = "Hero Object: " + heroSpawn + "\n" +
                                 "Debug: " + debugHeroSpawn + "\n" +
                                 "Can Save: " + !dontSave + "\n" +
                                 "Position: " + position + "\n" +
                                 "Rotation: " + rotation + "\n" +
                                 "Use Pool: " + usePool + "\n" +
                                 "Pool Name: " + poolName;
                }
            }
            else if (spawnType == 2)
            {
                GameObject prefabSpawn = (!usePool) ? PrefabValue.GetValue(heroKitObject, 5) : null;
                Vector3    position    = GetPosition();
                Quaternion rotation    = GetRotation();
                HeroKitDatabase.SpawnPrefab(usePool, poolName, position, rotation, prefabSpawn);
                if (heroKitObject.debugHeroObject)
                {
                    debugSpawn = "Game Object: " + prefabSpawn + "\n" +
                                 "Position: " + position + "\n" +
                                 "Rotation: " + rotation + "\n" +
                                 "Use Pool: " + usePool + "\n" +
                                 "Pool Name: " + poolName;
                }
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = debugSpawn;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }