void Start()
        {
            breadcrumbs = new GameObject[maxBreadcrumbs];
            GameObject holder = new GameObject("BCHolder");

            for (int i = 0; i < maxBreadcrumbs; i++)
            {
                breadcrumbs[i] = Instantiate(breadcrumbsPrefab, holder.transform, false);
                breadcrumbs[i].SetActive(false);
            }
            currentFuelQty = maxFuelQty;
            gravityCenter  = targetPlanet.GetComponent <Transform>();
            Rigidbody      = GetComponent <Rigidbody2D>();
            state          = ShipState.Alive;
            landingTimer   = float.MaxValue;

            // Ship starts on perfect circle orbit around center
            // Calculation to get the initial velocity
            Vector2 centerOfGravity     = gravityCenter.position;
            Vector2 shipPosition        = transform.position;
            Vector2 planetVector        = centerOfGravity - shipPosition;
            Vector2 startingOrientation = Vector3.Cross(planetVector, transform.forward).normalized;
            float   rand = Random.Range(0, 10);

            if (rand <= 5f)
            {
                startingOrientation = startingOrientation * -1;
            }

            float startingSpeed = planetVector.magnitude / (targetPlanet.Gravity);

            initialVelocity    = startingOrientation * startingSpeed;
            transform.rotation = Quaternion.Euler(0, 0, Mathf.Atan2(startingOrientation.y, startingOrientation.x));
        }
Пример #2
0
 public void UnsetOrbiting()
 {
     orbiting             = null;
     state                = ShipState.Flying;
     my_orbit.rotating    = false;
     my_orbit.centerPoint = null;
 }
Пример #3
0
    public void Start()
    {
        gameManager    = GameObject.Find("GameManager").GetComponent <GameManager>();
        player         = GameObject.Find("Player");
        shipState      = ShipState.ENTRY;
        rigidBody      = GetComponent <Rigidbody2D>();
        shipSpeed      = 0.8f;
        chargeDuration = 12.5f;
        chargeTrigger  = 15.0f;
        nodeTracker    = 0;
        timer          = 0f;

        bulletForce   = 15f;
        initialHeight = transform.position.y - player.transform.position.y;
        initialSide   = transform.position.x - player.transform.position.x;

        SHOOT_RESET = 3.0f;
        shootTimer  = SHOOT_RESET;
        bulletForce = 60f;

        if (hitPoints == 0)
        {
            hitPoints = 1;
        }

        if (entryIndex > 5 || entryIndex < 0)
        {
            entryIndex = 1;
        }
    }
        static void Initialize()
        {
            initialized = true;

            DefaultEffectsWho = new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Ship, TargetingTypes.None);
            InitShape();
            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(TimeWarp.AngularAcceleration),
                new Bounded <float>(TimeWarp.ScaleTurning(0)),
                new Bounded <float>(TimeWarp.ScaleAcceleration(20, 0)),
                new Bounded <float>(TimeWarp.ScaleVelocity(33)));
            DefaultState = new ShipState(new Bounded <float>(3),
                                         new Bounded <float>(0),
                                         new Bounded <float>(0),
                                         new Bounded <float>(0));
            DefaultLifeTime       = new LifeSpan(60);
            DefaultTargetingTypes = new TargetingInfo(TargetingTypes.Ship);
            DefaultEffectCollection.Effects.Add(
                new ShipStateEffect(DefaultEffectsWho,
                                    EffectTypes.None,
                                    new EffectSounds("DogiBark", null, null),
                                    new ShipStateChange(0, -8, 0, 0)));
            DefaultEffectCollection.AttachmentFlags |= EffectAttachmentFlags.ClonedAttachment;
            DefaultControlableSounds = new ControlableSounds(null, "DogiDie");
        }
        static void Initialize()
        {
            initialized = true;

            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(0),
                new Bounded <float>(0),
                new Bounded <float>(0),
                new Bounded <float>(TimeWarp.ScaleVelocity(120)));
            DefaultDelay    = new Bounded <float>(TimeWarp.RateToTime(20));
            DefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(45, 120));
            DefaultState    = new ShipState(new Bounded <float>(99), new Bounded <float>(0), new Bounded <float>(0), new Bounded <float>(0));
            DefaultCost     = new Costs(new ShipStateChange(0, 20, 0, 0), null, null);


            DefaultEffectCollection.ProlongedEffects.Add(
                new ControlerEffect(
                    TargetingInfo.All,
                    EffectTypes.Controls,
                    new EffectSounds(),
                    new LifeSpan(12),
                    new ConfusionControler(new LifeSpan(12))
                    ));
            DefaultTargetingTypes = TargetingInfo.None;
            DefaultActionSounds   = new ActionSounds("EnergyGun2", null, null);
        }
Пример #6
0
    public void SetState(ShipState state)
    {
        if (IsStateTransitioning)
        {
            throw new InvalidOperationException("Ship state changed while already changing state");
        }

        IsStateTransitioning = true;
        switch (state)
        {
        case ShipState.Awake: break;

        case ShipState.None: break;

        case ShipState.Alive:
            SpawnSequence();
            break;

        case ShipState.Dead:
            DeathSequence();
            break;

        default:
            throw new ArgumentOutOfRangeException(nameof(state), state, null);
        }
        _status.State        = state;
        IsStateTransitioning = false;
    }
Пример #7
0
    public void SetState(ShipState newState)
    {
        switch (newState)
        {
        case ShipState.REPAIR:
            if (State == ShipState.COMBAT)
            {
                return;
            }
            State = newState;
            break;

        case ShipState.COMBAT:
            State = newState;
            if (State == ShipState.REPAIR)
            {
                StopRepair();
            }
            CombatCooldownTimer = SpaceGameGlobal.COMBAT_COOLDOWN;
            break;

        default:
            State = newState;
            break;
        }
    }
Пример #8
0
        static void Initialize()
        {
            initialized = true;

            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(TimeWarp.AngularAcceleration),
                new Bounded <float>(TimeWarp.ScaleTurning(4)),
                new Bounded <float>(TimeWarp.ScaleAcceleration(2, 1)),
                new Bounded <float>(TimeWarp.ScaleVelocity(28)));
            DefaultState = new ShipState(new Bounded <float>(1),
                                         new Bounded <float>(0),
                                         new Bounded <float>(0),
                                         new Bounded <float>(0));
            DefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(2.8f, 28));


            DefaultCost           = new Costs(new ShipStateChange(0, 1, 0, 0), null, null);
            DefaultDelay          = new Bounded <float>(TimeWarp.RateToTime(0));
            DefaultTargetingTypes = new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Ship, TargetingTypes.None);

            DefaultInitialRadius = 3;
            DefaultExpansionRate = 5 + TimeWarp.ScaleRange(5);
            DefaultMass          = .1f;
            DefaultEffectCollection.Effects.Add(new ShipStateEffect(TargetingInfo.All, EffectTypes.None, new EffectSounds(), new ShipStateChange(-1, 0, 0, 0)));
            DefaultActionSounds = new ActionSounds("FlameThrower", null, "Uncloak");
        }
        static void Initialize()
        {
            initialized = true;

            InitShape();
            DefaultLifeTime     = new LifeSpan(TimeWarp.RangeToTime(400, 35));
            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(TimeWarp.AngularAcceleration),
                new Bounded <float>(20),
                new Bounded <float>(1000),
                new Bounded <float>(TimeWarp.ScaleVelocity(35)));
            DefaultState = new ShipState(
                new Bounded <float>(1),
                new Bounded <float>(1),
                new Bounded <float>(0),
                new Bounded <float>(1));

            DefaultEffectCollection.Effects.Add(new MedKitEffect(new TargetingInfo(TargetingTypes.None, TargetingTypes.Ally | TargetingTypes.Ship, TargetingTypes.None), EffectTypes.None, new EffectSounds(null, "FighterGet", null), 1));

            DefaultEffectsWho = new TargetingInfo(TargetingTypes.None, TargetingTypes.Ally | TargetingTypes.Ship, TargetingTypes.None);

            DefaultActions.Add(EarthlingFighterPrimary.Create());

            DefaultControlableSounds = new ControlableSounds();
            DefaultShipSounds        = new ShipSounds();
        }
Пример #10
0
        public Square(NumShip ship, ShipState s, int x, int y)
        {
            this.x = x;
            this.y = y;

            if (s == ShipState.clear)
                state = 0;
            else if (s == ShipState.shot)
                state = -1;
            else state = 1; // ShipState.hit

            if (ship == NumShip.four_ship)
                nship = 41;
            else if (ship == NumShip.three_ship_1)
                nship = 31;
            else if (ship == NumShip.three_ship_2)
                nship = 32;
            else if (ship == NumShip.double_ship_1)
                nship = 21;
            else if (ship == NumShip.double_ship_2)
                nship = 22;
            else if (ship == NumShip.double_ship_3)
                nship = 23;
            else if (ship == NumShip.single_ship_1)
                nship = 11;
            else if (ship == NumShip.single_ship_2)
                nship = 12;
            else if (ship == NumShip.single_ship_3)
                nship = 13;
            else if (ship == NumShip.single_ship_4)
                nship = 14;
            else nship = 0; // NumShip.empty
        }
Пример #11
0
    // Function that changes and tracks the ship state (AtBase / Deployed) and notifies other scripts
    private void ChangeShipState(ShipState newState)
    {
        CurrentShipState = newState;

        switch (CurrentShipState)
        {
        //Enable the ship and all it's components
        case ShipState.Idle:
            break;

        //Disable the ship and all it's components
        case ShipState.Busy:
            break;

        //Remove the ship from play
        case ShipState.Disabled:
            break;

        default:
            break;
        }

        // Action call when a ship changes state
        if (shipStateChange != null)
        {
            shipStateChange(this);
        }
    }
Пример #12
0
 public void setState(string p)
 {
     if (p.Equals("waiting"))
     {
         currentState = ShipState.Waiting;
     }
 }
Пример #13
0
 static void Initialize()
 {
     initialized = true;
     InitShape();
     DefaultMovementInfo = new ShipMovementInfo(
         new Bounded <float>(100),
         new Bounded <float>(TimeWarp.ScaleTurning(0.9f)),
         new Bounded <float>(8000),
         new Bounded <float>(TimeWarp.ScaleVelocity(60)));
     DefaultState = new ShipState(new Bounded <float>(20),
                                  new Bounded <float>(10),
                                  new Bounded <float>(0),
                                  new Bounded <float>(TimeWarp.RechargeRateToPerSeconds(8, -1), TimeWarp.RechargeRateToPerSeconds(8, -1), TimeWarp.RechargeRateToPerSeconds(8, -1), false));
     DefaultTargetingTypes = TargetingInfo.All;
     DefaultActions.Add(new NullAction());
     DefaultActions.Add(new NullAction());
     DefaultActions.Add(new NullAction());
     DefaultActions.Add(new NullTransformAction());
     DefaultActions[3].Costs        = new Costs(new ShipStateChange(0, 0, 0, 0), null, null);
     DefaultActions[3].ActionSounds = new ActionSounds();
     DefaultEffectCollection.Effects.Add(new ShipStateEffect(
                                             DefaultTargetingTypes,
                                             EffectTypes.None,
                                             new EffectSounds(),
                                             new ShipStateChange(-3, 0, 0, 0)));
     DefaultEffectCollection.AttachmentFlags = EffectAttachmentFlags.ClonedAttachment;
     DefaultControlableSounds = new ControlableSounds(null, "ShipDies");
     DefaultShipSounds        = new ShipSounds("AndrosynthGuardianDitty");
 }
Пример #14
0
    private float GetHealing()
    {
        float     recovery;
        ShipState shipState = repairableManager.GetShipState();

        if (shipState.repairableObjectDestroyedCount == 0)
        {
            if (currentHealth < 50)
            {
                recovery = (float)3.5;
            }
            else
            {
                recovery = (float)1.5;
            }
        }
        else
        {
            if (currentHealth < 50)
            {
                recovery = 3;
            }
            else
            {
                recovery = 1;
            }
        }
        return(recovery);
    }
Пример #15
0
        public Ship(bool shipRotation, string shipName, int x, int y)
        {
            this.shipType     = (ShipType)System.Enum.Parse(typeof(ShipType), shipName);
            this.shipRotation = shipRotation;
            this.xPosition    = x;
            this.yPosition    = y;
            this.shipState    = (ShipState)ShipState.ship;

            switch (this.shipType)
            {
            case ShipType.destroyer:
                this.shipSize = 2;
                break;

            case ShipType.submarine:
                this.shipSize = 3;
                break;

            case ShipType.cruiser:
                this.shipSize = 3;
                break;

            case ShipType.battleship:
                this.shipSize = 4;
                break;

            case ShipType.carrier:
                this.shipSize = 5;
                break;
            }
        }
Пример #16
0
 private static ShipState Apply(ShipState state, Instruction instruction)
 {
     return(instruction.Action switch
     {
         InstructionAction.North => state with {
             Waypoint = state.Waypoint.ShiftLatitude(instruction.Value)
         },
	// Use this for initialization
	void Start () {
		Time.timeScale = 1;
		//initialize ship health
		health = 100f;
		healthSlider.maxValue = 100f;
		healthSlider.minValue = 0f;
		healthSlider.value = 100f;

		//initialize healthObservers Array List
		healthObservers = new List<HealthObserver>();

		//initialize an instance of HealthSliderHealthObserver // this for attaching this obsever to ship controller subject 
		HealthSliderHealthObserver healthSliderHealthObserver = new HealthSliderHealthObserver(this);

		//intialize ship states
		redState = new RedShipState(this);
		blueState = new BlueShipState(this);

		//initialize currentShipState to blue
		currentShipState = blueState;
		// ignore collision for red laser
		Physics2D.IgnoreLayerCollision(8,10,true);
		Physics2D.IgnoreLayerCollision(8,9,false);
		rb = GetComponent<Rigidbody2D>();

	}
Пример #18
0
 // Обновление состояния кораблика
 public void UpdateState(ShipState AState, ShipMode AMode)
 {
     State = AState;
     Mode  = AMode;
     /*    IsCapture = ACapture;*/
     FScript.UpdateState();
 }
Пример #19
0
    public override void DoAction(ShipState state)
    {
        Debug.Log("Warp !!!");

        // 워프 중
        StartCoroutine(HandleWarp());
    }
Пример #20
0
 public Ship(int size, int yCoord, int xCoord, ShipState state)
 {
     this.size   = size;
     this.yCoord = yCoord;
     this.xCoord = xCoord;
     this.state  = state;
 }
Пример #21
0
 public void TryLaunch(RimWorld.Planet.GlobalTargetInfo target, PawnsArriveMode arriveMode, TravelingShipArrivalAction arrivalAction, bool launchedAsSingleShip = false)
 {
     this.timeToLiftoff = 0;
     if (this.parentLandedShip == null)
     {
         this.shipState = ShipState.Outgoing;
         ShipBase_Traveling travelingShip = new ShipBase_Traveling(this, target, arriveMode, arrivalAction);
         GenSpawn.Spawn(travelingShip, this.Position, this.Map);
         this.DeSpawn();
         if (this.LaunchAsFleet)
         {
             foreach (ShipBase current in DropShipUtility.currentShipTracker.ShipsInFleet(this.fleetID))
             {
                 if (current != this)
                 {
                     current.shipState = ShipState.Outgoing;
                     ShipBase_Traveling travelingShip2 = new ShipBase_Traveling(current, target, arriveMode, arrivalAction);
                     GenSpawn.Spawn(travelingShip2, current.Position, current.Map);
                     current.DeSpawn();
                 }
             }
         }
     }
     else
     {
         //      Find.WorldSelector.Select(parentLandedShip);
         TravelingShipsUtility.LaunchLandedFleet(this.parentLandedShip, target.Tile, target.Cell, arriveMode, arrivalAction);
         this.landedShipCached = null;
         //Find.MainTabsRoot.SetCurrentTab(MainButtonDefOf.World, false);
     }
 }
Пример #22
0
        static void Initialize()
        {
            initialized = true;

            InitShape();
            DefaultTargetingTypes = new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Ship, TargetingTypes.None);
            DefaultMovementInfo   = new ShipMovementInfo(
                new Bounded <float>(TimeWarp.AngularAcceleration),
                new Bounded <float>(TimeWarp.ScaleTurning(0)),
                new Bounded <float>(8000),
                new Bounded <float>(TimeWarp.ScaleVelocity(25)));
            DefaultState    = new ShipState(new Bounded <float>(1), new Bounded <float>(0), new Bounded <float>(0), new Bounded <float>(0));
            DefaultCost     = new Costs(new ShipStateChange(0, 2, 0, 0), null, null);
            DefaultDelay    = new Bounded <float>(TimeWarp.RateToTime(7));
            DefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(35, 25));
            DefaultEffectCollection.Effects.Add(
                new VuxSlowDownEffect(
                    DefaultTargetingTypes,
                    EffectTypes.None,
                    new EffectSounds("Bite", null, null),
                    new LifeSpan(),
                    new ShipMovementInfoChange(0, -.125f, -.125f, 0)));
            DefaultActionSounds = new ActionSounds("OrganicGun2", null, null);
            DefaultEffectCollection.AttachmentFlags |= EffectAttachmentFlags.WeaponExpires;
        }
Пример #23
0
        public void OnShipDamaged(ShipState state)
        {
            float length = this.tileViews.Count * LevelTile.TileWidth;


            switch (state)
            {
            case ShipState.LightDamaged:
            {
                EffectsManager.Singleton.Smoke(sceneMgr, staticNode, Effects.EffectsManager.SmokeType.NORMAL, new Vector3(0, 6, -Mogre.Math.RangeRandom(0, length)), Vector3.UNIT_Y, new Vector2(15, 15));
                EffectsManager.Singleton.Smoke(sceneMgr, staticNode, Effects.EffectsManager.SmokeType.LIGHTSMOKE, new Vector3(0, 6, -Mogre.Math.RangeRandom(0, length)), Vector3.UNIT_Y, new Vector2(3, 3));
            }
            break;

            case ShipState.HeavyDamage:
            {
                for (uint i = 0; i < 6; i++)
                {
                    EffectsManager.Singleton.Sprite(sceneMgr, staticNode,
                                                    new Vector3(Math.RangeRandom(-3, 3), 8.0f, -Mogre.Math.RangeRandom(0, length)), new Vector2(Math.RangeRandom(5, 10), Math.RangeRandom(5, 10)),
                                                    EffectsManager.EffectType.FIRE, true, i.ToString());
                }
            }
            break;
            }
        }
Пример #24
0
 public Ship()
     : base(new Point(5000, 3750))
 {
     _thrustOn = false;
     _state    = ShipState.Alive;
     InitPoints();
 }
Пример #25
0
 /// <summary>
 /// Default Constructor.  Sets values to default level
 /// </summary>
 public Player()
 {
     abilityActivateTime = abilityRechargeStartTime = TimeSpan.Zero;
     ABILITY_DURATION = 10000;       //10 seconds
     ABILITY_RECHARGE_MAX = 20000;   //20 seconds
     shipState = ShipState.AbilityRecharging;
 }
Пример #26
0
            static void Initialize()
            {
                initialized = true;

                InitShape();
                DefaultMovementInfo = new ShipMovementInfo(
                    new Bounded <float>(TimeWarp.AngularAcceleration),
                    new Bounded <float>(TimeWarp.ScaleTurning(9)),
                    new Bounded <float>(10000),
                    new Bounded <float>(TimeWarp.ScaleVelocity(80)));

                DefaultState = new ShipState(new Bounded <float>(1),
                                             new Bounded <float>(0),
                                             new Bounded <float>(0),
                                             new Bounded <float>(0));
                DefaultCost     = new Costs(new ShipStateChange(0, 1, 0, 0), null, null);
                DefaultDelay    = new Bounded <float>(TimeWarp.RateToTime(20));
                DefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(50, 80));

                DefaultEffectCollection.Effects.Add(
                    new ShipStateEffect(
                        TargetingInfo.All,
                        EffectTypes.None,
                        new EffectSounds("Boom1", null, null),
                        new ShipStateChange(-1, 0, 0, 0)));
                DefaultTargetingTypes = new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Other | TargetingTypes.Ship, TargetingTypes.None);
                DefaultEffectsWho     = TargetingInfo.All;
                DefaultActionSounds   = new ActionSounds("MissileLaunch2", null, null);
            }
Пример #27
0
 public Ship(int size, int[] height, int width, ShipState state)
 {
     this.size   = size;
     this.height = height;
     this.width  = width;
     this.state  = state;
 }
        static void Initialize()
        {
            initialized = true;

            DefaultTargetingTypes = new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Ship, TargetingTypes.None);
            DefaultEffectsWho     = new TargetingInfo(TargetingTypes.Enemy | TargetingTypes.Debris);
            InitShape();
            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(0),
                new Bounded <float>(0),
                new Bounded <float>(0),
                new Bounded <float>(TimeWarp.ScaleVelocity(64)));
            DefaultDelay       = new Bounded <float>(TimeWarp.RateToTime(0));
            DefaultLifeTime    = new LifeSpan(20);
            SubDefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(9, 64));
            DefaultState       = new ShipState(new Bounded <float>(6), new Bounded <float>(0), new Bounded <float>(0), new Bounded <float>(0));
            SubDefaultState    = new ShipState(new Bounded <float>(2), new Bounded <float>(0), new Bounded <float>(0), new Bounded <float>(0));

            DefaultCost = new Costs(new ShipStateChange(0, 5, 0, 0), new ShipStateChange(), new ShipStateChange());

            DefaultEffectCollection.Effects.Add(new ShipStateEffect(DefaultEffectsWho, EffectTypes.None, new EffectSounds(), new ShipStateChange(-6, 0, 0, 0)));

            SubDefaultEffectCollection.Effects.Add(new ShipStateEffect(DefaultEffectsWho, EffectTypes.None, new EffectSounds(), new ShipStateChange(-2, 0, 0, 0)));


            DefaultActionSounds = new ActionSounds("Crystal", null, "GlassBreak");
        }
Пример #29
0
            static void Initialize()
            {
                initialized = true;

                InitShape();
                DefaultMovementInfo = new ShipMovementInfo(
                    new Bounded <float>(100),
                    new Bounded <float>(TimeWarp.ScaleTurning(13)),
                    new Bounded <float>(TimeWarp.ScaleAcceleration(10, 0)),
                    new Bounded <float>(TimeWarp.ScaleVelocity(50)));
                DefaultState = new ShipState(new Bounded <float>(20),
                                             new Bounded <float>(10),
                                             new Bounded <float>(0),
                                             new Bounded <float>(TimeWarp.RechargeRateToPerSeconds(6, 1)));

                DefaultActions.Add(MmrnmhrmXFormMissilePrimary.Create());

                NullTransformAction t = new NullTransformAction();

                t.AIInfo = new SpecificRangeActionAIInfo(
                    MmrnmhrmXFormSecondary.DefaultCost.ActivationCost,
                    0,
                    800);
                DefaultActions.Add(t);

                DefaultControlableSounds = new ControlableSounds(null, "ShipDies");
                DefaultShipSounds        = new ShipSounds("MmrnmhrmXFormDitty");
            }
Пример #30
0
    // Update is called once per frame
    void FixedUpdate()
    {
        float forwardInputValue    = Input.GetAxis("Vertical");
        float horizontalInputValue = Input.GetAxis("Horizontal");

        Shipcontroller.CallLateralAndForardMove(forwardInputValue, horizontalInputValue);
        Shipcontroller.CallMouseAxisInput();

        if (!ShipState.IsGameover)
        {
            Shipcontroller.CallAxisRotation();
            if (Input.GetKeyUp(KeyCode.LeftControl))
            {
                Shipcontroller.ChangeCamera();
            }

            if (Input.GetKey(KeyCode.LeftShift))
            {
                Shipcontroller.Booster();
            }
            else
            {
                Shipcontroller.UnBooste();
            }
            //GetDirectionPoint();

            Shipcontroller.MoveForwarde();

            ShipState.ShieldCoolDownCompute();
        }
    }
Пример #31
0
        static void Initialize()
        {
            initialized = true;

            InitShape();
            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(TimeWarp.AngularAcceleration),
                new Bounded <float>(TimeWarp.ScaleTurning(1)),
                new Bounded <float>(TimeWarp.ScaleAcceleration(5, 0)),
                new Bounded <float>(TimeWarp.ScaleVelocity(35)));

            DefaultState = new ShipState(new Bounded <float>(16),
                                         new Bounded <float>(20),
                                         new Bounded <float>(0),
                                         new Bounded <float>(TimeWarp.RechargeRateToPerSeconds(6, 1)));

            DefaultActions.Add(OrzNemesisPrimary.Create());
            DefaultActions.Add(OrzNemesisSecondary.Create());
            DefaultActions.Add(OrzNemesisTernary.Create());

            DefaultSubShips    = new IShip[1];
            DefaultSubShips[0] = OrzTurret.Create(new PhysicsState(), new FactionInfo(0));


            DefaultControlableSounds = new ControlableSounds(null, "ShipDies");
            DefaultShipSounds        = new ShipSounds("OrzNemesisDitty");
        }
Пример #32
0
        static void Initialize()
        {
            initialized = true;

            InitShape();
            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(0),
                new Bounded <float>(0),
                new Bounded <float>(0),
                new Bounded <float>(TimeWarp.ScaleVelocity(120)));
            DefaultDelay    = new Bounded <float>(TimeWarp.RateToTime(4));
            DefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(20, 120));
            DefaultState    = new ShipState(new Bounded <float>(3), new Bounded <float>(0), new Bounded <float>(0), new Bounded <float>(0));

            DefaultCost = new Costs(new ShipStateChange(0, 6, 0, 0), null, null);
            DefaultEffectCollection.Effects.Add(
                new ShipStateEffect(
                    TargetingInfo.All,
                    EffectTypes.None,
                    new EffectSounds("Boom23", null, null),
                    new ShipStateChange(-3, 0, 0, 0)));

            DefaultTargetingTypes = TargetingInfo.None;
            DefaultActionSounds   = new ActionSounds("Gun2", null, null);
        }
Пример #33
0
        static void Initialize()
        {
            initialized = true;

            InitShape();
            DefaultMovementInfo = new ShipMovementInfo(
                new Bounded <float>(TimeWarp.AngularAcceleration),
                new Bounded <float>(TimeWarp.ScaleTurning(3)),
                new Bounded <float>(TimeWarp.ScaleAcceleration(40, 4)),
                new Bounded <float>(TimeWarp.ScaleVelocity(40)));
            DefaultState    = new ShipState(new Bounded <float>(3), new Bounded <float>(0), new Bounded <float>(0), new Bounded <float>(0));
            DefaultCost     = new Costs(new ShipStateChange(1, 0, 0, 0), null, null);
            DefaultDelay    = new Bounded <float>(TimeWarp.RateToTime(12));
            DefaultLifeTime = new LifeSpan(TimeWarp.RangeToTime(600, 80));
            DefaultEffectCollection.Effects.Add(new MedKitEffect(new TargetingInfo(TargetingTypes.None, TargetingTypes.Ally | TargetingTypes.Ship, TargetingTypes.None), EffectTypes.None, new EffectSounds(), 1));

            DefaultEffectCollection.ProlongedEffects.Add(new BordingPartyEffect(
                                                             new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Ship, TargetingTypes.None),
                                                             EffectTypes.Health,
                                                             new EffectSounds("Intruder", "Zap", "Argh"),
                                                             new LifeSpan(),
                                                             new Bounded <float>(TimeWarp.RateToTime(7)), 1));
            DefaultTargetingTypes = new TargetingInfo(TargetingTypes.None, TargetingTypes.Enemy | TargetingTypes.Ship, TargetingTypes.None);
            DefaultActionSounds   = new ActionSounds("Go", null, null);
        }
Пример #34
0
 /// <summary>
 /// Constructs new Player object from PlayerData structure, a texture to represent it, and a texture to represent its projectiles
 /// </summary>
 /// <param name="d">PlayerData structure which is loaded from an XML file through the ContentPipeline of the main game</param>
 /// <param name="tex">Texture to represent the player</param>
 /// <param name="cBTex">Texture to represent the player's projectiles</param>
 public Player(PlayerData d, Texture2D tex, Texture2D cBTex)
     : base(d, tex, cBTex)
 {
     abilityActivateTime = abilityRechargeStartTime = TimeSpan.Zero;
     ABILITY_DURATION = d.ABILITY_DURATION;
     ABILITY_RECHARGE_MAX = d.ABILITY_RECHARGE_MAX;
     shipState = ShipState.AbilityRecharging;
 }
Пример #35
0
        private Ship Build(ShipState state)
        {
            state.Code = ItemCode.LightFrigate;
            var builder = Ship.Builder.Build(null, state);
            builder
                .Dependent(new ShipInfo {Code = ItemCode.LightFrigate})
                .Build(info => new ObjectBuilder<ShipInfo>(info));

            return builder.Materialise();
        }
Пример #36
0
        public Square(int nship, ShipState s, int x, int y)
        {
            this.x = x;
            this.y = y;

            if (s == ShipState.clear)
                state = 0;
            else if (s == ShipState.shot)
                state = -1;
            else state = 1; // ShipState.hit

            this.nship = nship;
        }
Пример #37
0
            public static ObjectBuilder<Ship> Build(ILocation location, ShipState state)
            {
                var ship = new Ship
                {
                    Id = state.ObjectId,
                    Name = state.Name,
                    Heading = state.Heading,
                    Position = new Position(location, state.LocalCoordinates),
                    Statistics = new ShipStatistics(state.Statistics.Select(Build)),
                };

                var builder = new ObjectBuilder<Ship>(ship)
                    .Resolve((resolver, target) => BuildHardPoints(resolver, ship, state.HardPoints))
                    .Resolve((resolver, target) => target.ShipInfo = resolver.Get<ShipInfo>(ItemType.Ships.ToObjectReference(state.Code)));

                builder
                    .Dependent(state.Pilot)
                    .Build(Agent.Builder.Build)
                    .Resolve((resolver, target, dependentObject) => target.Pilot = dependentObject);

                return builder;
            }
Пример #38
0
        public void ShipCanTrack()
        {
            Vector left, right;
            double radiansOfMovement;

            HardPoint.CalculateHardPoint(HardPointPosition.Left, out left, out radiansOfMovement);
            HardPoint.CalculateHardPoint(HardPointPosition.Right, out right, out radiansOfMovement);

            Assert.That(left, Is.Not.EqualTo(Vector.Zero));
            Assert.That(right, Is.Not.EqualTo(Vector.Zero));

            var state = new ShipState
            {
                HardPoints = new[]
                {
                    new HardPointState {Position = HardPointPosition.Left, Speed = 0.5d, Orientation = left },
                    new HardPointState {Position = HardPointPosition.Right, Speed = 0.5d, Orientation = right },
                },
                LocalCoordinates = new Vector(0, 0, 0),
                Statistics = Enumerable.Empty<ShipStatisticState>()
            };

            var ship = Build(state);
            var inFront = Build(new ShipState { LocalCoordinates = new Vector(0, 10, 0), Statistics = Enumerable.Empty<ShipStatisticState>() });
            var toTheSide = Build(new ShipState { LocalCoordinates = new Vector(-10, 0, 0), Statistics = Enumerable.Empty<ShipStatisticState>() });

            ship.ShouldSatisfyAllConditions
                (
                    () => ship.HardPoints.ShouldNotBeEmpty(),
                    () => ship.CanAimAt(toTheSide).ShouldBe(true),
                    () => ship.CanTrack(toTheSide).ShouldBe(true),
                    () => ship.CanAimAt(inFront).ShouldBe(false),
                    () => ship.CanTrack(inFront).ShouldBe(false)
                );

            Should.Throw<ArgumentException>(() => ship.CanAimAt(ship)).Message.ShouldBe("Target must not be at the same position as the ship");
            Should.Throw<ArgumentException>(() => ship.CanTrack(ship)).Message.ShouldBe("Target must not be at the same position as the ship");
        }
	//set current ship state
	public void setCurrentShipState(ShipState shipState)
	{
		currentShipState = shipState;
	}
Пример #40
0
 public void setSunk()
 {
     state = ShipState.SUNK;
     this.setLaF(LAF.SUNK);
 }
Пример #41
0
 public void setShip()
 {
     state = ShipState.SHIP;
     this.setLaF(LAF.SELECTED);
 }
Пример #42
0
 /// <summary>
 /// Activate the player's special ability.  The function is virtual because each ship will have a different power, but this function implements the commonality between all ships (changing ship state, making invicible, and setting abilityActivateTime)
 /// </summary>
 /// <param name="gameTime">TimeSpan with relevant time information to set abilityActivateTime</param>
 /// <returns></returns>
 public virtual bool ActivateAbility(TimeSpan gameTime)
 {
     //if the ability has not recharged then do not activate it
     if (shipState != ShipState.AbilityCharged)
         return false;
     shipState = ShipState.AbilityActivated;
     damageResistance = 1;
     abilityActivateTime = gameTime;
     return true;
     //Console.WriteLine("ABILITY ACTIVATED: " + abilityActivateTime);
 }
    public void SetState(ShipState newState)
    {
        if (newState == state)
            return;

        lock(this) {

            switch (newState) {
                case ShipState.Dying:
                    deathCount++;
                    waitCount = Constants.DyingCycle;
                    sounds |= Sounds.ShipExplode;
                    break;

                case ShipState.Dead:
                    waitCount = Constants.DeadCycleWait;
                    shipMesh.Position.Move(this.startingPosition);

                    break;

                case ShipState.Normal:
                    if (state == ShipState.Hyper) {
                        SetRandomPosition(false);
                    }
                    else {
                        shipMesh.Position.Move(startingPosition);
                        velocity = 0.0f;
                    }
                    hyperSuccess = Constants.HyperSuccessFactor;
                    shots.Clear();
                    sounds |= Sounds.ShipAppear;
                    break;

                case ShipState.HyperCharge:
                    sounds |= Sounds.ShipHyper;
                    waitCount = Constants.HyperChargeWait;
                    break;

                case ShipState.Hyper:
                    waitCount = Constants.HyperCycleWait;
                    break;
            }
            state = newState;
        }
    }
Пример #44
0
    public void BeginHyperspace()
    {
        if( state != ShipState.Hyperspace )
        {
          if( energy > PENALTY_HYPERSPACE )
          {
        // hyperspace costs 8 units of energy
        energy -= PENALTY_HYPERSPACE;

        // set hyperspace time to max hyperspace length
        // If you change HYPERSPACE_LENGTH to something
        // bigger or smaller, then hyperspace will last
        // longer or shorter.
        hyperspaceTimeRem = HYPERSPACE_LENGTH;

        state = ShipState.Hyperspace;

        velocity = new Vector2( (float)( 0.5f - SPW.rand.NextDouble() ) * 10.0f, (float)( 0.5f - SPW.rand.NextDouble() ) * 10.0f );

        // play the sound
        SPW.world.sfx[ SFX.Hyperspace ].Play();
          }
        }
    }
Пример #45
0
    // Call this function to kill the player
    // in a !!DRAMATIC!! explosion over a few frames
    public void BlowUp()
    {
        if( state != ShipState.BlowingUp )
        {
          state = ShipState.BlowingUp;

          deathSequenceTimeRem = DEATH_SEQUENCE_LENGTH;

          SPW.world.sfx[ SFX.Death ].Play();
        }
    }
Пример #46
0
        public MockUniverse(IIdGenerator idGenerator = null)
        {
            _idGenerator = idGenerator ?? new IdGenerator();
            var universeId = Id();

            SpaceshipCommand = TestSkills.For(SkillCode.SpaceshipCommand);
            BluePrint = TestItems.BluePrint(ItemCode.MissileLauncher);
            ShipBluePrint = TestItems.BluePrint(ItemCode.LightFrigate);
            Weapon = TestItems.Weapon(ItemCode.MissileLauncher);
            Item = TestItems.Item(ItemCode.Veldnium);

            John = new AgentState
            {
                ObjectId = Id(),
                Name = "John",
                Statistics = Enum.GetValues(typeof(AgentStatistic)).Cast<AgentStatistic>().Select(x => new AgentStatisticState { Statistic = x, CurrentValue = 50, Value = 50 }),
                Implants = new[] { AgentStatistic.Intelligence, AgentStatistic.Willpower, }.Select(x => new Implant { Stat = x, Rank = 3, Value = 15 }),
                Skills = new[] { new SkillLevel(SkillCode.SpaceshipCommand, level: 5) }
            };

            MSCorp = new CorporationState
            {
                ObjectId = Id(),
                Name = "MS",
                Employees = new[] { John }
            };

            AppleCorp = new CorporationState
            {
                ObjectId = Id(),
                Name = "Apple",
            };

            BuyOrder = new AuctionState
            {
                ObjectId = Id(),
                PricePerUnit = 5,
                Trader = John.ToObjectReference(),
                Item = new ItemState { Code = ItemCode.Veldnium, Quantity = 50 },
                Owner = MSCorp.ToObjectReference(),
            };

            SellOrder = new AuctionState
            {
                ObjectId = Id(),
                PricePerUnit = 10,
                Trader = John.ToObjectReference(),
                Item = new ItemState { Code = ItemCode.Veldnium, Quantity = 100 },
                Owner = MSCorp.ToObjectReference(),
            };

            Earth = new CelestialObjectState
            {
                ObjectId = Id(),
                CelestialObjectType = CelestialObjectType.Planet,
                Name = "Earth",
                LocalCoordinates = new Vector(Units.FromAU(1), 0),
                Mass = Units.SolarMass*1E-6,
                Size = 5d,
            };
            AsteroidBelt = new CelestialObjectState
            {
                ObjectId = Id(),
                CelestialObjectType = CelestialObjectType.AsteriodBelt,
                Name = "Asteroid Belt",
                Orbits = Earth.ToObjectReference(),
                LocalCoordinates = new Vector(-5.5, 0, 0),
                AsteroidBelt = new AsteroidBeltState
                {
                    Richness = 500000,
                    AmountRemaining = 250000,
                },
            };
            Moon = new CelestialObjectState
            {
                ObjectId = Id(),
                CelestialObjectType = CelestialObjectType.Moon,
                Name = "Moon",
                Orbits = Earth.ToObjectReference(),
                Mass = 0.5d,
                Size = 0.5d,
                LocalCoordinates = new Vector(7.5, 0, 0)
            };
            Manufactory = new StructureState()
            {
                ObjectId = Id(),
                Name = "MFC",
                Orbits = Moon.ToObjectReference(),
                LocalCoordinates = new Vector(0.5001, 0, 0),
                Owner = MSCorp.ToObjectReference(),
                Manufactory = new ManufactoryState() { Efficiency = 0.5d },
            };
            TradingStation = new StructureState()
            {
                ObjectId = Id(),
                Name = "TS",
                Orbits = Moon.ToObjectReference(),
                LocalCoordinates = new Vector(-0.5001, 0, 0),
                Owner = MSCorp.ToObjectReference(),
                HangerItems = new[] { new HangarItemState { Owner = MSCorp.ToObjectReference(), Items = new[] { ItemCode.MissileLauncher.ToItemState(quantity:10) }  }, },
                BuyOrders = new[] { BuyOrder },
                SellOrders = new[] { SellOrder },
                TradingStation = new TradingStationState()
            };

            Ship = new ShipState()
            {
                ObjectId = Id(),
                Name = "Ship",
                LocalCoordinates = new Vector(8.5, 0, 0),
                Code = ItemCode.LightFrigate,
                HardPoints = new[]
                {
                    new HardPointState
                    {
                        Position = HardPointPosition.Front,
                        Orientation = HardPoint.CalculateOrientation(HardPointPosition.Front),
                        Speed = 0.5d,
                        Weapon = new WeaponState
                        {
                            ObjectId = Id(),
                            Name = "Blaster",
                            Code = Weapon.Code,
                        }
                    },
                },
                Pilot = John,
                Statistics = Enum.GetValues(typeof(ShipStatistic)).Cast<ShipStatistic>().Select(x => new ShipStatisticState { Statistic = x, CurrentValue = 50, Value = 50 }),
            };
            SolarSystem = new SolarSystemState
            {
                ObjectId = Id(),
                Name = "Sol",
                Satellites = new[] { Earth, Moon, AsteroidBelt, },
                Structures = new[] { Manufactory, TradingStation },
                Ships = new[] { Ship }
            };
            StarCluster = new StarClusterState
            {
                ObjectId = Id(),
                Name = "Revvon",
                SolarSystems = new[] { SolarSystem },
                MarketPlace = new MarketPlaceState
                {
                    AuctionLength = 10,
                    SettlementDelay = 5,
                    Settlements = new[]
                    {
                        new SettlementState
                        {
                            ObjectId = Id(),
                            Item = new ItemState { Code = ItemCode.Veldnium, Quantity = 50 },
                            Owner = MSCorp.ToObjectReference(),
                            Location = TradingStation.ToObjectReference(),
                            TimeToSettlement = 100,
                            SpendByOwner = new Dictionary<ObjectReference, long> { { AppleCorp.ToObjectReference(), 1000 } },
                        }
                    },
                    Auctions = new[] { BuyOrder.ToObjectReference(), SellOrder.ToObjectReference() },
                }
            };

            Universe = new UniverseState
            {
                ObjectId = universeId,
                StarClusters = new[] {StarCluster},
                Weapons = new[] { Weapon },
                Skills = TestSkills.Skills,
                Corporations = new[] { MSCorp, AppleCorp },
                Items = TestItems.Items,
                BluePrints = TestItems.BluePrints,
                Ships = new[]
                {
                    new ShipInfo
                    {
                        Code = ItemCode.LightFrigate,
                        ShipClass = ShipClass.LightFrigate,
                        PilotRequirements = new[]
                        {
                            new State.SkillLevel(SkillCode.SpaceshipCommand, level:1),
                        }
                    }
                }
            };
        }
Пример #47
0
        public void FireAll()
        {
            var items = new IObject[] { new ShipInfo { Code = ItemCode.LightFrigate }, new WeaponInfo { Code = ItemCode.MissileLauncher, MinimumDamage = 100, MaximumDamage = 100 }, };

            var ship = new ShipState(ItemCode.LightFrigate)
            {
                LocalCoordinates = Vector.Parse("0,-1"),
                Heading = Vector.Parse("0,-1"),
                HardPoints = new[]
                {
                    new HardPointState { Weapon = new WeaponState {Code = ItemCode.MissileLauncher}, Position = HardPointPosition.Front },
                    new HardPointState { Weapon = new WeaponState {Code = ItemCode.MissileLauncher}, Position = HardPointPosition.Rear },
                    new HardPointState { Weapon = new WeaponState {Code = ItemCode.MissileLauncher}, Position = HardPointPosition.Top },
                }
            };

            _combat = _combatFactory(ship, new IdResolutionContext(items));

            Assert.That(_combat.Ship.HardPoints, Is.Not.Empty);

            _random.Setup(x => x.GetNext()).Returns(0);

            var result =
                _combat.Ship.HardPoints
                .Where(hp => hp.Weapon != null)
                .Where(hp => hp.InRange(_combat.Target))
                .Select(x => _combat.Fire(x.Weapon))
                .ToArray();

            Assert.That(result, Is.Not.Empty);

            var dmg = result.Aggregate((Damage )null, (current, value) => current + value.TotalDamage);
            Assert.That(dmg.Value, Is.Not.EqualTo(0d));
        }
Пример #48
0
    public override void Step( float stepTime )
    {
        switch( state )
        {
          case ShipState.Cloaking:

        // take energy down by penalty amount
        energy -= PENALTY_CLOAK_PER_SEC * stepTime;

        // there, we spent the energy for the cloak,
        // and we'll try to revert to normal state if was cloaking
        state = ShipState.Normal;

        //C# doesn't allow fall-thru
        //without goto, but the rest of the frame
        // computation is going to be the same as Normal state
        goto case ShipState.Normal;

          case ShipState.Normal:

        if( this.thrusting )
        {
          this.energy -= PENALTY_ENGINES_PER_SEC * stepTime;

          float thrusterPower = 0.5f;

          // Get a vector pointing in
          // the direction of the ship.
          Vector2 heading = GetHeading();

          // reduce effect a bit
          heading *= thrusterPower;

          // now influence the velocity vector with
          // this heading vector.  There, we spent the thrust,
          // so, now we should turn it off for the next frame.
          velocity += heading;

          // we can impose a maximum velocity here.
          if( velocity.Length() > 5.0f )
          {
            velocity.Normalize();

            // max velocity imposed.
            velocity *= 5.0f;
          }

          // we computed the thruster contribution
          // to velocity so now we can just turn
          // the thruster off.  It will appear
          // to be continuously on though if
          // the player keeps holding down the thruster key
          this.thrusting = false;
        }

        // run the Step function in MovingSprite,
        // which actually physically moves the player
        base.Step( stepTime );
        break;

          case ShipState.Hyperspace:

        // reduce the amount of time the player
        // has left in hyperspace
        hyperspaceTimeRem -= stepTime;

        // now, actually move the player using
        // the MovingSprite class's Step() function
        base.Step( stepTime );

        // get out of phasing mode if done hyperspacing
        if( hyperspaceTimeRem < 0 )
        {
          state = ShipState.Normal;

          // ship STOPS when done hyperspace
          velocity = Vector2.Zero;
        }

        break;

          case ShipState.BlowingUp:

        // reduce the amount of time the player
        // has left in his death sequence (just
        // particles flying)
        deathSequenceTimeRem -= stepTime;

        // once he has finished blowing up,
        // we set this.dead to true, signalling
        // the end fo the game (see in the Update function
        // there is a check if EITHER player is DEAD.

        // If either player is dead it goes back to the menu screen,
        // meaning game over.
        if( deathSequenceTimeRem < 0 )
        {
          this.dead = true;
        }

        break;
        }

        // step the phasor gun
        phasor.Step( stepTime );

        // Player gets a chance to recharge a bit every turn
        // auto-shield ++
        Recharge( stepTime );
    }
Пример #49
0
        /// <summary>
        /// Update necessary player information.  Calls Ship.Update() (handles movement and projectile movement), but also updates ability times and changes player state accordingly.
        /// </summary>
        /// <param name="gameTime">provides a snapshot of timing values</param>
        public override void Update(TimeSpan gameTime)
        {
            //check if the ability has exceeded its duration
            if (shipState == ShipState.AbilityActivated && (gameTime.TotalMilliseconds - abilityActivateTime.TotalMilliseconds > ABILITY_DURATION))
            {
                DeactivateAbility(gameTime);
            }

            //check if the ability has recharged
            else if (shipState == ShipState.AbilityRecharging && ((gameTime.TotalMilliseconds - abilityRechargeStartTime.TotalMilliseconds) >= ABILITY_RECHARGE_MAX))
            {
                shipState = ShipState.AbilityCharged;
                Console.WriteLine("ABILITY CHARGED: " + gameTime + "; " + shipState + "; " + ABILITY_RECHARGE_MAX + "; " + (gameTime.TotalMilliseconds - abilityActivateTime.TotalMilliseconds));
            }
            base.Update(gameTime);
        }
Пример #50
0
 /// <summary>
 /// Reset the player's data to initial conditions.  Only modifies values that may have changed during the game (state, all time values, and health)
 /// </summary>
 public void Reset()
 {
     DeactivateAbility(TimeSpan.Zero);
     abilityActivateTime = TimeSpan.Zero;
     health = maxHealth;
     shipState = ShipState.AbilityRecharging;
 }
Пример #51
0
 /// <summary>
 /// Deactivate the player's special ability.  The function is virtual because each ship will deactivate differently, bu this function implements the commonality between all ships (changing ship state, making mortal, and setting abilityRechargeStartTime)
 /// </summary>
 /// <param name="gameTime">TimeSpan with relevant time information to set abilityRechargeStartTime</param>
 /// <returns></returns>
 public virtual bool DeactivateAbility(TimeSpan gameTime)
 {
     if (shipState != ShipState.AbilityActivated)
         return false;
     //Console.WriteLine("DEACTIVATING: " + (gameTime));
     shipState = ShipState.AbilityRecharging;
     abilityRechargeStartTime = gameTime;
     damageResistance = 0;
     return true;
 }
Пример #52
0
        private Ship Build(ShipState state)
        {
            var builder = Echo.Ships.Ship.Builder.Build(null, state);
            builder
                .Dependent(new ShipInfo { Code = state.Code })
                .Build(info => new ObjectBuilder<ShipInfo>(info));

            builder
                .Dependent(Universe.Weapon)
                .Build(x => new ObjectBuilder<WeaponInfo>(x));

            return builder.Materialise();
        }
Пример #53
0
 public void Cloak()
 {
     if( this.state != ShipState.Hyperspace )
     {
       if( this.energy > PENALTY_CLOAK_PER_SEC )
       {
     state = ShipState.Cloaking;
       }
     }
 }
        void SetState(ShipState newState)
        {
            switch (newState) {
                case ShipState.Dying:
                    deathCount++;
                    waitCount = Constants.DyingCycle;
                    sounds |= Sounds.ShipExplode;
                    break;

                case ShipState.Dead:
                    waitCount = Constants.DeadCycleWait;
                    position = new Vector2(-1000f, -1000f);	// not on board
                    break;

                case ShipState.Normal:
                    if (state == ShipState.Hyper) {
                        SetRandomPosition(false, game.SunLocation);
                    }
                    else {
                        position = originalPosition;
                        velocity = new Vector2(0.0f, 0.0f);
                    }
                    hyperSuccess = Constants.HyperSuccessFactor;
                    shots.Clear();
                    sounds |= Sounds.ShipAppear;
                    break;

                case ShipState.HyperCharge:
                    sounds |= Sounds.ShipHyper;
                    waitCount = Constants.HyperChargeWait;
                    break;

                case ShipState.Hyper:
                    position = new Vector2( -1000f, -1000f);		// not on board...
                    waitCount = Constants.HyperCycleWait;
                    break;
            }
            state = newState;
        }
Пример #55
0
 public ShipState(ShipState orig)
 {
     this.ShipID = orig.ShipID;
     this.ShipNameID = orig.ShipNameID;
     this.ShipTypeID = orig.ShipTypeID;
     this.InitialHP = orig.InitialHP;
     this.MaxHP = orig.MaxHP;
     this.DamageTotal = orig.DamageTotal;
     this.ShipName = orig.ShipName;
 }
Пример #56
0
 public void setHit()
 {
     state = ShipState.HIT;
     this.setLaF(LAF.HIT);
 }
Пример #57
0
    public Ship()
    {
        velocity = new Vector2();
        state = ShipState.Normal;
        dead = false;

        // total looks like about 160
        energy = MAX_ENERGY;
        shield = 40.0f;

        // create the particles that will be used
        // when the ship does hyperspace or explodes
        particles = new List<Particle>();
        for( int i = 0; i < 100; i++ )
        {
          particles.Add( new Particle( this ) );
        }

        // initialize the phasor
        phasor = new Phasor( this );
    }
Пример #58
0
 public void setMissed()
 {
     state = ShipState.MISSED;
     this.setLaF(LAF.MISSED);
 }
Пример #59
0
 public void setNotShip()
 {
     state = ShipState.NOT_SHIP;
     this.setLaF(LAF.NORMAL);
 }
Пример #60
0
    private void OnShipStateChanging(ShipState newState) {
        ShipState previousState = Item.CurrentState;
        switch (previousState) {
            case ShipState.Refitting:
            case ShipState.Repairing:
                // the state is changing from one of these states so stop the Showing
                View.StopShowing();
                break;
            case ShipState.ShowAttacking:
            case ShipState.ShowHit:
            case ShipState.ShowDying:
                // no need to stop any of these showing as they have already completed
                break;
            case ShipState.Entrenching:
            case ShipState.ProcessOrders:
            case ShipState.MovingTo:
            case ShipState.Idling:
            case ShipState.GoAttack:
            case ShipState.Dead:
            case ShipState.Chasing:
            case ShipState.Attacking:
            case ShipState.Dying:
            case ShipState.Joining:
            case ShipState.TakingDamage:
            case ShipState.Withdrawing:
                // do nothing
                break;
            case ShipState.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(previousState));
        }

        switch (newState) {
            case ShipState.ShowAttacking:
                View.ShowAttacking();
                break;
            case ShipState.ShowHit:
                View.ShowHit();
                break;
            case ShipState.ShowDying:
                View.ShowDying();
                break;
            case ShipState.Entrenching:
                //View.ShowEntrenching();   // no current plans to show entrenching animation at this stage
                break;
            case ShipState.Refitting:
                View.ShowRefitting();
                break;
            case ShipState.Repairing:
                View.ShowRepairing();
                break;
            case ShipState.ProcessOrders:
            case ShipState.MovingTo:
            case ShipState.Idling:
            case ShipState.GoAttack:
            case ShipState.Dead:
            case ShipState.Chasing:
            case ShipState.Attacking:
            case ShipState.Dying:
            case ShipState.Joining:
            case ShipState.TakingDamage:
            case ShipState.Withdrawing:
                // do nothing
                break;
            case ShipState.None:
            default:
                throw new NotImplementedException(ErrorMessages.UnanticipatedSwitchValue.Inject(newState));
        }
    }