Code Search for Developers
 
 
  

Telescreen.java from Riot in Emerald city at Krugle


Show Telescreen.java syntax highlighted

/*
 * Copyright (C) 2001-2005 Pleasant nightmare studio
 *
 * This program is free software; you can redistribute it and/or
 * modify it under the terms of the GNU General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
 *
 * See the GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
package org.pleasantnightmare.riotinecity.entities;

import org.pleasantnightmare.riotinecity.model.Model;
import org.pleasantnightmare.riotinecity.model.TelescreenModel;
import org.pleasantnightmare.riotinecity.spatials.Digipad;
import org.pleasantnightmare.riotinecity.spatials.Input;
import org.pleasantnightmare.riotinecity.spatials.TelescreenSpatial;

/**
 * @author: deus
 * @since: Jun 8, 2007 7:42:38 AM
 * @version: 1.0
 */
public class Telescreen extends Entity implements Toggleable, InputReceiver {
    private TelescreenModel model;
    private TelescreenSpatial spatial;
    private InputAction changeChannelAction;

    public Telescreen(TelescreenModel model, Input digipad) {
        this.model = model;

        changeChannelAction = new InputAction("Change channel", "digipad", digipad, this);
        actions.add(new ToggleAction("On/Off", this, false));
    }

    // TODO INVERSE Model/view/controller CONNECTION!!!
    public void setSpatial(TelescreenSpatial spatial) {
        this.spatial = spatial;
        toggleOff();
    }

    public String getType() {
        return "telescreen";
    }

    @Override
    public Model getModel() {
        return model;
    }

    public void toggleOn() {
        retextureToChannel(model.lastChannel());
        actions.add(changeChannelAction);
    }

    public void toggleOff() {
        retextureToChannel(model.getOffChannel());
        actions.remove(changeChannelAction);
    }

    public void inputReceived(Input source, String input) {
        if (input.equals(Digipad.RETURN)
                || input.equals(Digipad.DELETE)) {
            source.hide();
            return;
        }

        int channelNumber = Integer.parseInt(input);
        String channel = model.getChannelByNumber(channelNumber);
        if (channel.equals(model.lastChannel()))
            return;
        retextureToChannel(channel);
        model.rememberLastChannel(channelNumber);
    }

    private void retextureToChannel(String channel) {
        if (channel.equals("politics"))
            spatial.setScreenTexture("images/telescreen-politics.jpg");
        else if (channel.equals("war"))
            spatial.setScreenTexture("images/telescreen-war.png");
        else if (channel.equals("commercials"))
            spatial.setScreenTexture("images/telescreen-commercials.png");
        else if (channel.equals("movies"))
            spatial.setScreenTexture("images/telescreen-movies.png");
        else
            spatial.setScreenTexture("images/telescreen-off.png");
    }
}




See more files for this project here

Riot in Emerald city

Cyberpunk third-person 2100. noir RPG thriller using JMonkey. Its going to be mix between Bloodnet, Neuromancer, DeusEx in gameplay, with pieces of Uplink and many other mini-games for dealing with variety of tasks (lockpicking, hacking...)

Project homepage: http://sourceforge.net/projects/riot-in-ecity
Programming language(s): Java,XML
License: other

  Action.java
  Atm.java
  BufferedInputAction.java
  Computer.java
  CreditCard.java
  Door.java
  DoorController.java
  Entity.java
  EquipItemAction.java
  FocusAction.java
  HolsterAction.java
  InputAction.java
  InputReceiver.java
  ItemEntity.java
  ItemReceiver.java
  ItemUsageAction.java
  ReflectionAction.java
  Tablamp.java
  TakeAction.java
  Telescreen.java
  ToggleAction.java
  Toggleable.java