public void setReference(ShipSystem s)
 {
     if (s is Shield)
     {
         shield = (Shield)s;
     }
     if (s is Engine)
     {
         engine = (Engine)s;
     }
     if (s is PDSController)
     {
         pds = (PDSController)s;
     }
 }
	// Update is called once per frame
    public void setReadouts()
    {
        switch (systemType)
        {
            case ShipSystem.SystemType.Shields:
                shield = PlayerController.PC.shieldRef;
                system = (ShipSystem)shield;
                type.Display("Shields");
                classification.Display(shield.getComponentClass());
                field1.Display(shield.RegenRate + "/second");
                field2.Display(shield.RegenDelay + " seconds");
                power.Display(shield.PowerAllocation);
                icon.SpriteName = shield.Icon;
                break;
            case ShipSystem.SystemType.PointDefenseSystem:
                pds = PlayerController.PC.pdsref;
                system = (ShipSystem)pds;
                type.Display("Point Defense System");              
                classification.Display(pds.getComponentClass());
                field1.Display(pds.MissileDestroyTime + " seconds");
                field2.Display(pds.Range);
                power.Display(pds.PowerAllocation);
                icon.SpriteName = pds.Icon;
                break;
            case ShipSystem.SystemType.Engine:
                engine = PlayerController.PC.engineRef;
                system = (ShipSystem)engine;
                type.Display("Engines");  
                classification.Display(engine.getComponentClass());
                field1.Display(engine.Speed);
                field2.Display(engine.CanBoost);
                field3.Display(engine.BoostDuration + " seconds");
                power.Display(engine.PowerAllocation);
                icon.SpriteName = engine.Icon;
                break;
            case ShipSystem.SystemType.PowerGenerator:
                pg = PlayerController.PC.powerGenerator;
                if (apb == null)
                {
                    apb = GetComponentInChildren<aPowerBar>();
                    apb.initalize();
                }
                type.Display("Power Generator");
                classification.Display(pg.getComponentClass());
                field1.Display(pg.MaxAvailablePower);
                field2.Display(pg.AvailablePower);
                field3.Display(pg.powerProfiles);
                apb.updateValue();
                description.Display(pg.getDescription());
                upgradeDesc.Display(pg.getUpgradeDescription());
                icon.SpriteName = pg.Icon;
                costValue = pg.upgradeCost;
                break;    
        }
        if (system != null)
        {
            costValue = system.upgradeCost;
            description.Display(system.Description);
            upgradeDesc.Display(system.UpgradeDescription);
        }
        cost.Display(costValue);

    }    
示例#3
0
 protected IEnumerator initialize()
 {
     yield return new WaitForSeconds(.2f);
     ShipSystem[] unitializedShipSystems = GetComponentsInChildren<ShipSystem>(); //Initialize and set referencese for all ship components
     for (int i = 0; i < unitializedShipSystems.Length; i++)
     {
         unitializedShipSystems[i].setController(this);
         unitializedShipSystems[i].initialize(owner);
     }
     powerGenerator.initialize();
     yield return new WaitForSeconds(.2f);
     //baseline initialize all systems to 1 power               
     foreach (ShipSystem s in otherSystems)
     {
         s.increasePowerAllocation();
         if (owner == Owner.Player)
         {
             PowerManagementPanel.pmp.createControls(s);
             allSystemsInfoPanel.asip.setReference(s);
         }
     }
     foreach (ShipSystem s in defensiveSystems)
     {
         s.increasePowerAllocation();
         if (s is Shield)//if it is a shield initialize the bar values properly
         {
             Shield sh = (Shield)s;
             shieldRef = sh;
         }
         if (s is PDSController)//if it is a shield initialize the bar values properly
         {
             PDSController PDS = (PDSController)s;
             pdsref = PDS;
         }
         if (owner == Owner.Player && gameObject.layer != LayerMask.NameToLayer("NonPlayer"))
         {
             var playerHUD = FindObjectOfType<playerHUD>();
             var hbs = playerHUD.GetComponentInChildren<HullBarScript>();
             var sbs = playerHUD.GetComponentInChildren<ShieldBarScript>();
             PowerManagementPanel.pmp.createControls(s);
             allSystemsInfoPanel.asip.setReference(s);
             hbs.Target = this.gameObject;
             sbs.Target = this.gameObject;
             hbs.Initialize();
             sbs.Initialize();
             if (shieldRef != null)
                 shieldRef.initializeBar();
             if (hullRef != null)
                 hullRef.hBar.setValue();                    
         }
     }
     initialized = true;
     shieldRef.initializeBar();
     yield return null;
 }