arachnid killer
C#
scripts
-----------------------------------------------PLAYER-----------------PROTAGONISTA DEL JUEGO------
using UnityEngine;
using System.Collections;
public class TransformFunctions : MonoBehaviour
{
public float moveSpeed = 10f;
public float turnSpeed = 50f;
void Update ()
{
if (Input.GetKey(KeyCode.W))////funciona contantemente al apretar W mayusculas a de ser
//if (Input.GetKeyDown(KeyCode.W))// funciona pasito a pasito
//if(Input.GetKey(KeyCode.UpArrow))
transform.Translate(Vector3.forward * moveSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.S))////funciona contantemente al apretar W mayusculas a de ser
//if(Input.GetKey(KeyCode.DownArrow))
transform.Translate(-Vector3.forward * moveSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.A))////funciona contantemente al apretar W mayusculas a de ser
//if(Input.GetKey(KeyCode.LeftArrow))
transform.Rotate(Vector3.up, -turnSpeed * Time.deltaTime);
if (Input.GetKey(KeyCode.D))////funciona contantemente al apretar W mayusculas a de ser
//if(Input.GetKey(KeyCode.RightArrow))
transform.Rotate(Vector3.up, turnSpeed * Time.deltaTime);
}
}
----------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------
-------------ANIMACIONES DEL PLAYER-----POR LETRAS DEL TECLADO ASIGNADAS
----------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class manopega : MonoBehaviour {
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.Q)) {
Anim.SetBool ("lamano", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("lamano", false);
}
}
}
---------------------------------------------------------------------------------------------------------------------
--------------------------------------------------------------------------------------------------------------------------
---------------------------------------------------------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class CONTROLHUMANO : MonoBehaviour {
// Use this for initialization
//void Start () {
//}
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.W)) {
Anim.SetBool ("Walking", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("Walking", false);
}
}
}
------------------------------------------------------------------------------------------------------------------
-----------------------------------------------------------------------------------------------------------------
ESTE DE DEVAJO COMBINA VARIOS MOVIMIENTOS EN EL MISMO SCRIPT
----------------------------------------------------------------------------------------------------------------
using System.Collections.Generic;
using UnityEngine;
public class controlgira : MonoBehaviour {
public Animator Anim;
public float WalkSpeed;
// Update is called once per frame
void Update () {
if (Input.GetKey (KeyCode.D)) {
Anim.SetBool ("giro", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("giro", false);
if (Input.GetKey (KeyCode.A)) {
Anim.SetBool ("giroraro", true);
// Anim.SetBool ("lamano", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("giroraro", false);
//Anim.SetBool ("lamano", true);
if (Input.GetKey (KeyCode.S)) {
Anim.SetBool ("atras", true);
// Anim.SetBool ("lamano", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("atras", false);
//Anim.SetBool ("lamano", true);
}
//if (Input.GetKeyDown("space")) {
if (Input.GetKey (KeyCode.Space)) {
//if (Input.GetKey (KeyCode.P)) {
Anim.SetBool ("patada", true);
// Anim.SetBool ("lamano", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("patada", false);
//Anim.SetBool ("lamano", true);
}
if (Input.GetKey (KeyCode.E)) {
Anim.SetBool ("palote", true);
// Anim.SetBool ("lamano", true);
transform.Translate (Vector3.forward * WalkSpeed * Time.deltaTime);
} else {
Anim.SetBool ("palote", false);
//Anim.SetBool ("lamano", true);
}
}
}
}
}
----------------------------------------------------------------------------
------------------------MARCADOR DE PUNTOS-----------------------------------------------
---------------------------------------------------------------------
using UnityEngine;
// Include the namespace required to use Unity UI
using UnityEngine.UI;
using System.Collections;
public class bapuntos51 : MonoBehaviour {
// Create public variables for player speed, and for the Text UI game objects
public float speed;
public Text countText;
public Text winText;
//public AudioSource tickSource;
//public AudioSource tickSource;
// Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
private Rigidbody rb;
private int count;/// <summary>
/// //////////////////////////////////////////
/// </summary>
//private int PUNTOS;/// <summary>
/// /////////////////////////////////////////////////
/// </summary>
// At the start of the game..
void Start ()
{
//tickSource = GetComponent<AudioSource> ();
//tickSource = Getcomponent<AudioSource> ();
// Assign the Rigidbody component to our private rb variable
rb = GetComponent<Rigidbody>();
// Set the count to zero
count = 0;
// Run the SetCountText function to update the UI (see below)
SetCountText ();
// Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
winText.text = "";
}
// Each physics step..
//void FixedUpdate ()
//{
// Set some local float variables equal to the value of our Horizontal and Vertical Inputs
//float moveHorizontal = Input.GetAxis ("Horizontal");
//float moveVertical = Input.GetAxis ("Vertical");
// Create a Vector3 variable, and assign X and Z to feature our horizontal and vertical float variables above
//Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
// Add a physical force to our Player rigidbody using our 'movement' Vector3 above,
// multiplying it by 'speed' - our public player speed that appears in the inspector
// rb.AddForce (movement * speed);
//}
// When this game object intersects a collider with 'is trigger' checked,
// store a reference to that collider in a variable named 'other'..
void OnTriggerEnter(Collider other)
{
// ..and if the game object we intersect has the tag 'Pick Up' assigned to it..
//if (other.gameObject.CompareTag ("pruebassonido"))
//if (other.gameObject.CompareTag ("bolaesplota"))
if (other.gameObject.CompareTag ("ARAÑA-3-ESTE"))
//if (other.gameObject.CompareTag ("Terrain"))
//if (other.gameObject.CompareTag ("Pick Up 1"))
//if (other.gameObject.CompareTag ("Sphere"))
{
// Make the other game object (the pick up) inactive, to make it disappear
other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add one to the score variable 'count'
count = count + 1;
//tickSource.Play ();
// Run the 'SetCountText()' function (see below)
SetCountText ();
}
}
// Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
void SetCountText()
{
// Update the text field of our 'countText' variable
//countText.text = "Count: " + count.ToString ();
countText.text = "PUNTOS: " + count.ToString ();
// Check if our 'count' is equal to or exceeded 12
if (count >= 11)
//if (count >= 99)
{
// Set the text value of our 'winText'
winText.text = "JUEGO COMPLETADO";
//TextMeshPro = "CAMPEON GANASTES";
Destroy (gameObject, 1.2f);
//transform.position += transform.forward * 210.222f * Time.deltaTime; ///////etste solo
//transform.position += transform.forward *110.02f * Time.deltaTime;
//transform.position -= transform.forward *8.02f * Time.deltaTime;
//transform.Rotate (new Vector3 (12 * Time.deltaTime, 220, 290), Space.Self);
//Destroy (gameObject, 0.2f);
//transform.localScale += Vector3.right * 444 * Time.deltaTime;//OJOJOJOJOJOJOJOJOJO
//Destroy (gameObject, 0.2f);
//transform.Rotate(10, Time.deltaTime, 100, Space.World);
}
}
}
--------------------------------------------------------------------------
-------------------------------------------------------------------------
--------------------VIDAS DEL PLAYER I GUAL QUE MARCADOR DE PUNTOS PERO RESTANDO NO SUMANDO----------------------------------------------------
----------------------------------------------------------------------
// Include the namespace required to use Unity UI
using UnityEngine.UI;
using System.Collections;
public class matapuntos : MonoBehaviour {
// Create public variables for player speed, and for the Text UI game objects
public float speed;
public Text countText;
public Text winText;
// Create private references to the rigidbody component on the player, and the count of pick up objects picked up so far
private Rigidbody rb;
private int count;/// <summary>
// At the start of the game..
void Start ()
{
// Assign the Rigidbody component to our private rb variable
rb = GetComponent<Rigidbody>();
// Set the count to zero
count = 10;
// Run the SetCountText function to update the UI (see below)
SetCountText ();
// Set the text property of our Win Text UI to an empty string, making the 'You Win' (game over message) blank
winText.text = "";
}
// Each physics step..
// When this game object intersects a collider with 'is trigger' checked,
// store a reference to that collider in a variable named 'other'..
void OnTriggerEnter(Collider other)
{
// ..and if the game object we intersect has the tag 'Pick Up' assigned to it..
//if (other.gameObject.CompareTag ("pruebassonido"))
if (other.gameObject.CompareTag ("MATA"))
//if (other.gameObject.CompareTag ("ARAÑA-3-ESTE"))
//if (other.gameObject.CompareTag ("Terrain"))
//if (other.gameObject.CompareTag ("Pick Up 1"))
//if (other.gameObject.CompareTag ("Sphere"))
{
// Make the other game object (the pick up) inactive, to make it disappear
other.gameObject.SetActive (false);///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// Add one to the score variable 'count'
count = count - 1;
// Run the 'SetCountText()' function (see below)
SetCountText ();
}
}
// Create a standalone function that can update the 'countText' UI and check if the required amount to win has been achieved
void SetCountText()
{
// Update the text field of our 'countText' variable
//countText.text = "Count: " + count.ToString ();
countText.text = "VIDA: " + count.ToString ();
// Check if our 'count' is equal to or exceeded 12
if (count <= 0)
//if (count <= 0)
{
// Set the text value of our 'winText'
winText.text = "GAME OVER";
//winText.text = "https://videojuegosenlineaasaco4.blogspot.com";
//TextMeshPro = "CAMPEON GANASTES";
//transform.position += transform.forward * 210.222f * Time.deltaTime; ///////etste solo
//transform.position += transform.forward *110.02f * Time.deltaTime;
//transform.position -= transform.forward *8.02f * Time.deltaTime;
//transform.Rotate (new Vector3 (12 * Time.deltaTime, 220, 290), Space.Self);
//Destroy (gameObject, "yosoy");
//transform.localScale += Vector3.right * 444 * Time.deltaTime;//OJOJOJOJOJOJOJOJOJO
//Destroy (gameObject.CompareTag ("nini"));
//if (collision.gameObject.tag == "nini") {
//if (other.gameObject.CompareTag ("nini")){
Destroy (gameObject, 0.5f);
//if (other.gameObject.CompareTag ("yosoy"))
//transform.Rotate(10, Time.deltaTime, 100, Space.World);
}
}
}
--------------------------------------------------------------------------
-------------------ACTIBAR SONIDO PULSANDO TECLA-----------------------------------------------------
---------------------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class suenateclaayd : MonoBehaviour {
public AudioSource tickSource;
//public float Destroy = 0.2f;
// Use this for initialization
void Start () {
tickSource = GetComponent<AudioSource> ();
}
void Update () {
//void OnCollisionEnter (Collision collision){
// if (collision.gameObject.tag == "PUYO modelo"){
if (Input.GetKey (KeyCode.A)) {
tickSource.Play ();
}
if (Input.GetKey (KeyCode.D)) {
tickSource.Play ();
}}
}
--------------------------------------------------------------------
---ACTIVAR SONIDO AL TOCAR LOS PIES DEL PLAYER EL TERRENO USANDO EL TAG---------------------------------------------------------------
--------------------------------------------------
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class pasosrampasonido : MonoBehaviour {
public AudioSource tickSource;
//public float Destroy = 0.2f;
// Use this for initialization
void Start () {
tickSource = GetComponent<AudioSource> ();
}
void Update () {
}
//void OnCollisionEnter (Collision collision){
// if (collision.gameObject.tag == "PUYO modelo"){
void OnTriggerEnter(Collider other) {
if (other.gameObject.CompareTag ("Terrain")){
//void OnTriggerEnter(Collider other) {
// if (other.gameObject.CompareTag ("rampa")){
//void OnTriggerEnter(Collider other) {
//if (other.gameObject.CompareTag ("rampaarriba")){
tickSource.Play ();
//Destroy (gameObject, 0.2f);
//Destroy (gameObject, 0.2f);
}}
}
-------------------------------------------------------------------------
-----------------------TEXTO INICIO DEL JUEGO-------------------------------------------------------
------------------------------------------------------------------------
using UnityEngine;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
namespace TMPro.Examples
{
public class VertexZoom : MonoBehaviour
{
public float AngleMultiplier = 1.0f;
public float SpeedMultiplier = 1.0f;
public float CurveScale = 1.0f;
private TMP_Text m_TextComponent;
private bool hasTextChanged;
void Awake()
{
m_TextComponent = GetComponent<TMP_Text>();
}
void OnEnable()
{
// Subscribe to event fired when text object has been regenerated.
TMPro_EventManager.TEXT_CHANGED_EVENT.Add(ON_TEXT_CHANGED);
}
void OnDisable()
{
// UnSubscribe to event fired when text object has been regenerated.
TMPro_EventManager.TEXT_CHANGED_EVENT.Remove(ON_TEXT_CHANGED);
}
void Start()
{
StartCoroutine(AnimateVertexColors());
}
void ON_TEXT_CHANGED(Object obj)
{
if (obj == m_TextComponent)
hasTextChanged = true;
}
/// <summary>
/// Method to animate vertex colors of a TMP Text object.
/// </summary>
/// <returns></returns>
IEnumerator AnimateVertexColors()
{
// We force an update of the text object since it would only be updated at the end of the frame. Ie. before this code is executed on the first frame.
// Alternatively, we could yield and wait until the end of the frame when the text object will be generated.
m_TextComponent.ForceMeshUpdate();
TMP_TextInfo textInfo = m_TextComponent.textInfo;
Matrix4x4 matrix;
TMP_MeshInfo[] cachedMeshInfoVertexData = textInfo.CopyMeshInfoVertexData();
// Allocations for sorting of the modified scales
List<float> modifiedCharScale = new List<float>();
List<int> scaleSortingOrder = new List<int>();
hasTextChanged = true;
while (true)
{
// Allocate new vertices
if (hasTextChanged)
{
// Get updated vertex data
cachedMeshInfoVertexData = textInfo.CopyMeshInfoVertexData();
hasTextChanged = false;
}
int characterCount = textInfo.characterCount;
// If No Characters then just yield and wait for some text to be added
if (characterCount == 0)
{
yield return new WaitForSeconds(0.25f);
continue;
}
// Clear list of character scales
modifiedCharScale.Clear();
scaleSortingOrder.Clear();
for (int i = 0; i < characterCount; i++)
{
TMP_CharacterInfo charInfo = textInfo.characterInfo[i];
// Skip characters that are not visible and thus have no geometry to manipulate.
if (!charInfo.isVisible)
continue;
// Get the index of the material used by the current character.
int materialIndex = textInfo.characterInfo[i].materialReferenceIndex;
// Get the index of the first vertex used by this text element.
int vertexIndex = textInfo.characterInfo[i].vertexIndex;
// Get the cached vertices of the mesh used by this text element (character or sprite).
Vector3[] sourceVertices = cachedMeshInfoVertexData[materialIndex].vertices;
// Determine the center point of each character at the baseline.
//Vector2 charMidBasline = new Vector2((sourceVertices[vertexIndex + 0].x + sourceVertices[vertexIndex + 2].x) / 2, charInfo.baseLine);
// Determine the center point of each character.
Vector2 charMidBasline = (sourceVertices[vertexIndex + 0] + sourceVertices[vertexIndex + 2]) / 2;
// Need to translate all 4 vertices of each quad to aligned with middle of character / baseline.
// This is needed so the matrix TRS is applied at the origin for each character.
Vector3 offset = charMidBasline;
Vector3[] destinationVertices = textInfo.meshInfo[materialIndex].vertices;
destinationVertices[vertexIndex + 0] = sourceVertices[vertexIndex + 0] - offset;
destinationVertices[vertexIndex + 1] = sourceVertices[vertexIndex + 1] - offset;
destinationVertices[vertexIndex + 2] = sourceVertices[vertexIndex + 2] - offset;
destinationVertices[vertexIndex + 3] = sourceVertices[vertexIndex + 3] - offset;
//Vector3 jitterOffset = new Vector3(Random.Range(-.25f, .25f), Random.Range(-.25f, .25f), 0);
// Determine the random scale change for each character.
float randomScale = Random.Range(1f, 1.5f);
// Add modified scale and index
modifiedCharScale.Add(randomScale);
scaleSortingOrder.Add(modifiedCharScale.Count - 1);
// Setup the matrix for the scale change.
//matrix = Matrix4x4.TRS(jitterOffset, Quaternion.Euler(0, 0, Random.Range(-5f, 5f)), Vector3.one * randomScale);
matrix = Matrix4x4.TRS(new Vector3(0, 0, 0), Quaternion.identity, Vector3.one * randomScale);
destinationVertices[vertexIndex + 0] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 0]);
destinationVertices[vertexIndex + 1] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 1]);
destinationVertices[vertexIndex + 2] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 2]);
destinationVertices[vertexIndex + 3] = matrix.MultiplyPoint3x4(destinationVertices[vertexIndex + 3]);
destinationVertices[vertexIndex + 0] += offset;
destinationVertices[vertexIndex + 1] += offset;
destinationVertices[vertexIndex + 2] += offset;
destinationVertices[vertexIndex + 3] += offset;
// Restore Source UVS which have been modified by the sorting
Vector2[] sourceUVs0 = cachedMeshInfoVertexData[materialIndex].uvs0;
Vector2[] destinationUVs0 = textInfo.meshInfo[materialIndex].uvs0;
destinationUVs0[vertexIndex + 0] = sourceUVs0[vertexIndex + 0];
destinationUVs0[vertexIndex + 1] = sourceUVs0[vertexIndex + 1];
destinationUVs0[vertexIndex + 2] = sourceUVs0[vertexIndex + 2];
destinationUVs0[vertexIndex + 3] = sourceUVs0[vertexIndex + 3];
// Restore Source Vertex Colors
Color32[] sourceColors32 = cachedMeshInfoVertexData[materialIndex].colors32;
Color32[] destinationColors32 = textInfo.meshInfo[materialIndex].colors32;
destinationColors32[vertexIndex + 0] = sourceColors32[vertexIndex + 0];
destinationColors32[vertexIndex + 1] = sourceColors32[vertexIndex + 1];
destinationColors32[vertexIndex + 2] = sourceColors32[vertexIndex + 2];
destinationColors32[vertexIndex + 3] = sourceColors32[vertexIndex + 3];
}
// Push changes into meshes
for (int i = 0; i < textInfo.meshInfo.Length; i++)
{
//// Sort Quads based modified scale
scaleSortingOrder.Sort((a, b) => modifiedCharScale[a].CompareTo(modifiedCharScale[b]));
textInfo.meshInfo[i].SortGeometry(scaleSortingOrder);
// Updated modified vertex attributes
textInfo.meshInfo[i].mesh.vertices = textInfo.meshInfo[i].vertices;
textInfo.meshInfo[i].mesh.uv = textInfo.meshInfo[i].uvs0;
textInfo.meshInfo[i].mesh.colors32 = textInfo.meshInfo[i].colors32;
m_TextComponent.UpdateGeometry(textInfo.meshInfo[i].mesh, i);
}
yield return new WaitForSeconds(0.1f);
}
}
}
}
No hay comentarios:
Publicar un comentario