Beispiel #1
0
    /*
     * public BattleGUI(PokemonObj pokemonObj){
     *
     *      this.pokemonObj = pokemonObj;
     *      pokemonObj.pokemon.pp = 1;
     * }
     */

    public static BattleGUI CreateBattleGUI(GameObject where, PokemonObj pokeobjtmp)
    {
        BattleGUI myC = where.AddComponent <BattleGUI>();

        myC.pokemonObj = pokeobjtmp;
        return(myC);
    }
Beispiel #2
0
    public void CapturePokemon()
    {
        string     printme       = "";
        PokemonObj targetPokemon = Player.pokemon.obj.enemy;

        if (targetPokemon != null)
        {
            if (targetPokemon.GetComponent <PokemonWild>() != null)
            {
                float statusAilment = 0;                //statusAilment = 12 if poisoned/burned/paralyzed, 25 if frozen or asleep, 0 otherwise.
                float ballMod       = 150;              //ballMod = 255 if using a Poké Ball, 200 if using a Great Ball, and 150 otherwise.
                float captureOne    = statusAilment / (ballMod + 1);
                float captureRate   = 22;               //need to put this into DB: http://bulbapedia.bulbagarden.net/wiki/List_of_Pok%C3%A9mon_by_catch_rate
                float ballFactor    = 12;
                float f             = (((targetPokemon.pokemon.TotalHP()) * 255) / ballFactor) / (targetPokemon.pokemon.hp / 4);

                /*
                 *  f = (HPmax * 255 / Ball Factor) / (HPcurrent / 4), where all divisions
                 * are rounded down to the nearest integer (the denominator is set to 1 if
                 * it is 0 as a result). The Ball Factor is 8 if a Great Ball is used, and
                 * 12 otherwise. The resulting value is capped at a maximum of 255.
                 */
                float captureTwo = ((captureRate + 1) / (ballMod + 1)) * ((f + 1) / 256);

                //printme = "capture " + targetPokemon.pokemon.name + ". It has " + targetPokemon.pokemon.hp + "hp remaining!";
                //if (targetPokemon.pokemon.hp*100 < 15) {
                float captureChance = captureOne + captureTwo;
                if (captureChance >= Random.value)
                {
                    if (Player.trainer.party.Count() < PokeParty.PARTY_MAX)
                    {
                        //printme = printme + "\n Okay!";
                        printme = "You've captured a " + targetPokemon.pokemon.GetName() + "!";
                        targetPokemon.Return();
                        Player.trainer.party.AddPokemon(new Pokemon(targetPokemon.pokemon.number, true));
                    }
                    else
                    {
                        printme = "You would have captured a " + targetPokemon.pokemon.GetName() + ", but you have too many pokemon, and we haven't built" +
                                  "out a way to choose which pokemon you'd like to keep!";
                    }
                }
                else
                {
                    //printme = printme + "\n It's too strong!";
                    printme = "You tried to capture " + targetPokemon.pokemon.GetName() + ", but it broke free!";
                }
                //printme += "\n " + captureChance;
            }
            else
            {
                printme += "You can't capture that pokemon! That would be stealing!";
            }
        }
        else
        {
            //printme = "Nothing found to capture!";
        }
        Player.gamegui.SetChatWindow(printme);
    }
Beispiel #3
0
    /** Attack impements an eaiser way to call moves and effects saving ~20 lines of code per move
     * @string  effectResources:    Name of what should be loaded from Resources.Load()
     * @bool	costHP:				True if its an attack that should cost HP (i.e. Scratch)
     * @float	range:				Range of the Attack
     * @Vector3 direction:			Copy of the direction paramater from UseMove
     * @Move	move:				Copy of the Move paramater from UseMove
     **/
    private void Attack(string effectResource, bool costHP, float range, Vector3 direction, Move move)
    {
        move.cooldown = 0;
        pokemon.pp   -= move.GetPPCost();
        RaycastHit[] hits = Physics.SphereCastAll(transform.position + Vector3.up, 1, direction, range, 1 << 10);

        foreach (RaycastHit hit in hits)
        {
            if (hit.collider.gameObject != gameObject)
            {
                GameObject newEffect = (GameObject)Instantiate(Resources.Load(effectResource));
                PokemonObj enemyObj  = hit.collider.GetComponent <PokemonObj>();
                if (isWild && enemyObj.isWild)                //make sure wild pokemon don't attack each other.
                {
                    return;
                }
                if (costHP)
                {
                    newEffect.transform.position = hit.point;
                }
                else
                {
                    if ((enemyObj.transform.position - transform.position).sqrMagnitude < range * range)
                    {
                        newEffect.transform.position = enemyObj.transform.position + Vector3.up * 0.2f;
                        newEffect.transform.parent   = enemyObj.transform;
                    }
                }
                if (enemyObj)
                {
                    if (enemyObj.pokemon != null)
                    {
                        if (costHP)
                        {
                            enemyObj.pokemon.Damage(pokemon, move);
                        }
                        else
                        {
                            enemyObj.pokemon.DeBuff(pokemon, move);
                        }
                    }
                    enemy          = enemyObj;
                    enemyObj.enemy = this;
                }
            }
        }
    }
Beispiel #4
0
 void Start()
 {
     target     = transform.position;
     pokemonObj = GetComponent <PokemonObj>();
 }
Beispiel #5
0
    public bool UseMove(Vector3 direction, Move move)
    {
        if (move.GetPPCost() > pokemon.pp)
        {
            return(false);
        }
        string attackChat = "";

        if (pokemon.isPlayer)
        {
            attackChat = "Your ";
        }
        else
        {
            attackChat = "Enemy ";
        }
        attackChat += pokemon.name + " used " + move.moveType + "!";
        switch (move.moveType)
        {
        case MoveNames.Growl: {
            if (move.cooldown < 1)
            {
                return(false);
            }
            const float  range = 10;
            RaycastHit[] hits  = Physics.SphereCastAll(transform.position + Vector3.up, 1, direction, range, 1 << 10);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != gameObject)
                {
                    PokemonObj enemyObj = hit.collider.GetComponent <PokemonObj>();

                    if ((enemyObj.transform.position - transform.position).sqrMagnitude < range * range)
                    {
                        GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Debuff"));
                        newEffect.transform.position = enemyObj.transform.position + Vector3.up * 0.2f;
                        newEffect.transform.parent   = enemyObj.transform;
                    }

                    if (enemyObj)
                    {
                        if (enemyObj.pokemon != null)
                        {
                            enemyObj.pokemon.DeBuff(pokemon, move);
                        }
                        enemy          = enemyObj;
                        enemyObj.enemy = this;
                    }
                }
            }
            audio.PlayOneShot((AudioClip)Resources.Load("Audio/Growl"));
            move.cooldown = 0;
            pokemon.pp   -= move.GetPPCost();
            return(true);
        }

        case MoveNames.TailWhip: {
            if (move.cooldown < 1)
            {
                return(false);
            }
            const float  range = 10;
            RaycastHit[] hits  = Physics.SphereCastAll(transform.position + Vector3.up, 1, direction, range, 1 << 10);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != gameObject)
                {
                    PokemonObj enemyObj = hit.collider.GetComponent <PokemonObj>();

                    if ((enemyObj.transform.position - transform.position).sqrMagnitude < range * range)
                    {
                        GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Debuff"));
                        newEffect.transform.position = enemyObj.transform.position + Vector3.up * 0.2f;
                        newEffect.transform.parent   = enemyObj.transform;
                    }

                    if (enemyObj)
                    {
                        if (enemyObj.pokemon != null)
                        {
                            enemyObj.pokemon.DeBuff(pokemon, move);
                        }
                        enemy          = enemyObj;
                        enemyObj.enemy = this;
                    }
                }
            }



            move.cooldown = 0;
            pokemon.pp   -= move.GetPPCost();
            return(true);
        }

        case MoveNames.Tackle: {
            if (move.cooldown < 1)
            {
                return(false);
            }
            const float  range = 2;
            RaycastHit[] hits  = Physics.SphereCastAll(transform.position + Vector3.up, 1, direction, range, 1 << 10);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != gameObject)
                {
                    PokemonObj enemyObj  = hit.collider.GetComponent <PokemonObj>();
                    GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Bash"));
                    newEffect.transform.position = hit.point;
                    if (enemyObj)
                    {
                        if (enemyObj.pokemon != null)
                        {
                            enemyObj.pokemon.Damage(pokemon, move);
                        }
                        enemy          = enemyObj;
                        enemyObj.enemy = this;
                    }
                }
            }
            rigidbody.AddForce(direction * range * rigidbody.mass * 500);
            move.cooldown = 0;
            pokemon.pp   -= move.GetPPCost();
            return(true);
        }

        case MoveNames.Scratch: {
            if (move.cooldown < 1)
            {
                return(false);
            }
            const float  range = 2;
            RaycastHit[] hits  = Physics.SphereCastAll(transform.position + Vector3.up, 1, direction, range, 1 << 10);
            foreach (RaycastHit hit in hits)
            {
                if (hit.collider.gameObject != gameObject)
                {
                    PokemonObj enemyObj  = hit.collider.GetComponent <PokemonObj>();
                    GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Scratch"));
                    newEffect.transform.position = hit.point;
                    if (enemyObj)
                    {
                        if (enemyObj.pokemon != null)
                        {
                            enemyObj.pokemon.Damage(pokemon, move);
                        }
                        enemy          = enemyObj;
                        enemyObj.enemy = this;
                    }
                    move.cooldown = 0;
                    pokemon.pp   -= move.GetPPCost();
                    return(true);
                }
            }
            GameObject neweffect = (GameObject)Instantiate(Resources.Load("Effects/Scratch"));
            neweffect.transform.position = transform.position + Vector3.up + direction;
            move.cooldown = 0;
            pokemon.pp   -= move.GetPPCost();
            return(true);
        }
        }
        gamegui.SetChatWindow(attackChat);
        return(false);
    }
Beispiel #6
0
 public BattleGUI(PokemonObj pokemonObj)
 {
     this.pokemonObj       = pokemonObj;
     pokemonObj.pokemon.pp = 1;
 }
Beispiel #7
0
 void Start()
 {
     target = transform.position;
     pokemonObj = GetComponent<PokemonObj>();
 }
Beispiel #8
0
	/** Attack impements an eaiser way to call moves and effects saving ~20 lines of code per move
	 * @string 	effectResources: 	Name of what should be loaded from Resources.Load()
	 * @bool	costHP:				True if its an attack that should cost HP (i.e. Scratch)
	 * @float	range:				Range of the Attack
	 * @Vector3 direction:			Copy of the direction paramater from UseMove
	 * @Move	move:				Copy of the Move paramater from UseMove
	 **/
	private void Attack(string effectResource, bool costHP, float range, Vector3 direction, Move move)
	{	
		move.cooldown = 0;
		pokemon.pp-=move.GetPPCost();
		RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
	
		foreach(RaycastHit hit in hits){
			if (hit.collider.gameObject!=gameObject){
				GameObject newEffect = (GameObject)Instantiate(Resources.Load(effectResource));
				PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();
				if(isWild && enemyObj.isWild) //make sure wild pokemon don't attack each other.
					return;
				if(costHP){

					newEffect.transform.position = hit.point;
				}else{
					if ((enemyObj.transform.position-transform.position).sqrMagnitude<range*range){

						newEffect.transform.position = enemyObj.transform.position+Vector3.up*0.2f;
						newEffect.transform.parent = enemyObj.transform;
					}
				}
				if (enemyObj){
					if (enemyObj.pokemon!=null)	
						if (costHP) enemyObj.pokemon.Damage(pokemon,move);
						else enemyObj.pokemon.DeBuff(pokemon,move);
					enemy = enemyObj;
					enemyObj.enemy = this;
				}

			}
		}
	}
Beispiel #9
0
		//GameGUI gamegui = new GameGUI();
		void Awake ()
		{
				pokemonObj = GetComponent<PokemonObj> ();
				//battleGUI = new BattleGUI(pokemonObj);

		}
Beispiel #10
0
    public bool UseMove(Vector3 direction, Move move)
    {
        if (move.GetPPCost()>pokemon.pp)	return false;
        string attackChat = "";
        if (pokemon.isPlayer) {
            attackChat = "Your ";
        }
        else {
            attackChat = "Enemy ";
        }
        attackChat += pokemon.name + " used " + move.moveType + "!";
        switch(move.moveType){

        case MoveNames.Growl:{
            if (move.cooldown<1)	return false;
            const float range = 10;
            RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
            foreach(RaycastHit hit in hits){
                if (hit.collider.gameObject!=gameObject){
                    PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();

                    if ((enemyObj.transform.position-transform.position).sqrMagnitude<range*range){
                        GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Debuff"));
                        newEffect.transform.position = enemyObj.transform.position+Vector3.up*0.2f;
                        newEffect.transform.parent = enemyObj.transform;
                    }

                    if (enemyObj){
                        if (enemyObj.pokemon!=null)	enemyObj.pokemon.DeBuff(pokemon,move);
                        enemy = enemyObj;
                        enemyObj.enemy = this;
                    }
                }
            }
            audio.PlayOneShot((AudioClip)Resources.Load("Audio/Growl"));
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}

        case MoveNames.TailWhip:{
            if (move.cooldown<1)	return false;
            const float range = 10;
            RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
            foreach(RaycastHit hit in hits){
                if (hit.collider.gameObject!=gameObject){
                    PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();

                    if ((enemyObj.transform.position-transform.position).sqrMagnitude<range*range){
                        GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Debuff"));
                        newEffect.transform.position = enemyObj.transform.position+Vector3.up*0.2f;
                        newEffect.transform.parent = enemyObj.transform;
                    }

                    if (enemyObj){
                        if (enemyObj.pokemon!=null)	enemyObj.pokemon.DeBuff(pokemon,move);
                        enemy = enemyObj;
                        enemyObj.enemy = this;
                    }
                }
            }

            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}

        case MoveNames.Tackle:{
            if (move.cooldown<1)	return false;
            const float range = 2;
            RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
            foreach(RaycastHit hit in hits){
                if (hit.collider.gameObject!=gameObject){
                    PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();
                    GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Bash"));
                    newEffect.transform.position = hit.point;
                    if (enemyObj){
                        if (enemyObj.pokemon!=null)	enemyObj.pokemon.Damage(pokemon,move);
                        enemy = enemyObj;
                        enemyObj.enemy = this;
                    }
                }
            }
            rigidbody.AddForce(direction*range*rigidbody.mass*500);
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}

        case MoveNames.Scratch:{
            if (move.cooldown<1)	return false;
            const float range = 2;
            RaycastHit[] hits = Physics.SphereCastAll(transform.position+Vector3.up, 1, direction ,range, 1<<10);
            foreach(RaycastHit hit in hits){
                if (hit.collider.gameObject!=gameObject){
                    PokemonObj enemyObj = hit.collider.GetComponent<PokemonObj>();
                    GameObject newEffect = (GameObject)Instantiate(Resources.Load("Effects/Scratch"));
                    newEffect.transform.position = hit.point;
                    if (enemyObj){
                        if (enemyObj.pokemon!=null)	enemyObj.pokemon.Damage(pokemon,move);
                        enemy = enemyObj;
                        enemyObj.enemy = this;
                    }
                    move.cooldown = 0;
                    pokemon.pp-=move.GetPPCost();
                    return true;
                }
            }
            GameObject neweffect = (GameObject)Instantiate(Resources.Load("Effects/Scratch"));
            neweffect.transform.position = transform.position+Vector3.up+direction;
            move.cooldown = 0;
            pokemon.pp-=move.GetPPCost();
            return true;}
        }
        gamegui.SetChatWindow (attackChat);
        return false;
    }
Beispiel #11
0
 void Start()
 {
     pokemonObj            = GetComponent <PokemonObj>();
     pokemonObj.pokemon.pp = 1;
 }
 void Start()
 {
     pokemonObj = GetComponent<PokemonObj>();
     pokemonObj.pokemon.pp = 1;
 }
Beispiel #13
0
	/*
	public BattleGUI(PokemonObj pokemonObj){
		
		this.pokemonObj = pokemonObj;
		pokemonObj.pokemon.pp = 1;
	}
	*/

	public static BattleGUI CreateBattleGUI (GameObject where, PokemonObj pokeobjtmp) {
		BattleGUI myC = where.AddComponent<BattleGUI>();
		myC.pokemonObj = pokeobjtmp;
		return myC;
	}
Beispiel #14
0
 //GameGUI gamegui = new GameGUI();
 void Awake()
 {
     pokemonObj = GetComponent <PokemonObj> ();
     battleGUI  = new BattleGUI(pokemonObj);
 }
Beispiel #15
0
	void Start(){
		pokemonObj = GetComponent<PokemonObj>();
		pokemonObj.pokemon.pp = 1;
		battleGUI = Player.battleGUI;
	}