Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- // L'animal hérite de monobehavior
- public class Animal : MonoBehaviour {
- // La classe contient ce qui est commun à tous les animaux.
- protected int nombreDeMembres;
- protected int age;
- protected int pointDeVie;
- // Protected est "entre" private et public. Protected permet aux classes qui héritent de Animal d'accéder à cette fonction.
- protected void PerdrePointDeVie(int nbrDePointsDeVieAPerdre)
- {
- pointDeVie -= nbrDePointsDeVieAPerdre;
- }
- // Ceci est un paramètre.
- protected void CouperXMembres(int nbrDeMembresACouper)
- {
- nombreDeMembres -= nbrDeMembresACouper;
- }
- // Le mot clé "virtual" permet à la classe qui hérite de modifier le comportement de la fonction. Elle doit être public.
- public virtual void Attaquer()
- {
- // Code de la fonction attaquer.
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement