internal void Contact(EntitySystem_Core origin, InteractionType iType, float applicableValue)
 {
     if (CheckOwnership(origin) == true)               //ONLY POSITIVE SELF INFLICTIONS ARE ALLOWED.
     {
         if (CanSelfInflict(iType) == true)            //ONLY HEALING SO FAR. BUFFS ARE NEXT
         {
             DoAction(origin, iType, applicableValue); //DO THE ACTION TO OURSELVES OR GET IT FROM OUR PROXY OR SENTRY
         }
         else
         {
             return;
         }
     }
     else //We don't own this, so we check if we're in PvP
     {
         // if (AK_GameSystems.GameSystem_Core.Instance.pvpEnabled == true) //If so, we don't run any blocks. What's acting on us isn't ours and anything can act on us.
         // {
         //     DoAction(origin, iType, applicableValue); //Do the action as intended.
         // }
         // else
         // {
         DoAction(origin, iType, applicableValue);     //Check for PvP conflicts before doing the action.
         // }
     }
 }
Exemple #2
0
        private void AssignReferences()
        {
            entityCore          = this.GetComponent <EntitySystem_Core>();
            playerRigidbody     = this.GetComponent <Rigidbody>();
            playerController    = this.GetComponent <PlayerSystem.PlayerController>();
            playerAbilitySystem = this.GetComponent <EntitySystem_Abilities>();

            entityCore.entityInfo.entityOwner = entityCore.entityInfo.entityId; //We own ourselves.
        }
 /// <summary>
 /// Compare the IDs between two entities to see if they're the same. Returns TRUE if SAME, FALSE if NOT SAME.
 /// </summary>
 /// <param name="origin">The entity initiating the action.</param>
 /// <returns></returns>
 private bool CompareIDs(EntitySystem_Core origin)
 {
     if (origin.entityInfo.entityId == entityInfo.entityId)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
        /// <summary>
        /// Compare the Ownership ID between two entities to see if the entity being acted upon is owned by the origin entity. Returns TRUE if SAME, FALSE if NOT SAME.
        /// </summary>
        /// <param name="origin">The entity initiating the action.</param>
        /// <returns></returns>
        internal bool CheckOwnership(EntitySystem_Core origin)
        {
            if (origin.entityInfo == null)
            {
                return(false);
            }

            if (this == origin || origin.entityInfo.entityOwner == entityInfo.entityId || entityInfo.entityOwner == origin.entityInfo.entityId)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
 /// <summary>
 /// Filter the action taking place based on the type of action. Do one additional filter if PVP mode is disabled.
 /// </summary>
 /// <param name="origin">Entity doing the action.</param>
 /// <param name="iType">Type of action.</param>
 /// <param name="applicableValue">The value used in the action, if needed.</param>
 private void ActionChecking(EntitySystem_Core origin, InteractionType iType, float applicableValue)
 {
     if (iType == InteractionType.Damaging)
     {
         if (BlockPVPAction(origin) == false) //Prevent PVP type damage if the origin belongs to an unowned player/sentry/proxy.
         {
             return;
         }
         else
         {
             DoAction(origin, iType, applicableValue); //If damage is from machine or machine sentry, we can do what it wanted to do.
         }
     }
     else if (iType == InteractionType.Healing)
     {
         DoAction(origin, iType, applicableValue);
     }
 }
        internal static float StatCalc(EntitySystem_Core core, float baseFactor, float activeFactor, StatCalcType type)
        {
            float newValue = 0;

            if (type == StatCalcType.TypeOne)
            {
                newValue = core.entityInfo.active_entityLevel * (baseFactor + Mathf.Sqrt(activeFactor));
            }
            else if (type == StatCalcType.TypeTwo)
            {
                newValue = baseFactor + (core.entityInfo.active_entityLevel * Mathf.Sqrt(activeFactor));
            }
            else if (type == StatCalcType.TypeThree)
            {
                newValue = baseFactor * core.entityInfo.active_entityLevel / 1 + Mathf.RoundToInt(Mathf.Sqrt(activeFactor));
            }

            newValue = Mathf.RoundToInt(newValue);
            return(newValue);
        }
 /// <summary>
 /// This script checks to see if certain entities are trying to negatively impact eachother. When PvP is disabled, Players cannot hurt other players, sentries, or proxies. And Vice versa.
 /// Note: Tiles can be damaged by almost every entity.
 /// </summary>
 /// <param name="origin"></param>
 /// <returns></returns>
 internal bool BlockPVPAction(EntitySystem_Core origin)
 {
     if (thisType == EntityType.Player)
     {
         if (origin.thisType == EntityType.Player)
         {
             return(false); //Another player is attempting to do a negative thing to this player.
         }
         else if (origin.thisType == EntityType.Sentry)
         {
             return(false); //Another player's sentry is attempting to do a negative thing to this player.
         }
         else if (origin.thisType == EntityType.Proxy)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Machine)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.MachineSentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Pawn)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (thisType == EntityType.Sentry)
     {
         if (origin.thisType == EntityType.Player)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Sentry)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Proxy)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Machine)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.MachineSentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Pawn)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (thisType == EntityType.Proxy)
     {
         if (origin.thisType == EntityType.Player)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Sentry)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Proxy)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Machine)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.MachineSentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Pawn)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (thisType == EntityType.Machine)
     {
         if (origin.thisType == EntityType.Player)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Sentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Proxy)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Machine)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.MachineSentry)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Pawn)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (thisType == EntityType.MachineSentry)
     {
         if (origin.thisType == EntityType.Player)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Sentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Proxy)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Machine)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.MachineSentry)
         {
             return(false);
         }
         else if (origin.thisType == EntityType.Pawn)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else if (thisType == EntityType.Tile) //Everything can damage tiles.
     {
         if (origin.thisType == EntityType.Player)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Sentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Proxy)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Machine)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.MachineSentry)
         {
             return(true);
         }
         else if (origin.thisType == EntityType.Pawn)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(false);
     }
 }
        private void DoAction(EntitySystem_Core origin, InteractionType iType, float applicableValue)
        {
            if (thisType == EntityType.Player) //Run player-only actions
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(player, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                    HealingAction();
                }
            }
            else if (thisType == EntityType.Sentry) //Run sentry-only actions
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(sentry, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                }
            }
            else if (thisType == EntityType.Proxy) //Run proxy-only actions
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(proxy, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                }
            }
            else if (thisType == EntityType.Machine) //Run machine-only actions
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(machine, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                }

                if (iType == InteractionType.Stunning)
                {
                    StunningAction(machine, applicableValue);
                }
            }
            else if (thisType == EntityType.MachineSentry) //Run machine sentry-only actions
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(machineSentry, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                }
            }
            else if (thisType == EntityType.Tile) //Run tile-only actions
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(tile, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                }
            }
            else if (thisType == EntityType.Pawn)
            {
                if (iType == InteractionType.Damaging)
                {
                    DamageAction(pawn, applicableValue);
                }

                if (iType == InteractionType.Healing)
                {
                }
            }
        }