public static DataComponent CreateDataComponent(
            GameObject parent,
            UnitConfig config,
            MobilityData mobilityData)
        {
            MobilityConfig mobilityConfig = config.Mobility;
            ArmorConfig    armorConfig    = config.Armor;

            parent.AddComponent <DataComponent>();
            DataComponent c = parent.GetComponent <DataComponent>();

            c.MovementSpeed    = config.MovementSpeed.Value * Constants.MAP_SCALE;
            c.ReverseSpeed     = config.ReverseSpeed.Value * Constants.MAP_SCALE;
            c.AccelRate        = config.AccelRate.Value * Constants.MAP_SCALE;
            c.MaxRotationSpeed = config.MaxRotationSpeed.Value;
            c.MinTurnRadius    = config.MinTurnRadius.Value * Constants.MAP_SCALE;
            c.MaxLateralAccel  = config.MaxLateralAccel.Value * Constants.MAP_SCALE;
            c.Suspension       = config.Suspension.Value / Constants.MAP_SCALE;
            c.MaxHealth        = config.MaxHealth.Value;
            c.Length           = config.Length.Value * Constants.MAP_SCALE;
            c.Width            = config.Width.Value * Constants.MAP_SCALE;

            c.MobilityData = mobilityData;

            c.Radius           = Mathf.Sqrt(c.Length * c.Width) / 2;
            c.OptimumTurnSpeed = Mathf.Sqrt(c.MaxLateralAccel * c.MinTurnRadius);

            c.SuspensionForward = c.Suspension * c.Radius / c.Length;
            c.SuspensionSide    = c.Suspension * c.Radius / c.Width;

            c.AccelDampTime = 0.15f * c.MovementSpeed / c.AccelRate;

            c.ApImmunity = armorConfig.ApImmunity;
            c.FrontArmor = armorConfig.FrontArmor;
            c.SideArmor  = armorConfig.SideArmor;
            c.RearArmor  = armorConfig.RearArmor;
            c.TopArmor   = armorConfig.TopArmor;

            ReconConfig reconConfig = config.Recon;

            c.MaxSpottingRange   = reconConfig.MaxSpottingRange;
            c.Stealth            = reconConfig.Stealth;
            c.StealthPenetration = reconConfig.StealthPenetration;

            c.CanCaptureZones     = config.CanCaptureZones.Value;
            c.ModelCount          = config.ModelCount.Value;
            c.TransportableSize   = config.TransportableSize.Value;
            c.TransporterCapacity = config.TransporterCapacity.Value;

            return(c);
        }
示例#2
0
        public static DataComponent CreateDataComponent(
            GameObject parent,
            UnitConfig config,
            MobilityData mobilityData)
        {
            UnitDataConfig unitConfig     = config.Data;
            MobilityConfig mobilityConfig = config.Mobility;
            ArmorConfig    armorConfig    = config.Armor;

            parent.AddComponent <DataComponent>();
            DataComponent c = parent.GetComponent <DataComponent>();

            c.MovementSpeed    = unitConfig.MovementSpeed * Constants.MAP_SCALE;
            c.ReverseSpeed     = unitConfig.ReverseSpeed * Constants.MAP_SCALE;
            c.AccelRate        = unitConfig.AccelRate * Constants.MAP_SCALE;
            c.MaxRotationSpeed = unitConfig.MaxRotationSpeed;
            c.MinTurnRadius    = unitConfig.MinTurnRadius * Constants.MAP_SCALE;
            c.MaxLateralAccel  = unitConfig.MaxLateralAccel * Constants.MAP_SCALE;
            c.Suspension       = unitConfig.Suspension / Constants.MAP_SCALE;
            c.MaxHealth        = unitConfig.MaxHealth;
            c.Length           = unitConfig.Length * Constants.MAP_SCALE;
            c.Width            = unitConfig.Width * Constants.MAP_SCALE;

            c.MobilityData = mobilityData;

            c.Radius           = Mathf.Sqrt(c.Length * c.Width) / 2;
            c.OptimumTurnSpeed = Mathf.Sqrt(c.MaxLateralAccel * c.MinTurnRadius);

            c.SuspensionForward = c.Suspension * c.Radius / c.Length;
            c.SuspensionSide    = c.Suspension * c.Radius / c.Width;

            c.AccelDampTime = 0.15f * c.MovementSpeed / c.AccelRate;

            c.ApImmunity = armorConfig.ApImmunity;
            c.FrontArmor = armorConfig.FrontArmor;
            c.SideArmor  = armorConfig.SideArmor;
            c.RearArmor  = armorConfig.RearArmor;
            c.TopArmor   = armorConfig.TopArmor;

            ReconConfig reconConfig = config.Recon;

            c.MaxSpottingRange   = reconConfig.MaxSpottingRange;
            c.Stealth            = reconConfig.Stealth;
            c.StealthPenetration = reconConfig.StealthPenetration;

            return(c);
        }