//Initialization
    void Start()
    {
        gameplayManager = GameObject.Find("GameplayManager").GetComponent <GameplayManager>();

        stats               = new EntityStats();
        stats.health        = 100;
        stats.baseDamage    = 5;
        stats.movementSpeed = 10.0f;

        currentStance = MovementType.Neutral;

        currentVelocity = Vector3.zero;
        lastPos         = rigidBody.position;

        canMove = true;
        IsReturningToNeutral = false;

        turningSpeed    = 80;
        quickTurnTarget = transform.rotation;

        dodgeSpeed  = 8.0f;
        dodgePos    = 0.0f;
        dodgeTarget = 0.0f;

        standardDashSpeed  = 25.0f;
        adjustingDashSpeed = 40.0f;

        punchValue = 0;
        kickValue  = 0;
    }
 public virtual void OnKill(EntityStats victim)
 {
     foreach (var sys in projSystems)
     {
         sys.OnKill(victim);
     }
 }
Exemple #3
0
    public virtual void AddAttribute(EntityAttribute attr, EntityStats source)
    {
        AppliedAttribute app;

        app.attr   = attr;
        app.source = source;
        if (attr.duration == float.PositiveInfinity)
        {
            app.endTime = float.PositiveInfinity;
        }
        else
        {
            app.endTime = Time.time + attr.duration;
        }

        if (!attr.stackable)
        {
            for (int i = 0; i < attribList.Count; i++)
            {
                string temp = attribList[i].attr.name;
                if (temp != "" && temp == attr.name)
                {
                    return;
                }
            }
        }

        attribList.Add(app);
        attr.OnAdd(this);
    }
Exemple #4
0
    private void attack()
    {
        RaycastHit[] raycasts = Physics.RaycastAll(this.transform.position, eyes.position - this.transform.position, 4
                                                   );


        foreach (RaycastHit raycast in raycasts)
        {
            EntityManager manager = raycast.collider.gameObject.GetComponent <EntityManager>();

            if (manager == null)
            {
                return;
            }

            if (manager.Equals(this.gameObject.GetComponent <EntityManager>()))
            {
                return;
            }

            EntityStats stats = manager.getStats();
            stats.getStat("health").addValue(-this.GetComponent <EntityManager>().getStats().getStat("attack").value);

            particle.Play();
        }
    }
Exemple #5
0
    public override void OnStart()
    {
        EntityStats stats  = gameObject.GetComponent <EntityManager>().getStats();
        Stat        health = stats.getStat("health");

        health.addValue(increment);
    }
 public void SetupStateController(EntityStats objectStats, State state, ReactionStates _reactionStates, bool bActivateStateController = true)
 {
     reactionStatesContainer = _reactionStates;
     SetupStateController(objectStats, bActivateStateController);
     currentState = state;
     TransitionToState(state);
 }
        public void InventoryUnwieldItem()
        {
            IInventory      inventory = new Inventory(60);
            IItemWeaponInfo info      = new ItemWeaponInfo(ItemType.LongSword, ItemWieldType.OneHand, SkillType.HeavyBlade, 10, 3);
            IItem           testItem  = new Item(Guid.NewGuid(), info, null, ItemQualityCode.Superior, 1);
            IEntityStats    stats     = new EntityStats();
            IEntityAbility  abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None);

            inventory.Set(testItem, InventorySlot.Inventory1, stats);
            Assert.AreEqual(inventory.Remaining, 59);
            // equip the item
            bool wieldSuccess = inventory.Swap(InventorySlot.Inventory1, InventorySlot.WieldPrimary, stats);

            Assert.IsTrue(wieldSuccess);
            Assert.AreEqual(inventory.Remaining, 60);

            bool unwieldSuccess = inventory.Swap(InventorySlot.WieldPrimary, InventorySlot.Inventory1, stats);

            Assert.IsTrue(unwieldSuccess);
            Assert.AreEqual(inventory.Remaining, 59);

            // the item should be back in the zero'th position
            IItem getItem = inventory.Get(InventorySlot.Inventory1, stats);

            Assert.AreEqual(inventory.Remaining, 60);
            Assert.IsNotNull(getItem);
        }
 public override void OnDealDamage(EntityStats dealer, EntityStats target, DamageSource damageInfo = null)
 {
     if ((damageInfo != null && damageInfo.skillType == onlyForTypeAttacks) || onlyForTypeAttacks == SkillType.None)
     {
         target.ApplyState(stateToApply, dealer);
     }
 }
Exemple #9
0
 // Start is called before the first frame update
 void Start()
 {
     AssignSkills();
     RHand       = GameObject.FindGameObjectWithTag("RightHand");
     LHand       = GameObject.FindGameObjectWithTag("LeftHand");
     entityStats = gameObject.GetComponent <EntityStats>();
 }
        public void InventoryUnequipItem()
        {
            IInventory     inventory = new Inventory(60);
            IItemInfo      info      = new ItemArmorInfo(ItemType.ClothCap, InventorySlot.Head, 10, 5);
            IItem          testItem  = new Item(Guid.NewGuid(), info, null, ItemQualityCode.Superior, 1);
            IEntityStats   stats     = new EntityStats();
            IEntityAbility abilities = new EntityAbility(GeneralAbilities.All, ItemAbilities.None, EntityAbilities.ModifyInterationAbilities, EffectAbilities.ModifyMagicAbilities, AIAbilities.None);

            inventory.Set(testItem, InventorySlot.Inventory1, stats);
            Assert.AreEqual(inventory.Remaining, 59);
            // equip the item
            bool equipSuccess = inventory.Swap(InventorySlot.Inventory1, InventorySlot.Head, stats);

            Assert.IsTrue(equipSuccess);
            Assert.AreEqual(inventory.Remaining, 60);

            bool unequipSuccess = inventory.Swap(InventorySlot.Head, InventorySlot.Inventory1, stats);

            Assert.IsTrue(unequipSuccess);
            Assert.AreEqual(inventory.Remaining, 59);

            // the item should be back in the zero'th position
            IItem getItem = inventory.Get(InventorySlot.Inventory1, stats);

            Assert.AreEqual(inventory.Remaining, 60);
            Assert.IsNotNull(getItem);
        }
        private void IOnTakeDamage(EntityEffectFluid effect, EntityStats target, EntityEffectSourceData source)
        {
            if (effect == null || target == null || source == null || source.Value.Equals(0f))
            {
                return;
            }

            AIEntity entity = target.GetComponent <AIEntity>();

            if (entity != null)
            {
                Interface.CallHook("OnEntityTakeDamage", entity, source);
                return;
            }

#if ITEMV2
            HNetworkView networkView = target.networkView;
#else
            uLink.NetworkView networkView = target.uLinkNetworkView();
#endif
            if (networkView != null)
            {
                PlayerSession session = GameManager.Instance.GetSession(networkView.owner);
                if (session != null)
                {
                    Interface.CallHook("OnPlayerTakeDamage", session, source);
                }
            }
        }
Exemple #12
0
    public override bool TakeDamage(float amount, EntityStats source, bool tickDamage = false, string killerNameOverride = "")
    {
        // Only adjust incoming damage based on armor
        float realDmg = Mathf.Max((amount - armorStatic), Mathf.Min(1, amount)) * Mathf.Max(1 - armorMult, 0);

        return(parent.TakeDamage(realDmg, source));
    }
Exemple #13
0
 public Stat(double baseValue, double maxValue, EntityStats parent)
 {
     this.baseValue = baseValue;
     this.value     = baseValue;
     this.maxValue  = maxValue;
     this.parent    = parent;
 }
Exemple #14
0
    /* @brief Set the instance of the singleton to this class data.
     */
    private void Awake()
    {
        // Assure that the object can be destroyed if has to be created again later.
        if (instance != null && instance != this)
        {
            Destroy(this.gameObject);
        }
        else
        {
            instance = this;
        }

        // Loop over all entities in the entity list and set the max health/stamina to the first state of current health/stamina.
        for (int i = 0; i < entityList.Count; i++)
        {
            newData = entityList[i];

            newData.maxHealth  = entityList[i].health;
            newData.maxStamina = entityList[i].stamina;

            if (entityList[i].name == "Boss")
            {
                newData.lives = entityList[i].entityObject.GetComponent <BossBrain>().m_bossPhaseList.Count;
            }

            newData.maxLives = entityList[i].lives;

            entityList[i] = newData;
        }
    }
 void Start()
 {
     m_entity             = Player.instance;
     m_stats              = m_entity.m_stats;
     m_entityController   = m_entity.m_controller;
     m_interactController = m_entity.m_interactController;
 }
Exemple #16
0
 public Entity(
     string name, EntityStats entityStats, Weapon weapon, List <Spell> spells,
     Shield shield, Armor head, Armor torso, Armor arms, Armor legs, Armor feet
     ) : this(name, weapon, spells, shield, head, torso, arms, legs, feet)
 {
     EntityStats = entityStats;
 }
Exemple #17
0
        /// <summary>
        /// Damages the player by specified amount
        /// </summary>
        /// <param name="session"></param>
        /// <param name="amount"></param>
        public void Hurt(PlayerSession session, float amount)
        {
            EntityEffectFluid effect = new EntityEffectFluid(EntityFluidEffectKeyDatabase.Instance.Damage, EEntityEffectFluidModifierType.AddValuePure, -amount);
            EntityStats       stats  = session.WorldPlayerEntity.GetComponent <EntityStats>();

            effect.Apply(stats);
        }
Exemple #18
0
 public void ApplyDamage(EntityStats src)
 {
     if (src != null)
     {
         ApplyDamage(src.damage);
     }
 }
 public override void OnStart()
 {
     base.OnStart();
     _slowStat = new EntityStats(-2f, 0f, ElementalStats.Zero, ElementalStats.Zero, ElementalStats.Zero, ElementalStats.Zero);
     _slowTimer = new Timer(0.25f);
     _lastSelectTime = Time.time;
     _playerCharacter = gameObject.GetComponent<PlayerCharacter>();
     _costumeBaseSpellReference = GetComponent<PlayerCostume>().CostumeBaseSpell;
     GameMainController.Instance.OnCinematicChange += OnCinematicChange;
     // Unlock all saved elements
     int eIndex = 0;
     if (GameDataManager.GameData != null)
     {
         foreach (Element e in GameDataManager.GameData.PlayerData.UnlockedElements)
         {
             SetSelectedElement(eIndex, e);
             eIndex++;
         }
     }
     else
     {
         // Load debug elements
         SetSelectedElement(0, LevelMetaInfo.Instance.FirstDebugElement);
         SetSelectedElement(1, LevelMetaInfo.Instance.SecondDebugElement);
         SetSelectedElement(2, LevelMetaInfo.Instance.ThirdDebugElement);
         SetSelectedElement(3, LevelMetaInfo.Instance.FourthDebugElement);
     }
     var p = StatusTextPool.Instance.GetObjectFromPool((e) =>
     {
         e.TextColor = Color.green;
         e.StatusText = "This is test";
         e.Target = Entity.GUIHealthPoint;
     });
 }
Exemple #20
0
    private bool Sight()
    {
        Collider[] colliders = Physics.OverlapSphere(transform.position, enemyManager.detectRadius, detectionLayer);

        for (int i = 0; i < colliders.Length; i++)
        {
            EntityStats entityStats = colliders[i].transform.GetComponent <EntityStats>();

            if (entityStats != null)
            {
                LocalAlert(entityStats);
                Vector3 targetDirection = entityStats.transform.position - transform.position;
                float   viewableAngle   = Vector3.Angle(targetDirection, transform.forward);

                if (viewableAngle > enemyManager.minDetectAngle && viewableAngle < enemyManager.maxDetectAngle)
                {
                    currentTarget = entityStats;
                    return(true);
                }
            }
        }
        if (currentTarget != null && currentTarget.tag == "Player")
        {
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemple #21
0
    public virtual void Start()
    {
        m_Rigidbody = GetComponent <Rigidbody>();
        m_Stats     = GetComponent <EntityStats>();
        m_Agent     = GetComponent <NavMeshAgent>();

        //Set navmeshagent values
        m_Agent.updateRotation   = false;
        m_Agent.speed            = GetStats().GetMovementSpeed();
        m_Agent.stoppingDistance = GetStats().GetAttackRange();

        //Find and set chargebar
        m_Chargebar = transform.FindChild("Chargebar").GetComponent <Healthbar>();

        if (m_Chargebar)
        {
            m_Chargebar.SetScale(0);
            m_Chargebar.gameObject.SetActive(false);
        }
        else
        {
            Debug.Log("Entity " + gameObject.name + " could not find chargebar!");
        }

        //Set rotation
        transform.eulerAngles = new Vector3(90.0f, 0, 0);
        m_MovetoPosition      = transform.position;
    }
Exemple #22
0
    public override void InitState(EntityStats receiver, EntityStats applier = null)
    {
        if (amount <= 0 || amount > maxAmount)
        {
            return;
        }
        StateStack ss = new StateStack(this, -1, -1, 1, applier);

        receiver.states.Add(ss);
        addedMod = new StatModifier(values[amount - 1], targetModType, this);
        if (targetType == StatType.STRENGTH)
        {
            receiver.strength.AddModifier(addedMod);
        }
        if (targetType == StatType.MIND)
        {
            receiver.mind.AddModifier(addedMod);
        }
        if (targetType == StatType.CONSTITUTION)
        {
            receiver.constitution.AddModifier(addedMod);
        }
        if (targetType == StatType.SPIRIT)
        {
            receiver.spirit.AddModifier(addedMod);
        }
    }
Exemple #23
0
        private void IOnTakeDamage(EntityEffectFluid effect, EntityStats target, EntityEffectSourceData source)
        {
            if (effect == null || target == null || source?.Value == 0)
            {
                return;
            }

            var entity = target.GetComponent <AIEntity>();

            if (entity != null)
            {
                Interface.CallHook("OnEntityTakeDamage", entity, source);
                return;
            }

            var networkView = target.GetComponent <uLinkNetworkView>();

            if (networkView == null)
            {
                return;
            }

            var session = GameManager.Instance.GetSession(networkView.owner);

            if (session != null)
            {
                Interface.CallHook("OnPlayerTakeDamage", session, source);
            }
        }
Exemple #24
0
    public Skill(
        List <GameObject> skillPrefabs,
        GameObject user,
        GameObject rHand        = null,
        GameObject lHand        = null,
        DamageType damageType   = DamageType.None,
        EntityStats playerStats = null)
    {
        SkillPrefabs = skillPrefabs;
        User         = user;
        SkillObjects = new GameObject[SkillPrefabs.Count];
        RHand        = rHand;
        LHand        = lHand;
        DamageType   = damageType;
        PlayerStats  = playerStats;

        if (User.CompareTag("Player"))
        {
            TargetTag = "Enemy";
        }
        if (User.CompareTag("Enemy"))
        {
            TargetTag = "Player";
        }
    }
Exemple #25
0
    //Called from PlayerMaster to init state information
    public void init(int playerNumber, int totalPlayers, Color playerColor, FillScript healthBar, Overlord o)
    {
        this.overlord     = o;
        this.healthBar    = healthBar;
        this.color        = playerColor;
        this.stats        = new EntityStats();
        this.stats.hud    = hud;
        this.hud.playerID = playerNumber;                                                                       //Allows for items to be added in hud and stuff
        this.hud.player   = this;
        overlord.resourceCore.itemSlice.gearSpawnedPlayer(this);                                                //testing gearing
        playerColor.a        = 1.0f;                                                                            //Healthbar color - Werid issues when converting from Color to Color32
        trail.material.color = playerColor;
        stats.recalculateStats();
        this.stats.health           = this.stats.maxHealth;
        healthBar.healthcolor.color = playerColor;
        this.stats.hud.updateHealthbar();
        cSlice.init(stats, this, anim, healthBar);
        checkPlayerIDs();

        //playerMesh.GetComponent<Renderer>().material.color = c;                   //Set the color. Don't delete, we will need this
        cameraSetup(totalPlayers, playerNumber);                                                                        //initialize the camera based on the count of players
        switch (playerNumber)                                                                                           //Set the gamepad
        {
        case 1: gamepad = new InputController(ControllerNumber.ONE);   break;

        case 2: gamepad = new InputController(ControllerNumber.TWO);   break;

        case 3: gamepad = new InputController(ControllerNumber.THREE); break;

        case 4: gamepad = new InputController(ControllerNumber.FOUR);  break;
        }
    }
Exemple #26
0
    public override void InitState(EntityStats receiver, EntityStats applier = null)
    {
        StateStack ss = receiver.GetStack(this);

        if (ss == null)
        {
            ss = new StateStack(this, stunDuration, 1);
            receiver.states.Add(ss);
        }
        else
        {
            ss.ResetTimer();
        }

        /* receiver.canMove = false;
         * SkillUser su = receiver.GetComponent<SkillUser>();
         * if(su){
         *  su.canCastSkills = false;
         * } */
        SkillUser su = receiver.GetComponent <SkillUser>();

        if (su)
        {
            su.canCastSkills = false;
        }
        receiver.stunned = true;
    }
Exemple #27
0
    public Script_Enemy(Script_GameManager p_manager, Script_Grid p_grid, Vector3Int p_gridLocation)
    {
        _attackRange       = 1;
        _engageTargetRange = 3;

        _threatMultiplier = 1;
        _stats            = new EntityStats(10, 0, 100, 1.5f);

        _targetToAttack = null;

        _threatDictionary = new Dictionary <Script_IFriendly, int> ();

        _health = _stats._maxHealth;


        _manager = p_manager;
        _grid    = p_grid;

        _gridLocation = p_gridLocation;
        _position     = p_gridLocation;

        _gameObject                    = GameObject.CreatePrimitive(PrimitiveType.Cube);
        _gameObject.name               = "EnemyObject";
        _objectMaterial                = _gameObject.GetComponent <Renderer>().material;
        _objectMaterial.color          = Color.red;
        _gameObject.transform.position = p_gridLocation;



        InitializeThreatList();


        InitializeBehaviourTree();
    }
Exemple #28
0
 public override void ConcludeState(EntityStats receiver)
 {
     if (receiver.entityGraphic)
     {
         receiver.entityGraphic.color = defaultColor;
     }
 }
 public override void OnKill(EntityStats victim)
 {
     foreach (var sys in projSystems)
     {
         sys.OnKill(victim);
     }
 }
 void HealAll()
 {
     foreach (PlayerSession session in GameManager.Instance.GetSessions().Values)
     {
         if (session != null && session.IsLoaded)
         {
             EntityStats stats = session.WorldPlayerEntity.GetComponent <EntityStats>();
             stats.RemoveBinaryEffect(EEntityBinaryEffectType.Burning);
             stats.GetFluidEffect(EEntityFluidEffectType.ColdBar).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.Radiation).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.HeatBar).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.Dampness).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.Hungerbar).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.Nutrition).SetValue(100f);
             stats.GetFluidEffect(EEntityFluidEffectType.InternalTemperature).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.ExternalTemperature).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.Toxin).SetValue(0f);
             stats.GetFluidEffect(EEntityFluidEffectType.Health).SetValue(100f);
             stats.RemoveBinaryEffect(EEntityBinaryEffectType.BrokenLeg);
             stats.GetFluidEffect(EEntityFluidEffectType.ExternalTemperature).SetValue(0f);
             stats.RemoveBinaryEffect(EEntityBinaryEffectType.HeatStroke);
             stats.RemoveBinaryEffect(EEntityBinaryEffectType.SunBurn);
         }
     }
 }
 /* Called when projectile hits entity */
 public void OnHit(Projectile proj, EntityStats victim)
 {
     foreach (var sys in projSystems)
     {
         sys.OnHit(proj, victim);
     }
 }
Exemple #32
0
 public EntityStats Difference(EntityStats other)
 {
     return new EntityStats(FloatDifference(_speed, other._speed), FloatDifference(_maxHp, other._maxHp), _spellElementalModifier.Difference(other._spellElementalModifier), _rechargeRate.Difference(other.RechargeRate), _elementalResistance.Difference(other.ElementalResistance), _maxElementalCharge.Difference(other._maxElementalCharge));
 }
Exemple #33
0
 public void ApplyDamage(EntityStats src)
 {
     if(src != null) {
         ApplyDamage(src.damage);
     }
 }
Exemple #34
0
    protected virtual void Awake()
    {
        mStats = GetComponent<EntityStats>();
        mPlanetAttach = GetComponent<PlanetAttach>();

        Component[] cs = GetComponentsInChildren(typeof(IListener), true);
        mListeners = new IListener[cs.Length];
        for(int i = 0; i < cs.Length; i++) {
            mListeners[i] = cs[i] as IListener;
        }
    }
Exemple #35
0
 private void DoAddApplyStatModifier(string id, EntityStats stat)
 {
     if (!EntityStatModifiers.ContainsKey(id))
     {
         EntityStatModifiers.Add(id, new List<EntityStats>());
     }
     EntityStatModifiers[id].Add(stat);
     // Apply the stat to the cached stats
     CachedStats += stat;
 }
Exemple #36
0
    public void SetStats(EntityStats stats)
    {
        mStats = stats;

        if(stats == null) {
            Clear();
        }
        else if(gameObject.active) { //refresh later
            RefreshStats(true);
        }
    }
Exemple #37
0
 /// <summary>
 /// This will remove all stats and insert the new stat before updating the stat components
 /// </summary>
 /// <param name="id"></param>
 /// <param name="stats"></param>
 public void UpdateStatModifiers(string id, EntityStats stats)
 {
     UpdateStatModifiers(id, stats, true);
 }
Exemple #38
0
 private void DoRemoveAllStatModifiers(string id)
 {
     if (!EntityStatModifiers.ContainsKey(id))
     {
         return;
     }
     else
     {
         // Iterate through all EntityStats and remove them from the cached stats
         foreach (EntityStats s in EntityStatModifiers[id])
         {
             CachedStats = CachedStats.Difference(s);
         }
         // Clear the list
         EntityStatModifiers[id].Clear();
     }
 }
Exemple #39
0
 /// <summary>
 /// Modifies the EntityStats to add the amount passed in. It will automatically update the state of the Entity to reflect
 /// the new stats.
 /// </summary>
 /// <param name="stat"></param>
 public void ApplyStatModifier(string id, EntityStats stat)
 {
     DoAddApplyStatModifier(id, stat);
     // Update the stats of the Entity to reflect the new stats
     UpdateStatComponents();
 }
Exemple #40
0
 /// <summary>
 /// This will remove all stats and insert the new stat. Specifying true or false to the updateComponents argument will trigger an automatic update
 /// of updating the stats.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="stats"></param>
 /// <param name="updateComponents"></param>
 public void UpdateStatModifiers(string id, EntityStats stats, bool updateComponents)
 {
     DoRemoveAllStatModifiers(id);
     DoAddApplyStatModifier(id, stats);
     if (updateComponents)
         UpdateStatComponents();
 }