protected void OnEnable()
        {
            prefabList = new PrefabList();
            database   = LootDatabase.Load();

            richTextStyle.richText = true;
        }
Example #2
0
    public void sendForward(GameObject caster)
    {
        if (SceneLoader.instance && SceneLoader.instance.sceneLoading)
        {
            return;
        }

        // force wait
        StateController stateController = caster.GetComponent <StateController>();

        if (stateController && stateController.waiting && (!stateController.currentState || stateController.currentState.priority < 95))
        {
            stateController.forceChangeState(stateController.waiting);
        }

        // send forward in time
        GameObject tardis = new GameObject();

        tardis.transform.position = caster.transform.position;
        tardis.AddComponent <SelfDestroyer>();
        DisableChildrenForDurationThenRelease chameleonCircuit = tardis.AddComponent <DisableChildrenForDurationThenRelease>();

        chameleonCircuit.duration = duration;
        CreateOnDeath cod = tardis.AddComponent <CreateOnDeath>();

        cod.objectsToCreateOnDeath.Add(new CreateOnDeath.GameObjectHolder(PrefabList.getPrefab("AnomalyEndEffect")));

        chameleonCircuit.disableSceneLoaderForDuration = true;
        chameleonCircuit.tag        = "Persistent";
        chameleonCircuit.nextParent = caster.transform.parent;
        caster.transform.parent     = tardis.transform;
    }
 /// <summary>
 /// Detaches and recycles prefab instance to pool.
 /// Instance will be automatically deactivated.
 /// </summary>
 public void Detach()
 {
     if ((object)Prefab != null && _path != null)
     {
         Prefab.SetActive(false);
         PrefabList list;
         if (!_prefabPools.TryGetValue(_path, out list))
         {
             // Detaching after DestroyPool call.
             list                = new PrefabList();
             list.Prefab         = Prefab;
             _prefabPools[_path] = list;
         }
         else
         {
             if (list.Count == list.Instances.Length)
             {
                 Array.Resize(ref list.Instances, list.Count << 1);
             }
             list.Instances[list.Count++] = Prefab;
         }
         Prefab = null;
         _path  = null;
     }
 }
Example #4
0
 // Создать список префабов
 private void CreateNewList(string name)
 {
     viewIndex = 1;
     list      = Create(name);
     EditorUtility.FocusProjectWindow();
     Selection.activeObject = list;
 }
Example #5
0
    // Use this for initialization
    protected override void Awake()
    {
        ability = AbilityIDList.getAbility(AbilityID.summonWraith);
        health  = GetComponent <BaseHealth>();
        mana    = GetComponent <BaseMana>();

        if (health)
        {
            statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject);

            tracker = Comp <SummonTracker> .GetOrAdd(gameObject);

            AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject);

            listener.onCritEvent += OnCrit;
        }

        // get wraith prefabs
        if (flameWraithPrefab == null)
        {
            Ability wraithAbility = Ability.getAbility(AbilityID.summonFlameWraith);
            if (wraithAbility && wraithAbility.abilityPrefab)
            {
                SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>();
                if (summon)
                {
                    flameWraithPrefab = summon.entity;
                }
            }

            wraithAbility = Ability.getAbility(AbilityID.summonPutridWraith);
            if (wraithAbility && wraithAbility.abilityPrefab)
            {
                SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>();
                if (summon)
                {
                    putridWraithPrefab = summon.entity;
                }
            }

            wraithAbility = Ability.getAbility(AbilityID.summonBloodWraith);
            if (wraithAbility && wraithAbility.abilityPrefab)
            {
                SummonEntityOnDeath summon = wraithAbility.abilityPrefab.GetComponent <SummonEntityOnDeath>();
                if (summon)
                {
                    bloodWraithPrefab = summon.entity;
                }
            }
        }

        // spirit escape prefab
        if (spiritEscapePrefab == null)
        {
            spiritEscapePrefab = PrefabList.getPrefab("spiritEscape");
        }

        base.Awake();
    }
Example #6
0
 /// <summary>
 /// インスペクターが開かれる度に実行
 /// </summary>
 private void OnEnable()
 {
     list = (PrefabList)target;
     if (list.List == null)
     {
         list.List = new List <GameObject>();
     }
 }
Example #7
0
 void OnEnable()
 {
     listName = "Enter name";
     if (EditorPrefs.HasKey("ObjectPath"))
     {
         string objectPath = EditorPrefs.GetString("ObjectPath");
         list = AssetDatabase.LoadAssetAtPath(objectPath, typeof(PrefabList)) as PrefabList;
     }
 }
    private void Create()
    {
        if (list != null)
        {
            return;
        }

        // scriptableObjectを作成。
        list = ScriptableObject.CreateInstance <PrefabList>();

        // 保存。
        // AssetDatabaseはUnityEditorのネームスペースなので、Editor以外で使用する場合には注意。
        AssetDatabase.CreateAsset(list, PATH);
    }
Example #9
0
    // Открыть список префабов
    private void OpenList()
    {
        string absPath = EditorUtility.OpenFilePanel("Select Prefab List", "Assets/GameData/", "asset");

        if (absPath.StartsWith(Application.dataPath))
        {
            string relPath = absPath.Substring(Application.dataPath.Length - "Assets".Length);
            list = AssetDatabase.LoadAssetAtPath(relPath, typeof(PrefabList)) as PrefabList;
            if (list)
            {
                EditorPrefs.SetString("ObjectPath", relPath);
            }
        }
    }
    public void Display(QuizContent _content)
    {
        var content = _content as MultipleChoice;

        PrefabList.CacheInstances(
            prefab: OptionPrefab,
            parent: MultipleChoiceOptionContainer,
            amountWanted: content.QuizOptions.Count,
            cache: multipleChoiceObjects
            );
        for (int i = 0; i < content.QuizOptions.Count; i++)
        {
            multipleChoiceObjects[i].GetComponentInChildren <Text>().text = content.QuizOptions[i].optionText;
        }
    }
Example #11
0
    // Use this for initialization
    public void Initialize()
    {
        prefabList = new PrefabList();
        waveList = new List<Wave>();

        //플레이어들의 Targetting을 관리하기 위해 참조
        GameObject[] pl = GameObject.FindGameObjectsWithTag("Player");
        for (int i = 0; i < pl.Length; i++)
            playerList.Add(pl[i]);

        waveCount = 0;
        generateCoolDown = 1f;
        timeCounter = 0f;

        // 게임 컨트롤러 참조
        gameController = GetComponent<GameController>();
    }
Example #12
0
            public SubEventPrefab(string debugIdentifier, string[] prefabIdentifiers, float?commonness, float?probability)
            {
                EventPrefab tryFindPrefab(string id)
                {
                    var prefab = PrefabList.Find(p => p.Identifier.Equals(id, StringComparison.OrdinalIgnoreCase));

                    if (prefab is null)
                    {
                        DebugConsole.ThrowError($"Error in event set \"{debugIdentifier}\" - could not find the event prefab \"{id}\".");
                    }
                    return(prefab);
                }

                this.Prefabs = prefabIdentifiers
                               .Select(tryFindPrefab)
                               .Where(p => p != null)
                               .ToImmutableArray();
                this.Commonness  = commonness ?? this.Prefabs.Select(p => p.Commonness).MaxOrNull() ?? 0.0f;
                this.Probability = probability ?? this.Prefabs.Select(p => p.Probability).MaxOrNull() ?? 0.0f;
            }
        protected void BottomBar()
        {
            GUILayout.BeginHorizontal("Box", GUILayout.ExpandWidth(true));

            GUILayout.Label("Loot Ids: " + database.Count);

            if (GUILayout.Button("Refresh Cached PrefabList")) {
                prefabList = new PrefabList();
            }

            if (GUILayout.Button("Add Empty")) {
                int unnamedCount = 1;
                while (database.ContainsKey("Unnamed " + unnamedCount)) {
                    unnamedCount++;
                }
                database.Set("Unnamed " + unnamedCount, new Loot());
            }

            GUILayout.EndHorizontal();
        }
    public void sendForward(GameObject enemy)
    {
        if (enemy.transform.parent == null)
        {
            // force wait
            StateController stateController = enemy.GetComponent <StateController>();
            if (stateController && stateController.waiting && (!stateController.currentState || stateController.currentState.priority < 95))
            {
                stateController.forceChangeState(stateController.waiting);
            }

            // send forward in time
            GameObject tardis = new GameObject();
            tardis.transform.position = enemy.transform.position;
            enemy.transform.parent    = tardis.transform;
            tardis.AddComponent <SelfDestroyer>();
            DisableChildrenForDurationThenRelease chameleonCircuit = tardis.AddComponent <DisableChildrenForDurationThenRelease>();
            chameleonCircuit.duration = duration;
            CreateOnDeath cod = tardis.AddComponent <CreateOnDeath>();
            cod.objectsToCreateOnDeath.Add(new CreateOnDeath.GameObjectHolder(PrefabList.getPrefab("AnomalyEndEffect")));
        }
    }
Example #15
0
        /// <summary>
        /// Spawns prefab from specified path and assign to Prefab field.
        /// </summary>
        /// <param name="prefabPath">Prefab path in Resources folder.</param>
        public void Attach(string prefabPath)
        {
#if DEBUG
            if (string.IsNullOrEmpty(prefabPath))
            {
                throw new Exception("prefabPath");
            }
            if (_path != null)
            {
                throw new Exception("Already attached");
            }
#endif
            PrefabList list;
            if (!_prefabPools.TryGetValue(prefabPath, out list))
            {
                list        = new PrefabList();
                list.Prefab = Resources.Load <GameObject> (prefabPath);
#if DEBUG
                if (list.Prefab == null)
                {
                    throw new Exception(string.Format("Cant load prefab from \"{0}\"", prefabPath));
                }
#endif
                _prefabPools[prefabPath] = list;
            }
            _path = prefabPath;
            if (list.Count > 0)
            {
                list.Count--;
                Prefab = list.Instances[list.Count];
                list.Instances[list.Count] = null;
            }
            else
            {
                Prefab = UnityEngine.Object.Instantiate(list.Prefab);
                Prefab.SetActive(false);
            }
        }
Example #16
0
        private void OnTriggerEnter2D(Collider2D collision)
        {
            if (collision.gameObject.tag == "Player")
            {
                PrefabList prefabs = m_Prefabs.GetValue();

                Transform cur    = transform;
                Transform parent = cur;

                while (cur != null)
                {
                    parent = cur;
                    cur    = cur.parent;
                }

                // Choose a random prefab from the prefab list (that is not the same as the current segment) and randomly flips the instance for more variaty
                var nextPrefab = prefabs.Items[Random.Range(0, prefabs.Items.Length)];

                while (m_ParentObject.name.StartsWith(nextPrefab.name))
                {
                    nextPrefab = prefabs.Items[Random.Range(0, prefabs.Items.Length)];
                }

                GameObject nextSegObject = Instantiate(nextPrefab, parent);
                nextSegObject.transform.position = m_NextSpawnPoint.position;
                bool bFlip = Random.Range(0, 2) == 1;
                if (bFlip)
                {
                    Vector3 scale = nextSegObject.transform.localScale;
                    scale.x = -scale.x;
                    nextSegObject.transform.localScale = scale;
                }

                // Turn off collider to avoid repeated triggering
                var collider = gameObject.GetComponent <Collider2D>();
                collider.enabled = false;
            }
        }
        protected void BottomBar()
        {
            GUILayout.BeginHorizontal("Box", GUILayout.ExpandWidth(true));

            GUILayout.Label("Loot Ids: " + database.Count);

            if (GUILayout.Button("Refresh Cached PrefabList"))
            {
                prefabList = new PrefabList();
            }

            if (GUILayout.Button("Add Empty"))
            {
                int unnamedCount = 1;
                while (database.ContainsKey("Unnamed " + unnamedCount))
                {
                    unnamedCount++;
                }
                database.Set("Unnamed " + unnamedCount, new Loot());
            }

            GUILayout.EndHorizontal();
        }
Example #18
0
        public bool IsValid(out string error, PrefabList plist)
        {
            if (prefabName.Trim().Equals(""))
            {
                error = "Prefab name is empty";
                return(false);
            }

            if (!plist.IsValidPrefabName(prefabName) && !prefabName.Equals(NONE_PREFAB_NAME))
            {
                error = string.Format("Prefab name: {0} is not a valid prefab name", prefabName);
                return(false);
            }

            if (weight == 0)
            {
                error = "Weight is 0";
                return(false);
            }

            error = "";
            return(true);
        }
Example #19
0
        //選択肢表示に使うプレハブを取得
        protected virtual GameObject GetPrefab(AdvSelection selectionData)
        {
            GameObject prefab = null;

            if (!string.IsNullOrEmpty(selectionData.PrefabName))
            {
                //プレハブ名と一致するものを探す
                prefab = PrefabList.Find(x => x.name == selectionData.PrefabName);
                if (prefab != null)
                {
                    return(prefab);
                }
                else
                {
                    //見つからないとき
                    Debug.LogError("Not found Selection Prefab : " + selectionData.PrefabName);
                }
            }

            //プレハブ名の指定がなかったら、リストの一番目を
            //旧バージョンとの互換性のためListViewから選ぶ
            prefab = PrefabList.Count > 0 ? PrefabList[0] : ListView.ItemPrefab;
            return(prefab);
        }
Example #20
0
    // Use this for initialization
    protected override void Awake()
    {
        ability = AbilityIDList.getAbility(AbilityID.marrowShards);
        physTag.Add(Tags.AbilityTags.Physical);
        AbilityEventListener listener = Comp <AbilityEventListener> .GetOrAdd(gameObject);

        listener.onKillEvent += OnKill;
        listener.onCritEvent += OnCrit;
        health = GetComponent <BaseHealth>();
        if (health)
        {
            statBuffs = Comp <StatBuffs> .GetOrAdd(gameObject);

            tracker = Comp <SummonTracker> .GetOrAdd(gameObject);
        }
        aoc = Comp <AbilityObjectConstructor> .GetOrAdd(gameObject);

        mana               = GetComponent <BaseMana>();
        baseStats          = GetComponent <BaseStats>();
        boneNovaOffset     = new Vector3(0f, 1.2f, 0f);
        spiritEscapeOffset = new Vector3(0f, 1.1f, 0f);
        spiritEscapePrefab = PrefabList.getPrefab("spiritEscape");
        base.Awake();
    }
    /// <summary>Display the given content in the UI</summary>
    public void Display(UiContent content)
    {
        TitleObject.text = content.Title.ToUpper();

        PrefabList.CacheInstances(DescriptionPrefab, transform, content.Description.Count, descriptionObjects);
        for (int i = 0; i < content.Description.Count; i++)
        {
            descriptionObjects[i].text = content.Description[i];
        }

        PrefabList.CacheInstances(ImagePrefab, transform, content.Images.Count, imageObjects);
        for (int i = 0; i < content.Images.Count; i++)
        {
            var img    = imageObjects[i].GetComponentInChildren <Image>();
            var fitter = imageObjects[i].GetComponentInChildren <AspectRatioFitter>();
            var sprite = content.Images[i];

            if (sprite)
            {
                fitter.aspectRatio = sprite.rect.size.x / sprite.rect.size.y;
                img.sprite         = sprite;
            }
        }
    }
        protected void OnEnable()
        {
            prefabList = new PrefabList();
            database = LootDatabase.Load();

            richTextStyle.richText = true;
        }
Example #23
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        firstHit           = true;
        lastTargetPosition = targetLocation;

        if (movesRandomly)
        {
            RandomiseDirection component = abilityObject.AddComponent <RandomiseDirection>();
            component.maximumAngleChange      = 180f * (1 + increasedRandomisation);
            component.timeToRandomise         = RandomiseDirection.TimeToRandomise.DirectionMode;
            component.directionChangeInterval = directionChangeInterval;
            component.boundingAngle           = boundingAngle;
        }

        if (chanceToPoison > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Poison);
            newComponent.chance       = chanceToPoison;
        }

        if (chanceToIgnite > 0)
        {
            ChanceToApplyStatusOnEnemyHit chanceTo = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            chanceTo.chance       = chanceToIgnite;
            chanceTo.statusEffect = StatusEffectList.getEffect(StatusEffectID.Ignite);
        }

        if (chanceToShredArmour > 0)
        {
            ChanceToApplyStatusOnEnemyHit chanceTo = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            chanceTo.chance       = chanceToShredArmour;
            chanceTo.statusEffect = StatusEffectList.getEffect(StatusEffectID.ArmourShred);
        }

        if (addedCritChance != 0)
        {
            foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>())
            {
                damage.baseDamageStats.critChance += addedCritChance;
            }
        }

        if (addedCritMultiplier != 0)
        {
            foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>())
            {
                damage.baseDamageStats.critMultiplier += addedCritMultiplier;
            }
        }

        if (cullPercent > 0)
        {
            foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>())
            {
                damage.baseDamageStats.cullPercent += cullPercent;
            }
        }

        if (increasedDamage != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(increasedDamage);
                //holder.addBaseDamage(DamageType.PHYSICAL, holder.getBaseDamage(DamageType.PHYSICAL) * increasedDamage);
            }
        }

        if (addedFireDamage > 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.addBaseDamage(DamageType.FIRE, addedFireDamage);
            }
            // change the vfx
            abilityObject.GetComponent <CreateOnDeath>().objectsToCreateOnDeath.RemoveAt(0);
            abilityObject.GetComponent <CreateOnDeath>().add(PrefabList.getPrefab("animalSwipeVFXOrange"));
        }

        if (addedPhysicalDamage > 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.addBaseDamage(DamageType.PHYSICAL, addedPhysicalDamage);
            }
        }

        if (slows)
        {
            AttachAttachableOnEnemyHit newComponent = abilityObject.AddComponent <AttachAttachableOnEnemyHit>();
            newComponent.attachable = AbilityIDList.getAbility(AbilityID.slow).abilityPrefab;
        }

        if (travels)
        {
            // enable the vfx on the ability object itself
            foreach (Transform child in abilityObject.transform)
            {
                if (child.name == "SwipeVFX" && addedFireDamage <= 0)
                {
                    child.gameObject.SetActive(true);
                }
                if (child.name == "SwipeVFXOrange" && addedFireDamage > 0)
                {
                    child.gameObject.SetActive(true);
                }
            }
            // disable creating the vfx on death
            abilityObject.GetComponent <CreateOnDeath>().objectsToCreateOnDeath.RemoveAt(0);
            // set duration
            abilityObject.GetComponent <DestroyAfterDuration>().duration = 0.18f * (1 + increasedDuration);
            // set speed
            abilityObject.GetComponent <AbilityMover>().speed = 12f + addedSpeed;
            // remove start towards target
            abilityObject.GetComponent <StartsTowardsTarget>().distance = 0f;

            // add extra projectiles
            if (chanceOfExtraProjectiles > 0)
            {
                float rand2 = Random.Range(0f, 1f);
                if (rand2 < chanceOfExtraProjectiles)
                {
                    ExtraProjectiles extraProjectiles = abilityObject.AddComponent <ExtraProjectiles>();
                    extraProjectiles.angle        = 180f;
                    extraProjectiles.randomAngles = true;
                }
            }
        }


        return(abilityObject);
    }
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        if (convertToCold)
        {
            foreach (CreateOnDeath cod in abilityObject.GetComponents <CreateOnDeath>())
            {
                cod.objectsToCreateOnDeath.Clear();
                cod.objectsToCreateOnDeath.Add(new CreateOnDeath.GameObjectHolder(PrefabList.getPrefab("QuickIceCircleVFX")));
            }
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.addBaseDamage(DamageType.COLD, holder.getBaseDamage(DamageType.FIRE));
                holder.addBaseDamage(DamageType.FIRE, -holder.getBaseDamage(DamageType.FIRE));
            }
            foreach (ConstantRotation rot in abilityObject.GetComponents <ConstantRotation>())
            {
                rot.degreesPerSecond = 0f;
            }
        }

        if (increasedStunChance != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.baseDamageStats.increasedStunChance += increasedStunChance;
            }
        }

        if (increasedDamage != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(increasedDamage);
            }
        }

        if (moreDamageInstances != null && moreDamageInstances.Count > 0)
        {
            float moreDamage = 1f;
            foreach (float instance in moreDamageInstances)
            {
                moreDamage *= 1 + instance;
            }

            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(moreDamage - 1);
            }
        }

        if (chillChance > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Chill);
            newComponent.chance       = chillChance;
        }

        if (igniteChance > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Ignite);
            if (convertToCold)
            {
                newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Chill);
            }
            newComponent.chance = igniteChance;
        }

        return(abilityObject);
    }
Example #25
0
 void Awake()
 {
     m_singleton = this;
 }
Example #26
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        if (splatterChance > 0 && (!mana || mana.currentMana > 0) && (splatterChance >= 1 || splatterChance > (Random.Range(0f, 1f))))
        {
            // splatter trigger
            CreateAbilityObjectOnDeath component = abilityObject.AddComponent <CreateAbilityObjectOnDeath>();
            component.abilityToInstantiate = Ability.getAbility(AbilityID.bloodSplatter);

            // splatter mutator
            BloodSplatterMutator mutator = abilityObject.AddComponent <BloodSplatterMutator>();
            mutator.increasedRadius               = splatter_increasedRadius;
            mutator.increasedDamage               = splatter_increasedDamage;
            mutator.chanceToPoison                = splatter_chanceToPoison;
            mutator.armourReductionChance         = splatter_armourReductionChance;
            mutator.armourReduction               = splatter_armourReduction;
            mutator.armourReductionStacks         = splatter_armourReductionStacks;
            mutator.increasedArmourDebuffDuration = splatter_increasedArmourDebuffDuration;
            mutator.increasedDamagePerMinion      = splatter_increasedDamagePerMinion;
            mutator.minionBuffs = splatter_minionBuffs;
            mutator.reducesDarkProtectionInstead = splatter_reducesDarkProtectionInstead;
            mutator.necrotic = necrotic;
        }


        if (necrotic)
        {
            // replace vfx
            CreateOnDeath cod = abilityObject.GetComponent <CreateOnDeath>();
            if (cod && cod.objectsToCreateOnDeath != null && cod.objectsToCreateOnDeath.Count > 0)
            {
                cod.objectsToCreateOnDeath[0] = new CreateOnDeath.GameObjectHolder(PrefabList.getPrefab("NecroticRipBloodOnDeathVFX"));
            }

            // convert damage
            foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>())
            {
                damage.convertAllDamageOfType(DamageType.PHYSICAL, DamageType.NECROTIC);
            }
        }

        if (targetsAlliesInstead)
        {
            // change the damage component to hit allies (only hits minions by default)
            DamageEnemyOnHit damageComponent = abilityObject.GetComponent <DamageEnemyOnHit>();
            DamageAllyOnHit  component       = abilityObject.AddComponent <DamageAllyOnHit>();
            component.baseDamageStats = damageComponent.baseDamageStats;
            damageComponent.deactivate();
            Destroy(damageComponent);

            // make sure it still creates a blood orb
            CreateResourceReturnAbilityObjectOnEnemyHit component2 = abilityObject.GetComponent <CreateResourceReturnAbilityObjectOnEnemyHit>();
            component2.hitsAlliesInstead = true;

            // change the targetting
            MoveToNearestEnemyOnCreation moveComponent = abilityObject.GetComponent <MoveToNearestEnemyOnCreation>();
            if (moveComponent)
            {
                moveComponent.moveToAllyInstead = true;
            }
        }


        if (chanceToPoison > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Poison);
            newComponent.chance       = chanceToPoison;
        }

        if (chanceToBleed > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Bleed);
            newComponent.chance       = chanceToBleed;
        }

        if (addedHealthGained != 0 || increasedHealthGained != 0 || manaGained != 0 || convertHealthToWard || necrotic)
        {
            CreateResourceReturnAbilityObjectOnEnemyHit component = abilityObject.GetComponent <CreateResourceReturnAbilityObjectOnEnemyHit>();

            // check if this behaviour needs to be removed
            if (increasedHealthGained < -1 && manaGained <= 0)
            {
                component.deactivated = true;
            }
            // if it does not then change its values
            else
            {
                component.health += addedHealthGained;
                component.health *= (1 + increasedHealthGained);
                if (increasedHealthGainedPerAttunement != 0)
                {
                    component.health *= (1 + baseStats.GetStatValue(Tags.Properties.Attunement) * increasedHealthGainedPerAttunement);
                }
                component.mana += manaGained;
                if (convertHealthToWard)
                {
                    component.ward   = component.health;
                    component.health = 0;
                }
                if (necrotic)
                {
                    component.abilityObject = Ability.getAbility(AbilityID.necroticReturn);
                }
            }
        }


        if (increasedStunChance != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.baseDamageStats.increasedStunChance += increasedStunChance;
            }
        }

        // increase damage based on the number of minions
        float realIncreasedDamage = increasedDamage;

        if (increasedDamagePerMinion != 0)
        {
            if (tracker && tracker.summons != null)
            {
                realIncreasedDamage += increasedDamagePerMinion * tracker.summons.Count;
            }
        }


        if (realIncreasedDamage != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(realIncreasedDamage);
            }
        }

        if (moreDamageInstances != null && moreDamageInstances.Count > 0)
        {
            float moreDamage = 1f;
            foreach (float instance in moreDamageInstances)
            {
                moreDamage *= 1 + instance;
            }

            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(moreDamage - 1);
            }
        }

        return(abilityObject);
    }
Example #27
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        // if this is a meteor shower
        if (additionalMeteors > 0)
        {
            Destroy(abilityObject);

            abilityObject = Instantiate(AbilityIDList.getAbility(AbilityID.meteorShower).abilityPrefab);
            abilityObject.transform.position = location;
            CastAtRandomPointAfterDuration meteorCaster = abilityObject.GetComponent <CastAtRandomPointAfterDuration>();
            meteorCaster.duration       /= (1 + increasedMeteorFrequency);
            meteorCaster.remainingCasts += additionalMeteors;
            meteorCaster.radius         *= (1 + increasedShowerRadius);

            if (line)
            {
                StartsAtTarget sat = meteorCaster.GetComponent <StartsAtTarget>();
                if (sat)
                {
                    sat.active = false;
                    Destroy(sat);
                }
                AbilityMover mover = Comp <AbilityMover> .GetOrAdd(abilityObject);

                mover.SetDirection(targetLocation - location);
                mover.speed         = 10 * (1 + increasedShowerRadius);
                meteorCaster.radius = 0;
                StartsTowardsTarget stt = abilityObject.AddComponent <StartsTowardsTarget>();
                stt.distance       = 1f;
                stt.addWeaponRange = false;
            }

            // create a mutator on the meteor shower object
            MeteorMutator newMutator = abilityObject.AddComponent <MeteorMutator>();



            // variables for all damage
            newMutator.moreDamageInstances = moreDamageInstances;

            // meteor variables (except use all mana)
            newMutator.increasedFallSpeed     = increasedFallSpeed;
            newMutator.increasedCastSpeed     = increasedCastSpeed;
            newMutator.shrapnelChance         = shrapnelChance;
            newMutator.increasedShrapnelSpeed = increasedShrapnelSpeed;
            newMutator.shrapnelPierces        = shrapnelPierces;
            newMutator.replaceFireCircle      = replaceFireCircle;

            // aoe variables
            newMutator.moreDamageAgainstFullHealth = moreDamageAgainstFullHealth;
            newMutator.increasedShrapnelDamage     = increasedShrapnelDamage;
            newMutator.increasedStunChance         = increasedStunChance;
            newMutator.moreDamageInstances         = new List <float>();
            newMutator.moreDamageInstances.AddRange(moreDamageInstances);

            // apply mana variable once for all meteors
            if (usesAllMana && myMana)
            {
                float totalCost = myMana.getManaCost(ability);
                totalCost += myMana.currentMana;

                float proportion = totalCost / myMana.maxMana;
                newMutator.moreDamageInstances.Add(proportion * 2);

                myMana.currentMana = 0;
            }

            return(abilityObject);
        }


        // if this is a regular meteor

        // apply aoe variables
        MeteorAoEMutator aoeMutator = abilityObject.AddComponent <MeteorAoEMutator>();

        aoeMutator.moreDamageAgainstFullHealth = moreDamageAgainstFullHealth;
        aoeMutator.increasedStunChance         = increasedStunChance;
        aoeMutator.moreDamageInstances         = new List <float>();
        aoeMutator.moreDamageInstances.AddRange(moreDamageInstances);


        // meteor variables

        if (increasedFallSpeed != 0)
        {
            abilityObject.GetComponent <AbilityMover>().speed *= (1 + increasedFallSpeed);
        }

        MeteorShrapnelMutator shrapnelMutator = null;

        if (shrapnelChance > 0)
        {
            float rand = Random.Range(0f, 1f);
            if (rand < shrapnelChance)
            {
                CreateAbilityObjectOnDeath caood = abilityObject.AddComponent <CreateAbilityObjectOnDeath>();
                caood.abilityToInstantiate = AbilityIDList.getAbility(AbilityID.meteorShrapnel);
                caood.createAtTarget       = true;
                caood.offset    = -caood.GetComponent <LocationDetector>().targetLocationOffset;
                shrapnelMutator = abilityObject.AddComponent <MeteorShrapnelMutator>();
                shrapnelMutator.increasedDamage     = increasedShrapnelDamage;
                shrapnelMutator.increasedSpeed      = increasedShrapnelSpeed;
                shrapnelMutator.pierces             = shrapnelPierces;
                shrapnelMutator.increasedStunChance = increasedStunChance;
                shrapnelMutator.moreDamageInstances = new List <float>();
                shrapnelMutator.moreDamageInstances.AddRange(moreDamageInstances);
            }
        }

        if (replaceFireCircle)
        {
            CreateAtTargetLocationOnCreation component = abilityObject.GetComponent <CreateAtTargetLocationOnCreation>();
            if (component)
            {
                component.objectsToCreate.Clear();
                GameObject prefab = PrefabList.getPrefab("EnemyMeteorCircle");
                if (prefab)
                {
                    CreateAtTargetLocationOnCreation.GameObjectHolder holder = new CreateAtTargetLocationOnCreation.GameObjectHolder();
                    holder.gameObject          = prefab;
                    holder.destroyWhenThisDies = true;
                    component.objectsToCreate.Add((holder));
                }
            }
        }

        if (usesAllMana && myMana)
        {
            float totalCost = myMana.getManaCost(ability);
            totalCost += myMana.currentMana;

            float proportion = totalCost / myMana.maxMana;

            aoeMutator.moreDamageInstances.Add(proportion * 2);
            if (shrapnelMutator)
            {
                shrapnelMutator.moreDamageInstances.Add(proportion * 2);
            }

            myMana.currentMana = 0;
        }


        return(abilityObject);
    }
 /// <summary>
 /// ウィンドウが開かれたタイミングで実行。
 /// </summary>
 private void OnEnable()
 {
     list = AssetDatabase.LoadAssetAtPath <PrefabList>(PATH);
 }
Example #29
0
 void Awake()
 {
     m_singleton = this;
 }
Example #30
0
        public bool IsValid(out string error, PrefabList plist)
        {
            if (prefabName.Trim().Equals("")) {
                error = "Prefab name is empty";
                return false;
            }

            if (!plist.IsValidPrefabName(prefabName) && !prefabName.Equals(NONE_PREFAB_NAME)) {
                error = string.Format("Prefab name: {0} is not a valid prefab name", prefabName);
                return false;
            }

            if (weight == 0) {
                error = "Weight is 0";
                return false;
            }

            error = "";
            return true;
        }
Example #31
0
 public VisChecker(PrefabList parentPrefabList) => this.parentPrefabList = parentPrefabList;
Example #32
0
    public override GameObject Mutate(GameObject abilityObject, Vector3 location, Vector3 targetLocation)
    {
        if (increasedRadius != 0)
        {
            foreach (CreateOnDeath cod in abilityObject.GetComponents <CreateOnDeath>())
            {
                cod.increasedRadius = increasedRadius;
                cod.increasedHeight = increasedRadius;
            }
            foreach (CapsuleCollider col in abilityObject.GetComponents <CapsuleCollider>())
            {
                col.height *= (1 + increasedRadius);
                col.radius *= (1 + increasedRadius);
            }
        }

        if (necrotic)
        {
            // replace vfx
            CreateOnDeath cod = abilityObject.GetComponent <CreateOnDeath>();
            if (cod && cod.objectsToCreateOnDeath != null && cod.objectsToCreateOnDeath.Count > 0)
            {
                cod.objectsToCreateOnDeath[0] = new CreateOnDeath.GameObjectHolder(PrefabList.getPrefab("NecroticBloodSplatterOnDeathVFX"));
            }

            // convert damage
            foreach (DamageStatsHolder damage in abilityObject.GetComponents <DamageStatsHolder>())
            {
                damage.convertAllDamageOfType(DamageType.PHYSICAL, DamageType.NECROTIC);
            }
        }

        if (chanceToPoison > 0)
        {
            ChanceToApplyStatusOnEnemyHit newComponent = abilityObject.AddComponent <ChanceToApplyStatusOnEnemyHit>();
            newComponent.statusEffect = StatusEffectList.getEffect(StatusEffectID.Poison);
            newComponent.chance       = chanceToPoison;
        }

        if (armourReductionChance > 0 && Random.Range(0f, 1f) < armourReductionChance)
        {
            DebuffOnEnemyHit component = abilityObject.AddComponent <DebuffOnEnemyHit>();
            if (reducesDarkProtectionInstead)
            {
                if (armourReductionStacks)
                {
                    component.addDebuffToList(Tags.Properties.DarkProtection, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration));
                }
                else
                {
                    component.addDebuffToList(Tags.Properties.DarkProtection, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration), null, "blood splatter armour reduction");
                }
            }
            else
            {
                if (armourReductionStacks)
                {
                    component.addDebuffToList(Tags.Properties.Armour, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration));
                }
                else
                {
                    component.addDebuffToList(Tags.Properties.Armour, armourReduction, 0f, null, null, 4f * (1 + increasedArmourDebuffDuration), null, "blood splatter armour reduction");
                }
            }
        }

        if (minionBuffs != null && minionBuffs.Count > 0)
        {
            string        buffName  = "blood splatter buff";
            BuffOnAllyHit component = abilityObject.AddComponent <BuffOnAllyHit>();
            component.onlyApplyToCreatorsMinions = true;
            for (int i = 0; i < minionBuffs.Count; i++)
            {
                string fullBuffName = buffName + minionBuffs[i].property;
                foreach (Tags.AbilityTags _tag in minionBuffs[i].tagList)
                {
                    fullBuffName += _tag;
                }
                component.addBuffToList(minionBuffs[i].property, minionBuffs[i].addedValue, minionBuffs[i].increasedValue, minionBuffs[i].moreValues,
                                        minionBuffs[i].quotientValues, 4f, minionBuffs[i].tagList, fullBuffName);
            }
        }


        if (increasedStunChance != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.baseDamageStats.increasedStunChance += increasedStunChance;
            }
        }


        // increase damage based on the number of minions
        float realIncreasedDamage = increasedDamage;

        if (increasedDamagePerMinion != 0)
        {
            if (references && references.creator)
            {
                SummonTracker tracker = references.creator.GetComponent <SummonTracker>();
                if (tracker && tracker.summons != null)
                {
                    realIncreasedDamage += increasedDamagePerMinion * tracker.summons.Count;
                }
            }
        }


        if (realIncreasedDamage != 0)
        {
            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(realIncreasedDamage);
            }
        }

        if (moreDamageInstances != null && moreDamageInstances.Count > 0)
        {
            float moreDamage = 1f;
            foreach (float instance in moreDamageInstances)
            {
                moreDamage *= 1 + instance;
            }

            foreach (DamageStatsHolder holder in abilityObject.GetComponents <DamageStatsHolder>())
            {
                holder.increaseAllDamage(moreDamage - 1);
            }
        }

        return(abilityObject);
    }