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

📄 warder.java

📁 Vyger offers a D & D and Rogue-like environment in a graphical online roleplay game.
💻 JAVA
📖 第 1 页 / 共 2 页
字号:
  /** Return the character's aura.
   *  @return character's Aura Drawable.
   */
     public Drawable getAura(){

         if(warderAuraEffect!=null) {
             if(warderAuraEffect.isLive()) {
                return null; // aura still displayed on screen
             }

             warderAuraEffect.reset();
             return (Drawable) warderAuraEffect;
         }

      // Aura Creation
         warderAuraEffect = new AuraEffect( warderSprite.getDataSupplier(), getAuraImage(),
                                            ImageLibRef.AURA_PRIORITY, 5000 );
         warderAuraEffect.useAntialiasing(true);
         warderAuraEffect.setAuraMaxAlpha(0.75f);

         if(characterRank.equals("Tower Guard"))
            warderAuraEffect.setAmplitudeLimit( 2.6f );
         else if( characterRank.equals("Youngling") )
            warderAuraEffect.setAmplitudeLimit( 3.1f );

         return warderAuraEffect;
     }

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

   /** To get the Aura Image Identifier.
    */
    private ImageIdentifier getAuraImage() {
      // symbol selection
         String symbolName = null;

            for( int i=0; i<warderRank.length; i++ )
              if( characterRank.equals(warderRank[i][0]) ) {
                  symbolName = warderRank[i][1];
                  break;
              }

         if(symbolName==null) symbolName=warderRank[0][1]; // default if not found

      // Aura Creation
         return new ImageIdentifier( "players-0/symbols-2/warder-symbols-1/"+symbolName+".gif" );
    }

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

  /** Return the character's color.
   *  @return character's color
   */
     public Color getColor(){
         for( int i=0; i<warderRank.length; i++ )
              if( characterRank.equals(warderRank[i][0]) )
                  return warderColor[i];

        return Color.black;
     }

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

  /** To get the WotCharacter community name.
   * @return the name of the community.
   */
     public String getCommunityName() {
        if( characterRank.equals("Tower Guard") )
            return "Tar Valon Army";
        return "Warder";
     }

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

  /** To get the rank of this WotCharacter in his/her community.
   * @return the rank of this wotcharacter in his/her community.
   */
     public String getCharacterRank() {
        return characterRank;
     }

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

  /** To set the rank of this WotCharacter in his/her community.
   *  IMPORTANT : if the rank doesnot exist it is  set to "unknown".
   *
   * @param rank the rank of this wotcharacter in his/her community.
   */
     public void setCharacterRank( String rank ) {

         if(rank!=null)
            for( int i=0; i<warderRank.length; i++ )
              if( rank.equals(warderRank[i][0]) ) {
                  characterRank = rank;
                  return; // success
              }

         characterRank="unknown"; // not found
     }

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

  /** To get the cloak color of the warder. If there is no cloak we return null.
   * @return color name.
   */
     public String getCloakColor() {
        return cloakColor;
     }

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

  /** To set the cloak color of the warder. If the warder is a Tower Guard or a
   *  youngling it won't be set.
   *
   * @param cloakColor cloak color name
   */
     public void setCloakColor( String cloakColor ) {

         if( characterRank==null || (!characterRank.equals(warderRank[2][0]) &&
             !characterRank.equals(warderRank[3][0])) )
            return;

            for( int i=0; i<warderCloakColor.length; i++ )
              if( cloakColor.equals(warderCloakColor[i]) ) {
                  this.cloakColor = cloakColor;
                  return; // success
              }

         // not found
     }

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

  /** Returns an image for this character.
   *
   *  @param playerLocation player current location
   *  @return image identifier of this character.
   */
     public ImageIdentifier getImage( WotlasLocation playerLocation ) {

         ImageIdentifier imID = super.getImage(playerLocation);

         if( imID==null ) {
              if(warderSprite!=null && filter!=null)
                 warderSprite.setDynamicImageFilter(filter);

           // We return the default Warder Image...
              String path = null;

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

              return new ImageIdentifier( path );
         }

         if(warderSprite!=null)
            warderSprite.setDynamicImageFilter( null ); // no filter for player small image

         return imID;
     }

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

  /** Returns the fanfare sound of this character class.
   *  @return fanfare sound file name
   */
     public String getFanfareSound() {
        if(characterRank.equals("Tower Guard"))
           return "fanfare-tower.wav";

        return "fanfare.wav";
     }

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

  /** To get a new Inventory for this WotCharacter.<br>
   * In this case, it is a WarderInventory.
   * @return a new inventory for this char
   */
     public Inventory createInventory()
	 {
	  return new WarderInventory();
	 }	 
	 
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /** write object data with serialize.
   */
    public void writeExternal(java.io.ObjectOutput objectOutput)
    throws java.io.IOException {
        objectOutput.writeInt( ExternalizeGetVersion() );
        super.writeExternal( objectOutput );
        objectOutput.writeUTF( characterRank );
        objectOutput.writeBoolean(cloakColor!=null);
        if(cloakColor!=null)
           objectOutput.writeUTF( cloakColor );
    }
    
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /** read object data with serialize.
   */
    public void readExternal(java.io.ObjectInput objectInput)
    throws java.io.IOException, java.lang.ClassNotFoundException {
        int IdTmp = objectInput.readInt();
        if( IdTmp == ExternalizeGetVersion() ){
            super.readExternal( objectInput );
            characterRank = objectInput.readUTF();
            if(objectInput.readBoolean())
                cloakColor = objectInput.readUTF();
        } else {
            // to do.... when new version
        }
    }

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

  /** id version of data, used in serialized persistance.
   */
    public int ExternalizeGetVersion(){
        return 1;
    }

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

  /** write object data with serialize.
   */
    public void writeObject(java.io.ObjectOutputStream objectOutput)
    throws java.io.IOException {
        objectOutput.writeInt( ExternalizeGetVersion() );
        super.writeExternal( objectOutput );
        objectOutput.writeUTF( characterRank );
        objectOutput.writeBoolean(cloakColor!=null);
        if(cloakColor!=null)
           objectOutput.writeUTF( cloakColor );
    }
    
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -*/

  /** read object data with serialize.
   */
    public void readObject(java.io.ObjectInputStream objectInput)
    throws java.io.IOException, java.lang.ClassNotFoundException {
        int IdTmp = objectInput.readInt();
        if( IdTmp == ExternalizeGetVersion() ){
            super.readExternal( objectInput );
            characterRank = objectInput.readUTF();
            if(objectInput.readBoolean())
                cloakColor = objectInput.readUTF();
        } else {
            // to do.... when new version
        }
    }

   /** used to store the drawable for tilemaps after creating it.
    */
    transient private FakeSprite fakeSprite;
}

⌨️ 快捷键说明

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