Ejemplo n.º 1
0
    //Color of Sky
    private EnvironmentState ReadEnvironmentState()
    {
        var env = new EnvironmentState
        {
            ambientLight     = RenderSettings.ambientLight,
            moonTintColor    = moon.gameObject.GetComponent <Renderer>().material.GetColor("_Color"),
            fogColor         = RenderSettings.fogColor,
            fogDensity       = RenderSettings.fogDensity,
            sunColor         = _sunLight.color,
            sunIntensity     = _sunLight.intensity,
            sunTintColor     = sun.gameObject.GetComponent <Renderer>().material.GetColor("_TintColor"),
            skyboxBlendValue = RenderSettings.skybox.GetFloat("_Blend"),
            skyboxTintColor  = RenderSettings.skybox.GetColor("_Tint"),
        };

        if (_currentEnvironmentState != null)
        {
            env.auxColor1 = _currentEnvironmentState.auxColor1;
            env.auxColor2 = _currentEnvironmentState.auxColor2;
        }
        else
        {
            env.auxColor1 = Color.black;
            env.auxColor2 = Color.black;
        }

        return(env);
    }
Ejemplo n.º 2
0
 private void SetMessageMenuState(EnvironmentState state)
 {
     MenuItemBag.MessageNew.Enabled     = state.IsQSetActiveItemQueue;
     MenuItemBag.MessageForward.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
     MenuItemBag.MessageMove.Enabled    = state.ActiveMessageBrowserSelectedMessageCount > 0;
     MenuItemBag.MessageDelete.Enabled  = state.ActiveMessageBrowserSelectedMessageCount > 0;
 }
Ejemplo n.º 3
0
        private void Execute()
        {
            if (!Ready())
            {
                return;
            }

            GameObject target = SelectTrainingTarget();

            if (target == null)
            {
                return;
            }

            var state = EnvironmentState.GetState(me);

            SendObject(new
            {
                State  = state.ToInt(),
                Reward = 0
            });
            var selectedAction = actionPool.GetAction(GetAgentAction());

            selectedAction.Perform();

            Console.WriteLine("--- For state ---");
            Console.WriteLine(state);
            Console.WriteLine($"performed {selectedAction.Name}");
        }
Ejemplo n.º 4
0
//Time and Light
    private void Start()
    {
        _sunLight = sun.GetComponentInChildren <Light>();
        if (InitialStateIndex >= 0 && InitialStateIndex < timeOfDayTransitions.Length)
        {
            _currentTransition = timeOfDayTransitions[InitialStateIndex];
        }
        else
        {
            _currentTransition = timeOfDayTransitions[0];
        }
        if (RenderSettings.skybox == null || RenderSettings.skybox != SkyBlend)
        {
            RenderSettings.skybox = SkyBlend;
        }
        //If playercamera no have skycamera script, them added this.
        if (playerCamera != null)
        {
            if (playerCamera.GetComponent <DNC_SkyCamera>() == null)
            {
                playerCamera.gameObject.AddComponent <DNC_SkyCamera>();
                playerCamera.cullingMask = UDayMask;
            }
        }
        else
        {
            Debug.LogError("you need to add the playerCamera");
        }
        _timeInSeconds          = HOUR * timeInHours;
        _sourceEnvironmentState = GetEnvironmentStateFromTransition(_currentTransition);
        ApplyEnvironmentState(_sourceEnvironmentState);
    }
Ejemplo n.º 5
0
        public EnvironmentState getResourceStatus()
        {
            var state = new EnvironmentState();

            state.clock       = clock;
            state.Atmospheric = new EnvironmentState.Atmosphere();
            var airState = ThermoEngine.getAverageAirState();

            state.Atmospheric.TotalPressure    = airState.Pressure;
            state.Atmospheric.RelativeHumdiity = airState.RelativeHumidity;
            state.Atmospheric.Temperature      = airState.Temperature;
            state.Atmospheric.TotalMass        = ThermoEngine.getSystemMass();
            state.Atmospheric.TotalEnthalpy    = ThermoEngine.getSystemEnthalpy();

            var atmos_rms = from element in getAllResourceManagers()
                            where element.managedResource.IsAtmospheric()
                            select element;

            foreach (var rm in atmos_rms)
            {
                state.Atmospheric.Add(new EnvironmentState.Gas((AtmosphericResourceManager)rm));
            }

            state.Stored = new EnvironmentState.Storage();
            var stored_rms = from element in getAllResourceManagers()
                             where (!element.managedResource.IsAtmospheric())
                             select element;

            foreach (var rm in stored_rms)
            {
                state.Stored.Add(new EnvironmentState.StoredResource(rm));
            }

            return(state);
        }
Ejemplo n.º 6
0
 private void SetMessageBrowserCtxMenuState(EnvironmentState state)
 {
     MenuItemBag.MessageBrowserCtxForwardMessage.Enabled  = state.ActiveMessageBrowserSelectedMessageCount > 0;
     MenuItemBag.MessageBrowserCtxMoveMessage.Enabled     = state.ActiveMessageBrowserSelectedMessageCount > 0;
     MenuItemBag.MessageBrowserCtxDeleteMessage.Enabled   = state.ActiveMessageBrowserSelectedMessageCount > 0;
     MenuItemBag.MessageBrowserCtxRefreshMessages.Enabled = state.IsMessageBrowserActive;
     MenuItemBag.MessageBrowserCtxPurgeQueue.Enabled      = state.IsMessageBrowserActive;
 }
Ejemplo n.º 7
0
    private void Start()
    {
        currentStage = 1;
        State        = EnvironmentState.Steady;

        CreateBackgroundGears();
        CreateBackgroundBricks();
    }
 protected void updateEnvironmentViewsAgentActed(Agent agent, Action action,
                                                 EnvironmentState state)
 {
     foreach (EnvironmentView view in views)
     {
         view.agentActed(agent, action, state);
     }
 }
Ejemplo n.º 9
0
 public BenchmarkRunner()
 {
     _suiteManager         = new BenchmarkSuiteManager(this);
     _process              = new BenchmarkProcess(this);
     _configurationManager = new ConfigurationManager(this);
     _reportGenerator      = new ReportGenerator(this);
     _environmentState     = new EnvironmentState(this);
 }
Ejemplo n.º 10
0
 public void SetEnvironment()
 {
     exp      = pc.experience;
     curState = SetEnvironmentState();
     DisableAll();
     SetEnvironmentVariables();
     SetActiveEnvironment();
     fc.SetEnviroFloor();
 }
 private static void Generate(EnvironmentState envState)
 {
     Generate <RunnerRegistrations>(envState);
     Generate <MinHUDRegistrations>(envState);
     Generate <HUDRegistrations>(envState);
     Generate <DialogueRegistrations>(envState);
     Generate <MemoflowRegistrations>(envState);
     Generate <FlashGlanceRegistrations>(envState);
 }
Ejemplo n.º 12
0
        private static void OnSceneView(SceneView sceneView)
        {
            if (m_environmentState != EnvironmentState.Initialized)
            {
                var prev = m_environmentState;
                m_environmentState = ConfigureEnvironment();
                if (prev != m_environmentState)
                {
                    Debug.LogWarning($"Environment state changed from {prev} to {m_environmentState}.");
                }
                if (m_environmentState != EnvironmentState.Initialized)
                {
                    return;
                }
            }

            if (m_requestSceneViewFocus)
            {
                sceneView.Focus();
                m_requestSceneViewFocus = false;
            }

            Event current = Event.current;

            LeftMouseClick  = !current.control && !current.shift && !current.alt && current.type == EventType.MouseDown && current.button == 0;
            KeyEscapeDown   = IsKeyEscapeDown(current);
            RightMouseClick = current.type == EventType.MouseDown && current.button == 1;

            if (RightMouseClick)
            {
                RightMouseDown = true;
            }
            if (current.type == EventType.MouseUp && current.button == 1)
            {
                RightMouseDown = false;
            }

            IsCameraControl = current.alt || RightMouseDown;

            foreach (var primitive in m_visualPrimitives)
            {
                primitive.OnSceneView(sceneView);
            }

            UpdateMouseOverPrimitives(current);

            ToolManager.HandleOnSceneViewGUI(sceneView);

            HandleWindowsGUI(sceneView);

            LeftMouseClick = false;

            if (EditorData.Instance.SecondsSinceLastGC > 5.0 * 60)
            {
                EditorData.Instance.GC();
            }
        }
Ejemplo n.º 13
0
        public DpsOptimizationDeepQLearn(Client client) : base(client)
        {
            ci = client.ControlInterface;

            me.LuaEventListener.Bind("SWING_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("RANGE_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("SPELL_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("SPELL_PERIODIC_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("DAMAGE_SHIELD", DamageEvent);
            me.LuaEventListener.Bind("DAMAGE_SPLIT", DamageEvent);

            me.LuaEventListener.Bind("do", ControlEvent);


            /*
             *      turn on no-cost spells
             *      assume training agent has GM powers(training on own server emulator)
             */
            ci.remoteControl.FrameScript__Execute("SendChatMessage('.cheat power on')", 0, 0);

            actionPool = new ActionPool(me, new[]
            {
                typeof(WrathAction),
                typeof(StarfireAction),
            });


            SetupConnection(new IPEndPoint(IPAddress.Parse(ip), port));

            SendObject(new
            {
                StateCount  = EnvironmentState.GetTotalStateCount(),
                ActionCount = actionPool.ActionCount()
            });

            ResetSession();
            Console.WriteLine("Running.");
            this.Active = true;

            if (!me.GetObjectMgrAndPlayer())
            {
                return;
            }
            GameObject target = SelectTrainingTarget();

            if (target == null)
            {
                return;
            }

            currentState = EnvironmentState.GetState(me);
            SendObject(new
            {
                State  = currentState.ToInt(),
                Reward = 0
            });
        }
        public static void GenerateForWeb()
        {
            var envState = new EnvironmentState
            {
                editor = EditorFlags.IsNotEditor
            };

            Generate(envState);
        }
Ejemplo n.º 15
0
        private void SetQSetMenuState(EnvironmentState state)
        {
            MenuItemBag.QSetCtxAddActiveQueueToSet.Visible = false;
            //MenuItemBag.QSetAddActiveQueue.Enabled = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine && state.IsMessageBrowserActive && !state.IsMessageBrowserQueueChildOfActiveQSetItem);
            MenuItemBag.QSetNewFolder.Enabled    = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine);
            MenuItemBag.QSetRenameFolder.Enabled = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet || state.IsQSetActiveItemWebService) && !state.IsQSetActiveItemMachine);
            MenuItemBag.QSetDeleteItem.Enabled   = (state.IsQSetOpen && !state.IsQSetActiveItemQSet && !state.IsQSetParentItemMachine);

            MenuItemBag.QSetPurgeAllQueues.Enabled = (state.IsQSetOpen && !state.IsQSetActiveItemQSet && !state.IsQSetParentItemMachine);
        }
Ejemplo n.º 16
0
 private bool MatchingToggleState(EnvironmentState environmentState, ToggleState toggleState, Toggle toggle)
 {
     return
         (toggleState.Created == environmentState.Created &&
          toggleState.CreatedBy == environmentState.CreatedBy &&
          toggleState.LastModified == toggleState.Created &&
          toggleState.LastModifiedBy == toggleState.CreatedBy &&
          toggleState.Key == toggle.Key &&
          toggleState.Value == toggle.DefaultValue &&
          toggleState.LastModifiedVersion == NewAggregate.Version);
 }
Ejemplo n.º 17
0
        private void Train()
        {
            GameObject target = SelectTrainingTarget();

            if (target == null)
            {
                return;
            }



            Action selectedAction;
            bool   canPerformAction;

            do
            {
                selectedAction   = actionPool.GetAction(GetAgentAction());
                canPerformAction = selectedAction.CanPerform(currentState);

                SendObject(new
                {
                    ActionValid = canPerformAction
                });
            } while (!canPerformAction);

            selectedAction.Perform();
            do
            {
                Thread.Sleep(10);
            } while (!Ready());

            var newState = EnvironmentState.GetState(me);
            var reward   = GetReward();

            Console.WriteLine("--- Current state ---");
            Console.WriteLine(currentState);
            Console.WriteLine("--- New state ---");
            Console.WriteLine(newState);
            Console.WriteLine($"Reward: {reward}");

            SendObject(new
            {
                State  = newState.ToInt(),
                Reward = reward
            });

            currentState = newState;

            /* wait for ping from server */
            if (!GetPing())
            {
                throw new Exception("Error getting pinged from server. Shutting down.");
            }
        }
Ejemplo n.º 18
0
        public EnvironmentState[] React(Reaction reaction)
        {
            var states = new EnvironmentState[this._environments.Values.Count];
            var i      = 0;

            foreach (var environment in this._environments.Values)
            {
                states [i++] = environment.React(reaction);
            }
            return(states);
        }
Ejemplo n.º 19
0
        /// <summary>
        /// sets the state of all menus.
        /// </summary>
        public void SetAllMenusState()
        {
            EnvironmentState state = GetEnvironmentState();

            SetFileMenuState(state);
            SetQSetMenuState(state);
            SetQueueMenuState(state);
            SetMessageMenuState(state);
            SetToolsMenuState(state);
            SetMessageBrowserCtxMenuState(state);
            SetQSetCtxMenuState(state);
        }
Ejemplo n.º 20
0
    private void Update()
    {
        // Update time
        var _realSecondToIngameSecond = 24 * 60 / dayCycleInMinutes;

        _timeInSeconds += Time.deltaTime * _realSecondToIngameSecond;

        if (_timeInSeconds >= DAY)
        {
            _timeInSeconds -= DAY;
            daysPassed++;
        }
        if (_timeInSeconds < 0)
        {
            timeInHours += DAY;
        }

        timeInHours = _timeInSeconds / HOUR;

        if (timeInHours >= 6 && timeInHours <= 18)
        {
            isDay = true;
        }
        else
        {
            isDay = false;
        }
        // Update Sun and Moon position
        transform.rotation = Quaternion.Euler(new Vector3(360 / DAY * _timeInSeconds, 0, 0));

        if (playerCamera != null)
        {
            transform.position = attachedTo.position;

            var ambient = _sunLight.color * _sunLight.intensity;
            playerCamera.backgroundColor = ambient;
        }

        // Update environment state
        if (_currentTransition == null)
        {
            _currentTransition = FindActiveTransition(_timeInSeconds);
            if (_currentTransition != null)
            {
                _sourceEnvironmentState = ReadEnvironmentState();
            }
        }

        if (_currentTransition != null)
        {
            ApplyCurrentTransition();
        }
    }
        private void GivenThatThereIsSomeStateInformationInTheRepository()
        {
            _togglesInRepo = new List <ToggleState>();
            for (var i = 0; i < 3; i++)
            {
                _togglesInRepo.Add(new ToggleState(_fixture.Create <string>(), _fixture.Create <bool>()));
            }

            var environmentState = new EnvironmentState(_fixture.Create <int>(), _togglesInRepo);

            _repo.Set(environmentState);
        }
Ejemplo n.º 22
0
        private void Train()
        {
            if (!Ready())
            {
                return;
            }

            GameObject target = SelectTrainingTarget();

            if (target == null)
            {
                return;
            }



            var currentAction = actionPool.GetViableRandomAction(currentState);

            currentAction?.Perform();

            /*
             * in order to see what next state is, perform action
             *
             * wait, so action can be performed in game world
             * and it's impact on both reward and state can be registered
             */
            do
            {
                Thread.Sleep(200);
            } while (!Ready());
            Thread.Sleep(1000);

            var newState = GetState(target);
            var reward   = GetReward();

            Console.WriteLine("--- Current state ---");
            Console.WriteLine(currentState);
            Console.WriteLine("--- New state ---");
            Console.WriteLine(newState);
            Console.WriteLine($"Reward: {reward}");

            /* update Q-Matrix */
            float qValueOld = QMatrix[currentState.ToInt(), currentAction.Id];
            float qValue    =
                qValueOld +
                LearningRate * (reward + DiscountFactor * GetBestActionForState(newState).Item2 - qValueOld);

            QMatrix[currentState.ToInt(), currentAction.Id] = qValue;
            PrintCurrentQMatrix();

            currentState = newState;
        }
 /**
  * Central template method for controlling agent simulation. The
  * concrete behavior is determined by the primitive operations
  * {@link #getPerceptSeenBy(Agent)}, {@link #executeAction(Agent, Action)},
  * and {@link #createExogenousChange()}.
  */
 public void step()
 {
     foreach (Agent agent in agents)
     {
         if (agent.isAlive())
         {
             Action           anAction = agent.execute(getPerceptSeenBy(agent));
             EnvironmentState es       = executeAction(agent, anAction);
             updateEnvironmentViewsAgentActed(agent, anAction, es);
         }
     }
     createExogenousChange();
 }
Ejemplo n.º 24
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public EnvironmentState[] CollectStates()
        {
            var environments = this._Environments.Values;
            var states       = new EnvironmentState[environments.Count];
            var i            = 0;

            foreach (var environment in environments)
            {
                states[i++] = environment.CollectState();
            }

            return(states);
        }
Ejemplo n.º 25
0
 private void SetQSetCtxMenuState(EnvironmentState state)
 {
     MenuItemBag.QSetCtxNewMessage.Visible          = state.IsQSetActiveItemQueue;
     MenuItemBag.QSetCtxAddActiveQueueToSet.Visible = false;
     //MenuItemBag.QSetCtxAddActiveQueueToSet.Visible = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine && state.IsMessageBrowserActive && !state.IsMessageBrowserQueueChildOfActiveQSetItem);
     MenuItemBag.QSetCtxDeleteItem.Visible          = (state.IsQSetOpen && !state.IsQSetActiveItemQSet && !state.IsQSetParentItemMachine);
     MenuItemBag.QSetCtxPurgeAllQueues.Visible      = (state.IsQSetOpen && !state.IsQSetActiveItemQSet && !state.IsQSetParentItemMachine);
     MenuItemBag.QSetCtxDeleteQueue.Visible         = state.IsQSetActiveItemQueue;
     MenuItemBag.QSetCtxNewFolder.Visible           = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine);
     MenuItemBag.QSetCtxRenameFolder.Visible        = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet || state.IsQSetActiveItemWebService) && !state.IsQSetActiveItemMachine);
     MenuItemBag.QSetCtxPurgeQueue.Visible          = state.IsQSetActiveItemQueue;
     MenuItemBag.QSetCtxNewWebServiceClient.Visible = false;
     //MenuItemBag.QSetCtxNewWebServiceClient.Visible = state.IsQSetActiveItemFolder && !state.IsQSetActiveItemMachine;
 }
Ejemplo n.º 26
0
    private void Update()
    {
        switch (state)
        {
        case EnvironmentState.Transitioning:

            Color preColor  = Color.black;
            Color postColor = Color.white;

            switch (currentStage)
            {
            case 1:
                preColor  = config.Stage1Color;
                postColor = config.Stage2Color;
                break;

            case 2:
                preColor  = config.Stage2Color;
                postColor = config.Stage3Color;
                break;

            case 3:
                preColor  = config.Stage3Color;
                postColor = config.Stage4Color;
                break;

            default:
                break;
            }

            float interpolant = stateTime / config.TransitionTime;

            if (interpolant >= 1f)
            {
                currentStage++;
                SetEnvironmentColor(postColor);
                State = EnvironmentState.Steady;
            }

            else
            {
                SetEnvironmentColor(Color.Lerp(preColor, postColor, interpolant));
            }

            break;
        }

        stateTime += Time.deltaTime;
    }
Ejemplo n.º 27
0
        public DpsOptimization(Client client) : base(client)
        {
            ci = client.ControlInterface;

            me.LuaEventListener.Bind("SWING_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("RANGE_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("SPELL_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("SPELL_PERIODIC_DAMAGE", DamageEvent);
            me.LuaEventListener.Bind("DAMAGE_SHIELD", DamageEvent);
            me.LuaEventListener.Bind("DAMAGE_SPLIT", DamageEvent);

            me.LuaEventListener.Bind("do", ControlEvent);


            /*
             *      turn on no-cost spells
             *      assume training agent has GM powers(training on own server emulator)
             */
            ci.remoteControl.FrameScript__Execute("SendChatMessage('.cheat power on')", 0, 0);

            actionPool = new ActionPool(me);

            QMatrix = new float[
                EnvironmentState.GetTotalStateCount(),
                actionPool.ActionCount()
                      ];

            ResetSession();
            Console.WriteLine("Running.");
            this.Active = true;

            /*
             * perform initial random action
             * initial state is needed to not perform actions prohibited by state
             */
            if (!me.GetObjectMgrAndPlayer())
            {
                return;
            }
            GameObject target = SelectTrainingTarget();

            if (target == null)
            {
                return;
            }

            /* initialize learning */
            currentState = GetState(target);
        }
Ejemplo n.º 28
0
	public float timeInHours; // In game time in hours

	private void Start()
	{
		_sunLight = sun.GetComponentInChildren<Light>();

		if (InitialStateIndex >= 0 && InitialStateIndex < timeOfDayTransitions.Length)
		{
			_currentTransition = timeOfDayTransitions[InitialStateIndex];
		}
		else
		{
			_currentTransition = timeOfDayTransitions[0];
		}
		_timeInSeconds = HOUR * timeInHours;

		_sourceEnvironmentState = GetEnvironmentStateFromTransition(_currentTransition);
		ApplyEnvironmentState(_sourceEnvironmentState);
	}
Ejemplo n.º 29
0
        public void Set(EnvironmentState environmentState)
        {
            if (environmentState?.ToggleStates == null)
            {
                throw new InvalidEnvironmentStateException();
            }

            _lock.EnterWriteLock();
            try
            {
                _environmentState = environmentState;
            }
            finally
            {
                _lock.ExitWriteLock();
            }
        }
Ejemplo n.º 30
0
    private void EnvironmentStateCallback(EnvironmentState s)
    {
        EnviromnentServerExists = true;
        Hour   = (int)(s.TimeOfDay / 3600);
        Minute = (int)((s.TimeOfDay % 3600) / 60);
        Second = (int)(s.TimeOfDay % 60);

        tenkokuObject.currentHour   = Hour;
        tenkokuObject.currentMinute = Minute;
        tenkokuObject.currentSecond = Second;

        tenkokuObject.weather_RainAmt   = (s.weatherState == EnvironmentState.WeatherState.Rainy ? 1 : 0) * s.Intensity;
        tenkokuObject.weather_SnowAmt   = (s.weatherState == EnvironmentState.WeatherState.Snowy ? 1 : 0) * s.Intensity;
        tenkokuObject.weather_lightning = (s.Lightning ? 0.5f : 0f) * s.Intensity;

        tenkokuObject.nightBrightness = NightBrightness;
        CloudsManager(CloudsCoverageConverter(s.CloudsCoverageScale));
    }
Ejemplo n.º 31
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="reaction"></param>
        /// <returns></returns>
        public EnvironmentState[] ReactAndCollectStates(Reaction reaction)
        {
            this.SetStepping(reaction);
            var states = new EnvironmentState[this._Environments.Values.Count];
            var i      = 0;

            foreach (var environment in this._Environments.Values)
            {
                if (reaction.RecipientEnvironment != "all")
                {
          #if NEODROID_DEBUG
                    if (this.Debugging)
                    {
                        Debug.Log($"Applying reaction to {reaction.RecipientEnvironment} environment");
                    }
          #endif
                    if (this._Environments.ContainsKey(reaction.RecipientEnvironment))
                    {
                        states[i++] = this._Environments[reaction.RecipientEnvironment].ReactAndCollectState(reaction);
                    }
          #if NEODROID_DEBUG
                    else
                    {
                        if (this.Debugging)
                        {
                            Debug.Log($"Could not find environment: {reaction.RecipientEnvironment}");
                        }
                    }
          #endif
                }
                else
                {
          #if NEODROID_DEBUG
                    if (this.Debugging)
                    {
                        Debug.Log("Applying reaction to all environments");
                    }
          #endif
                    states[i++] = environment.ReactAndCollectState(reaction);
                }
            }

            return(states);
        }
Ejemplo n.º 32
0
		private void SetQSetCtxMenuState(EnvironmentState state)
		{
			MenuItemBag.QSetCtxNewMessage.Visible = state.IsQSetActiveItemQueue;							
			MenuItemBag.QSetCtxAddActiveQueueToSet.Visible = false;
			//MenuItemBag.QSetCtxAddActiveQueueToSet.Visible = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine && state.IsMessageBrowserActive && !state.IsMessageBrowserQueueChildOfActiveQSetItem);
			MenuItemBag.QSetCtxDeleteItem.Visible = (state.IsQSetOpen && !state.IsQSetActiveItemQSet && !state.IsQSetParentItemMachine);			
			MenuItemBag.QSetCtxDeleteQueue.Visible = state.IsQSetActiveItemQueue;			
			MenuItemBag.QSetCtxNewFolder.Visible = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine);
			MenuItemBag.QSetCtxRenameFolder.Visible = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet || state.IsQSetActiveItemWebService) && !state.IsQSetActiveItemMachine);
			MenuItemBag.QSetCtxPurgeQueue.Visible = state.IsQSetActiveItemQueue;
			MenuItemBag.QSetCtxNewWebServiceClient.Visible = false;
			//MenuItemBag.QSetCtxNewWebServiceClient.Visible = state.IsQSetActiveItemFolder && !state.IsQSetActiveItemMachine;
		}
Ejemplo n.º 33
0
		private void SetQueueMenuState(EnvironmentState state)
		{
			MenuItemBag.QueueRefresh.Enabled = state.IsQSetActiveItemQueue && state.IsMessageBrowserActive;
			MenuItemBag.QueuePurge.Enabled = state.IsMessageBrowserActive;			
			MenuItemBag.QueueDelete.Enabled = state.IsQSetActiveItemQueue;
		}
Ejemplo n.º 34
0
		private void SetMessageMenuState(EnvironmentState state)
		{
			MenuItemBag.MessageNew.Enabled = state.IsQSetActiveItemQueue;
			MenuItemBag.MessageForward.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
			MenuItemBag.MessageMove.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
			MenuItemBag.MessageDelete.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
		}
	public void agentAdded(Agent agent, EnvironmentState state) {
		// Do nothing by default.
	}
Ejemplo n.º 36
0
 protected void updateEnvironmentViewsAgentActed(Agent agent, Action action,
     EnvironmentState state)
 {
     foreach (EnvironmentView view in views)
     {
         view.agentActed(agent, action, state);
     }
 }
Ejemplo n.º 37
0
	public void agentActed(IAgent agent, Action action,
			EnvironmentState resultingState) {
		System.Console.WriteLine("Agent acted: " + action.ToString());
	}
Ejemplo n.º 38
0
	private static EnvironmentState GetEnvironmentStateFromTransition(TimeOfDayTransition t)
	{
		var env = new EnvironmentState
		          {
		          		ambientLight = t.ambientLight,
		          		moonTintColor = t.moonTintColor,
		          		sunColor = t.sunColor,
		          		sunIntensity = t.sunIntensity,
		          		sunTintColor = t.sunTintColor,
		          		fogColor = t.fogColor,
		          		fogDensity = t.fogDensity,
		          		skyboxBlendValue = t.skyboxBlendValue,
		          		skyboxTintColor = t.skyboxTintColor,
		          		auxColor1 = t.auxColor1,
		          		auxColor2 = t.auxColor2,
		          };
		return env;
	}
Ejemplo n.º 39
0
	private void ApplyCurrentTransition()
	{
		var s = _sourceEnvironmentState;
		var t = _currentTransition;

		var currentTime = timeInHours;
		if (currentTime - t.startHour < 0)
		{
			currentTime += 24;
		}

		var x = (currentTime - t.startHour) / t.durationInHours;
		if (x > 1)
		{
			x = 1;

			_currentTransition = null;
		}

		Debug.Log(x);

		var env = new EnvironmentState
		          {
		          		ambientLight = Color.Lerp(s.ambientLight, t.ambientLight, x),
		          		moonTintColor = Color.Lerp(s.moonTintColor, t.moonTintColor, x),
		          		sunColor = Color.Lerp(s.sunColor, t.sunColor, x),
		          		sunIntensity = Mathf.Lerp(s.sunIntensity, t.sunIntensity, x),
		          		sunTintColor = Color.Lerp(s.sunTintColor, t.sunTintColor, x),
		          		fogColor = Color.Lerp(s.fogColor, t.fogColor, x),
		          		fogDensity = Mathf.Lerp(s.fogDensity, t.fogDensity, x),
		          		skyboxBlendValue = Mathf.Lerp(s.skyboxBlendValue, t.skyboxBlendValue, x),
		          		skyboxTintColor = Color.Lerp(s.skyboxTintColor, t.skyboxTintColor, x),
		          		auxColor1 = Color.Lerp(s.auxColor1, t.auxColor1, x),
		          		auxColor2 = Color.Lerp(s.auxColor2, t.auxColor2, x),
		          };

		ApplyEnvironmentState(env);
	}
Ejemplo n.º 40
0
	private void Update()
	{
		// Update time
		var _realSecondToIngameSecond = 24 * 60 / dayCycleInMinutes;
		_timeInSeconds += Time.deltaTime * _realSecondToIngameSecond;

		if (_timeInSeconds >= DAY)
		{
			_timeInSeconds -= DAY;
			daysPassed++;
		}
		if (_timeInSeconds < 0)
		{
			timeInHours += DAY;
		}

		timeInHours = _timeInSeconds / HOUR;

		// Update Sun and Moon position
		transform.rotation = Quaternion.Euler(new Vector3(360 / DAY * _timeInSeconds, 0, 0));

		if (playerCamera != null)
		{
			transform.position = attachedTo.position;

			var ambient = _sunLight.color * _sunLight.intensity;
			playerCamera.backgroundColor = ambient;
		}

		// Update environment state
		if (_currentTransition == null)
		{
			_currentTransition = FindActiveTransition(_timeInSeconds);
			if (_currentTransition != null)
			{
				_sourceEnvironmentState = ReadEnvironmentState();
			}
		}

		if (_currentTransition != null)
		{
			ApplyCurrentTransition();
		}
	}
Ejemplo n.º 41
0
		public void agentActed(Agent agent, Action action,
				EnvironmentState state) {
			envChanges.append(action).append(":");
		}
Ejemplo n.º 42
0
		private void SetToolsMenuState(EnvironmentState state)
		{
			MenuItemBag.ToolsNewWebServiceClient.Visible = false; //TODO remove this line for 1.2
			MenuItemBag.ToolsNewWebServiceClient.Enabled = state.IsQSetActiveItemFolder && !state.IsQSetActiveItemMachine;
		}
Ejemplo n.º 43
0
		private void SetQSetMenuState(EnvironmentState state)
		{
			MenuItemBag.QSetCtxAddActiveQueueToSet.Visible = false;
			//MenuItemBag.QSetAddActiveQueue.Enabled = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine && state.IsMessageBrowserActive && !state.IsMessageBrowserQueueChildOfActiveQSetItem);
			MenuItemBag.QSetNewFolder.Enabled = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet) && !state.IsQSetActiveItemMachine);
			MenuItemBag.QSetRenameFolder.Enabled = (state.IsQSetOpen && (state.IsQSetActiveItemFolder || state.IsQSetActiveItemQSet || state.IsQSetActiveItemWebService) && !state.IsQSetActiveItemMachine);
			MenuItemBag.QSetDeleteItem.Enabled = (state.IsQSetOpen && !state.IsQSetActiveItemQSet && !state.IsQSetParentItemMachine);			
		}
Ejemplo n.º 44
0
		private EnvironmentState GetEnvironmentState()
		{
			//ascertain the state of the environment
			EnvironmentState environmentState = new EnvironmentState();
			environmentState.IsQSetOpen = _primaryControls.QSetExplorer.QSet != null;
			environmentState.IsQSetDirty = environmentState.IsQSetOpen && _primaryControls.QSetExplorer.QSet.IsDirty;
			environmentState.IsQSetItemActive = (environmentState.IsQSetOpen && _primaryControls.QSetExplorer.ActiveItem != null);
			if (environmentState.IsQSetItemActive)
			{				
				environmentState.IsQSetActiveItemQueue = _primaryControls.QSetExplorer.ActiveItem is QSetQueueItem;
				environmentState.IsQSetActiveItemFolder = _primaryControls.QSetExplorer.ActiveItem is QSetFolderItem;
				environmentState.IsQSetActiveItemMachine = _primaryControls.QSetExplorer.ActiveItem is QSetMachineItem;
				environmentState.IsQSetActiveItemQSet = _primaryControls.QSetExplorer.ActiveItem is QSetModel;
				environmentState.IsQSetActiveItemQueue = _primaryControls.QSetExplorer.ActiveItem is QSetQueueItem;
				environmentState.IsQSetActiveItemWebService = _primaryControls.QSetExplorer.ActiveItem is QSetWebServiceItem;

				if (_primaryControls.QSetExplorer.ActiveItem.ParentItem != null)
				{					
					environmentState.IsQSetParentItemMachine = _primaryControls.QSetExplorer.ActiveItem.ParentItem is QSetMachineItem;
					environmentState.IsQSetParentItemQSet = _primaryControls.QSetExplorer.ActiveItem.ParentItem is QSetModel;					
				}
			}
            environmentState.IsMessageBrowserActive = _primaryControls.DocumentContainer.Manager.ActiveTabbedDocument != null &&
                _primaryControls.DocumentContainer.Manager.ActiveTabbedDocument.Controls.Count > 0 &&
                _primaryControls.DocumentContainer.Manager.ActiveTabbedDocument.Controls[0] is MessageBrowser;
			if (environmentState.IsMessageBrowserActive)
			{
                environmentState.ActiveMessageBrowserSelectedMessageCount = ((MessageBrowser)_primaryControls.DocumentContainer.Manager.ActiveTabbedDocument.Controls[0]).SelectedItems.Count;

				environmentState.IsMessageBrowserQueueChildOfActiveQSetItem
                    = environmentState.IsQSetActiveItemFolder && ((QSetFolderItem)_primaryControls.QSetExplorer.ActiveItem).ChildItems.Exists(((MessageBrowser)_primaryControls.DocumentContainer.Manager.ActiveTabbedDocument.Controls[0]).QSetQueueItem.Name);
			}

			return environmentState;
		}
Ejemplo n.º 45
0
		private void SetFileMenuState(EnvironmentState state)
		{						
			MenuItemBag.FileCloseQSet.Enabled = state.IsQSetOpen;
			MenuItemBag.FileSaveQSet.Enabled = state.IsQSetOpen && state.IsQSetDirty;
			MenuItemBag.FileSaveQSetAs.Enabled = state.IsQSetOpen;			
		}
Ejemplo n.º 46
0
 public void ReadPacket(IMinecraftStream stream)
 {
     State = (EnvironmentState)stream.ReadInt8();
 }
Ejemplo n.º 47
0
    public void agentAdded(IAgent agent, EnvironmentState resultingState)
    {
		System.Console.WriteLine("Agent added.");
	}
Ejemplo n.º 48
0
		private void SetMessageBrowserCtxMenuState(EnvironmentState state)
		{
			MenuItemBag.MessageBrowserCtxForwardMessage.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
			MenuItemBag.MessageBrowserCtxMoveMessage.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
			MenuItemBag.MessageBrowserCtxDeleteMessage.Enabled = state.ActiveMessageBrowserSelectedMessageCount > 0;
			MenuItemBag.MessageBrowserCtxRefreshMessages.Enabled = state.IsMessageBrowserActive;
			MenuItemBag.MessageBrowserCtxPurgeQueue.Enabled = state.IsMessageBrowserActive;
		}
Ejemplo n.º 49
0
	private EnvironmentState ReadEnvironmentState()
	{
		var env = new EnvironmentState
		          {
		          		ambientLight = RenderSettings.ambientLight,
		          		moonTintColor = moon.gameObject.GetComponent<Renderer>().material.GetColor("_Color"),
		          		fogColor = RenderSettings.fogColor,
		          		fogDensity = RenderSettings.fogDensity,
		          		sunColor = _sunLight.color,
		          		sunIntensity = _sunLight.intensity,
		          		sunTintColor = sun.gameObject.GetComponent<Renderer>().material.GetColor("_TintColor"),
		          		skyboxBlendValue = RenderSettings.skybox.GetFloat("_Blend"),
		          		skyboxTintColor = RenderSettings.skybox.GetColor("_Tint"),
		          };

		if (_currentEnvironmentState != null)
		{
			env.auxColor1 = _currentEnvironmentState.auxColor1;
			env.auxColor2 = _currentEnvironmentState.auxColor2;
		}
		else
		{
			env.auxColor1 = Color.black;
			env.auxColor2 = Color.black;
		}

		return env;
	}
	public void agentActed(Agent agent, Action action, EnvironmentState state) {
		actions.append(action);
	}
Ejemplo n.º 51
0
	private void ApplyEnvironmentState(EnvironmentState env)
	{
		RenderSettings.ambientLight = env.ambientLight;

		moon.gameObject.GetComponent<Renderer>().material.SetColor("_Color", env.moonTintColor);

		RenderSettings.fogColor = env.fogColor;
		RenderSettings.fogDensity = env.fogDensity;
		RenderSettings.fog = Mathf.Abs(env.fogDensity) > Mathf.Epsilon;

		RenderSettings.skybox.SetFloat("_Blend", env.skyboxBlendValue);
		RenderSettings.skybox.SetColor("_Tint", env.skyboxTintColor);

		_sunLight.color = env.sunColor;
		_sunLight.intensity = env.sunIntensity;
		sun.gameObject.GetComponent<Renderer>().material.SetColor("_TintColor", env.sunTintColor);

		_currentEnvironmentState = env;
	}
Ejemplo n.º 52
0
		public void agentAdded(Agent agent, EnvironmentState state) {
			// Nothing
		}