DINO GAME SCRIPT.
Dino Script (Game Object) :
using [Link];
using [Link];
using UnityEngine;
public class Script : MonoBehaviour
{
private float move;
public float playerspeed;
public float jumpspeed;
private bool isJumping;
private Rigidbody2D rb;
private Animator anim;
// Start is called before the first frame update
void Start()
{
rb = GetComponent<Rigidbody2D>();
anim=GetComponent<Animator>();
}
// Update is called once per frame
void Update()
{
move = [Link]("Horizontal");
[Link] = new Vector2(move * playerspeed, [Link].y);
if(move > 0)
{
[Link] = new Vector3(0, 0, 0);
}
else if(move < 0)
{
[Link] = new Vector3(0, 180, 0);
}
if([Link]("Jump")&& !isJumping)
{
[Link](new Vector2([Link].x, jumpspeed));
isJumping = true;
}
RunAnimation();
}
private void OnCollisionEnter2D(Collision2D other)
{
if([Link]("Tiles"))
{
isJumping = false;
}
}
void RunAnimation()
{
[Link]("movement",[Link](move));
[Link]("isjumping",isJumping);
}
private void OnTriggerEnter2D(Collider2D other)
{
if([Link]("Stone"))
{
Destroy(gameObject);
}
}
}
Eggcollection Script (Collectable object) :
using [Link];
using [Link];
using UnityEngine;
public class eggcollection : MonoBehaviour
{
public int eggvalue = 1;
// Start is called before the first frame update
void Start()
{
}
// Update is called once per frame
void Update()
{
private void OnTriggerEnter2D(Collider2D other)
{
Destroy(gameObject);
if([Link]("Player"))
{
[Link](eggvalue);
}
}
}
Score Script :
using [Link];
using [Link];
using UnityEngine;
using TMPro;
public class Score : MonoBehaviour
{
public static Score instance;
public TextMeshProUGUI text;
int score;
// Start is called before the first frame update
void Start()
{
if(instance == null)
{
instance = this;
}
}
// Update is called once per frame
void Update()
{
}
public void checkScore(int eggvalue)
{
score += eggvalue;
[Link] = "X" + [Link]();
}
}