public void Configure(IEntity entity)
        {
            Entity = (GridEntity)entity;



            // drop abilities we can't use because of stat requirements or stats consumed on using the ability our side of range
            // ie requirement level 14, strength 25   , consumer = 25 mana
            _actions.ToList().ForEach((action) =>
            {
                action.Requirements.ForEach((requirement) =>
                {
                    if (!Entity.Stats.Any(s => s.Name == requirement.Name && s.Base >= requirement.Min && s.Base <= requirement.Max))
                    {
                        _actions.Remove(action);
                    }
                });

                action.Modifiers.Where(m => m.TargetType == ModifierTargetTypes.Caster).ToList().ForEach((consumer) =>
                {
                    if (!Entity.BaseStatAtLeast(consumer))
                    {
                        _actions.Remove(action);
                    }
                });
            });

            // cache/categorize some generic spell types
            _actionsDmg  = _actions.Where(a => a.Modifiers.Any(m => m.TargetType == ModifierTargetTypes.Other && m.Name == "health" && m.Min < 0)).ToList();
            _actionsHeal = _actions.Where(a => (a.TargetType == TargetTypes.Self || a.TargetType == TargetTypes.Friend || a.TargetType == TargetTypes.FriendArea) &&
                                          a.Modifiers.Any(m => m.Name == "health" && m.TargetType == ModifierTargetTypes.Other && m.Min > 0)).ToList();
        }
Example #2
0
    public void UpdateEntity(GridEntity entity)
    {
        var lastPos    = lastPositions.ContainsKey(entity) ? lastPositions[entity] : Outside;
        var currentPos = GetPositionInGrid(entity.gameObject.transform.position);

        //Misma posición, no necesito hacer nada
        if (lastPos.Equals(currentPos))
        {
            return;
        }

        //Lo "sacamos" de la posición anterior
        if (IsInsideGrid(lastPos))
        {
            buckets[lastPos.Item1, lastPos.Item2].Remove(entity);
        }

        //Lo "metemos" a la celda nueva, o lo sacamos si salio de la grilla
        if (IsInsideGrid(currentPos))
        {
            buckets[currentPos.Item1, currentPos.Item2].Add(entity);
            lastPositions[entity] = currentPos;
        }
        else
        {
            lastPositions.Remove(entity);
        }
    }
        public MainMenuScreen(OnScreenChanged screenChanged) : base(screenChanged)
        {
            UserInterfaceLoader uiLoader   = UserInterfaceLoader.GetInstance();
            TileLoader          tileLoader = TileLoader.GetInstance();

            tileBrick1Sprite = tileLoader.Get("brick1");
            titleSprite      = uiLoader.Get("title");
            newGameSprite    = uiLoader.Get("newGame");
            loadGameSprite   = uiLoader.Get("loadGame");
            sandboxSprite    = uiLoader.Get("sandbox");
            adventureSprite  = uiLoader.Get("adventure");

            title           = new StaticEntity("Title Card", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 2), titleSprite);
            newGameButton   = new StaticEntity("New Game Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 11 / 2), newGameSprite);
            loadGameButton  = new StaticEntity("Load Game Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 8), loadGameSprite);
            sandboxButton   = new StaticEntity("Sandbox Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 21 / 2), sandboxSprite);
            adventureButton = new StaticEntity("Achievements Button", new Vector2(GameConstants.WINDOW_WIDTH / 2, GameConstants.TILE_SIZE * 13), adventureSprite);

            for (int i = 0; i < GameConstants.TILES_WIDE; i++)
            {
                for (int j = 0; j < GameConstants.TILES_HIGH + 1; j++) //The +1 allows us to cover the action bar
                {
                    Vector2    tileLocation = new Vector2(i * GameConstants.TILE_SIZE + GameConstants.TILE_SIZE / 2, j * GameConstants.TILE_SIZE + GameConstants.TILE_SIZE / 2);
                    GridEntity newTile      = new GridEntity("Tile", i, j, 0, tileLocation, GameConstants.TILE_SIZE, tileBrick1Sprite);
                    menuBackground.Add(newTile);
                }
            }
        }
Example #4
0
    public void SelectEntity(GridEntity gridEntity)
    {
        if (selectedBoardFightCreature != null)
        {
            // The currently selected fight creature will be unselected
            selectedFightCreatureMoveSet.Clear();
            UnselectSelectedFightCreature();
        }

        if (gridEntity != null)
        {
            if (gridEntity is FightCreature)
            {
                selectedBoardFightCreature = gridEntity as FightCreature;
                GlobalGameManager.Instance.fightPanels.OnSelectedBoardEntity(selectedBoardFightCreature);
                ProcessSelectedCreature();
            }
            else
            {
                Debug.LogWarning("Warning: entity of type " + gridEntity + " selected but only FightCreature supported by FightManager");
            }
        }
        else
        {
        }
    }
Example #5
0
 private List <AttackReaction> TriggerAttackReaction(GridEntity attacker)
 {
     return(currentReactions
            .Where(reaction => reaction is AttackReaction && reaction.ReactsTo(attacker))
            .Select(reaction => (AttackReaction)reaction)
            .ToList());
 }
Example #6
0
        private void AddEntity(GridEntity entity, Vector3 vector)
        {
            Debug.Assert(entity.Map == null);

            ActivateGrid(entity, vector);
            AddEntity(GetGrid(vector), entity, vector);
        }
Example #7
0
        /// <summary>
        /// Handles all entity placements
        /// </summary>
        private void HandleEntityInteraction()
        {
            var hits = Physics2D.RaycastAll(Camera.main.ScreenToWorldPoint(Input.mousePosition), Vector2.zero, 15);

            if (hits.Length == 0)
            {
                return;
            }

            MapGrid grid     = null;
            Vector2 mousePos = new Vector2();

            foreach (var hit in hits)
            {
                var tryGrid = hit.collider.gameObject.GetComponent <MapGrid>();
                if (tryGrid)
                {
                    grid     = tryGrid;
                    mousePos = hit.point;
                }
            }

            // Handles  phantom movement
            if (this.HoldingPhantom != null)
            {
                this.HoldingPhantom.transform.position = mousePos;
            }

            if (Input.GetMouseButtonUp(0))
            {
                // If the mouse indeed clicked a grid
                if (grid != null)
                {
                    // If the player is actually holding onto something
                    if (this.HoldingEntity != null && this._isMoving)
                    {
                        if (grid.TryAddEntity(this.HoldingEntity, mousePos))
                        {
                            this.HoldingEntity.gameObject.SetActive(true);
                            this.HoldingEntity.OnMove();

                            if (this.HoldingPhantom != null)
                            {
                                Destroy(this.HoldingPhantom.transform.gameObject);
                            }

                            this._isMoving     = false;
                            this.HoldingEntity = null;
                        }
                    }
                    else
                    {
                        // Not holding anything, instead pick up the item that was placed there
                        this.HoldingEntity = grid.GetEntityAtPosition(mousePos);
                        this._isHeldOnGrid = true;
                    }
                }
            }
        }
Example #8
0
    public void MakeAttack(GridEntity target)
    {
        currentAttacks--;
        var calculatedDamage = (damage + damageModify) * damageMult;

        if (target.totalFearValue >= target.fearThreshold)
        {
            calculatedDamage *= 2;
        }
        var triggeredReactions = target.TriggerAttackReaction(this);

        void ResolveDefaultAttack()
        {
            target.TakeDamage(calculatedDamage);
            Debug.Log(String.Format("<color=blue>{0}</color> attacked <color=red>{1}</color> for <color=yellow>{2} damage</color>.",
                                    this.entityName,
                                    target.entityName,
                                    calculatedDamage
                                    ));
            Debug.Log(String.Format("<color=red>{0}</color> has <color=yellow>{1} health</color> remaining.",
                                    target.entityName,
                                    target.currentHP
                                    ));
        }

        if (triggeredReactions.Count() > 0)
        {
            triggeredReactions.ForEach(reaction => {
                var useDefaultAttackResolution = reaction.ResolveAttack(this, target);
                if (useDefaultAttackResolution)
                {
                    ResolveDefaultAttack();
                }
            });
        }
        else
        {
            ResolveDefaultAttack();
        }
        if (currentAttacks <= 0)
        {
            outOfAttacks = true;
        }
        if (currentAttackSkill != null)
        {
            UseSkill(currentAttackSkill);
        }

        var attackAnim = DOTween.Sequence();

        attackAnim.Append(transform.DOMove(target.transform.position, .2f));
        // this uses the tile.transform, because the actual entity's position has not been updated at the time of this reference
        attackAnim.Append(transform.DOMove(this.tile.transform.position, .2f));
        turnAnimSequence.Append(attackAnim);

        DOTween.Sequence()
        .PrependInterval(attackAnim.Duration())
        .Append(target.transform.DOShakePosition(duration: .3f, strength: (calculatedDamage * .25f)));
    }
        public GridEntity <Common_Department> GetDepartmentSummary(GridOptions options)
        {
            var Department = new GridEntity <Common_Department>();

            Department = KendoGrid <Common_Department> .GetGridData_5(options, "sp_Select_Department_Grid", "get_Department_summary", "DepartmentName");

            return(Department);
        }
Example #10
0
        public GridEntity <Color> GetColorInfoSummary(GridOptions options)
        {
            var color = new GridEntity <Color>();

            color = KendoGrid <Color> .GetGridData_5(options, "sp_select_color_grid", "get_color_summary", "ColorId");

            return(color);
        }
Example #11
0
 public void OnEntityEnters(GridEntity entity)
 {
     if (gridEntity != null)
     {
         Debug.LogError("Error: Entity " + entity + " trying to enter grid spot but there was already entity " + gridEntity, gameObject);
     }
     gridEntity = entity;
 }
Example #12
0
 public void OnEntityLeave(GridEntity entity)
 {
     if (gridEntity != entity)
     {
         Debug.LogError("Error: entity " + entity + " trying to leave grid spot but grid spot entity was " + gridEntity, gameObject);
     }
     gridEntity = null;
 }
Example #13
0
        public GridEntity <Buyer> GetBuyerInfoSummary(GridOptions options)
        {
            var buyer = new GridEntity <Buyer>();

            buyer = KendoGrid <Buyer> .GetGridData_5(options, "sp_select_buyer_grid", "get_buyer_summary", "BuyerName");

            return(buyer);
        }
Example #14
0
        public GridEntity <Yarn> GetYarnInfoSummary(GridOptions options)
        {
            var yarn = new GridEntity <Yarn>();

            yarn = KendoGrid <Yarn> .GetGridData_5(options, "sp_select_yarn_grid", "get_yarn_summary", "YarnName");

            return(yarn);
        }
        public GridEntity <Common_Designation> GetDesignationSummary(GridOptions options)
        {
            var Designation = new GridEntity <Common_Designation>();

            Designation = KendoGrid <Common_Designation> .GetGridData_5(options, "sp_Select_Designation_Grid", "get_Designation_summary", "DesignationName");

            return(Designation);
        }
Example #16
0
    public void Move(GridEntity entity, Vector3 direction)
    {
        Vector2 pos    = GetPosition(entity);
        Vector2 target = pos + new Vector2(direction.x, -direction.z);

        grid[(int)pos.y, (int)pos.x].PassOccupant(grid[(int)target.y, (int)target.x]);
        entity.Move(new Vector3(direction.x, 0, direction.z));
    }
Example #17
0
        public GridEntity <Supplier> GetSupplierInfoSummary(GridOptions options)
        {
            var Supplier = new GridEntity <Supplier>();

            Supplier = KendoGrid <Supplier> .GetGridData_5(options, "sp_select_Supplier_grid", "get_Supplier_summary", "SupplierName");

            return(Supplier);
        }
        public GridEntity <Common_DesignationGroup> GetDesignationGroupSummary(GridOptions options)
        {
            var DesignationGroup = new GridEntity <Common_DesignationGroup>();

            DesignationGroup = KendoGrid <Common_DesignationGroup> .GetGridData_5(options, "sp_Select_DesignationGroup_Grid", "get_DesignationGroup_summary", "DesGroupName");

            return(DesignationGroup);
        }
Example #19
0
        public GridEntity <Common_Company> GetCompanySummary(GridOptions options)
        {
            var Company = new GridEntity <Common_Company>();

            Company = KendoGrid <Common_Company> .GetGridData_5(options, "sp_Select_Company_Grid", "get_Company_summary", "CompanyName");

            return(Company);
        }
Example #20
0
        public GridEntity <R_DeptSection> GetDeptSectionSummary(GridOptions options)
        {
            var Wing = new GridEntity <R_DeptSection>();

            Wing = KendoGrid <R_DeptSection> .GetGridData_5(options, "sp_Select_Unit_Department_Section_Grid", "get_Unit_Department_Section_Summary", "SectionName");

            return(Wing);
        }
Example #21
0
        public GridEntity <Common_Wing> GetWingSummary(GridOptions options)
        {
            var Wing = new GridEntity <Common_Wing>();

            Wing = KendoGrid <Common_Wing> .GetGridData_5(options, "sp_Select_Wing_Grid", "get_Wing_summary", "WingName");

            return(Wing);
        }
Example #22
0
        public GridEntity <Common_Unit> GetUnitSummary(GridOptions options)
        {
            var Unit = new GridEntity <Common_Unit>();

            Unit = KendoGrid <Common_Unit> .GetGridData_5(options, "sp_Select_Unit_Grid", "get_Unit_summary", "UnitName");

            return(Unit);
        }
        public GridEntity <Payroll_AllowanceByDesGroup> GetAllowanceByDesGroupSummary(GridOptions options)
        {
            var AllowanceByDesGroup = new GridEntity <Payroll_AllowanceByDesGroup>();

            AllowanceByDesGroup = KendoGrid <Payroll_AllowanceByDesGroup> .GetGridData_5(options, "sp_Select_AllowanceByDesGroup_Grid", "get_AllowanceByDesGroup_summary", "DesGroupName");

            return(AllowanceByDesGroup);
        }
Example #24
0
 public override int CalculateFear(GridEntity entity)
 {
     if (entity.currentHP == 0)
     {
         return(0);
     }
     return(Mathf.CeilToInt(Mathf.Pow(1 / ((float)entity.currentHP / entity.maxHP), 2)));
 }
Example #25
0
        public GridEntity <R_SecWing> GetSectionWingSummary(GridOptions options)
        {
            var Team = new GridEntity <R_SecWing>();

            Team = KendoGrid <R_SecWing> .GetGridData_5(options, "sp_Select_Unit_Department_Section_Team_Grid", "get_Unit_Department_Section_Wing_Summary", "SectionName");

            return(Team);
        }
        public GridEntity <Order> GetOrderInfoSummary(GridOptions options)
        {
            var order = new GridEntity <Order>();

            order = KendoGrid <Order> .GetGridData_5(options, "sp_select_order_grid", "get_order_summary", "OrderId");

            return(order);
        }
Example #27
0
        public GridEntity <Common_Team> GetTeamSummary(GridOptions options)
        {
            var Team = new GridEntity <Common_Team>();

            Team = KendoGrid <Common_Team> .GetGridData_5(options, "sp_Select_Team_Grid", "get_Team_summary", "TeamName");

            return(Team);
        }
Example #28
0
        public GridEntity <Common_Shift> GetShiftSummary(GridOptions options)
        {
            var Shift = new GridEntity <Common_Shift>();

            Shift = KendoGrid <Common_Shift> .GetGridData_5(options, "sp_Select_Shift_Grid", "get_Shift_summary", "ShiftName");

            return(Shift);
        }
Example #29
0
 IEnumerable <System.Tuple <GridEntity, float> > GetNeighbours(GridEntity n)
 {
     return(n.neighbours.Aggregate(new List <System.Tuple <GridEntity, float> >(), (acum, current) =>
     {
         acum.Add(System.Tuple.Create(current, 1f));
         return acum;
     }));
 }
Example #30
0
 public static List <Behavior> ToBehaviors(this List <string> behaviorNames, GridEntity entity)
 {
     return(behaviorNames.Select(name => {
         var behavior = behaviorNameToBehavior[name]();
         behavior.entity = entity;
         return behavior;
     }).ToList());
 }
Example #31
0
        private static void InitializeGridDataStructure()
        {
            GridRect = new Rectangle(OffsetX + BorderLineWidth, OffsetY + BorderLineWidth, GridSheetWidth, GridSheetHeight);
            GridBox = new GridEntity[CountX, CountY];

            for (int y = 0; y < CountY; y++)
            {
                for (int x = 0; x < CountX; x++)
                {
                    int gridLocalMinX = GridSize * x + OffsetX;
                    int gridLocalMinY = GridSize * y + OffsetY;
                    Rectangle gridRect = new Rectangle(gridLocalMinX + BorderLineWidth, gridLocalMinY + BorderLineWidth, GridSize, GridSize);
                    GridBox[x, y] = new GridEntity(gridRect, GridBoxType.None, GridStatus.Vacant, false, false);
                }
            }
        }