New anim added

This commit is contained in:
2023-01-18 18:04:32 +05:30
parent 652134f007
commit 638cae044d
103 changed files with 17807 additions and 20 deletions

View File

@@ -3,7 +3,7 @@ using System.Collections.Generic;
using UnityEngine;
public static class DataManager{
public const string API_Endpoint="http://vmi1005083.contaboserver.net/pogebird/api/";
public const string API_Endpoint="https://pogebird.io/pogebird/api/";
public static string Username{get; private set;}
public static bool LoggedIn {get{return PlayerPrefs.HasKey("username");}}

View File

@@ -30,8 +30,8 @@ public class Leaderboard : MonoBehaviour
string[] columns = req.text.Split(col,System.StringSplitOptions.RemoveEmptyEntries);
//Purge
for(int i=0; i < itemsParent.childCount; i++){
if(itemsParent.GetChild(i) != rowPrefab){
Destroy(itemsParent.GetChild(i));
if(itemsParent.GetChild(i).gameObject != rowPrefab){
Destroy(itemsParent.GetChild(i).gameObject);
}else{
}

View File

@@ -63,4 +63,13 @@ public class LevelGenerator : MonoBehaviour
{
}
void OnDrawGizmos(){
if(Levels == null){return;}
if(Levels.Count < 2){return;}
for(int i=1; i < Levels.Count; i++){
Gizmos.DrawLine(new Vector3((i-1)*spaceBetween, Levels[i-1]), new Vector3((i)*spaceBetween, Levels[i]));
}
}
}

View File

@@ -5,7 +5,8 @@ using UnityEngine;
public class Player : MonoBehaviour
{
public GameObject StartPanel;
public Color[] pogeColors;
// public Color[] pogeColors;
[SerializeField]private Animator anim;
[SerializeField]private Transform body;
[field:SerializeField]public Vector2 Velocity {get; private set;}
[SerializeField]private float gravity=1;
@@ -17,7 +18,7 @@ public class Player : MonoBehaviour
[Header("Sprites")]
public Sprite normalFace;
public Sprite sadFace;
public Sprite jumpFace;
public bool isReadyToJump { get{ return jumpTimer >= jumpCooldown;}}
@@ -41,7 +42,11 @@ public class Player : MonoBehaviour
timeAliveMoney = GetComponent<TimeAliveMoney>();
isAlive = true;
spriteRenderer.sprite =normalFace;
spriteRenderer.color = pogeColors[DataManager.selectedPogeLevel];
// spriteRenderer.color = pogeColors[DataManager.selectedPogeLevel];
foreach(PogeSkinItem skinItem in GetComponentsInChildren<PogeSkinItem>()){
skinItem.SetSprite(DataManager.selectedPogeLevel);
Debug.Log("Changing skin of " + skinItem.name + " to " + DataManager.selectedPogeLevel);
}
startPos = body.position;
Velocity = new Vector2(forwardSpeed,0);
@@ -54,7 +59,8 @@ public class Player : MonoBehaviour
}
int lastX = 0;
void FixedUpdate()
{if(Input.GetKey(KeyCode.Space)){
{
if(Input.GetKey(KeyCode.Space)){
Jump();
}
@@ -86,13 +92,22 @@ public class Player : MonoBehaviour
Collider2D col = Physics2D.OverlapCircle(body.position, radius);
if(col == null){ return;}
if(col.tag == "Death"){
Debug.Log("Im dead bro");
timeAliveMoney.OnPlayerDeath();
isAlive = false;
spriteRenderer.sprite = sadFace;
GameUI.ShowDeath();
Die();
return;
}
if(body.position.y < 0){
Die();
}
}
void Die(){
Debug.Log("Im dead bro");
timeAliveMoney.OnPlayerDeath();
isAlive = false;
spriteRenderer.sprite = sadFace;
GameUI.ShowDeath();
}
void HandleJump(){
@@ -113,6 +128,15 @@ public class Player : MonoBehaviour
if(!isReadyToJump){ return; }
jumpTimer =0;
Velocity = new Vector2(Velocity.x, jumpForce);
anim.CrossFadeInFixedTime("jump",0.01f);
StartCoroutine(switchToJumpFace());
}
IEnumerator switchToJumpFace(){
spriteRenderer.sprite = jumpFace;
yield return new WaitForSeconds(0.5f);
spriteRenderer.sprite = normalFace;
}

View File

@@ -0,0 +1,12 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
[RequireComponent(typeof(SpriteRenderer))]
public class PogeSkinItem : MonoBehaviour
{
public Sprite[] sprites;
public void SetSprite(int i){
GetComponent<SpriteRenderer>().sprite = sprites[i];
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: b32425b8c08124245b3520ee437b9923
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: