Android Open Source - Phylane Level Complete






From Project

Back to project page Phylane.

License

The source code is released under:

COPYRIGHT 2014 TRISTON JONES

If you think the Android project Phylane listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.lvadt.phylane.activity;
/*from ww  w .j av a2 s  . c  om*/
import android.app.Activity;
import android.content.DialogInterface;
import android.graphics.Bitmap;
import android.os.Bundle;
import android.view.SurfaceView;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.lvadt.phylane.R;
import com.lvadt.phylane.model.Objects;

public class LevelComplete extends Activity implements View.OnClickListener {

    //Logic variables
    private int messages;
    private int counter = 0;
    private String messageTitle[];
    private String messageBody[];
    private int messageId[];

    //Display variables
    TextView title;
    TextView msg;
    ImageView img;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.levelcomplete);

        RelativeLayout relativeLayout;
        relativeLayout = (RelativeLayout) findViewById(R.id.rlLevelComplete);
        relativeLayout.setOnClickListener(this);

        title = (TextView) findViewById(R.id.tvLevelCompleteTitle);
        msg = (TextView) findViewById(R.id.tvLevelCompleteMessage);
        img = (ImageView) findViewById(R.id.ivLevelComplete);

        //For now only a level complete message
        messages = 1;
        messageTitle = new String[1];
        messageTitle[0] = "Level Complete!";
        messageBody = new String[1];
        messageBody[0] = "Congratulations, you completed a level!";
        messageId = new int[1];
        messageId[0] = -1;

        HomeScreen.getPlayer().setMoney(HomeScreen.getPlayer().getMoney() + HomeScreen.getPlayer().getMission().reward);
        //Move the player to the next mission if there is one
        if(HomeScreen.getPlayer().getMission().ordinal() < Objects.Missions.values().length-1){
            HomeScreen.getPlayer().setMission(Objects.Missions.values()[HomeScreen.getPlayer().getMission().ordinal()+1]);
        }
        next();
    }

    @Override
    public void onClick(View v) {
        //No more messages to display
        if(!next()){
            this.finish();
        }
    }

    //Moves the user to the next message
    private boolean next(){
        if(counter == messages){
            return false;
        }
        else{
            title.setText(messageTitle[counter]);
            msg.setText(messageBody[counter]);
            if(messageId[counter] != -1){
                img.setImageResource(messageId[counter]);
            }
            else {
                img.setVisibility(View.GONE);
            }
            counter += 1;
            return true;
        }
    }
}




Java Source Code List

com.lvadt.phylane.BuildConfig.java
com.lvadt.phylane.activity.Fly.java
com.lvadt.phylane.activity.HomeScreen.java
com.lvadt.phylane.activity.LevelComplete.java
com.lvadt.phylane.activity.LoadScreen.java
com.lvadt.phylane.activity.MainMenu.java
com.lvadt.phylane.activity.MessagePopup.java
com.lvadt.phylane.activity.Prefs.java
com.lvadt.phylane.activity.Splash.java
com.lvadt.phylane.activity.Store.java
com.lvadt.phylane.activity.Tutorial.java
com.lvadt.phylane.graphics.GLRenderer.java
com.lvadt.phylane.graphics.Sprite.java
com.lvadt.phylane.model.GameObject.java
com.lvadt.phylane.model.Level.java
com.lvadt.phylane.model.LoadingScreens.java
com.lvadt.phylane.model.Objects.java
com.lvadt.phylane.model.Plane.java
com.lvadt.phylane.model.Player.java
com.lvadt.phylane.model.WorldObject.java
com.lvadt.phylane.physics.Physics.java
com.lvadt.phylane.utils.Data.java
com.lvadt.phylane.utils.OnSwipeTouchListener.java
com.lvadt.phylane.utils.Sound.java