Beispiel #1
0
 public BaseState(Events.SpawnEvent e)
 {
     Position = e.Position;
     Side     = e.Side;
     LaneKey  = e.LaneKey;
     Angle    = e.Angle;
 }
Beispiel #2
0
        private void _spawnSoldier(int laneIndex, Side side)
        {
            var pos = Map.GetSoldierSpawnPosition(laneIndex, side);
            var e   = new Events.SpawnEvent(pos, 0, side, laneIndex.ToString(), ObjectType.UnitSoldier);

            Game.PushEvent(e);
        }
Beispiel #3
0
    public static void Spawn(Events.SpawnEvent e, GameState privateState)
    {
        var objectState = _getStateForSpawnEvent(e);
        var position    = M.SetZ(e.Position, ParticleConsts.Z);

        _updateInternalState(e.ObjectType, objectState, privateState);
        FactoryBehaviour.SpawnPrefab(position, e.ObjectType, objectState);
    }
    private void _produceResources()
    {
        State.ProductionCooldown -= Time.deltaTime;
        if (State.ProductionCooldown < 0 && State.Side != Side.Neutral)
        {
            State.ProductionCooldown = BalanceConsts.ControlPointProductionCooldown;
            Game.PushEvent(new Events.ProduceResourceEvent(State.Id));

            if (State.Side == Side.Player)
            {
                var e = new Events.SpawnEvent(State.Position, ObjectType.ParticleResource);
                Game.PushEvent(e);
            }
        }
    }
Beispiel #5
0
    private static BaseState _getStateForSpawnEvent(Events.SpawnEvent e)
    {
        switch (e.ObjectType)
        {
        // Units
        case ObjectType.UnitControlPoint:
            return(new ControlPointState(e));

        case ObjectType.UnitSoldier:
            return(new SoldierState(e));

        case ObjectType.UnitTurret:
            return(new TurretState(e));

        // Map + Scenery
        case ObjectType.MapBarrier:
            return(new BarrierState(e));

        // Misc
        case ObjectType.EnemyAI:
            return(new EnemyAIState());

        // Decal
        case ObjectType.DecalBlood:
            return(new DecalState(e, DecalType.Blood));

        case ObjectType.DecalExplosion:
            return(new DecalState(e, DecalType.Scorch));

        case ObjectType.DecalBullet:
            return(new DecalState(e, DecalType.Bullet));

        // Lights
        case ObjectType.LightMuzzle:
            return(new LightGlowState(e, LightGlowType.Muzzle));

        case ObjectType.LightExplosion:
            return(new LightGlowState(e, LightGlowType.Explosion));

        case ObjectType.LightTurretMuzzle:
            return(new LightGlowState(e, LightGlowType.TurretMuzzle));

        // Particles
        default:
            return(null);
        }
    }
Beispiel #6
0
    private void _produceResources()
    {
        State.ProductionCooldown -= Time.deltaTime;
        if (State.ProductionCooldown <= 0f)
        {
            State.ProductionCooldown = BalanceConsts.ControlPointProductionCooldown;
            Game.PushEvent(new Events.ProduceResourceEvent(State.Id));

            if (State.Side == Side.Player)
            {
                var laneIndex = Int32.Parse(State.LaneKey);
                var e         = new Events.SpawnEvent(Map.GetSoldierSpawnPosition(laneIndex, State.Side),
                                                      ObjectType.ParticleResource);
                Game.PushEvent(e);
            }
        }
    }
Beispiel #7
0
 public ControlPointState(Events.SpawnEvent e) : base(e)
 {
     UnitType = UnitType.ControlPoint;
 }
Beispiel #8
0
 public BaseUnitState(Events.SpawnEvent e) : base(e)
 {
     Angle = e.Angle;
 }
Beispiel #9
0
 public LightGlowState(Events.SpawnEvent e, LightGlowType type) : base(e)
 {
     LightGlowType = type;
 }
Beispiel #10
0
 public DecalState(Events.SpawnEvent e, DecalType type) : base(e)
 {
     DecalType = type;
 }
Beispiel #11
0
 public BarrierState(Events.SpawnEvent e) : base(e)
 {
 }
Beispiel #12
0
 public TurretState(Events.SpawnEvent e) : base(e)
 {
     Health             = BalanceConsts.TurretHealth;
     UnitType           = UnitType.Turret;
     ProductionCooldown = BalanceConsts.ControlPointProductionCooldown * (0.8f + 0.2f * Random.value);
 }
Beispiel #13
0
 public SoldierState(Events.SpawnEvent e) : base(e)
 {
     Health   = BalanceConsts.SoldierHealth;
     UnitType = UnitType.Soldier;
 }