Welcome to GEMENTAR TOUR PUO V2 Development Documentation. Enjoy your stay!

This is an old revision of the document!


Table of Contents

Health

Health Script

using Sirenix.OdinInspector;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
 
public class ZombieHealth : MonoBehaviour
{
    [HideInEditorMode]
    public UnityEvent sendEventOnMinusHealth;
 
    [HideInEditorMode]
    public UnityEvent<float> sendEventHealthCount;
 
 
    [SerializeField]
    public float _health { get; private set; } = 100f;
 
    private void Start()
    {
        sendEventHealthCount.Invoke(_health);
    }
 
    public bool IsDead()
    {
        if(_health <= 0f)
        {
            return true;
        }
 
        return false;
    }
 
    public void MinusHealth(float x)
    {
        _health -= x;
        sendEventOnMinusHealth.Invoke();
        sendEventHealthCount.Invoke(_health);
    }
 
    [Button]
    public void FullHealth()
    {
        _health = 100f;
    }
 
    [Button]
    public void EmptyHealth()
    {
        _health = -1f;
    }
 
 
}

Coin

CoinPickup Script

using Micosmo.SensorToolkit;
using MoreMountains.Feedbacks;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Events;
 
public class ZombieCoinController : MonoBehaviour
{
    public static int totalPoint = 0;
 
    public GameObject coinObject;
 
    public RangeSensor rangeSensor;
 
    private AudioSource audSource;
    public AudioClip audClip;
 
    private void Awake()
    {
        audSource = this.GetComponent<AudioSource>();
        rangeSensor.OnDetected.AddListener(AddPoint);
    }
 
    public void AddPoint(GameObject arg0, Sensor arg1)
    {
        Action<int> firstAction = FindObjectOfType<ZombieUIManager>().UpdateCoinCount;
 
        audSource.PlayOneShot(audClip);
 
 
        totalPoint += 1;
        rangeSensor.enabled = false;
        firstAction(totalPoint);
        coinObject.SetActive(false);
    }
}

Ammo

AmmoPickup Script

using Micosmo.SensorToolkit;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
 
public class ZombieAmmoPickup : MonoBehaviour
{
    public int respawnTime = 60;
    public int bulletCount = 15;
 
    private RangeSensor _rangeSensor;
    private ZombieGunController _gunController;
    private MeshRenderer _meshRenderer;
    private AudioSource _audioSource;
 
    private void Start()
    {
 
        _rangeSensor = this.GetComponent<RangeSensor>();
        _rangeSensor.OnDetected.AddListener(ReceivedEventOnDetected);
 
        _gunController = FindObjectOfType<ZombieGunController>();
 
        _meshRenderer = this.GetComponent<MeshRenderer>();
 
        _audioSource = this.GetComponent<AudioSource>();
 
    }
 
    private bool _canBePickedUp = true;
    private void ReceivedEventOnDetected(GameObject arg0, Sensor arg1)
    {
        if (!_canBePickedUp) return;
 
        _gunController.addBullet(bulletCount);
 
        _meshRenderer.enabled = false;
 
        _canBePickedUp = false;
 
        _audioSource.Play();
 
        StartCoroutine(enableIt());
    }
 
    private IEnumerator enableIt()
    {
        yield return new WaitForSeconds(respawnTime);
        _meshRenderer.enabled = true;
        _canBePickedUp = true;
    }
 
 
}


QR Code
QR Code wiki:etc_prototyping (generated for current page)
Hello World!
DokuWiki with monobook... rules!