⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 warder.java

📁 Vyger offers a D & D and Rogue-like environment in a graphical online roleplay game.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
/*
 * Light And Shadow. A Persistent Universe based on Robert Jordan's Wheel of Time Books.
 * Copyright (C) 2001-2003 WOTLAS Team
 *
 * 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 wotlas.common.character;

import java.io.*;
import java.awt.Color;

import wotlas.common.*;
import wotlas.common.universe.*;
import wotlas.common.objects.inventories.*;
import wotlas.libs.graphics2D.*;
import wotlas.libs.graphics2D.drawable.*;
import wotlas.libs.graphics2D.filter.*;

import wotlas.common.environment.*;

/** A Warder character.
 *
 * @author Aldiss, Elann, Diego
 * @see wotlas.common.character.Male
 */

public class Warder extends Male {

    /** id used in Serialized interface.
     */
    private static final long serialVersionUID = 556565L;

 /*------------------------------------------------------------------------------------*/

  /** Warder rank
   */
    public final static String warderRank[][] = {
          //        Rank Name                Rank Symbol
                {   "Youngling",             "youngling-0",  },
                {   "Tower Guard",           "guard-1",      },
                {   "Warder",                "warder-2",     },
                {   "Blade Master",          "blade-3",      },
    };

  /** Warder rank
   */
    public final static Color warderColor[] = {
         //        Rank Color
                   Color.white,
                   new Color(184,184,184),
                   new Color(160,160,180),
                   new Color(140,140,160),
    };

  /** Warder Cloak Color
   */
    public final static String warderCloakColor[] = {
         //        Cloak Color
                   "gray",
                   "blue",
                   "yellow",
                   "red",
                   "green",
                   "brown",
                   "black",
    };


 /*------------------------------------------------------------------------------------*/

  /** Warder status ( youngling, guard, ... ). [PUBLIC INFO]
   */
    private String characterRank;

  /** Warder cloak color ( for warders only ). [PUBLIC INFO]
   *  possible values are listed in the static array WarderCloakColor.
   */
    private String cloakColor;

 /*------------------------------------------------------------------------------------*/

  /** Current Sprite.
   */
    transient private Sprite warderSprite;

  /** Current Shadow.
   */
    transient private ShadowSprite warderShadowSprite;

  /** Current Aura.
   */
    transient private AuraEffect warderAuraEffect;

  /** ColorImageFilter for InteriorMap Sprites.
   */
    transient private ColorImageFilter filter;

 /*------------------------------------------------------------------------------------*/

   /** Constructor
    */
    public Warder() {
        InitCharData();
        InitWotData();

        classes[0] = CLASSES_WOT_WARDER;
        
        this.charAttributes[this.ATTR_STR][this.IDX_ACTUAL] = 10;
        this.charAttributes[this.ATTR_STR][this.IDX_MAX]    = 10;
        this.charAttributes[this.ATTR_INT][this.IDX_ACTUAL] = 10;
        this.charAttributes[this.ATTR_INT][this.IDX_MAX]    = 10;
        this.charAttributes[this.ATTR_WIS][this.IDX_ACTUAL] = 10;
        this.charAttributes[this.ATTR_WIS][this.IDX_MAX]    = 10;
        this.charAttributes[this.ATTR_CON][this.IDX_ACTUAL] = 10;
        this.charAttributes[this.ATTR_CON][this.IDX_MAX]    = 10;
        this.charAttributes[this.ATTR_DEX][this.IDX_ACTUAL] = 10;
        this.charAttributes[this.ATTR_DEX][this.IDX_MAX]    = 10;
        this.charAttributes[this.ATTR_CHA][this.IDX_ACTUAL] = 10;
        this.charAttributes[this.ATTR_CHA][this.IDX_MAX]    = 10;
     }

 /*------------------------------------------------------------------------------------*/

   /** To get a Drawable for this character. This should not be used on the
    *  server side.
    *
    *  The returned Drawable is unique : we always return the same drawable per
    *  AesSedai instance.
    *
    * @param player the player to chain the drawable to. If a XXXDataSupplier is needed
    *               we sets it to this player object.
    * @return a Drawable for this character.
    */
    public Drawable getDrawable( Player player ) {
        if( !player.getLocation().isTileMap() ){
             if(warderSprite!=null)
                 return (Drawable) warderSprite;

           // 1 - Sprite Creation + Filter
              warderSprite = new Sprite( (SpriteDataSupplier) player, ImageLibRef.PLAYER_PRIORITY );
              warderSprite.useAntialiasing(true);
              updateColorFilter();
             return warderSprite;
        }
        else {
            if(fakeSprite!=null)
                return (Drawable) fakeSprite;
            int imageNr = 0;
            switch( EnvironmentManager.whtGraphicSetIs() ){
                case EnvironmentManager.GRAPHICS_SET_ROGUE:
                    imageNr = 0;
                    break;
                default:
                    imageNr = EnvironmentManager.getDefaultNpcImageNr();
            }

            fakeSprite = new FakeSprite( (FakeSpriteDataSupplier) player, ImageLibRef.PLAYER_PRIORITY
            , EnvironmentManager.getServerEnvironment().getGraphics(EnvironmentManager.SET_OF_NPC
            )[ EnvironmentManager.getDefaultPlayerImage() ], imageNr  );
            return fakeSprite;
        }
    }

 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /** Updates the color filter that is used for the AesSedai sprite.
   */
      private void updateColorFilter() {
         if(warderSprite==null)
             return;

         filter = new ColorImageFilter();


      // 1 - Cloak Color
         if( cloakColor!=null) {
             if( cloakColor.equals("brown") ) {
                   filter.addColorChangeKey( ColorImageFilter.blue, ColorImageFilter.brown );
             }
             else if( cloakColor.equals("gray") ) {
                   filter.addColorChangeKey( ColorImageFilter.blue, ColorImageFilter.gray );
             }
             else if( cloakColor.equals("green") ) {
                   filter.addColorChangeKey( ColorImageFilter.blue, ColorImageFilter.green );
             }
             else if( cloakColor.equals("yellow") ) {
                   filter.addColorChangeKey( ColorImageFilter.blue, ColorImageFilter.yellow );
             }
             else if( cloakColor.equals("red") ) {
                   filter.addColorChangeKey( ColorImageFilter.blue, ColorImageFilter.red );
             }
             else if( cloakColor.equals("black") ) {
                   filter.addColorChangeKey( ColorImageFilter.blue, ColorImageFilter.darkgray );
             }
         }

      // 2 - Hair Color
         if( hairColor.equals("brown") ) {
                   filter.addColorChangeKey( ColorImageFilter.lightYellow, ColorImageFilter.brown );
         }
         else if( hairColor.equals("black") ) {
                   filter.addColorChangeKey( ColorImageFilter.lightYellow, ColorImageFilter.darkgray );
         }
         else if( hairColor.equals("gray") ) {
                   filter.addColorChangeKey( ColorImageFilter.lightYellow, ColorImageFilter.gray );
         }
         else if( hairColor.equals("white") ) {
                   filter.addColorChangeKey( ColorImageFilter.lightYellow, ColorImageFilter.lightgray );
         }
         else if( hairColor.equals("reddish") ) {
                   filter.addColorChangeKey( ColorImageFilter.lightYellow, ColorImageFilter.red );
         }
         else if( hairColor.equals("golden") ) {
                   filter.addColorChangeKey( ColorImageFilter.lightYellow, ColorImageFilter.yellow );
         }

       // 3 - Set Filter
         warderSprite.setDynamicImageFilter( filter );
      }

 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /** Return the character's shadow. Important: a character Drawable MUST have been created
   *  previously ( via a getDrawable call ). You don't want to create a shadow with no
   *  character, do you ?
   *
   *  @return character's Shadow Drawable.
   */
     public Drawable getShadow(){

         if(warderShadowSprite!=null)
             return (Drawable) warderShadowSprite;

      // Shadow Creation
         String path = null;

              if(characterRank.equals("Youngling")) {
                 path = "players-0/shadows-3/youngling-walking-1";
              }
              else if(characterRank.equals("Tower Guard")) {
                 path = "players-0/shadows-3/guard-walking-2";
              }
              else {
                 path = "players-0/shadows-3/warder-walking-3";
              }

         warderShadowSprite = new ShadowSprite( warderSprite.getDataSupplier(),
                                                  new ImageIdentifier( path ),
                                                  ImageLibRef.SHADOW_PRIORITY, 4, 4 );
         return warderShadowSprite;
     }

 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -