Exemplo n.º 1
0
        public override IDictionary <PortIdentifier, List <LedColor> > GenerateColors(List <PortIdentifier> ports, ICacheProvider cache)
        {
            var current = Environment.TickCount;
            var diff    = current - _ticks;

            if ((_state && diff > Config.OnTime) || (!_state && diff > Config.OffTime))
            {
                _ticks = current;
                _state = !_state;
            }

            if (Config.ColorGenerationMethod == ColorGenerationMethod.PerPort)
            {
                return(EffectUtils.GenerateColorsPerPort(ports, cache,
                                                         (port, ledCount) => (_state ? Config.OnColor : Config.OffColor).Get(ledCount).ToList()
                                                         ));
            }
            else if (Config.ColorGenerationMethod == ColorGenerationMethod.SpanPorts)
            {
                var totalLedCount = ports.Select(p => cache.GetDeviceConfig(p).LedCount).Sum();
                var colors        = (_state ? Config.OnColor : Config.OffColor).Get(totalLedCount).ToList();
                return(EffectUtils.SplitColorsPerPort(colors, ports, cache));
            }

            return(null);
        }
Exemplo n.º 2
0
 /// <summary>
 /// Awake is called before Start
 /// </summary>
 void Awake()
 {
     // initialize screen utils
     ScreenUtils.Initialize();
     ConfigurationUtils.Initialize();
     EffectUtils.Initialize();
 }
Exemplo n.º 3
0
        public override IDictionary <PortIdentifier, List <LedColor> > GenerateColors(List <PortIdentifier> ports, ICacheProvider cache)
        {
            _rotation += Config.Step;
            if (Config.ColorGenerationMethod == ColorGenerationMethod.PerPort)
            {
                return(EffectUtils.GenerateColorsPerPort(ports, cache, (port, ledCount) => GenerateColors(ledCount, 0)));
            }
            else if (Config.ColorGenerationMethod == ColorGenerationMethod.SpanPorts)
            {
                var result = new Dictionary <PortIdentifier, List <LedColor> >();

                var offset = 0;
                foreach (var port in ports)
                {
                    var ledCount = cache.GetDeviceConfig(port).LedCount;
                    var colors   = GenerateColors(ledCount, offset);
                    result.Add(port, colors);
                    offset += Config.Mirror ? ledCount / 2 : ledCount;
                }

                return(result);
            }

            return(null);
        }
Exemplo n.º 4
0
        public void Initialize(Device device)
        {
            _b = EffectUtils.Load(ShadersResourceManager.Manager, "DeferredTransparent");
            E  = new Effect(device, _b);

            TechDebug                 = E.GetTechniqueByName("Debug");
            TechDebugPost             = E.GetTechniqueByName("DebugPost");
            TechDebugLighting         = E.GetTechniqueByName("DebugLighting");
            TechDebugLocalReflections = E.GetTechniqueByName("DebugLocalReflections");
            TechCombine0              = E.GetTechniqueByName("Combine0");

            for (var i = 0; i < TechDebug.Description.PassCount && InputSignaturePT == null; i++)
            {
                InputSignaturePT = TechDebug.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePT == null)
            {
                throw new System.Exception("input signature (DeferredTransparent, PT, Debug) == null");
            }
            LayoutPT = new InputLayout(device, InputSignaturePT, InputLayouts.VerticePT.InputElementsValue);

            FxWorldViewProjInv   = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldViewProjInv").AsMatrix());
            FxBaseMap            = E.GetVariableByName("gBaseMap").AsResource();
            FxNormalMap          = E.GetVariableByName("gNormalMap").AsResource();
            FxMapsMap            = E.GetVariableByName("gMapsMap").AsResource();
            FxDepthMap           = E.GetVariableByName("gDepthMap").AsResource();
            FxLightMap           = E.GetVariableByName("gLightMap").AsResource();
            FxLocalReflectionMap = E.GetVariableByName("gLocalReflectionMap").AsResource();
            FxReflectionCubemap  = E.GetVariableByName("gReflectionCubemap").AsResource();
            FxAmbientDown        = E.GetVariableByName("gAmbientDown").AsVector();
            FxAmbientRange       = E.GetVariableByName("gAmbientRange").AsVector();
            FxEyePosW            = E.GetVariableByName("gEyePosW").AsVector();
        }
Exemplo n.º 5
0
        public override IDictionary <PortIdentifier, List <LedColor> > GenerateColors(List <PortIdentifier> ports, ICacheProvider cache)
        {
            if (Config.ColorGenerationMethod == ColorGenerationMethod.PerPort)
            {
                return(EffectUtils.GenerateColorsPerPort(ports, cache, (_, ledCount) => GenerateColors(ledCount, cache)));
            }
            else if (Config.ColorGenerationMethod == ColorGenerationMethod.SpanPorts)
            {
                var result        = new Dictionary <PortIdentifier, List <LedColor> >();
                var totalLedCount = ports.Select(p => cache.GetDeviceConfig(p).LedCount).Sum();
                var colors        = GenerateColors(totalLedCount, cache);

                var offset = 0;
                foreach (var port in ports)
                {
                    var ledCount     = cache.GetDeviceConfig(port).LedCount;
                    var halfLedCount = ledCount / 2;

                    var topColors    = colors.GetRange(offset, halfLedCount);
                    var bottomColors = colors.GetRange(colors.Count - offset - halfLedCount, halfLedCount);
                    result.Add(port, topColors.Concat(bottomColors).ToList());

                    offset += halfLedCount;
                }

                return(result);
            }

            return(null);
        }
 /// <summary>
 /// Awake is called before Start
 /// </summary>
 void Awake()
 {
     ConfigurationUtils.Initialize();
     ScreenUtils.Initialize();
     EffectUtils.Initialize();
     EventManager.Initialize();
 }
Exemplo n.º 7
0
        public void Initialize(Device device)
        {
            _b = EffectUtils.Load(ShadersResourceManager.Manager, "BakeryShaders");
            E  = new Effect(device, _b);

            TechPerPixel              = new EffectReadyTechnique(E.GetTechniqueByName("PerPixel"));
            TechMultiLayer            = new EffectReadyTechnique(E.GetTechniqueByName("MultiLayer"));
            TechPerPixel_SecondPass   = new EffectReadyTechnique(E.GetTechniqueByName("PerPixel_SecondPass"));
            TechMultiLayer_SecondPass = new EffectReadyTechnique(E.GetTechniqueByName("MultiLayer_SecondPass"));
            TechPerPixel_GrassPass    = new EffectReadyTechnique(E.GetTechniqueByName("PerPixel_GrassPass"));

            for (var i = 0; i < TechPerPixel.Description.PassCount && InputSignaturePNTG == null; i++)
            {
                InputSignaturePNTG = TechPerPixel.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePNTG == null)
            {
                throw new System.Exception("input signature (BakeryShaders, PNTG, PerPixel) == null");
            }
            LayoutPNTG = new InputLayout(device, InputSignaturePNTG, InputLayouts.VerticePNTG.InputElementsValue);

            FxWorldViewProj  = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldViewProj"));
            FxDiffuseMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDiffuseMap"));
            FxMaskMap        = new EffectOnlyResourceVariable(E.GetVariableByName("gMaskMap"));
            FxDetailRMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailRMap"));
            FxDetailGMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailGMap"));
            FxDetailBMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailBMap"));
            FxDetailAMap     = new EffectOnlyResourceVariable(E.GetVariableByName("gDetailAMap"));
            FxAlphaMap       = new EffectOnlyResourceVariable(E.GetVariableByName("gAlphaMap"));
            FxKsDiffuse      = new EffectOnlyFloatVariable(E.GetVariableByName("gKsDiffuse"));
            FxAlphaRef       = new EffectOnlyFloatVariable(E.GetVariableByName("gAlphaRef"));
            FxMagicMult      = new EffectOnlyFloatVariable(E.GetVariableByName("gMagicMult"));
            FxSecondPassMode = new EffectOnlyFloatVariable(E.GetVariableByName("gSecondPassMode"));
            FxMultRGBA       = new EffectOnlyVector4Variable(E.GetVariableByName("gMultRGBA"));
        }
Exemplo n.º 8
0
        public void Initialize(Device device)
        {
            _b = EffectUtils.Load(ShadersResourceManager.Manager, "DeferredPpSslr");
            E  = new Effect(device, _b);

            TechHabrahabrVersion = E.GetTechniqueByName("HabrahabrVersion");

            for (var i = 0; i < TechHabrahabrVersion.Description.PassCount && InputSignaturePT == null; i++)
            {
                InputSignaturePT = TechHabrahabrVersion.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePT == null)
            {
                throw new System.Exception("input signature (DeferredPpSslr, PT, HabrahabrVersion) == null");
            }
            LayoutPT = new InputLayout(device, InputSignaturePT, InputLayouts.VerticePT.InputElementsValue);

            FxWorldViewProjInv = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldViewProjInv").AsMatrix());
            FxWorldViewProj    = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldViewProj").AsMatrix());
            FxBaseMap          = E.GetVariableByName("gBaseMap").AsResource();
            FxLightMap         = E.GetVariableByName("gLightMap").AsResource();
            FxNormalMap        = E.GetVariableByName("gNormalMap").AsResource();
            FxMapsMap          = E.GetVariableByName("gMapsMap").AsResource();
            FxDepthMap         = E.GetVariableByName("gDepthMap").AsResource();
            FxEyePosW          = E.GetVariableByName("gEyePosW").AsVector();
        }
Exemplo n.º 9
0
        public override IDictionary <PortIdentifier, List <LedColor> > GenerateColors(List <PortIdentifier> ports, ICacheProvider cache)
        {
            _fill += Config.FillStep;
            if (_fill >= 1)
            {
                _fill       = 0;
                _lastHue    = _currentHue;
                _currentHue = ((_currentHue + Config.HueStep) % 360 + 360) % 360;
            }

            var lastColor    = LedColor.FromHsv(_lastHue, Config.Saturation, Config.Brightness);
            var currentColor = LedColor.FromHsv(_currentHue, Config.Saturation, Config.Brightness);

            if (Config.ColorGenerationMethod == ColorGenerationMethod.PerPort)
            {
                return(EffectUtils.GenerateColorsPerPort(ports, cache, (port, ledCount) => GenerateColors(ledCount, currentColor, lastColor)));
            }
            else if (Config.ColorGenerationMethod == ColorGenerationMethod.SpanPorts)
            {
                var totalLedCount = ports.Select(p => cache.GetDeviceConfig(p).LedCount).Sum();
                var colors        = GenerateColors(totalLedCount, currentColor, lastColor);
                return(EffectUtils.SplitColorsPerPort(colors, ports, cache));
            }

            return(null);
        }
Exemplo n.º 10
0
        public void Initialize(Device device)
        {
            _b = EffectUtils.Load(ShadersResourceManager.Manager, "DarkMaterial");
            E  = new Effect(device, _b);

            TechStandard      = E.GetTechniqueByName("Standard");
            TechAlpha         = E.GetTechniqueByName("Alpha");
            TechReflective    = E.GetTechniqueByName("Reflective");
            TechNm            = E.GetTechniqueByName("Nm");
            TechNmUvMult      = E.GetTechniqueByName("NmUvMult");
            TechAtNm          = E.GetTechniqueByName("AtNm");
            TechMaps          = E.GetTechniqueByName("Maps");
            TechDiffMaps      = E.GetTechniqueByName("DiffMaps");
            TechGl            = E.GetTechniqueByName("Gl");
            TechAmbientShadow = E.GetTechniqueByName("AmbientShadow");
            TechMirror        = E.GetTechniqueByName("Mirror");
            TechFlatMirror    = E.GetTechniqueByName("FlatMirror");

            for (var i = 0; i < TechAmbientShadow.Description.PassCount && InputSignaturePT == null; i++)
            {
                InputSignaturePT = TechAmbientShadow.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePT == null)
            {
                throw new System.Exception("input signature (DarkMaterial, PT, AmbientShadow) == null");
            }
            LayoutPT = new InputLayout(device, InputSignaturePT, InputLayouts.VerticePT.InputElementsValue);
            for (var i = 0; i < TechStandard.Description.PassCount && InputSignaturePNTG == null; i++)
            {
                InputSignaturePNTG = TechStandard.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePNTG == null)
            {
                throw new System.Exception("input signature (DarkMaterial, PNTG, Standard) == null");
            }
            LayoutPNTG = new InputLayout(device, InputSignaturePNTG, InputLayouts.VerticePNTG.InputElementsValue);

            FxShadowViewProj     = E.GetVariableByName("gShadowViewProj").AsMatrix();
            FxWorld              = E.GetVariableByName("gWorld").AsMatrix();
            FxWorldInvTranspose  = E.GetVariableByName("gWorldInvTranspose").AsMatrix();
            FxWorldViewProj      = E.GetVariableByName("gWorldViewProj").AsMatrix();
            FxShadowMaps         = E.GetVariableByName("gShadowMaps").AsResource();
            FxDiffuseMap         = E.GetVariableByName("gDiffuseMap").AsResource();
            FxNormalMap          = E.GetVariableByName("gNormalMap").AsResource();
            FxMapsMap            = E.GetVariableByName("gMapsMap").AsResource();
            FxDetailsMap         = E.GetVariableByName("gDetailsMap").AsResource();
            FxDetailsNormalMap   = E.GetVariableByName("gDetailsNormalMap").AsResource();
            FxReflectionCubemap  = E.GetVariableByName("gReflectionCubemap").AsResource();
            FxFlatMirrored       = E.GetVariableByName("gFlatMirrored").AsScalar();
            FxEyePosW            = E.GetVariableByName("gEyePosW").AsVector();
            FxLightDir           = E.GetVariableByName("gLightDir").AsVector();
            FxMaterial           = E.GetVariableByName("gMaterial");
            FxReflectiveMaterial = E.GetVariableByName("gReflectiveMaterial");
            FxMapsMaterial       = E.GetVariableByName("gMapsMaterial");
            FxAlphaMaterial      = E.GetVariableByName("gAlphaMaterial");
            FxNmUvMultMaterial   = E.GetVariableByName("gNmUvMultMaterial");
        }
    // INTERNALS

    private void DoAction()
    {
        EffectUtils.PlayEffect2D(m_ActionEffect, transform);

        if (onAction != null)
        {
            onAction();
        }
    }
Exemplo n.º 12
0
        public override void OnEnter()
        {
            if (!effect.IsNone && effect.Value != null)
            {
                Effect effectPrefab = effect.Value.GetComponent <Effect>();
                EffectUtils.PlayEffect(effectPrefab, position.Value, rotation.Value, parent.Value != null ? parent.Value.transform : null);
            }

            Finish();
        }
Exemplo n.º 13
0
        public bool Crashed(IEnemy enemy)
        {
            if (enemy.GetKind() != IEnemies.Kind_e.SHOT)
            {
                EffectUtils.小爆発(this.X, this.Y);

                return(false);
            }
            return(true);
        }
Exemplo n.º 14
0
    /// <summary>
    /// Awake is called before Start
    /// </summary>
    void Awake()
    {
        // initialize screen utils
        ScreenUtils.Initialize();

        // initialize configuration utils
        ConfigurationUtils.Initialize();

        // initialize effect utils
        EffectUtils.Initialize();
    }
Exemplo n.º 15
0
        public bool EachFrame()
        {
            this.X += 8.0 * (this.FacingLeft ? -1 : 1);

            if (Game.I.Map.GetCellByPixelPoint(this.X, this.Y).Wall)
            {
                EffectUtils.小爆発(this.X, this.Y);
                return(false);
            }
            return(DDUtils.IsOutOfCamera(new D2Point(this.X, this.Y), 100.0) == false);
        }
Exemplo n.º 16
0
        public bool Crashed(IWeapon weapon)
        {
            this.HP -= weapon.GetAttackPoint();

            if (this.HP <= 0)
            {
                EffectUtils.大爆発(this.X, this.Y);

                return(false);
            }
            return(true);
        }
Exemplo n.º 17
0
        public bool Crashed(IWeapon weapon)
        {
            this.X += 10.0 * (weapon.IsFacingLeft() ? -1 : 1);             // ヒットバック

            this.HP -= weapon.GetAttackPoint();

            if (this.HP <= 0)             // ? dead
            {
                EffectUtils.中爆発(this.X, this.Y);
                return(false);
            }
            return(true);
        }
Exemplo n.º 18
0
    /// <summary>
    /// Awake is called before Start
    /// </summary>
    void Awake()
    {
        // initialize screen utils
        ScreenUtils.Initialize();
        ConfigurationUtils.Initialize();
        EffectUtils.Initialize();

        HUD hud = gameObject.GetComponent <HUD>();

        hud.BallsLeft = 0;
        hud.Score     = 0;
        Destroy(hud);
    }
Exemplo n.º 19
0
    public override void OnSyncedUpdate()
    {
        base.OnSyncedUpdate();

        if (!m_RunSyncedUpdate)
        {
            return;
        }

        // Read delta time.

        FP deltaTime = TrueSyncManager.deltaTimeMain;

        // Update timers.

        UpdateTimers(deltaTime);

        // Handle actions.

        bool buttonDown = TrueSyncInput.HasByte(m_ButtonDownCode);

        if (buttonDown && (m_Timer == FP.Zero))
        {
            int tick = TrueSyncManager.ticksMain;
            if (!m_EffectTicks.Contains(tick))
            {
                if (m_Pivot != null)
                {
                    EffectUtils.PlayEffect(m_Effect, m_Pivot);
                }

                m_EffectTicks.Add(tick);
            }

            m_Timer = m_Cooldown;
        }

        // Clear effect ticks cache.

        for (int index = 0; index < m_EffectTicks.Count; ++index)
        {
            int tick = m_EffectTicks[index];

            if (TrueSyncManager.IsTickOutOfRollbackMain(tick))
            {
                m_EffectTicks.RemoveAt(index);
                index = -1;
            }
        }
    }
Exemplo n.º 20
0
        public override IDictionary <PortIdentifier, List <LedColor> > GenerateColors(List <PortIdentifier> ports, ICacheProvider cache)
        {
            if (Config.ColorGenerationMethod == ColorGenerationMethod.PerPort)
            {
                return(EffectUtils.GenerateColorsPerPort(ports, cache, (_, ledCount) => GenerateColors(ledCount, cache)));
            }
            else if (Config.ColorGenerationMethod == ColorGenerationMethod.SpanPorts)
            {
                var totalLedCount = ports.Select(p => cache.GetDeviceConfig(p).LedCount).Sum();
                return(EffectUtils.SplitColorsPerPort(GenerateColors(totalLedCount, cache), ports, cache));
            }

            return(null);
        }
    protected override void OnKickOff()
    {
        base.OnKickOff();

        int currentTick = TrueSyncManager.ticksMain;

        if (!m_KickOffEffectsTicks.Contains(currentTick))
        {
            EffectUtils.PlayEffect(m_KickOffEffect, midfieldPosition, Quaternion.identity);
            SfxPlayer.PlayMain(m_KickOffSfx);

            m_KickOffEffectsTicks.Add(currentTick);
        }
    }
Exemplo n.º 22
0
    private void Awake()
    {
        if (_instance != null && _instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            _instance = this;
        }
        GameObject gameController = GameObject.FindGameObjectWithTag("GameController");

        gameManager = gameController.GetComponent <GameManager>();
        gameState   = gameController.GetComponent <GameState>();
    }
Exemplo n.º 23
0
        private void DeadProcessor()
        {
            GetContext().Play(AnimationDefs.Dead.ToString().ToLower());

            GetContext().motor2D.platformMask = 0;
            GetContext().motor2D.triggerMask  = 0;

            Collider2D[] colliders = GetContext().GetComponentsInChildren <Collider2D>();

            for (int index = 0; index < colliders.Length; index++)
            {
                Physics2D.IgnoreCollision(colliders[index], DungeonManager.GetInstance().girlEntity.motor2D.boxCollider);
            }

            EffectUtils.Drop(GetContext().gameObject, payload.hitPoint);
        }
    // LOGIC

    public void Teleport(int i_HoleIndex, TSVector2 i_Position, TSVector2 i_OutForce, FP i_Delay, Effect i_InEffect = null, Effect i_OutEffect = null)
    {
        if (m_Teleporting)
        {
            return;
        }

        int tick = TrueSyncManager.ticksMain;

        // Play effect.

        if (m_TeleportRequestTick != tick)
        {
            EffectUtils.PlayEffect(i_InEffect, currentPosition);
        }

        // Cache rigidbody data and set it kinematic.

        if (m_Rigidbody != null)
        {
            m_CachedMass      = m_Rigidbody.mass;
            m_CachedKinematic = m_Rigidbody.isKinematic;

            m_Rigidbody.isKinematic = true;
        }

        // Setup class variables.

        m_EnteringHoleIndex = i_HoleIndex;

        m_Teleporting         = true;
        m_Timer               = FP.Zero;
        m_TeleportRequestTick = tick;

        m_Delay           = i_Delay;
        m_OutForce        = i_OutForce;
        m_RespawnPosition = i_Position;

        m_OutEffect = i_OutEffect;

        // If no delay, teleport instant.

        if (i_Delay == FP.Zero)
        {
            Respawn();
        }
    }
Exemplo n.º 25
0
        public void Initialize(Device device)
        {
            _b = EffectUtils.Load(ShadersResourceManager.Manager, "DeferredGObject");
            E  = new Effect(device, _b);

            TechStandardDeferred      = E.GetTechniqueByName("StandardDeferred");
            TechStandardForward       = E.GetTechniqueByName("StandardForward");
            TechAmbientShadowDeferred = E.GetTechniqueByName("AmbientShadowDeferred");
            TechTransparentDeferred   = E.GetTechniqueByName("TransparentDeferred");
            TechTransparentForward    = E.GetTechniqueByName("TransparentForward");
            TechTransparentMask       = E.GetTechniqueByName("TransparentMask");

            for (var i = 0; i < TechStandardDeferred.Description.PassCount && InputSignaturePNTG == null; i++)
            {
                InputSignaturePNTG = TechStandardDeferred.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePNTG == null)
            {
                throw new System.Exception("input signature (DeferredGObject, PNTG, StandardDeferred) == null");
            }
            LayoutPNTG = new InputLayout(device, InputSignaturePNTG, InputLayouts.VerticePNTG.InputElementsValue);
            for (var i = 0; i < TechAmbientShadowDeferred.Description.PassCount && InputSignaturePT == null; i++)
            {
                InputSignaturePT = TechAmbientShadowDeferred.GetPassByIndex(i).Description.Signature;
            }
            if (InputSignaturePT == null)
            {
                throw new System.Exception("input signature (DeferredGObject, PT, AmbientShadowDeferred) == null");
            }
            LayoutPT = new InputLayout(device, InputSignaturePT, InputLayouts.VerticePT.InputElementsValue);

            FxWorld                     = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorld").AsMatrix());
            FxWorldInvTranspose         = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldInvTranspose").AsMatrix());
            FxWorldViewProj             = new EffectOnlyMatrixVariable(E.GetVariableByName("gWorldViewProj").AsMatrix());
            FxDiffuseMap                = E.GetVariableByName("gDiffuseMap").AsResource();
            FxNormalMap                 = E.GetVariableByName("gNormalMap").AsResource();
            FxMapsMap                   = E.GetVariableByName("gMapsMap").AsResource();
            FxDetailsMap                = E.GetVariableByName("gDetailsMap").AsResource();
            FxDetailsNormalMap          = E.GetVariableByName("gDetailsNormalMap").AsResource();
            FxReflectionCubemap         = E.GetVariableByName("gReflectionCubemap").AsResource();
            FxEyePosW                   = E.GetVariableByName("gEyePosW").AsVector();
            FxAmbientDown               = E.GetVariableByName("gAmbientDown").AsVector();
            FxAmbientRange              = E.GetVariableByName("gAmbientRange").AsVector();
            FxLightColor                = E.GetVariableByName("gLightColor").AsVector();
            FxDirectionalLightDirection = E.GetVariableByName("gDirectionalLightDirection").AsVector();
            FxMaterial                  = E.GetVariableByName("gMaterial");
        }
Exemplo n.º 26
0
        public override IDictionary <PortIdentifier, List <LedColor> > GenerateColors(List <PortIdentifier> ports, ICacheProvider cache)
        {
            var values = Config.Sensors.Select(cache.GetSensorValue);
            var value  = float.NaN;

            if (Config.SensorMixFunction == SensorMixFunction.Average)
            {
                value = values.Average();
            }
            else if (Config.SensorMixFunction == SensorMixFunction.Minimum)
            {
                value = values.Min();
            }
            else if (Config.SensorMixFunction == SensorMixFunction.Maximum)
            {
                value = values.Max();
            }

            if (value < _minValue)
            {
                value = _minValue;
            }
            if (value > _maxValue)
            {
                value = _maxValue;
            }

            if (float.IsNaN(value))
            {
                _r = Config.ColorGradient.Start.Color.R;
                _g = Config.ColorGradient.Start.Color.G;
                _b = Config.ColorGradient.Start.Color.B;
            }
            else
            {
                var(rr, gg, bb) = Config.ColorGradient.GetColorSmooth(value);

                _r = _r * (1 - Config.SmoothingFactor) + rr * Config.SmoothingFactor;
                _g = _g * (1 - Config.SmoothingFactor) + gg * Config.SmoothingFactor;
                _b = _b * (1 - Config.SmoothingFactor) + bb * Config.SmoothingFactor;
            }

            var color = new LedColor((byte)_r, (byte)_g, (byte)_b);

            return(EffectUtils.GenerateColorsPerPort(ports, cache, (port, ledCount) => Enumerable.Repeat(color, ledCount).ToList()));
        }
    // INTERNALS

    private void Respawn()
    {
        int tick = TrueSyncManager.ticksMain;

        // If rigidbody, re-config it. Move otherwise.

        if (m_Rigidbody != null)
        {
            m_Rigidbody.isKinematic = m_CachedKinematic;
            m_Rigidbody.mass        = m_CachedMass;

            m_Rigidbody.MovePosition(m_RespawnPosition);
            m_Rigidbody.AddForce(m_OutForce);
        }
        else
        {
            tsTransform2D.position = m_RespawnPosition;
        }

        // Play Effect.

        if (!m_OutEffectTicks.Contains(tick))
        {
            Effect outEffect = m_OutEffect;
            EffectUtils.PlayEffect(outEffect, currentPosition);

            m_OutEffectTicks.Add(tick);
        }

        // Clear class variables.

        m_EnteringHoleIndex = -1;
        m_TeleportTick      = 0;

        m_Teleporting = false;
        m_Timer       = FP.Zero;

        m_Delay           = FP.Zero;
        m_OutForce        = TSVector2.zero;
        m_RespawnPosition = TSVector2.zero;

        m_OutEffect           = null;
        m_TeleportRequestTick = 0;
    }
 public override void OnSyncedCollisionExit(TSCollision2D i_Collision)
 {
     if (m_HitEffectTimer == 0f)
     {
         if (!i_Collision.collider.CompareTag(Tags.s_Ball))
         {
             if (m_DurationTimer > 0f)
             {
                 EffectUtils.PlayEffect(m_HitEffect, transform.position, transform.rotation);
                 m_HitEffectTimer = m_HitEffectInterval;
             }
         }
         else
         {
             EffectUtils.PlayEffect(m_BallHitEffect, transform.position, transform.rotation);
             m_HitEffectTimer = m_HitEffectInterval;
         }
     }
 }
    // EVENTS

    private void Teleport()
    {
        if (m_TargetsCache.Count < 1 || m_RespawnPointsCache.Count < 1)
        {
            return;
        }

        Collider2D target = m_TargetsCache[0];

        m_TargetsCache.RemoveAt(0);

        RespawnPoint respawnPoint = m_RespawnPointsCache[0];

        m_RespawnPointsCache.RemoveAt(0);

        if (target != null && respawnPoint != null && respawnPoint.transform != null)
        {
            target.transform.position = respawnPoint.transform.position;

            Rigidbody2D rb2d = target.GetComponent <Rigidbody2D>();
            if (rb2d != null)
            {
                rb2d.isKinematic = false;
                rb2d.velocity    = Vector2.zero;

                Vector2 forceDirection = respawnPoint.forceDirection;
                forceDirection.Normalize();

                if (Mathf.Abs(respawnPoint.errorAngle) > Mathf.Epsilon)
                {
                    float randomError = Random.Range(-respawnPoint.errorAngle, respawnPoint.errorAngle);
                    forceDirection = forceDirection.Rotate(randomError);
                }

                Vector2 outForce = forceDirection * respawnPoint.forceIntensity;
                rb2d.AddForce(outForce);
            }

            EffectUtils.PlayEffect(m_OutEffect, respawnPoint.transform.position);
            RaisePostHoleOccuredEvent(target);
        }
    }
    protected override void OnKickOff()
    {
        base.OnKickOff();

        int currentTick = TrueSyncManager.ticksMain;

        if (!m_KickOffEffectsTicks.Contains(currentTick))
        {
            // Play effects.

            EffectUtils.PlayEffect(m_KickOffEffect, midfieldPosition, Quaternion.identity);
            SfxPlayer.PlayMain(m_KickOffSfx);

            m_KickOffEffectsTicks.Add(currentTick);
        }

        // Enable energy recovery.

        SetEnergyRecoveryEnabled(true);
    }