Разработка мобильного игрового приложения для операционной системы android

Обязательные и возможные составляющие структуры Android-приложения. Выбор инструментальных средств разработки, проектирование структур данных, алгоритмов и пользовательского интерфейса. Целостное представления о работе движка и связи его компонентов.

Рубрика Программирование, компьютеры и кибернетика
Вид дипломная работа
Язык русский
Дата добавления 24.06.2018
Размер файла 1,3 M

Отправить свою хорошую работу в базу знаний просто. Используйте форму, расположенную ниже

Студенты, аспиранты, молодые ученые, использующие базу знаний в своей учебе и работе, будут вам очень благодарны.

m_LastTargetPosition = target.position;

if (border == true)

{

transform.position = new Vector3(Mathf.Clamp(transform.position.x, minX, maxX), Mathf.Clamp(transform.position.y, minY, maxY), transform.position.z);

}

}

}

}

26) Character.cs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public abstract class Character : MonoBehaviour

{

[SerializeField]

protected Transform throwPoint;

[SerializeField]

protected float mSpeed;

protected bool fRight;

[SerializeField]

protected Stat HPStat;

public abstract bool IsDead { get; }

[SerializeField]

protected Transform[] groundPoints;

[SerializeField]

protected float groundRadius;

[SerializeField]

protected LayerMask whatIsGround;

[SerializeField]

protected bool AirControl;

[SerializeField]

protected float AirControlSpeed;

[SerializeField]

protected float jumpF;

[SerializeField]

protected GameObject throwPrefab;

[SerializeField]

private EdgeCollider2D swordCollider;

[SerializeField]

private List<string> damageSources;

public bool Attack { get; set; } //bool attack

public bool Jump { get; set; } //bool jump

public bool OnGround { get; set; } //isGrounded

public bool TakingDamage { get; set; }

public Animator mAnimator { get; private set; }

public EdgeCollider2D SwordCollider

{

get

{

return swordCollider;

}

}

// Use this for initialization

public virtual void Start ()

{

fRight = true;

mAnimator = GetComponent<Animator>();

HPStat.Initialize();

}

public abstract IEnumerator TakeDamage();

public abstract void Death();

public virtual void ChangeDirection()

{

fRight = !fRight;

transform.localScale = new Vector3(transform.localScale.x * -1, 1, 1);

}

public virtual void ThrowWeapon(int value)

{

if (!OnGround && value == 1 || OnGround && value == 0)

{

if (fRight)

{

GameObject tmp = (GameObject)Instantiate(throwPrefab, throwPoint.position, Quaternion.identity);

tmp.GetComponent<ThrowWeapon>().Initialize(Vector2.right);

}

else

{

GameObject tmp = (GameObject)Instantiate(throwPrefab, throwPoint.position, Quaternion.Euler(new Vector3(0, 0, 180)));

tmp.GetComponent<ThrowWeapon>().Initialize(Vector2.left);

}

}

}

public void MeleeAttack()

{

SwordCollider.enabled = true;

AudioManager.instance.PlaySound("PlayerSword");

}

public virtual void OnTriggerEnter2D(Collider2D other)

{

if(damageSources.Contains(other.tag))

{

StartCoroutine(TakeDamage());

}

}

}

27) GameOverUI.cs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

using UnityEngine.SceneManagement;

public class GameOverUI : MonoBehaviour

{

public void Quit()

{

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex - 1);

AudioManager.instance.PlaySound("buttonPress");

}

public void Retry()

{

SceneManager.LoadScene(SceneManager.GetActiveScene().buildIndex);

AudioManager.instance.PlaySound("buttonPress");

}

}

28) Parallaxing.cs

using UnityEngine;

using System.Collections;

public class Parallaxing : MonoBehaviour {

public Transform[] backgrounds;

private float[] parallaxScales;

public float smoothing = 1f;

private Transform cam;

private Vector3 previousCamPos;

void Awake () {

cam = Camera.main.transform;

}

void Start () {

previousCamPos = cam.position;

parallaxScales = new float[backgrounds.Length];

for (int i = 0; i < backgrounds.Length; i++) {

parallaxScales[i] = backgrounds[i].position.z*-1;

}

}

void Update () {

for (int i = 0; i < backgrounds.Length; i++) {

float parallax = (previousCamPos.x - cam.position.x) * parallaxScales[i];

float backgroundTargetPosX = backgrounds[i].position.x + parallax;

Vector3 backgroundTargetPos = new Vector3 (backgroundTargetPosX, backgrounds[i].position.y, backgrounds[i].position.z);

backgrounds[i].position = Vector3.Lerp (backgrounds[i].position, backgroundTargetPos, smoothing * Time.deltaTime);

}

previousCamPos = cam.position;

}

}

29) PauseMenu.cs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public class PauseMenu : MonoBehaviour

{

public static bool GamePaused = false;

public GameObject pauseMenuUI;

public void PauseButton()

{

if (!GamePaused)

{

Pause();

}

else

{

Resume();

}

}

void Resume()

{

pauseMenuUI.SetActive(false);

Time.timeScale = 1f;

GamePaused = false;

AudioManager.instance.PlaySound("buttonPress");

}

void Pause()

{

pauseMenuUI.SetActive(true);

Time.timeScale = 0f;

GamePaused = true;

AudioManager.instance.PlaySound("buttonPress");

}

public void QuitTheGame()

{

Application.Quit();

AudioManager.instance.PlaySound("buttonPress");

}

}

30) Player.cs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

public delegate void DeadEventHandler();

public class Player : Character

{

private static Player instance;

public event DeadEventHandler Dead;

public Rigidbody2D rb2d { get; set; }

public bool OnPlatform { get; set; }

public bool Slide { get; set; } //bool slide

private Vector2 startPos;

private bool immortal = false;

[SerializeField]

private float immortalTime;

public Stat MPStat;

private IUseable useable;

private SpriteRenderer spriteRenderer;

[SerializeField]

private GameObject gameOverUI;

private bool gameend = false;

private bool buttonsaccess = false;

public static Player Instance

{

get

{

if (instance == null)

{

instance = GameObject.FindObjectOfType<Player>();

}

return instance;

}

}

public override bool IsDead

{

get

{

if (HPStat.CurrentVal<=0)

{

OnDead();

}

return HPStat.CurrentVal <= 0;

}

}

// Use this for initialization

public override void Start ()

{

base.Start();

startPos = transform.position;

rb2d = GetComponent<Rigidbody2D>();

spriteRenderer = GetComponent<SpriteRenderer>();

MPStat.Initialize();

}

void Update()

{

if(!TakingDamage && !IsDead)

{

if (transform.position.y <= -14f)

{

Death();

}

HandleInput();

}

}

// Update is called once per frame

void FixedUpdate ()

{

if(!TakingDamage && !IsDead)

{

float horizontal = Input.GetAxis("Horizontal");

OnGround = IsGrounded();

HandleMovement(horizontal);

Flip(horizontal);

HandleLayers();

}

}

public void OnDead()

{

if (Dead != null)

{

Dead();

rb2d.velocity = Vector2.zero;

}

}

private void RunSound(int i)

{

if (OnGround)

{

if (i == 0)

{

AudioManager.instance.PlaySound("footstep0");

}

if (i == 2)

{

AudioManager.instance.PlaySound("footstep2");

}

if (i == 4)

{

AudioManager.instance.PlaySound("footstep4");

}

}

}

public void JumpSound()

{

AudioManager.instance.PlaySound("Jump");

}

private void HandleMovement(float horizontal)

{

if (!buttonsaccess)

{

if (rb2d.velocity.y < 0)

{

mAnimator.SetBool("land", true);

}

if (!Attack && !Slide && OnGround)

{

rb2d.velocity = new Vector2(horizontal * (mSpeed), rb2d.velocity.y);

}

if (!OnGround && AirControl)

{

rb2d.velocity = new Vector2(horizontal * (AirControlSpeed), rb2d.velocity.y);

}

if (Jump && rb2d.velocity.y == 0)

{

rb2d.AddForce(new Vector2(0f, jumpF));

}

mAnimator.SetFloat("Speed", Mathf.Abs(horizontal));

}

}

private void HandleInput()

{

if (!buttonsaccess)

{

if (Input.GetButtonMobile("Fire2"))

{

mAnimator.SetTrigger("attack");

}

if (Input.GetAxis("Vertical") < -0.7)

{

mAnimator.SetTrigger("slide");

}

if (Input.GetAxis("Vertical") > 0.7)

{

mAnimator.SetTrigger("jump");

}

if (Input.GetButtonMobile("Fire1"))

{

if (MPStat.CurrentVal >= 10)

{

mAnimator.SetTrigger("throw");

}

}

if (Input.GetButtonMobile("Jump"))

{

Use();

if (OnPlatform)

{

mAnimator.SetTrigger("jmpoff");

}

}

}

}

private void Flip(float horizontal)

{

if (horizontal>0 && !fRight || horizontal < 0 && fRight)

{

ChangeDirection();

}

}

private bool IsGrounded()

{

if (rb2d.velocity.y<=0)

{

foreach (Transform point in groundPoints)

{

Collider2D[] colliders = Physics2D.OverlapCircleAll(point.position, groundRadius, whatIsGround);

for (int i = 0; i<colliders.Length;i++)

{

if (colliders[i].gameObject != gameObject)

{

if (!OnGround)

{

AudioManager.instance.PlaySound("Land");

}

return true;

}

}

}

}

return false;

}

private void HandleLayers()

{

if (!OnGround)

{

mAnimator.SetLayerWeight(1, 1);

}

else

{

mAnimator.SetLayerWeight(1, 0);

}

}

private IEnumerator IndicateImmortal()

{

while (immortal)

{

spriteRenderer.enabled = false;

yield return new WaitForSeconds(.1f);

spriteRenderer.enabled = true;

yield return new WaitForSeconds(.1f);

}

}

public override void ThrowWeapon(int value)

{

if (!OnGround && value == 1 || OnGround && value == 0)

{

if (fRight)

{

MPStat.CurrentVal -= 10;

GameObject tmp = (GameObject)Instantiate(throwPrefab, throwPoint.position, Quaternion.identity);

tmp.GetComponent<ThrowWeapon>().Initialize(Vector2.right);

AudioManager.instance.PlaySound("PlayerSword");

}

else

{

MPStat.CurrentVal -= 10;

GameObject tmp = (GameObject)Instantiate(throwPrefab, throwPoint.position, Quaternion.Euler(new Vector3(0, 0, 180)));

tmp.GetComponent<ThrowWeapon>().Initialize(Vector2.left);

AudioManager.instance.PlaySound("PlayerSword");

}

}

}

public override IEnumerator TakeDamage()

{

if (!immortal)

{

HPStat.CurrentVal -= 10;

if (!IsDead)

{

AudioManager.instance.PlaySound("hit");

mAnimator.SetTrigger("damage");

immortal = true;

StartCoroutine(IndicateImmortal());

yield return new WaitForSeconds(immortalTime);

immortal = false;

}

else

{

AudioManager.instance.PlaySound("die");

mAnimator.SetLayerWeight(1, 0);

mAnimator.SetTrigger("die");

}

}

}

private void EndGame()

{

if (gameend)

{

Debug.Log("gameover");

gameOverUI.SetActive(true);

}

}

public override void Death()

{

rb2d.velocity = Vector2.zero;

mAnimator.SetTrigger("idle");

if (GameManager.Instance.LivesLeft > 0)

{

GameManager.Instance.LivesLeft--;

HPStat.CurrentVal = HPStat.MaxVal;

transform.position = startPos;

if (GameManager.Instance.LivesLeft == 0)

{

gameend = true;

rb2d.velocity = Vector2.zero;

}

}

else if (GameManager.Instance.LivesLeft < 1)

{

if (gameend)

{

EndGame();

buttonsaccess = true;

gameend = false;

mAnimator.SetLayerWeight(1, 0);

mAnimator.SetTrigger("die");

}

}

}

private void OnCollisionEnter2D(Collision2D other)

{

if (other.gameObject.tag == "HP")

{

HPStat.CurrentVal += 10;

Destroy(other.gameObject);

}

if (other.gameObject.tag == "MP")

{

MPStat.CurrentVal += 10;

Destroy(other.gameObject);

}

}

public override void OnTriggerEnter2D(Collider2D other)

{

if (other.tag == "Useable")

{

useable = other.GetComponent<IUseable>();

}

base.OnTriggerEnter2D(other);

}

private void Use()

{

if (useable != null)

{

useable.Use();

}

}

private void OnTriggerExit2D(Collider2D other)

{

if(other.tag == "Useable")

{

useable = null;

}

}

}

31) ThrowWeapon.cs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

[RequireComponent(typeof(Rigidbody2D))]

public class ThrowWeapon : MonoBehaviour {

[SerializeField]

private float speed;

[SerializeField]

private float delay;

private Rigidbody2D rb;

private Vector2 dir;

// Use this for initialization

void Start ()

{

rb = GetComponent<Rigidbody2D>();

}

public void Initialize(Vector2 dir)

{

this.dir = dir;

}

void FixedUpdate()

{

rb.velocity = dir * speed;

}

// Update is called once per frame

void Update ()

{

Destroy(gameObject, delay);

}

}

32) Tiling.cs

using System.Collections;

using System.Collections.Generic;

using UnityEngine;

[RequireComponent(typeof(SpriteRenderer))]

public class Tiling : MonoBehaviour

{

public int offsetX = 2;

public bool hasARightBuddy = false;

public bool hasALeftBuddy = false;

public bool reverseScale = false;

private float spriteWidth = 0f;

private Camera cam;

private Transform myTransform;

void Awake()

{

cam = Camera.main;

myTransform = transform;

}

void Start()

{

SpriteRenderer sRenderer = GetComponent<SpriteRenderer>();

spriteWidth = sRenderer.sprite.bounds.size.x;

}

void Update()

{

if (hasALeftBuddy == false || hasARightBuddy == false)

{

float camHorizontalExtend = cam.orthographicSize * Screen.width / Screen.height;

float edgeVisiblePositionRight = (myTransform.position.x + spriteWidth / 2) - camHorizontalExtend;

float edgeVisiblePositionLeft = (myTransform.position.x - spriteWidth / 2) + camHorizontalExtend;

if (cam.transform.position.x >= edgeVisiblePositionRight - offsetX && hasARightBuddy == false)

{

MakeNewBuddy(1);

hasARightBuddy = true;

}

else if (cam.transform.position.x <= edgeVisiblePositionLeft + offsetX && hasALeftBuddy == false)

{

MakeNewBuddy(-1);

hasALeftBuddy = true;

}

}

}

void MakeNewBuddy(int rightOrLeft)

{

Vector3 newPosition = new Vector3(myTransform.position.x + spriteWidth * rightOrLeft, myTransform.position.y, myTransform.position.z);

Transform newBuddy = Instantiate(myTransform, newPosition, myTransform.rotation) as Transform;

if (reverseScale == true)

{

newBuddy.localScale = new Vector3(newBuddy.localScale.x * -1, newBuddy.localScale.y, newBuddy.localScale.z);

}

newBuddy.parent = myTransform.parent;

if (rightOrLeft > 0)

{

newBuddy.GetComponent<Tiling>().hasALeftBuddy = true;

}

else

{

newBuddy.GetComponent<Tiling>().hasARightBuddy = true;}}}

Размещено на Allbest.ru


Подобные документы

  • Преимущества операционной системы Android. Проектирование интерфейса приложений. Визуальные редакторы и средства кроссплатформенной разработки. Оптимизация игрового процесса, выбор фреймворка и библиотек. Классификация и характеристика игр по жанрам.

    дипломная работа [2,6 M], добавлен 10.07.2017

  • Обзор мобильной ОС Android. Выбор инструментов и технологий. Проектирование прототипа графического интерфейса. Характеристика и описание пользовательского интерфейса. Проектирование и разработка базы данных. Определение списка необходимых разрешений.

    курсовая работа [376,6 K], добавлен 13.09.2017

  • Архитектура и история создания операционной системы Android. Язык программирования Java. Выбор средства для реализации Android приложения. Программная реализация Android приложения. Проведение тестирования разработанного программного обеспечения.

    курсовая работа [167,8 K], добавлен 18.01.2017

  • Структура Android-приложений. Особенности игрового движка. Алгоритмизация и программирование. Список игровых состояний. Настройка, отладка и тестирование программы. Разработка руководства пользователя. Тестирование инсталляции и отображения элементов.

    дипломная работа [4,5 M], добавлен 19.01.2017

  • Современное состояние рынка мобильных приложений. Основные подходы к разработке мобильных приложений. Обоснование выбора целевой группы потребителей приложения. Этапы проектирования и разработки мобильного приложения для операционной системы Android.

    курсовая работа [987,1 K], добавлен 27.06.2019

  • Создание, изучение и разработка приложение на Android. Среда разработки приложения DelphiXE5. Установка и настройка среды программирования. Этапы разработки приложения. Инструменты для упрощения конструирования графического интерфейса пользователя.

    курсовая работа [1,6 M], добавлен 19.04.2017

  • Структура и архитектура платформы Android. Основные достоинства и недостатки операционной системы Android. Среда разработки Eclipse, платформа Java. Подготовка среды разработки. Вкладка "Погода", "Курс валют", "Новости". Просмотр полной новости.

    дипломная работа [1,0 M], добавлен 11.07.2014

  • Архитектура операционной системы Android, набор библиотек для обеспечения базового функционала приложений и виртуальная машина Dalvik. Объектно-ориентированный язык программирования Java как инструмент разработки мобильных приложений для ОС Android.

    дипломная работа [1,6 M], добавлен 08.07.2015

  • Разработка клиент-серверного игрового приложения на примере игры в шашки для мобильных устройств на базе операционной системы Android. Обзор мобильных платформ. Экраны приложения и их взаимодействие. Графический интерфейс, руководство пользователя.

    курсовая работа [2,6 M], добавлен 15.06.2013

  • Общая схема работы приложения Android. Разработка обучающего приложения для операционной системы Android, назначение которого - развитие речи посредством произнесения скороговорок. Описание компонентов разработанного приложения, его тестирование.

    дипломная работа [1,2 M], добавлен 04.02.2016

Работы в архивах красиво оформлены согласно требованиям ВУЗов и содержат рисунки, диаграммы, формулы и т.д.
PPT, PPTX и PDF-файлы представлены только в архивах.
Рекомендуем скачать работу.