Esempio n. 1
0
        public ShipLevelConversionEngine(ShipDefinition shipDefinition)
        {
            _speedsByLevel = new[] { shipDefinition.MerchantSpeed, shipDefinition.Speed, shipDefinition.PirateSpeed };

            _conversionWait = new WaitForSecondsEnumerator(shipDefinition.TimeBetweenConversion);
            _transitionWait = new WaitForSecondsEnumerator(shipDefinition.ConversionTransitionTime);
            _animationWait  = new WaitForSecondsEnumerator(shipDefinition.BlinkAnimationTime);
        }
    public void Init(string tag, ShipDefinition shipDefinition, Vector3 direction, Quaternion rotation)
    {
        Speed = shipDefinition.ProjectileSpeed;
        ProjectileRendererBehaviour.Init(tag, this, rotation);
        ProjectileRendererBehaviour.SetSprite(shipDefinition.ProjectileSpriteID);

        this.direction = direction;
    }
 public void Init(string tag, ShipDefinition shipDefinition, Transform target)
 {
     //TODO: Definition
     Speed = 15;
     timer = 0;
     this.target = target;
     MissileRendererBehaviour.Init(tag, this);
     MissileRendererBehaviour.SetSprite(shipDefinition.MissileSpriteID);
 }
Esempio n. 4
0
    public static void CreateObject()
    {
        ShipDefinition asset = (ShipDefinition)ScriptableObject.CreateInstance(typeof(ShipDefinition));

        UnityEditor.AssetDatabase.CreateAsset(asset, "Assets/ShipDefinitions/New Ship.asset");
        UnityEditor.AssetDatabase.SaveAssets();

        UnityEditor.EditorUtility.FocusProjectWindow();

        UnityEditor.Selection.activeObject = asset;
    }
Esempio n. 5
0
 public void BuyShip(ShipDefinition ship)
 {
     if (GameManager.instance.credits >= ship.shipPrice)
     {
         GameManager.instance.credits    -= ship.shipPrice;
         GameManager.instance.currentShip = GameManager.instance.ships.IndexOf(ship);
         ship.isBought = true;
         FindObjectOfType <MenuUIController> ().creditsText.text = GameManager.instance.credits.ToString("N0");
         UseShip();
     }
     DataManager.SaveData();
 }
Esempio n. 6
0
 public ShipSpawningEngine(uint seed, IEntityFactory entityFactory, IEntityFunctions functions, GameObjectFactory gameObjectFactory, Transform[] spawnPoints, ShipDefinition shipDefinition)
 {
     _entityFactory     = entityFactory;
     _functions         = functions;
     _gameObjectFactory = gameObjectFactory;
     _spawnPoints       = spawnPoints;
     _shipDefinition    = shipDefinition;
     _respawnWait       = new WaitForSecondsEnumerator(_shipDefinition.TimeToRespawn);
     _transitionWait    = new WaitForSecondsEnumerator(_shipDefinition.RespawnTransitionTime);
     _animationWait     = new WaitForSecondsEnumerator(_shipDefinition.BlinkAnimationTime);
     _random            = new Random(seed);
 }
    /// <summary>
    /// Load Enemy Ship data from definition, init components and setup config data
    /// </summary>
    public void Init(EdgeCollider2D path)
    {
        ShipDefinition =
            GameDefinitions.ShipDefinitions.FirstOrDefault(x => x.ID == LevelManager.EnemyDefinitionPool.ID);

        shipStats = new ShipStats(ShipDefinition.Health, ShipDefinition.Speed, ShipDefinition.ShootTime);

        ShipRendererBehaviour = GetComponentInChildren <ShipRendererBehaviour>();
        ShipRendererBehaviour.Init(this);

        if (path != null)
        {
            aiManager = new AIManager(this);
            aiManager.Init(path, shipStats);
        }
    }
    /// <summary>
    /// Load Player Ship data from definition, init components and setup config data
    /// </summary>
    public void Init()
    {
        ShipDefinition =
            GameDefinitions.ShipDefinitions.FirstOrDefault(x => x.ID == LevelManager.PlayerDefitionPool.ID);

        ShipStats = new ShipStats(ShipDefinition.Health, ShipDefinition.Speed, ShipDefinition.ShootTime);
        Weapons   = new Weapons(this, ShipDefinition);

#if UNITY_EDITOR
        playerController = new PlayerController();
#elif UNITY_ANDROID
        playerController = new PlayerMobileController();
#endif

        playerController.Init(this);

        ShipRendererBehaviour = GetComponentInChildren <ShipRendererBehaviour>();
        ShipRendererBehaviour.Init(this);
    }
Esempio n. 9
0
        public override void PostMapGenerate(Map map)
        {
            if (Find.GameInitData == null)
            {
                return;
            }
            string str1 = Path.Combine(Path.Combine(GenFilePaths.SaveDataFolderPath, "Ships"), shipFactionName + ".rwship");
            string actualFactionName = shipFactionName;
            bool   isVersion2        = false;

            if (File.Exists(str1 + "2")) //woo 2.0
            {
                str1      += "2";
                isVersion2 = true;
            }
            Scribe.loader.InitLoading(str1);

            FactionDef     factionDef = Faction.OfPlayer.def;
            ShipDefinition ship       = null;

            ShipInteriorMod.Log("Loading base managers...");
            Scribe_Deep.Look(ref Current.Game.uniqueIDsManager, false, "uniqueIDsManager", new object[0]);
            Scribe_Deep.Look(ref Current.Game.tickManager, false, "tickManager", new object[0]);
            Scribe_Deep.Look(ref Current.Game.drugPolicyDatabase, false, "drugPolicyDatabase", new object[0]);
            Scribe_Deep.Look(ref Current.Game.outfitDatabase, false, "outfitDatabase", new object[0]);

            //spawn a temp pawn.
            Pawn tmpPawn = StartingPawnUtility.NewGeneratedStartingPawn();

            //Advancing time
            ShipInteriorMod.Log("Advancing time...");
            Current.Game.tickManager.DebugSetTicksGame(Current.Game.tickManager.TicksAbs + 3600000 * Rand.RangeInclusive(Mod.minTravelTime.Value, Mod.maxTravelTime.Value));

            if (isVersion2)
            {
                Scribe_Values.Look(ref actualFactionName, "playerFactionName");
                Scribe_Deep.Look(ref ship, "shipDefinition");
            }
            else
            {
                ship = new ShipDefinition();
                //load the data the more cludgey way.
                ship.ExposeData();
            }

            highCorner = ship.Max;
            lowCorner  = ship.Min;

            IntVec3 spot   = MapGenerator.PlayerStartSpot;
            int     width  = highCorner.x - lowCorner.x;
            int     height = highCorner.z - lowCorner.z;

            //try to position us over the start location
            spot.x -= width / 2;
            spot.z -= height / 2;

            //now offset the corners and the parts to the spot.
            int offsetx = spot.x - lowCorner.x;
            int offsety = spot.z - lowCorner.z;

            lowCorner.x  += offsetx;
            lowCorner.z  += offsety;
            highCorner.x += offsetx;
            highCorner.z += offsety;

            tmpPawn.Position = lowCorner - new IntVec3(3, 0, 3);
            tmpPawn.SpawnSetup(map, false);

            ShipInteriorMod.Log("Low Corner: " + lowCorner.x + ", " + lowCorner.y + ", " + lowCorner.z);
            ShipInteriorMod.Log("High Corner: " + highCorner.x + ", " + highCorner.y + ", " + highCorner.z);
            ShipInteriorMod.Log("Map Size: " + map.Size.x + ", " + map.Size.y + ", " + map.Size.z);

            ship.AdaptToNewGame(map, offsetx, offsety, "Landing", true, Handler);

            new MapScanner()
            .DestroyThings(-2, 2)
            .ForPoints((point, m) => m.roofGrid.SetRoof(point, null), -2, 2)
            .ForPoints((point, m) => m.terrainGrid.SetTerrain(point, TerrainDefOf.Gravel))
            .Unfog(-3, 3)
            .QueueAsLongEvent(map, lowCorner, highCorner, "Landing_Clean", true, Handler);

            ship.SpawnInNewGame(map, "Landing", true, Handler);


            LongEventHandler.QueueLongEvent(() =>
            {
                ShipInteriorMod.Log("Loading managers...");
                Scribe_Deep.Look(ref Current.Game.researchManager, false, "researchManager", new object[0]);
                Scribe_Deep.Look(ref Current.Game.taleManager, false, "taleManager", new object[0]);
                Scribe_Deep.Look(ref Current.Game.playLog, false, "playLog", new object[0]);
                Scribe.loader.FinalizeLoading();
                tmpPawn.DeSpawn();

                Faction.OfPlayer.Name = actualFactionName;

                ShipInteriorMod.Log("Done.");
            }, "Landing_Managers", true, Handler);
        }
 public Weapons(ShipBase shipBase, ShipDefinition shipDefiniton)
 {
     this.shipBase      = shipBase;
     this.shipDefiniton = shipDefiniton;
     shipWeaponType     = ShipWeaponType.OneWayShot;
 }
        private Fleet CreateFleet(ShipDefinition ships)
        {
            Fleet fleet = new Fleet();

            for (int i = 0; i < ships.m_numInterceptors; i++)
            {
                Interceptor interceptor;
                if (ships.m_interceptorUpgrades.Count > 0)
                {
                    interceptor = new Interceptor(ships.m_interceptorUpgrades);
                }
                else
                {
                    interceptor = new Interceptor();
                }
                fleet.AddShip(interceptor);
            }

            for (int i = 0; i < ships.m_numCruisers; i++)
            {
                Cruiser cruiser;
                if (ships.m_cruiserUpgrades.Count > 0)
                {
                    cruiser = new Cruiser(ships.m_cruiserUpgrades);
                }
                else
                {
                    cruiser = new Cruiser();
                }
                fleet.AddShip(cruiser);
            }

            for (int i = 0; i < ships.m_numDreadnaughts; i++)
            {
                Dreadnaught dreadnaught;
                if (ships.m_dreadnaughtUpgrades.Count > 0)
                {
                    dreadnaught = new Dreadnaught(ships.m_dreadnaughtUpgrades);
                }
                else
                {
                    dreadnaught = new Dreadnaught();
                }
                fleet.AddShip(dreadnaught);
            }

            for (int i = 0; i < ships.m_numOrbitals; i++)
            {
                Orbital orbital;
                if (ships.m_orbitalUpgrades.Count > 0)
                {
                    orbital = new Orbital(ships.m_orbitalUpgrades);
                }
                else
                {
                    orbital = new Orbital();
                }
                fleet.AddShip(orbital);
            }

            for (int i = 0; i < ships.m_numAncients; i++)
            {
                Ancient ancient = new Ancient();
                fleet.AddShip(ancient);
            }

            for (int i = 0; i < ships.m_numCenterBases; i++)
            {
                CenterBase centerBase = new CenterBase();
                fleet.AddShip(centerBase);
            }

            return(fleet);
        }
Esempio n. 12
0
 public RemoteShip(ShipDefinition def)
 {
     this.m_that = def;
 }
Esempio n. 13
0
 public void Update(ShipDefinition def)
 {
     this.m_that = def;
 }
 public ShipAttackEngine(IEntityStreamConsumerFactory consumerFactory, ShipDefinition shipDefinition)
 {
     _consumer  = consumerFactory.GenerateConsumer <ShipComponent>("ShipAttack", 20);
     _coinDrops = shipDefinition.CoinDrop;
 }
        public override IEnumerable <Gizmo> CompGetGizmosExtra()
        {
            Command_Action launch = new Command_Action
            {
                action       = TryLaunch,
                defaultLabel = "CommandShipLaunch".Translate(),
                defaultDesc  = "CommandShipLaunchDesc".Translate()
            };

            if (!CanLaunchNow)
            {
                launch.Disable(ShipUtility.LaunchFailReasons(parentBuilding).First());
            }
            if (ShipCountdown.CountingDown)
            {
                launch.Disable();
            }
            launch.hotKey = KeyBindingDefOf.Misc1;
            launch.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip");

            Command_Action orbit = new Command_Action
            {
                action       = TryOrbit,
                defaultLabel = "ShipInsideOrbit".Translate(),
                defaultDesc  = "ShipInsideOrbitDesc".Translate()
            };

            if (!CanOrbitNow)
            {
                orbit.Disable(ShipUtility.LaunchFailReasons(parentBuilding).First());
            }
            if (ShipCountdown.CountingDown)
            {
                orbit.Disable();
            }
            orbit.hotKey = KeyBindingDefOf.Misc1;
            orbit.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip");

            Command_Action land = new Command_Action
            {
                action       = TryLand,
                defaultLabel = "ShipInsideLand".Translate(),
                defaultDesc  = "ShipInsideLandDesc".Translate()
            };

            if (!CanOrbitNow)
            {
                land.Disable(ShipUtility.LaunchFailReasons(parentBuilding).First());
            }
            if (ShipCountdown.CountingDown)
            {
                land.Disable();
            }
            land.hotKey = KeyBindingDefOf.Misc1;
            land.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip");

            ShipDefinition def = parent.Map.GetSpaceAtmosphereMapComponent().DefinitionAt(parent.Position);

            Command_Action shortJump = new Command_Action
            {
                action       = TryShortJump,
                defaultLabel = "ShipInsideShortJump".Translate(),
                defaultDesc  = "ShipInsideShortJumpDesc".Translate()
            };

            if (ShipCountdown.CountingDown)
            {
                shortJump.Disable();
            }
            shortJump.hotKey = KeyBindingDefOf.Misc1;
            shortJump.icon   = ContentFinder <Texture2D> .Get("UI/Commands/LaunchShip");

            Command_Action renameShip = new Command_Action
            {
                action = delegate
                {
                    Find.WindowStack.Add(new Dialog_NameShip(def));
                },
                defaultLabel = "ShipInsideRename".Translate(),
                defaultDesc  = "ShipInsideRenameDesc".Translate()
            };

            if (ShipCountdown.CountingDown)
            {
                renameShip.Disable();
            }
            renameShip.hotKey = KeyBindingDefOf.Misc1;
            renameShip.icon   = ContentFinder <Texture2D> .Get("UI/Commands/RenameZone");

            // Soon... so soon...
            List <Gizmo> gizmos = base.CompGetGizmosExtra().ToList();

            gizmos.Add(launch);

            if (parent.Map.terrainGrid.TerrainAt(IntVec3.Zero).defName == "HardVacuum")
            {
                if (def != null)
                {
                    gizmos.Add(land);
                }
                if (def.ReadyForShortRangeJump)
                {
                    gizmos.Add(shortJump);
                }
            }
            else
            {
                if (def != null)
                {
                    gizmos.Add(orbit);
                }
            }

            if (def != null)
            {
                gizmos.Add(renameShip);
            }

            return(gizmos);
        }
Esempio n. 16
0
 public Dialog_NameShip(ShipDefinition ship)
 {
     this.ship = ship;
     curName   = ship.Name;
 }
 public Battle(ShipDefinition attackerShips, ShipDefinition defenderShips)
 {
     attackerFleet = CreateFleet(attackerShips);
     defenderFleet = CreateFleet(defenderShips);
 }