Exemple #1
0
        public void init(ISpotlightModel spotlightModel, IList <Vector2> drillAirBubblePositionList, IPlayerModel playerModel, IGameModel gameModel)
        {
            // get the model from the mediator
            this.m           = spotlightModel;
            this.playerModel = playerModel;
            this.gameModel   = gameModel;

            // get the reference to the list of airbubbles from the mediator;
            this.drillAirBubblePositionList = drillAirBubblePositionList;

            // call View object's start
            base.Start();

            // position well above everything else
            transform.position = new Vector3(transform.position.x, transform.position.y, -9);

            // start at the median angle
            m.currentAngle = m.spotMedianAngle - m.fieldOfViewRange / 2;

            // Add required Mesh components
            meshRenderer                  = gameObject.AddComponent <MeshRenderer>();
            meshRenderer.material         = Resources.Load <Material>("Materials/Transparent-VertexLit");
            meshRenderer.castShadows      = meshRenderer.receiveShadows = false;
            meshRenderer.sortingLayerName = "SpotLight";
            meshFilter = gameObject.AddComponent <MeshFilter>();

            // if the parent is a zeppelin, adjust the cone of the spotlight
            if (transform.parent.gameObject.GetComponent <ZeppelinView>() != null)
            {
                m.updateConeSettingsForZeppelin();
            }
        }
        ISpotlightModel _spotlightModel;         // this is the current view's spotlightModel;

        public override void OnRegister()
        {
            // Subscribe to view's signals
            view._spotlightPlayerNoticedSignal.AddListener(spotlightPlayerNoticedSignal.Dispatch);
            view._spotlightSunkShipNoticedSignal.AddListener(spotlightSunkShipNoticedSignal.Dispatch);

            // Subscribe to external signals
            smokeBombExplodedSignal.AddListener(view.OnSmokeBombExplodedSignal);

            // get a spotlightmodel and populate fields sourced from the XML
            _spotlightModel = spotlightModel;
            _spotlightModel.spotMedianAngle = view.spotMedianAngle;

            // add current spotlight to the dictionary
            spotlightDict.addInstance(view.GetInstanceID(), _spotlightModel);

            // run view's init method
            view.init(_spotlightModel, shipDrillableModel.drillAirBubblePositionList, playerModel, gameModel);
        }
 public void addInstance(int instanceID, ISpotlightModel m)
 {
     spotlights.Add(instanceID, m);
 }