Ejemplo n.º 1
0
        void CreatePrefabAction(GameObject InstancedPrefab)
        {
            UnitSource us = GetGamedataFile.LoadUnit(SelectedUnit.CodeName);

            SelectedUnitSource.Parent = FirstSelected.Source;
            SelectedUnitSource.Owner  = FirstSelected.Owner;
            us.FillGameObjectValues(InstancedPrefab, SelectedUnitSource, FirstSelected.Source, Vector3.zero, Quaternion.identity);
        }
Ejemplo n.º 2
0
                public void Instantiate()
                {
                    if (Instance && Instance.gameObject)
                    {
                        return;
                    }
                    UnitInstance ui = GetGamedataFile.LoadUnit(type).CreateUnitObject(this, Parent);

                    ui.IsWreckage = Parent.IsWreckage ? 1 : 0;
                    if (AllNames.Contains(Name))
                    {
                        Name = GetFreeName("UNIT_");
                    }
                    AllNames.Add(Name);
                }
Ejemplo n.º 3
0
                public UnitsGroup(string name, LuaTable Table)
                {
                    Name    = name;
                    orders  = LuaParser.Read.StringFromTable(Table, KEY_ORDERS);
                    platoon = LuaParser.Read.StringFromTable(Table, KEY_PLATOON);

                    UnitGroups    = new HashSet <UnitsGroup>();
                    UnitInstances = new HashSet <UnitInstance>();

                    LuaTable[] UnitsTables = LuaParser.Read.GetTableTables((LuaTable)Table.RawGet(KEY_UNITS));
                    string[]   UnitsNames  = LuaParser.Read.GetTableKeys((LuaTable)Table.RawGet(KEY_UNITS));

                    if (UnitsNames.Length > 0)
                    {
                        for (int i = 0; i < UnitsNames.Length; i++)
                        {
                            if (LuaParser.Read.ValueExist(UnitsTables[i], KEY_TYPE))
                            {
                                Unit NewUnit = new Unit();
                                NewUnit.Name    = UnitsNames[i];
                                NewUnit.type    = LuaParser.Read.StringFromTable(UnitsTables[i], KEY_TYPE);
                                NewUnit.orders  = LuaParser.Read.StringFromTable(UnitsTables[i], KEY_ORDERS);
                                NewUnit.platoon = LuaParser.Read.StringFromTable(UnitsTables[i], KEY_PLATOON);
                                //Debug.Log(UnitsTables[i].RawGet(KEY_POSITION));
                                NewUnit.Position    = LuaParser.Read.Vector3FromTable(UnitsTables[i], KEY_POSITION);
                                NewUnit.Orientation = LuaParser.Read.Vector3FromTable(UnitsTables[i], KEY_ORIENTATION);

                                GetGamedataFile.LoadUnit(NewUnit.type).CreateUnitObject(NewUnit, this);
                            }
                            else
                            {
                                UnitsGroup NewUnitsGroup = new UnitsGroup(UnitsNames[i], UnitsTables[i]);
                                UnitGroups.Add(NewUnitsGroup);
                            }
                        }
                    }
                    else
                    {
                        UnitGroups    = new HashSet <UnitsGroup>();
                        UnitInstances = new HashSet <UnitInstance>();
                    }
                }