Exemplo n.º 1
0
        public override void Execute(clsGroundAtom refGroundAtom)
        {
            // update route so that the destination will be the most similar atom
            refGroundAtom.currentRoute = RouteUtils.planStraightLineRoute(new DPoint(refGroundAtom.curr_X, refGroundAtom.curr_Y),
                                                                          new DPoint(mostSimilarAtom.curr_X, mostSimilarAtom.curr_Y), "RouteToMostSimilar");

            // minimize differences
            SocialComparison.correctBehaviorToMostSimilar(refGroundAtom, mostSimilarAtom, m_baselineSpeed);

            // move
            base.Execute(refGroundAtom);
        }
Exemplo n.º 2
0
        public override void Execute(clsGroundAtom refGroundAtom)
        {
            targetPosition.x = mostSimilar.curr_X;
            targetPosition.y = mostSimilar.curr_Y;

            // minimize differences
            SocialComparison.correctBehaviorToMostSimilar(refGroundAtom, mostSimilar, m_baselineSpeed);

            TerrainService.shPoint[] pnts = Structure.Points.ToArray();

            // if most similar leads to outside of structure do social comparison outside of structure
            bool mostSimilarExitedStructure = !TerrainService.GeometryHelper.GeometryMath.isPointInPolygon(mostSimilar.curr_X, mostSimilar.curr_Y, ref pnts);

            if (mostSimilarExitedStructure)
            {
                refGroundAtom.clearStageTransitionEventSubscriptions();
                refGroundAtom.earthquakeStartedEventHandler += earthquakeStartedDefaultEventHandler;
                refGroundAtom.earthquakeEndedEventHandler   += earthquakeEndedDefaultEventHandler;
                refGroundAtom.forcesHaveArrivedEventHandler += forcesHaveArrivedDefaultEventHandler;

                clsActivityMovement moveToMostSimilar = RouteUtils.createActivityAndStart(refGroundAtom, (int)refGroundAtom.currentSpeed, null);
                refGroundAtom.resetMovementData();

                refGroundAtom.ChangeState(new SOCIAL_COMPARISON_STATE(moveToMostSimilar, mostSimilar));

                // re-assign reevaluation handler. It should not be the same outside of a structure.
                switch (refGroundAtom.m_GameObject.simulationStage)
                {
                case GameObject.SimulationStage.STAGE_2:
                    refGroundAtom.reEvaluationEventHandler += reevaluationAfterEarthquakeStartedEventHandler;
                    break;

                case GameObject.SimulationStage.STAGE_3:
                    refGroundAtom.reEvaluationEventHandler += reevaluationAfterEarthquakeEndedEventHandler;
                    break;

                case GameObject.SimulationStage.STAGE_4:
                    refGroundAtom.reEvaluationEventHandler += reevaluationAfterForcesHaveArrivedEventHandler;
                    break;

                default:
                    refGroundAtom.reEvaluationEventHandler += null;
                    break;
                }

                return;
            }

            base.Execute(refGroundAtom);
        }