Example #1
0
 protected override void Update(ActiveEntity e)
 {
     if (e.CurrentPath == null || e.CurrentPath.Count == 0)
     {
         Complete();
     }
 }
Example #2
0
 // Use this for initialization
 void Awake()
 {
     if (playerStats_ == null)
     {
         playerStats_ = GetComponent <ActiveEntity>();
     }
 }
Example #3
0
        public ForgingMachineViewModel(UserInformation userInformation, string entityPrimaryKey)
        {
            bll          = new ForgingMachine(userInformation);
            ActiveEntity = bll.GetEntityByCode(new DDFORGING_MAC()
            {
                COST_CENT_CODE = entityPrimaryKey
            });
            if (!ActiveEntity.IsNotNullOrEmpty())
            {
                ActiveEntity = new DDFORGING_MAC()
                {
                    COST_CENT_CODE = entityPrimaryKey
                };
            }

            MachineTypes = bll.GetForgingMachineTypesByID();
            if (ActiveEntity.MACHINE_TYPE.ToValueAsString().Trim() != "")
            {
                SelectedRow             = new ForgingMachineTypes();
                SelectedRow.DESCRIPTION = ActiveEntity.MACHINE_TYPE;
                for (int ictr = 0; ictr <= MachineTypes.Count - 1; ictr++)
                {
                    if (ActiveEntity.MACHINE_TYPE.Trim() == MachineTypes[ictr].DESCRIPTION.Trim())
                    {
                        SelectedIndexType = ictr;
                        NotifyPropertyChanged("SelectedIndexType");
                    }
                }
            }
            else
            {
                SelectedIndexType = -1;
            }
        }
Example #4
0
    // Use this for initialization
    void Start()
    {
        player_      = FindObjectOfType <PlayerController>();
        playerStats_ = player_.playerStats_;

        UpdateSkills();
    }
        private void AssignHudLayers(ActiveEntity EntityToRender)
        {
            switch (EntityToRender.CurrentRenderLayer)
            {
            case 1:
                RenderSprites.AddToLayer(RenderSprites.HudLayer1, EntityToRender.Graphic);
                break;

            case 2:
                RenderSprites.AddToLayer(RenderSprites.HudLayer2, EntityToRender.Graphic);
                break;

            case 3:
                RenderSprites.AddToLayer(RenderSprites.HudLayer3, EntityToRender.Graphic);
                break;

            case 4:
                RenderSprites.AddToLayer(RenderSprites.HudLayer4, EntityToRender.Graphic);
                break;

            case 5:
                RenderSprites.AddToLayer(RenderSprites.HudLayer5, EntityToRender.Graphic);
                break;

            default:
                RenderSprites.AddToLayer(RenderSprites.HudLayer1, EntityToRender.Graphic);
                break;
            }
        }
Example #6
0
 protected override void OnCancel(ActiveEntity e)
 {
     if (e.IsPlottingPath)
     {
         e.CancelPathPlot();
     }
     e = null;
 }
Example #7
0
 /// <summary>
 ///
 /// </summary>
 protected void onAttributeChange()
 {
     if (ActiveEntity != null)
     {
         ActiveEntity.UpdateParents();
     }
     this.IsModify = true;
 }
Example #8
0
 /// <summary>
 /// Important to call!
 /// </summary>
 protected override void OnCancel(ActiveEntity e)
 {
     // Cancel currently active task.
     if (CurrentSubTask != null)
     {
         CurrentSubTask.Cancel(e);
     }
 }
Example #9
0
 public PerformActionEvent(ActiveEntity entity, string tag, float[] floatArgs, int[] intArgs, string[] stringArgs, Vector3[] vector3Args)
 {
     this.entity = entity;
     this.tag = tag;
     this.floatArgs = floatArgs;
     this.intArgs = intArgs;
     this.stringArgs = stringArgs;
     this.vector3Args = vector3Args;
 }
Example #10
0
 public PerformActionEvent(ActiveEntity entity, string tag, string[] stringArgs)
 {
     this.entity = entity;
     this.tag = tag;
     this.vector3Args = new Vector3[0];
     this.floatArgs = new float[0];
     this.intArgs = new int[0];
     this.stringArgs = stringArgs;
 }
Example #11
0
        protected override void OnStart(ActiveEntity e)
        {
            Vector2 position = e.Center + Offset;
            var     dropped  = new DroppedItem(ItemStack);

            dropped.Center = position;

            ItemStack.Data = null;
            Complete();
        }
Example #12
0
        protected override void Update(ActiveEntity e)
        {
            e.Destroy();
            if (!e.RemovePending)
            {
                Debug.Warn($"Destroy task ran on entity {e} but it's removal from world is not pending... Is the entity a destructible type, or is it in some other way prevented from being destroyed?");
            }

            Complete();
        }
Example #13
0
        public void Cancel(ActiveEntity e)
        {
            if (State != TaskState.Running)
            {
                Debug.Error($"Cannot cancel task when it is in the {State} state. It must be in the Running state.");
                return;
            }

            State = TaskState.Cancelled;
            OnCancel(e);
        }
Example #14
0
        public void Start(ActiveEntity e)
        {
            if (State != TaskState.Idle)
            {
                Debug.Error($"Cannot start a task when it is in the {State} state. It must be in the Idle state.");
                return;
            }

            State = TaskState.Running;
            OnStart(e);
        }
Example #15
0
    void Start()
    {
        ActiveEntity.ResetCount();
        EventManager.TriggerEvent(cEvents.INVOKE_CHARACTER, new CharacterInvokerTag()
        {
            Character = cCards.RedBeetle, X = -3, Y = 8
        });

        // When the user clicks on a tile
        EventManager.StartListening(cEvents.USER_SEND_TILE, OnUSER_SEND_TILE);
    }
Example #16
0
        private void PushBackEntity(ActiveEntity entity)
        {
            for (var i = _activeEntities.Length - 1; i > 0; i--)
            {
                _activeEntities[i] = _activeEntities[i - 1];
            }

            _activeEntities[0] = entity;

            _activeEntityCount = Math.Min(_activeEntityCount + 1, _activeEntities.Length);
        }
Example #17
0
 /// <summary>
 ///
 /// </summary>
 protected void onAttributeValueChange()
 {
     Kernel.Domain.Attribute attribute = attributeTreeList.GetSelectedValue();
     if (ActiveEntity != null && attribute != null)
     {
         attributeTreeList.ForgetDefaultAttributes(attribute);
         attribute.UpdateParents();
         ActiveEntity.UpdateParents();
         attributeTreeList.AddDefaultAttributes(attribute);
     }
     this.IsModify = true;
 }
Example #18
0
        protected override void Update(ActiveEntity e)
        {
            TimeRemaining -= UseUnscaledTime ? Time.unscaledDeltaTime : Time.deltaTime;
            Progress       = 1f - (TimeRemaining / TotalTime);
            if (TimeRemaining <= 0f)
            {
                TimeRemaining = 0f;
                Progress      = 1f;

                // Done!
                Complete();
            }
        }
Example #19
0
    public IEnumerator SkillWaiter(PlayerSkill skill, int targetLevel, ActiveEntity target)
    {
        int currentTurn = TurnManager._Instance.totalTurnCount;
        int targetTurn  = skill.turnDuration_ + currentTurn;

        if (skill.turnDuration_ < 0)   // Skills with negative lengths are permanent!
        {
            yield break;
        }

        yield return(new WaitUntil(() => TurnManager._Instance.totalTurnCount >= targetTurn));

        skill.DeactivateSkill(target, targetLevel);
    }
Example #20
0
        private void copyMandatoryFieldsToEntity(PartNumberConfigurationModel mandatoryFields)
        {
            if (!ActiveEntity.IsNotNullOrEmpty() || !mandatoryFields.IsNotNullOrEmpty())
            {
                return;
            }


            ActiveEntity.Code          = mandatoryFields.Code;
            ActiveEntity.Description   = mandatoryFields.Description;
            ActiveEntity.Location_code = mandatoryFields.Location_code;
            ActiveEntity.Prefix        = mandatoryFields.Prefix;
            ActiveEntity.BeginningNo   = mandatoryFields.BeginningNo;
            ActiveEntity.EndingNo      = mandatoryFields.EndingNo;
        }
Example #21
0
 public void DeactivateSkill(ActiveEntity target, int targetLevel)
 {
     // Remove the buffs according to the level they had when they were given
     target.health_         -= Health(targetLevel);
     target.dodge_          -= Dodge(targetLevel);
     target.attackRating_   -= AttackRating(targetLevel);
     target.criticalChance_ -= CriticalChance(targetLevel);
     target.damage_         -= Damage(targetLevel);
     target.armor_          -= Armor(targetLevel);
     target.armorPiercing_  -= AP(targetLevel);
     target.speed_          -= Speed(targetLevel);
     target.energy_         -= Energy(targetLevel);
     // Update UI
     MainUIManager.instance_.UpdateUI();
 }
Example #22
0
        /// <summary>
        /// Important to call!
        /// </summary>
        /// <param name="e"></param>
        protected override void Update(ActiveEntity e)
        {
            if (CurrentSubTask != null)
            {
                switch (CurrentSubTask.State)
                {
                case TaskState.Idle:
                    CurrentSubTask.Start(e);
                    CurrentSubTask.InternalUpdate(e);
                    break;

                case TaskState.Running:
                    CurrentSubTask.InternalUpdate(e);
                    break;

                case TaskState.Cancelled:
                    // Since all tasks need to be completed in order, this global task must also cancel.
                    this.Cancel(e);
                    break;

                case TaskState.Completed:
                    // Set as no longer active and don't place it back into the queue.
                    CurrentSubTask = null;
                    CompletedTaskCount++;
                    break;
                }
            }
            if (CurrentSubTask == null)
            {
                // Try to take a new one from the queue.
                if (QueuedTaskCount != 0)
                {
                    CurrentSubTask = subTasks[0];
                    subTasks.RemoveAt(0);
                }
                else
                {
                    Complete();
                }
            }

            // Update progress.
            float perTask  = 1f / TotalTaskCount;
            float progress = perTask * CompletedTaskCount;

            progress     += CurrentSubTask == null ? 0f : CurrentSubTask.Progress * perTask;
            this.Progress = progress;
        }
Example #23
0
    public IEnumerator Attack(EnemyController enemy)
    {
        Debug.Log("Player is Attacking " + enemy.gameObject.name);
        isMoving_ = true;
        ActiveEntity enemyStats = enemy.GetComponentInParent <ActiveEntity>();

        // Attempt attack!
        float attackRoll  = Random.Range(0f, 1f);
        int   damage      = playerStats_.damage_;
        int   armorPierce = playerStats_.armorPiercing_;

        // Critical hit?!
        if (enemyStats.AttemptCritical(attackRoll, playerStats_.criticalChance_))
        {
            damage     *= 2;
            armorPierce = (armorPierce + 1) * 2;
            enemyStats.AttemptDoDamage(damage, armorPierce);
            characterAnimator_.SetTrigger("Critical");
            enemy.characterAnimator_.SetTrigger("Stumble");
            player_Attack.Invoke(enemy, "Critical");
        }
        else
        {
            if (!enemyStats.AttemptDodge(attackRoll + playerStats_.attackRating_))
            {
                enemyStats.AttemptDoDamage(damage, armorPierce);
                characterAnimator_.SetTrigger("Swing");
                enemy.characterAnimator_.SetTrigger("Stumble");
                player_Attack.Invoke(enemy, "Hit");
            }
            else
            {
                characterAnimator_.SetTrigger("Swing");
                enemy.characterAnimator_.SetTrigger("Dodge");
                player_Attack.Invoke(enemy, "Dodge");
            }
        };
        if (enemyStats.health <= 0)
        {
            enemy.Die((playerObj_.transform.position - enemy.transform.position).normalized);
            PlayerManager.instance_.AddXP(enemyStats.reference_);
        }

        yield return(new WaitForSeconds(0.5f));

        EndTurn();
        isMoving_ = false;
    }
Example #24
0
        protected override void OnStart(ActiveEntity e)
        {
            Tile tile       = JEngine.TileMap.GetTile(X, Y, Z);
            bool basicCheck = tile.ID == ID;

            bool secondCheck = CheckAction == null ? true : CheckAction(tile, X, Y, Z);

            if (!basicCheck || !secondCheck)
            {
                Cancel(e);
            }
            else
            {
                Complete();
            }
        }
Example #25
0
 protected override void Update(ActiveEntity e)
 {
     this.e = e;
     if (!hasStarted)
     {
         e.PlotPath(new Point(DestinationX, DestinationY));
         hasStarted = true;
     }
     else
     {
         if (!e.IsPlottingPath)
         {
             Complete();
             e = null;
         }
     }
 }
Example #26
0
        protected override void Update(ActiveEntity e)
        {
            base.Update(e);

            if (CurrentSubTask != null && CurrentSubTask is Task_Wait)
            {
                Loop.AddDrawAction((spr) =>
                {
                    GameUtils.DrawProgressBar(spr, e.Center + new Vector2(0, -16), CurrentSubTask.Progress);
                });
            }

            Tile tile = JEngine.TileMap.GetTile(X, Y, 1, false, false);

            if (tile.ID != 3)
            {
                Cancel(e);
            }
        }
Example #27
0
    void Start()
    {
        if (playerObj_ == null)
        {
            playerObj_ = gameObject;
        }
        if (movementGrid_ == null)
        {
            movementGrid_ = FindObjectOfType <Grid>();
        }
        if (playerStats_ == null)
        {
            playerStats_ = GetComponent <ActiveEntity>();
        }

        rb = GetComponentInChildren <Rigidbody>();

        movementSteps_ = movementGrid_.cellSize.x + movementGrid_.cellGap.x;
    }
Example #28
0
    public void RunSkill(ActiveEntity target)
    {
        if (SkillsManager.instance_.playerStats_.energy >= energyCost_)
        {
            int currentLevel = PlayerManager.currentPlayerLevel_;
            SkillsManager.instance_.playerStats_.energy_ -= energyCost_;

            // Run the thingie
            target.health_         += Health(currentLevel);
            target.dodge_          += Dodge(currentLevel);
            target.attackRating_   += AttackRating(currentLevel);
            target.criticalChance_ += CriticalChance(currentLevel);
            target.damage_         += Damage(currentLevel);
            target.armor_          += Armor(currentLevel);
            target.armorPiercing_  += AP(currentLevel);
            target.speed_          += Speed(currentLevel);
            target.energy_         += Energy(currentLevel);
            // And start the waiter on the skillsmanager
            SkillsManager.instance_.StartCoroutine(SkillsManager.instance_.SkillWaiter(this, currentLevel, target));
            // And update UI!
            MainUIManager.instance_.UpdateUI();

            if (skipsPlayerTurn)
            {
                TurnManager._Instance.NextTurn(target);
            }
            if (moveTargetInDirection_ != Directions.NONE)
            {
                if (!moveSelf)
                {
                    target.playerController_.player_Attack.AddListener(MoveTarget);
                }
                else
                {
                    target.playerController_.player_Move.AddListener(MoveTarget);
                }
            }
        }
        ;
    }
Example #29
0
    void OnTriggerEnter(Collider coll)
    {
        bool isPlayer = false;
        bool isEnemy  = false;
        //bool isWall = false;

        ActiveEntity entity = coll.gameObject.GetComponentInParent <ActiveEntity>();

        if (entity != null)
        {
            if (triggerer_ == Triggerers.EITHER)
            {
                grid_triggered.Invoke(entity, this);
                Debug.Log("Triggered by either!");
                return;
            }

            if (entity.playerController_ != null)
            {
                isPlayer = true;
            }
            else if (entity.enemyController_ != null)
            {
                isEnemy = true;
            }
            ;
        }
        if (isPlayer && triggerer_ == Triggerers.PLAYER)
        {
            grid_triggered.Invoke(entity, this);
            Debug.Log("Player triggered!");
        }
        else if (isEnemy && triggerer_ == Triggerers.ENEMY)
        {
            grid_triggered.Invoke(entity, this);
            Debug.Log("Enemy triggered!");
        }
        ;
    }
Example #30
0
    void OnTriggerEnter(Collider coll)
    {
        //Debug.Log("Collided with " + coll.gameObject.name);
        ActiveEntity entity = coll.gameObject.GetComponentInParent <ActiveEntity>();

        if (entity != null)
        {
            if (entity.health > 0)
            {
                entity.AttemptDoDamage(999, 999);
                if (entity.playerController_ != null)
                {
                    entity.playerController_.Die(Vector3.zero);
                }
                else if (entity.enemyController_ != null)
                {
                    entity.enemyController_.Die(Vector3.zero);
                }
            }
            ;
        }
    }
Example #31
0
 public void NextTurn(ActiveEntity sender)
 {
     if (currentActive != null)
     {
         if (sender == currentActive)
         {
             currentActive.controllerActive = false;
             currentIndex_   += 1;
             totalTurnCount_ += 1;
             if (currentActive != null)
             {
                 //mainCamera_.target = currentActive.gameObject;
                 if (currentActive != playerEntity_)
                 {
                     Time.timeScale = 2f;
                 }
                 else
                 {
                     Time.timeScale = 1f;
                 };
                 currentActive.controllerActive = true;
             }
             else
             {
                 StartNewTurn();
             }
         }
         else
         {
             Debug.Log("Wrong sender attempted to end turn: " + sender.gameObject.name);
         }
     }
     else
     {
         StartNewTurn();
     };
     //Debug.Log(currentIndex_);
 }
Example #32
0
    // Use this for initialization
    void Start()
    {
        rb = GetComponentInChildren <Rigidbody>();

        if (enemyObj_ == null)
        {
            enemyObj_ = gameObject;
        }
        if (movementGrid_ == null)
        {
            movementGrid_ = FindObjectOfType <Grid>();
        }
        if (enemyStats_ == null)
        {
            enemyStats_ = GetComponent <ActiveEntity>();
        }

        player_ = FindObjectOfType <PlayerController>().playerObj_.transform;

        rb = GetComponentInChildren <Rigidbody>();

        movementSteps_ = movementGrid_.cellSize.x + movementGrid_.cellGap.x;
    }
Example #33
0
 public static void RemoveSelectableEntity(ActiveEntity t)
 {
     _list.Remove(t);
 }
Example #34
0
 public static void AddSelectableEntity(ActiveEntity t)
 {
     _list.Add(t);
 }
Example #35
0
 protected void SetEntityAndFollow(ActiveEntity entity)
 {
     ActionEntity = entity;
     ActionTransform = entity.transform;
     AIPath.target = entity.transform;
 }
Example #36
0
 /// <summary>
 /// This method essentially calls PerformAction on another ActiveEntity from this current mob.
 /// Unlike accessing PerformAction directly this method takes into account the mobs action speed
 /// i.e how fast a mob can perform an action in succession.
 /// </summary>
 /// <param name="actionEvent"></param>
 public void TryPerformAction(PerformActionEvent actionEvent, ActiveEntity otherEntity)
 {
     if (Time.time - _lastActionTime > skills.actionSpeed)
     {
         _lastActionTime = Time.time;
         otherEntity.PerformAction(actionEvent);
     }
 }
Example #37
0
 public TriggerData(Collider other, int triggerType)
 {
     this.entity = other.GetComponent<ActiveEntity>();
     this.triggerType = triggerType;
 }