Exemplo n.º 1
0
        public BigAbility(
            Table AbilityTable,
            string texturePath,
            List <string> researchRequirements,
            int maxLevel,
            int abilityCastRange,
            float abilityCooldown,
            int abilityManaCost,
            AbilityProperties.AbilityBehaviorEnum abilityBehavior,
            AbilityProperties.AbilityTypeEnum abilityType,
            AbilityProperties.AbilityUnitTargetTeamEnum abilityUnitTargetTeam,
            AbilityProperties.AbilityUnitTargetTypeEnum abilityUnitTargetType,
            AbilityProperties.AbilityUnitDamageTypeEnum abilityUnitDamageType)
        {
            this.texturePath     = texturePath;
            ResearchRequirements = researchRequirements;
            MaxLevel             = maxLevel;

            AbilityCastRange      = abilityCastRange;
            AbilityCooldown       = abilityCooldown;
            AbilityManaCost       = abilityManaCost;
            AbilityBehavior       = abilityBehavior;
            AbilityType           = abilityType;
            AbilityUnitTargetTeam = abilityUnitTargetTeam;
            AbilityUnitTargetType = abilityUnitTargetType;
            AbilityUnitDamageType = abilityUnitDamageType;

            eventsPreset  = LuaAbilitiesGetter.GetEventsPreset(AbilityTable);
            modifierTable = LuaAbilitiesGetter.GetAbilityModifiersTable(AbilityTable);
        }
Exemplo n.º 2
0
 public static void PostInit()
 {
     LuaNpcGetter.Init();
     LuaQuestGetter.Init();
     LuaModifiersGetter.Init();
     LuaLanguageGetter.Init();
     LuaAbilitiesGetter.Init();
     LuaResearchGetter.Init();
 }
Exemplo n.º 3
0
        public Ability(Table AbilityTable,
                       string abilityName,
                       string texturePath,
                       List <string> researchRequirements,
                       int maxLevel,
                       int abilityCastRange,
                       float abilityCooldown,
                       int abilityManaCost,
                       AbilityProperties.AbilityBehaviorEnum abilityBehavior,
                       AbilityProperties.AbilityTypeEnum abilityType,
                       AbilityProperties.AbilityUnitTargetTeamEnum abilityUnitTargetTeam,
                       AbilityProperties.AbilityUnitTargetTypeEnum abilityUnitTargetType,
                       AbilityProperties.AbilityUnitDamageTypeEnum abilityUnitDamageType)
        {
            abilityID = lastID;
            lastID++;
            this.abilityName = abilityName;
            CurrentCooldown  = 0f;
            PostCurrent      = -1f;

            onOwnerSpawnedEventName = abilityName + "_OnOwnerSpawned";
            onSpellStartEventName   = abilityName + "_OnSpellStart";

            eventTable = DynValue.NewTable(LuaManager.ScriptObj).Table;
            var specials = LuaAbilitiesGetter.GetSpecials(AbilityTable);


            abilitySpecial = specials
                             .Select(c => new { c.Key, value = c.Value + " " })
                             .ToDictionary(x => x.Key, x => x.value);

            upgradedAbilitySpecial = abilitySpecial.ToDictionary(x => x.Key, x => x.Value);

            vars = DynValue.NewTable(LuaManager.ScriptObj).Table;

            parentBigAbility = BigAbilityManager.SetupBigAbility(AbilityTable,
                                                                 abilityName,
                                                                 texturePath,
                                                                 researchRequirements,
                                                                 maxLevel,
                                                                 abilityCastRange,
                                                                 abilityCooldown,
                                                                 abilityManaCost,
                                                                 abilityBehavior,
                                                                 abilityType,
                                                                 abilityUnitTargetTeam,
                                                                 abilityUnitTargetType,
                                                                 abilityUnitDamageType);
        }
Exemplo n.º 4
0
        public void OnOwnerSpawned(AbstractGameObject caster)
        {
            if (!parentBigAbility.eventsPreset.ContainsKey("OnOwnerSpawned"))
            {
                return;
            }
            eventTable["caster"]  = caster;
            eventTable["target"]  = DynValue.Nil;
            eventTable["ability"] = this;
            eventTable["name"]    = onOwnerSpawnedEventName;
            if (UnitEvents.isEventNotPreloaded(eventTable, onOwnerSpawnedEventName))
            {
                eventTable["preset"] = parentBigAbility.eventsPreset["OnOwnerSpawned"];
            }

            LuaAbilitiesGetter.OnOwnerSpawned(eventTable);
        }
Exemplo n.º 5
0
        public bool OnSpellStart(AbstractGameObject caster, GameUnit target)
        {
            if (!parentBigAbility.eventsPreset.ContainsKey("OnSpellStart"))
            {
                return(true);
            }
            eventTable["caster"]  = caster;
            eventTable["target"]  = target;
            eventTable["ability"] = this;
            eventTable["name"]    = onSpellStartEventName;

            if (UnitEvents.isEventNotPreloaded(eventTable, onSpellStartEventName))
            {
                eventTable["preset"] = parentBigAbility.eventsPreset["OnSpellStart"];
            }

            return(LuaAbilitiesGetter.OnSpellStart(eventTable));
        }
Exemplo n.º 6
0
        public static GameEntity InitObject(int chunkNumber, string name, Vector3Int vecInt, int index,
                                            Table npc, Player owner)
        {
            var chunk = GetChunkByNum(chunkNumber);

            if (chunk == null)
            {
                return(null);
            }

            var vec = Util.Get3DPosByIndex(vecInt.x, vecInt.y, vecInt.z);

            var vecIntPos = new Vector3Int(vecInt.x, vecInt.y, vecInt.z);


            var prefab = Loader.GetPrefabByIndex(index);
            var obj    = Instantiate(prefab, vec + prefab.transform.position, new Quaternion());

            if (IsGroupVVithName(prefab.name))
            {
                var trans = GetGroupVVithName(prefab.name);
                obj.transform.SetParent(trans);
            }
            else
            {
                var o = new GameObject {
                    name = prefab.name
                };

                o.transform.SetParent(BATYAtrans);
                Groups.Add(o);

                obj.transform.SetParent(o.transform);
            }


            var group = LuaNpcGetter.GetNpcGroup(npc);

            Stats stats = null;

            if (!GroupUtil.IsGround(group))
            {
                stats     = LuaNpcGetter.GetStatsFromTable(npc);
                obj.layer = 9;


                if (staticFogEnabled)
                {
                    obj.AddComponent <FogCoverable>();
                }
            }


            var abilities = new List <Ability>();

            if (!GroupUtil.IsGround(group))
            {
                if (!GroupUtil.IsItem(group) && staticFogEnabled)
                {
                    var spRend = obj.GetComponent <SpriteRenderer>();
                    if (spRend != null)
                    {
                        spRend.enabled = false;
                    }
                }

                if (!GroupUtil.IsNeutral(group) && !GroupUtil.IsItem(group))
                {
                    var npcAbilitiesNames = LuaNpcGetter.GetNpcAbilitiesNames(npc);
                    foreach (var KV in npcAbilitiesNames)
                    {
                        var ability = LuaAbilitiesGetter.GetAbility(KV.Value);
                        ability.Owner = owner;
                        abilities.Add(ability);
                    }
                }
            }

            GameEntity ent;

            if (GroupUtil.IsGround(group))
            {
                ent = obj.AddComponent <GameEntity>();
                ent.Init(chunkNumber, vecIntPos, false, index);
                ent.Group = group;

                chunk.SetIndex(vecIntPos, index);

                obj.layer = 8;
                chunk.IndexMas[vecInt.z][vecInt.x][vecInt.y] = index;
                chunk.Ground[vecInt.z][vecInt.x][vecInt.y]   = ent;
            }
            else if (GroupUtil.IsItem(group))
            {
                var item = obj.AddComponent <GameItem>();

                item.Init(chunkNumber, vecIntPos, false, index, stats);
                item.Group = group;

                var npcModifiersNames = LuaNpcGetter.GetNpcModifiersNames(npc);
                item.ModifierNamesList.AddRange(npcModifiersNames);

                ent = item;
            }
            else
            {
                var unit = obj.AddComponent <GameUnit>();

                unit.Init(chunkNumber, vecIntPos, false, index, stats);
                unit.Group = group;

                var soundVolume  = LuaNpcGetter.GetNpcSoundVolume(npc);
                var soundByIndex = Loader.GetSoundByIndex(index, soundVolume);

                unit.GameAudio = soundByIndex;
                unit.itemDrop  = LuaNpcGetter.GetNpcItemDrop(npc);

                CreatureGroupManager.Init(unit);

                if (GroupUtil.isBuilding(group))
                {
                    var researchName = LuaNpcGetter.GetNpcResearch(npc);
                    if (researchName.Length > 0)
                    {
                        var research = ResearchManager.SetupResearch(researchName);
                        unit.research = research;
                        owner.AddResearch(research);
                        AbilityBar_HTML.Update();
                    }
                    BuildingsGroupManager.Init(unit);
                }

                foreach (var ab in abilities)
                {
                    unit.AddAbility(ab);
                }

                ent = unit;
                chunk.IndexMas[vecInt.z][vecInt.x][vecInt.y] = index;
                chunk.Ground[vecInt.z][vecInt.x][vecInt.y]   = ent;
            }
            ent.OriginalName = name;
            ent.ExtraPos     = prefab.transform.position;


            ent.foodCost = LuaNpcGetter.GetNpcFoodCost(npc);
            ent.foodGive = LuaNpcGetter.GetNpcFoodGive(npc);

            owner.foodCount += ent.foodCost;
            owner.foodMax   += ent.foodGive;


            ent.goldDrop = LuaNpcGetter.GetNpcGoldDrop(npc);


            //obj.name = prefab.name + "_" + vecInt.z + "_" + vecInt.x + "_" + vecInt.y;


            PathCalcManager.CalculatePoint(vecInt);
            PathCalcManager.CalculatePoint(ChunkUtil.GetDovvner(vecInt));


            return(ent);
        }