using UnityEngine;
using System.Collections;
public class mushroomCollider : MonoBehaviour {
public bool mushroomDirection = true;
void OnTriggerEnter(Collider other) {
// pickup_mushroom : ÀÚ±â¿Í °°Àº ű×
if (other.tag == "block" || other.tag == "pickup_mushroom")
{
mushroomDirection = !mushroomDirection;
}
}
}
using UnityEngine;
using System.Collections;
public class mushroom : MonoBehaviour {
public GameObject mushroomDirection;
public float mushroomSpeed = 1.0F;
private mushroomCollider Collider;
// Use this for initialization
void Start () {
Collider = mushroomDirection.GetComponent<mushroomCollider>();
}
// Update is called once per frame
void Update () {
//bool moveDirection = Collider.mushroomDirection;
//Collider = mushroomDirection.GetComponent<mushroomCollider>();
if (Collider.mushroomDirection)
{
mushroomSpeed = 1;
}
else mushroomSpeed = -1;
//if (!Collider.mushroomDirection)
//{
// mushroomSpeed = -1;
//}
transform.Translate(mushroomSpeed * Time.deltaTime, 0, 0);
}
}
sing UnityEngine;
using System.Collections;
public class projectFireball3101 : MonoBehaviour {
public float moveSpeed = 1.0f;
public float bounceHeight = 1.0f;
public float lifespan = 2.0f;
public Transform smokePuff;
public float hitPosition = 0.25f;
public bool bounceUp = false;
public float heightDifference = 0.0f;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
transform.Translate(moveSpeed * Time.deltaTime, .75f * Time.deltaTime, 0);
}
void OnTriggerEnter(Collider other)
{
}
void KillFireball()
{
}
}
using UnityEngine;
using System.Collections;
public class projectileFireball3102 : MonoBehaviour {
public float moveSpeed = 1.0f;
public float bounceHeight = 1.0f;
public float lifespan = 2.0f;
public Transform smokePuff;
public float hitPosition = 0.25f;
public bool bounceUp = false;
public float heightDifference = 0.0f;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
if (bounceUp == true)
{
transform.Translate(moveSpeed * Time.deltaTime, .75f * Time.deltaTime, 0);
heightDifference = transform.position.y - hitPosition;
if (bounceHeight <= heightDifference)
{
bounceUp = false;
}
}
else
{
transform.Translate(moveSpeed * Time.deltaTime, -1.0f * Time.deltaTime, 0);
}
}
void OnTriggerEnter(Collider other)
{
//print("fireball");
bounceUp = true;
hitPosition = transform.position.y;
}
void KillFireball()
{
}
}
using UnityEngine;
using System.Collections;
public class projectileFireball3103 : MonoBehaviour {
public float moveSpeed = 1.0f;
public float bounceHeight = 1.0f;
public float lifespan = 2.0f;
public Transform smokePuff;
public float hitPosition = 0.25f;
public bool bounceUp = false;
public float heightDifference = 0.0f;
// Use this for initialization
void Start()
{
//KillFireball();
}
// Update is called once per frame
void Update()
{
if (bounceUp == true)
{
transform.Translate(moveSpeed * Time.deltaTime, .75f * Time.deltaTime, 0);
heightDifference = transform.position.y - hitPosition;
if (bounceHeight <= heightDifference)
{
bounceUp = false;
}
}
else
{
transform.Translate(moveSpeed * Time.deltaTime, -1.0f * Time.deltaTime, 0);
}
}
void OnTriggerEnter(Collider other)
{
//print(other.name);
if (other.transform.tag == "Untagged")
{
print("Hit Untagged(tag)");
RaycastHit hit;
//Vector3 Dir = new Vector3(1.0f, 0.0f, 0.0f);
//if (Physics.Raycast(transform.position, new Vector3(-1.0f, 0.0f, 0.0f), out hit, 0.2f) || Physics.Raycast(transform.position, new Vector3(-1.0f, 0.0f, 0.0f), out hit, 0.2f))
//{
// //print("Hit Untagged(Ray)");
// Destroy(gameObject);
//}
if (Physics.Raycast(transform.position, Vector3.left, out hit, 0.2f) || Physics.Raycast(transform.position, Vector3.right, out hit, 0.2f))
{
//print("Hit Untagged(Ray)");
Destroy(gameObject);
}
else
{
bounceUp = true;
hitPosition = transform.position.y;
}
}
if (other.transform.tag == "enemy")
{
Destroy(other.gameObject);
Destroy(gameObject);
}
}
void KillFireball()
{
//Destroy(gameObject, lifespan);
}
}
using UnityEngine;
using System.Collections;
public class projectileFireball3104 : MonoBehaviour {
public float moveSpeed = 1.0f;
public float bounceHeight = 1.0f;
public float lifespan = 2.0f;
public Transform smokePuff;
public float hitPosition = 0.25f;
public bool bounceUp = false;
public float heightDifference = 0.0f;
// Use this for initialization
void Start()
{
KillFireball();
}
// Update is called once per frame
void Update()
{
if (bounceUp == true)
{
transform.Translate(moveSpeed * Time.deltaTime, .75f * Time.deltaTime, 0);
heightDifference = transform.position.y - hitPosition;
if (bounceHeight <= heightDifference)
{
bounceUp = false;
}
}
else
{
transform.Translate(moveSpeed * Time.deltaTime, -1.0f * Time.deltaTime, 0);
}
}
void OnTriggerEnter(Collider other)
{
//print(other.name);
if (other.transform.tag == "Untagged")
{
print("Hit Untagged(tag)");
RaycastHit hit;
//Vector3 Dir = new Vector3(1.0f, 0.0f, 0.0f);
//if (Physics.Raycast(transform.position, new Vector3(-1.0f, 0.0f, 0.0f), out hit, 0.2f) || Physics.Raycast(transform.position, new Vector3(-1.0f, 0.0f, 0.0f), out hit, 0.2f))
//{
// //print("Hit Untagged(Ray)");
// Destroy(gameObject);
//}
if (Physics.Raycast(transform.position, Vector3.left, out hit, 0.2f) || Physics.Raycast(transform.position, Vector3.right, out hit, 0.2f))
{
//print("Hit Untagged(Ray)");
ParticlePlay();
Destroy(gameObject);
}
else
{
bounceUp = true;
hitPosition = transform.position.y;
}
}
if (other.transform.tag == "enemy")
{
ParticlePlay();
Destroy(other.gameObject);
Destroy(gameObject);
}
}
void KillFireball()
{
Destroy(gameObject, lifespan);
}
void ParticlePlay()
{
if (smokePuff)
Instantiate(smokePuff, transform.position, transform.rotation);
else
Debug.Log("Smoke Particle not Loaded");
}
}
using UnityEngine;
using System.Collections;
[AddComponentMenu("Component/csk0123/Actor/Player Properties Script")]
public class playerProperties3105 : MonoBehaviour {
public enum PlayerState
{
MarioDead = 0,
MarioSmall = 1,
MarioLarge = 2,
MarioFire = 3
}
public PlayerState MarioState = PlayerState.MarioSmall;
public int lives = 3;
public int key = 0;
public int coins = 0;
public GameObject projectileFire;
public Transform projectileSocketRight;
public Transform projectileSocketLeft;
public Material materialMarioStandard;
public Material materialMarioFire;
public bool changeMario = false;
public bool hasFire = false; // can shot ÇÒ Œö ÀÖ°Ô µÊ
private int coinLife = 20;
private bool canShoot = false;
private playerControls PlayerControls;
// Use this for initialization
void Start()
{
PlayerControls = GetComponent<playerControls>();
}
// Update is called once per frame
void Update()
{
if (changeMario)
{
SetPlayerState();
}
if (canShoot)
{
GameObject Clone;
if (Input.GetButtonDown("Fire1") && projectileFire && PlayerControls.moveDirection == 0)
{
Clone = (GameObject)Instantiate(projectileFire, projectileSocketLeft.transform.position, transform.rotation);
Clone.GetComponent<projectileFireball>().moveSpeed = -2.0f;
}
if (Input.GetButtonDown("Fire1") && projectileFire && PlayerControls.moveDirection == 1)
{
Clone = (GameObject)Instantiate(projectileFire, projectileSocketRight.transform.position, transform.rotation);
//Clone.rigidbody.AddForce(90, 0, 0);
Clone.GetComponent<projectileFireball>().moveSpeed = 2.0f;
}
}
}
public void AddKeys(int numKey)
{
key = numKey;
}
public void AddCoins(int numCoin)
{
coins += numCoin;
}
void SetPlayerState()
{
playerControls playerControls = GetComponent<playerControls>();
CharacterController controller = GetComponent<CharacterController>();
switch (MarioState)
{
case PlayerState.MarioSmall:
playerControls.gravity = 0.0F;
transform.Translate(0F, 0.2F, 0F);
transform.localScale = new Vector3(1.0F, 0.75F, 1.0F);
controller.height = 0.45F;
transform.renderer.material = materialMarioStandard;
playerControls.gravity = 20.0F;
canShoot = false;
changeMario = false;
break;
case PlayerState.MarioLarge:
playerControls.gravity = 0.0F;
transform.Translate(0F, 0.2F, 0F);
transform.localScale = new Vector3(1.0F, 1.0F, 1.0F);
transform.renderer.material = materialMarioStandard;
playerControls.gravity = 20.0F;
canShoot = false;
changeMario = false;
break;
case PlayerState.MarioFire:
playerControls.gravity = 0.0F;
transform.Translate(0F, 0.2F, 0F);
transform.localScale = new Vector3(1.0F, 1.0F, 1.0F);
transform.renderer.material = materialMarioFire;
playerControls.gravity = 20.0F;
canShoot = true;
changeMario = false;
break;
case PlayerState.MarioDead:
Destroy(gameObject);
changeMario = false;
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3401 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void Start()
{
}
// Update is called once per frame
void Update()
{
}
}
using UnityEngine;
using System.Collections;
public class blockBump3402 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start()
{
}
// Update is called once per frame
void Update()
{
if (blockAni)
{
//print("blockAni True");
animation.Play("blockBounce");
blockAni = false;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3403 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start()
{
}
// Update is called once per frame
void Update()
{
switch (BlockState)
{
case BlockType.blockBounce:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
blockAni = false;
audio.Play();
}
break;
case BlockType.blockCoin:
break;
case BlockType.blockBreakable:
break;
case BlockType.blockSolid:
break;
case BlockType.blockQuestion:
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3404 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start()
{
coinPos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.2f);
}
// Update is called once per frame
void Update()
{
switch (BlockState)
{
case BlockType.blockBounce:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockCoin:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
Instantiate(pickupCoin, coinPos, transform.rotation);
blockAni = false;
blockCoinAmount--;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockBreakable:
break;
case BlockType.blockSolid:
break;
case BlockType.blockQuestion:
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3405 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start()
{
coinPos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.2f);
breakablePos = new Vector3(transform.position.x, transform.position.y + 0.25f, transform.position.z - 9.0f);
}
// Update is called once per frame
void Update()
{
switch (BlockState)
{
case BlockType.blockBounce:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockCoin:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
Instantiate(pickupCoin, coinPos, transform.rotation);
blockAni = false;
blockCoinAmount--;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockBreakable:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
if (BreakState == BreakType.breakableGeometry)
{
Instantiate(breakalbeGeometry, breakablePos, transform.rotation);
}
if (BreakState == BreakType.breakableParticles)
{
Instantiate(breakableParticles, breakablePos, transform.rotation);
}
Destroy(transform.parent.gameObject);
blockAni = false;
}
break;
case BlockType.blockSolid:
renderer.material = materialBlock2;
if (blockAni)
{
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockQuestion:
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3501 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start()
{
coinPos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.2f);
breakablePos = new Vector3(transform.position.x, transform.position.y + 0.25f, transform.position.z - 9.0f);
pickupPos = new Vector3(transform.position.x, transform.position.y + 0.45f, transform.position.z - 0.1f);
}
// Update is called once per frame
void Update()
{
switch (BlockState)
{
case BlockType.blockBounce:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockCoin:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
Instantiate(pickupCoin, coinPos, transform.rotation);
blockAni = false;
blockCoinAmount--;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockBreakable:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
if (BreakState == BreakType.breakableGeometry)
{
Instantiate(breakalbeGeometry, breakablePos, transform.rotation);
}
if (BreakState == BreakType.breakableParticles)
{
Instantiate(breakableParticles, breakablePos, transform.rotation);
}
Destroy(transform.parent.gameObject);
blockAni = false;
}
break;
case BlockType.blockSolid:
renderer.material = materialBlock2;
if (blockAni)
{
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockQuestion:
renderer.material = materialBlock4;
if (blockAni && PickupState == PickUpType.picktupMushroomGrow)
{
animation.Play("blockBounce");
Instantiate(pickupMushroomGrow, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundBump;
audio.Play();
//BlockState = BlockStateAfter;
}
if (blockAni && PickupState == PickUpType.pikcupMushroomLife)
{
animation.Play("blockBounce");
Instantiate(pickupMushroomLife, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundPickup;
audio.Play();
//BlockState = BlockStateAfter;
}
if (blockAni && PickupState == PickUpType.pickupFireFlower)
{
animation.Play("blockBounce");
Instantiate(pickupFireFlower, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundPickup;
audio.Play();
//BlockState = BlockStateAfter;
}
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3502 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start()
{
coinPos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.2f);
breakablePos = new Vector3(transform.position.x, transform.position.y + 0.25f, transform.position.z - 9.0f);
pickupPos = new Vector3(transform.position.x, transform.position.y + 0.45f, transform.position.z - 0.1f);
audio.clip = soundBump;
blockCoinAmountReset = blockCoinAmount;
}
// Update is called once per frame
void Update()
{
switch (BlockState)
{
case BlockType.blockBounce:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockCoin:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
Instantiate(pickupCoin, coinPos, transform.rotation);
blockAni = false;
blockCoinAmount--;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockBreakable:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
if (BreakState == BreakType.breakableGeometry)
{
Instantiate(breakalbeGeometry, breakablePos, transform.rotation);
}
if (BreakState == BreakType.breakableParticles)
{
Instantiate(breakableParticles, breakablePos, transform.rotation);
}
Destroy(transform.parent.gameObject);
blockAni = false;
}
break;
case BlockType.blockSolid:
renderer.material = materialBlock2;
if (blockAni)
{
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockQuestion:
renderer.material = materialBlock4;
if (blockAni && PickupState == PickUpType.picktupMushroomGrow)
{
animation.Play("blockBounce");
Instantiate(pickupMushroomGrow, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundBump;
audio.Play();
//BlockState = BlockStateAfter;
}
if (blockAni && PickupState == PickUpType.pikcupMushroomLife)
{
animation.Play("blockBounce");
Instantiate(pickupMushroomLife, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundPickup;
audio.Play();
//BlockState = BlockStateAfter;
}
if (blockAni && PickupState == PickUpType.pickupFireFlower)
{
animation.Play("blockBounce");
Instantiate(pickupFireFlower, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundPickup;
audio.Play();
//BlockState = BlockStateAfter;
}
float offset = Time.time * blockQuestionScrollSpeed;
renderer.material.mainTextureOffset = new Vector2(offset, 0);
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBump3601 : MonoBehaviour {
public enum BlockType
{
blockBounce,
blockCoin,
blockBreakable,
blockSolid,
blockQuestion
}
public enum PickUpType
{
picktupMushroomGrow,
pikcupMushroomLife,
pickupFireFlower
}
public enum BreakType
{
breakableGeometry,
breakableParticles
}
public BlockType BlockState;
public BlockType BlockStateAfter;
public PickUpType PickupState;
public BreakType BreakState;
public int blockCoinAmount = 3;
public float blockQuestionScrollSpeed = 0.5f;
public Material materialBlock1;
public Material materialBlock2;
public Material materialBlock3;
public Material materialBlock4;
public Transform pickupCoin;
public Transform pickupMushroomGrow;
public Transform pickupMushroomLife;
public Transform pickupFireFlower;
public Transform breakalbeGeometry;
public Transform breakableParticles;
public AudioClip soundBump;
public AudioClip soundPickup;
private Vector3 breakablePos;
private Vector3 pickupPos;
private Vector3 coinPos;
private bool blockAni = false;
private bool coinMove = false;
private int blockCoinAmountReset = 0;
// Use this for initialization
void OnTriggerEnter(Collider other)
{
print("head hit (collision)");
if (other.tag == "collisionBoxHead")
{
blockAni = true;
print("head hit blockA");
}
}
void Start () {
coinPos = new Vector3(transform.position.x, transform.position.y, transform.position.z + 0.2f);
breakablePos = new Vector3(transform.position.x, transform.position.y + 0.25f, transform.position.z - 0.9f);
pickupPos = new Vector3(transform.position.x, transform.position.y + 0.45f, transform.position.z - 0.1f);
audio.clip = soundBump;
blockCoinAmountReset = blockCoinAmount;
}
// Update is called once per frame
void Update () {
switch (BlockState)
{
case BlockType.blockBounce:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockCoin:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
Instantiate(pickupCoin, coinPos, transform.rotation);
blockAni = false;
blockCoinAmount--;
audio.clip = soundBump;
audio.Play();
}
if (blockCoinAmount == 0 && BlockStateAfter == BlockType.blockBounce)
{
BlockState = BlockStateAfter;
}
if (blockCoinAmount == 0 && BlockStateAfter == BlockType.blockCoin)
{
BlockState = BlockStateAfter;
BlockStateAfter = BlockType.blockBreakable;
}
if (blockCoinAmount == 0 && BlockStateAfter == BlockType.blockBreakable)
{
BlockState = BlockStateAfter;
}
if (blockCoinAmount == 0 && BlockStateAfter == BlockType.blockSolid)
{
BlockState = BlockStateAfter;
}
if (blockCoinAmount == 0 && BlockStateAfter == BlockType.blockQuestion)
{
BlockState = BlockStateAfter;
}
break;
case BlockType.blockBreakable:
renderer.material = materialBlock1;
if (blockAni)
{
animation.Play("blockBounce");
if (BreakState == BreakType.breakableGeometry)
{
Instantiate(breakalbeGeometry, breakablePos, transform.rotation);
}
if (BreakState == BreakType.breakableParticles)
{
Instantiate(breakableParticles, breakablePos, transform.rotation);
}
Destroy(transform.parent.gameObject);
blockAni = false;
}
break;
case BlockType.blockSolid:
renderer.material = materialBlock2;
if (blockAni)
{
blockAni = false;
audio.clip = soundBump;
audio.Play();
}
break;
case BlockType.blockQuestion:
renderer.material = materialBlock4;
if (blockAni && PickupState == PickUpType.picktupMushroomGrow)
{
animation.Play("blockBounce");
Instantiate(pickupMushroomGrow, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundBump;
audio.Play();
BlockState = BlockStateAfter;
}
if (blockAni && PickupState == PickUpType.pikcupMushroomLife)
{
animation.Play("blockBounce");
Instantiate(pickupMushroomLife, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundPickup;
audio.Play();
BlockState = BlockStateAfter;
}
if (blockAni && PickupState == PickUpType.pickupFireFlower)
{
animation.Play("blockBounce");
Instantiate(pickupFireFlower, pickupPos, transform.rotation);
blockAni = false;
audio.clip = soundPickup;
audio.Play();
BlockState = BlockStateAfter;
}
float offset = Time.time * blockQuestionScrollSpeed;
renderer.material.mainTextureOffset = new Vector2(offset, 0);
break;
default:
break;
}
}
}
using UnityEngine;
using System.Collections;
public class blockBreakables : MonoBehaviour {
public float breakableTime = 2.5f;
// Use this for initialization
IEnumerator Start()
{
rigidbody.AddForce(Vector3.up * 250);
yield return new WaitForSeconds(breakableTime);
rigidbody.AddForce(Vector3.up * -200);
Destroy(this.gameObject, breakableTime);
}
}