示例#1
0
        public Ghost(ContentManager content, Vector2 position, GhostObservationHandler observerHandler, CharactersInRange charactersInRange, OnDeath onDeath, float health = Constants.DEFAULT_HEALTH)
            : base(content, position, SPEED, charactersInRange, onDeath, health)
        {
            this.observerHandler = observerHandler;
            Texture2D texture = LoadingUtils.load <Texture2D>(content, "Ghost");

            StaticDrawable2DParams characterParms = new StaticDrawable2DParams {
                Position = position,
                Texture  = texture,
                Origin   = new Vector2(Constants.TILE_SIZE / 2)
            };

            base.init(new StaticDrawable2D(characterParms));

            Texture2D radiusTexture      = LoadingUtils.load <Texture2D>(content, "Ring");
            StaticDrawable2DParams parms = new StaticDrawable2DParams();

            parms.Position    = position;
            parms.LightColour = Color.LimeGreen;
            parms.Texture     = radiusTexture;
            parms.Origin      = new Vector2(Constants.TILE_SIZE / 2, -(Constants.TILE_SIZE / 4));

            this.selectedImg = new StaticDrawable2D(parms);
            this.seeking     = new Tracking(position, SPEED);
            this.fadeEffect  = createEffect(base.LightColour);
            this.addEffect(fadeEffect);
            this.selectedFadeEffect = createEffect(this.selectedImg.LightColour);

            initSkills();
        }
示例#2
0
        protected void init(bool fullRegen = false)
        {
            if (fullRegen)
            {
                this.allGhosts.Clear();
                this.mobs.Clear();
                this.map             = null;
                this.recentlySpawned = new List <Ghost>();
            }
            this.ghostObserverHandler = new GhostObservationHandler();
            this.hud = new HUD(content, delegate(int id) {
                Ghost selected = this.selectedGhosts[id];
                clearSelectedGhosts();
                selectGhost(selected);
                this.clearSelection = false;
            });
            initDelegates();
            loadMap();
            // if we have ghosts left over, we need to preserve them
            if (GameStateMachine.getInstance().LevelContext != null && GameStateMachine.getInstance().LevelContext.Ghosts != null)
            {
                Ghost primary = this.allGhosts[0];
                Ghost ghost   = null;
                for (int i = 1; i <= GameStateMachine.getInstance().LevelContext.Ghosts.Count; i++)
                {
                    ghost = GameStateMachine.getInstance().LevelContext.Ghosts[i - i];
                    float factor = ghost.Health;
                    if (factor > 0)
                    {
                        Vector2 newPosition = Vector2.Add(primary.Position, new Vector2(i * (Constants.TILE_SIZE / 2)));
                        this.allGhosts.Add(new Ghost(content, newPosition, this.ghostObserverHandler, this.mobsInRange, this.ghostDeathFinish, factor));
                    }
                }
            }
#if DEBUG
            /*Ghost g = new Ghost(content, new Vector2(672, 360), this.ghostObserverHandler, this.mobsInRange, this.ghostDeathFinish, 10f);
             * this.allGhosts.Add(g);*/
#endif
            StaticDrawable2DParams botParms = new StaticDrawable2DParams()
            {
                Position = new Vector2(0f, 672),
                Texture  = LoadingUtils.load <Texture2D>(content, "BottomBorder"),
            };
            this.bottomBorder = new StaticDrawable2D(botParms);
            CombatManager.getInstance().init();
            EffectsManager.getInstance().init();
        }
示例#3
0
 public void Subscribe(GhostObservationHandler provider, Character ghost)
 {
     this.unsubscriber = provider.Subscribe(this, ghost);
     this.trackTarget(ghost);
 }