Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.97 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. // L'animal hérite de monobehavior
  6. public class Animal : MonoBehaviour {
  7.  
  8.     // La classe contient ce qui est commun à tous les animaux.
  9.  
  10.     protected int nombreDeMembres;
  11.     protected int age;
  12.     protected int pointDeVie;
  13.  
  14.     // Protected est "entre" private et public. Protected permet aux classes qui héritent de Animal d'accéder à cette fonction.
  15.     protected void PerdrePointDeVie(int nbrDePointsDeVieAPerdre)
  16.     {
  17.         pointDeVie -= nbrDePointsDeVieAPerdre;
  18.     }
  19.  
  20.     //                             Ceci est un paramètre.
  21.     protected void CouperXMembres(int nbrDeMembresACouper)
  22.     {
  23.         nombreDeMembres -= nbrDeMembresACouper;
  24.     }
  25.  
  26.     // Le mot clé "virtual" permet à la classe qui hérite de modifier le comportement de la fonction. Elle doit être public.
  27.     public virtual void Attaquer()
  28.     {
  29.         // Code de la fonction attaquer.
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement