Exemple #1
0
 void ExecuteCanalise()
 {
     if (CurrentSpell != null)
     {
         bool    canCast = true;
         float[] costs   = SpellsManager.GetSpellByID(CurrentSpell.GetSpell().ID).OnCastCosts;
         if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetBlood() < costs[0])
         {
             canCast = false;
         }
         if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetPhlegm() < costs[1])
         {
             canCast = false;
         }
         if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetYellowBile() < costs[2])
         {
             canCast = false;
         }
         if (((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).GetBlackBile() < costs[3])
         {
             canCast = false;
         }
         if (canCast)
         {
             ((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent))).RemoveHumors(costs);
             CurrentSpell.ExecuteOnCanalise();
         }
         else
         {
             ExecuteEnd();
             Debugger.Log("Pas assez d'humeur par rapoort au coût de ce sort !");
         }
     }
 }
Exemple #2
0
        void Cast(uint spellID, object target)
        {
            Spell s = SpellsManager.GetSpellByID(spellID);

            if (s != null)
            {
                bool    canCast = true;
                float[] costs   = s.OnCastCosts;
                if (LinkedEntity.GetComponent <HumorsComponent>() != null)
                {
                    HumorsComponent humors = ((HumorsComponent)LinkedEntity.GetComponent(typeof(HumorsComponent)));
                    if (humors.GetBlood() < costs[0])
                    {
                        canCast = false;
                    }
                    else if (humors.GetPhlegm() < costs[1])
                    {
                        canCast = false;
                    }
                    else if (humors.GetYellowBile() < costs[2])
                    {
                        canCast = false;
                    }
                    else if (humors.GetBlackBile() < costs[3])
                    {
                        canCast = false;
                    }
                }
                if (canCast)
                {
                    if (LinkedEntity.GetComponent <HumorsComponent>() != null)
                    {
                        LinkedEntity.GetComponent <HumorsComponent>().RemoveHumors(costs);
                    }
                    CurrentSpell = s.Cast(LinkedEntity, target);
                }
                else
                {
                    Debugger.Log("Pas assez d'humeur par rapport au coût de ce sort !");
                }
            }
        }
Exemple #3
0
        /// <summary>
        /// Appelle "OnSynch" de tous les Components implémentants IEntitySynchroniser de cette entité.
        /// Synchronise également la Position, la Rotation, la Cellule actuelle,
        /// la taille, et la hauteur.
        /// </summary>
        public void OnSynch()
        {
            if (SynchData == null)
            {
                Debugger.Log("ERREUR : le SynchData n'a pas été initialisé !", UnityEngine.Color.red);
                return;
            }
            // Synchronisation des propriétés basiques :
            LinkedEntity.Position = (BloodAndBileEngine.SerializableVector3)SynchData.GetSynchInfo("Position");
            LinkedEntity.Rotation = (BloodAndBileEngine.SerializableQuaternion)SynchData.GetSynchInfo("Rotation");
            LinkedEntity.SetCellID((int)SynchData.GetSynchInfo("CurrentCell"));
            LinkedEntity.Size   = (float)SynchData.GetSynchInfo("Size");
            LinkedEntity.Height = (float)SynchData.GetSynchInfo("Height");

            // Synchronisation des Components
            // Pour chaque ComponentSynchronizationDataObject, on vérifie que l'entité
            // possède le component correspondant, puis on exécute le GetSynch() sur ce dernier.
            // Si l'entité n'a pas le component, on lui ajoute.
            foreach (ComponentSynchronizationDataObject componentData in SynchData.GetComponentSynchData())
            {
                EntityComponent component = LinkedEntity.GetComponent(componentData.ComponentType);
                if (component != null)
                {
                    if (component is IEntitySynchroniser)
                    {
                        ((IEntitySynchroniser)(component)).OnSynch(componentData); // On lance la synchronisation.
                    }
                }
                else // On ajoute le component
                {
                    component = LinkedEntity.AddComponent(componentData.ComponentType);
                    if (component != null && component is IEntitySynchroniser)
                    {
                        ((IEntitySynchroniser)(component)).OnSynch(componentData);
                    }
                }
            }
        }
Exemple #4
0
 public override void Initialise(BloodAndBileEngine.WorldState.WorldState worldState)
 {
     Mover = (EntityMover)LinkedEntity.GetComponent(typeof(EntityMover));
 }