private void Effect()
    {
        List <BuildingAI> affectedBuildings = new List <BuildingAI>();
        int distanceSqrt = this.Scope * this.Scope;

        Vector2      targetPosition = (Vector2)this.transform.position;
        TilePosition targetTile     = PositionConvertor.GetActorTileIndexFromWorldPosition(this.transform.position);
        int          radius         = Mathf.CeilToInt(this.Scope / (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                    ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));

        List <TilePosition> affectedTiles = RoundHelper.FillCircle(targetTile.Column, targetTile.Row, radius);

        foreach (TilePosition tile in affectedTiles)
        {
            if (tile.IsValidActorTilePosition())
            {
                Vector2 p   = (Vector2)PositionConvertor.GetWorldPositionFromActorTileIndex(tile);
                Vector2 dis = p - targetPosition;
                if (dis.sqrMagnitude <= distanceSqrt)
                {
                    GameObject building = BattleMapData.Instance.GetBulidingObjectFromActorObstacleMap(tile.Row, tile.Column);
                    if (building != null)
                    {
                        BuildingAI ai = building.GetComponent <BuildingAI>();
                        if (ai != null && !affectedBuildings.Contains(ai))
                        {
                            affectedBuildings.Add(ai);
                            ai.SetTarget(this.gameObject, (Vector2)this.transform.position);
                        }
                    }
                }
            }
        }
    }
    protected override void CalculateLightPositions(GameObject target, int targetRow, int targetColumn)
    {
        base.CalculateLightPositions(target, targetRow, targetColumn);
        IObstacleInfo property = this.m_MapData.GetObstacleInfoFormActorObstacleMap(targetRow, targetColumn);

        int radius = Mathf.FloorToInt(m_AttackScope /
                                      Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));

        radius = Mathf.Max(0, radius - 1);
        foreach (TilePosition offset in property.ActorObstacleList)
        {
            TilePosition targetPosition = property.ActorPosition + offset;

            List <TilePosition> destinationTiles = RoundHelper.FillCircle(targetPosition.Column, targetPosition.Row, radius);
            foreach (TilePosition lightPosition in destinationTiles)
            {
                if (lightPosition.IsValidActorTilePosition())
                {
                    if (!this.m_PreviousTargetLightPositions.Contains(lightPosition.Column + (lightPosition.Row << 16)))
                    {
                        this.m_PreviousTargetLightPositions.Add(lightPosition.Column + (lightPosition.Row << 16));
                    }
                }
            }
        }
    }
    // Use this for initialization
    void Start()
    {
//		this.m_DetectScopeSqr = this.m_DetectScope * this.m_DetectScope;
        this.m_DetectScopeList = RoundHelper.FillCircle(0, 0, Mathf.FloorToInt(this.m_DetectScope /
                                                                               Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                         ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height)));
    }
    protected override void Calculate()
    {
        TilePosition        affectPosition = PositionConvertor.GetActorTileIndexFromWorldPosition(this.DestinationObject.GetDestinationPosition(this.transform.position));
        List <TilePosition> affectedTiles  = RoundHelper.FillCircle
                                                 (affectPosition.Column, affectPosition.Row, Mathf.CeilToInt(this.DamageScope /
                                                                                                             (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height,
                                                                                                                              ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width)));

        foreach (TilePosition tile in affectedTiles)
        {
            if (tile.IsValidActorTilePosition())
            {
                List <GameObject> characters = BattleMapData.Instance.ActorArray[tile.Row, tile.Column];
                foreach (GameObject character in characters)
                {
                    CharacterPropertyBehavior property = character.GetComponent <CharacterPropertyBehavior>();
                    if (property.CharacterType == CharacterType.Invader)
                    {
                        //float distance = Vector2.Distance((Vector2)this.transform.position, (Vector2)character.transform.position);

                        //float percentage = (1 - distance) / this.m_GroupDamageScope;
                        //percentage = Mathf.Max(percentage, 0);

                        CharacterHPBehavior hpBehavior = character.GetComponent <CharacterHPBehavior>();
                        hpBehavior.DecreaseHP(this.Damage, this.AttackCategory);

                        this.PushCharacter(character);
                    }
                }
            }
        }
    }
    public List <GameObject> GetNearByBuilding(Vector3 position, int scope)
    {
        List <GameObject> result = new List <GameObject>();
        int distanceSqrt         = scope * scope;

        TilePosition tilePosition = PositionConvertor.GetActorTileIndexFromWorldPosition(position);
        int          radius       = Mathf.CeilToInt(scope / (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                             ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));
        List <TilePosition> affectedTiles = RoundHelper.FillCircle(tilePosition.Column, tilePosition.Row, radius);

        foreach (TilePosition tile in affectedTiles)
        {
            if (tile.IsValidActorTilePosition())
            {
                Vector2 p   = (Vector2)PositionConvertor.GetWorldPositionFromActorTileIndex(tile);
                Vector2 dis = p - (Vector2)position;
                if (dis.sqrMagnitude <= distanceSqrt)
                {
                    GameObject building = BattleMapData.Instance.GetBulidingObjectFromActorObstacleMap(tile.Row, tile.Column);
                    if (building != null && !result.Contains(building) && building.GetComponent <BuildingHPBehavior>() != null)
                    {
                        result.Add(building);
                    }
                }
            }
        }
        return(result);
    }
 public virtual void Start()
 {
     this.m_AttackConfig     = this.GetComponent <AttackConfig>();
     this.m_AttackScopeSqr   = this.AttackScope * this.AttackScope;
     this.m_AttackScopeArray = RoundHelper.FillCircle(0, 0, Mathf.CeilToInt(this.AttackScope /
                                                                            Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                      ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height)));
 }
    private List <TilePosition> GetTilePositionList(int scope)
    {
        TilePosition actorPosition = PositionConvertor.GetActorTileIndexFromWorldPosition
                                         (this.m_Property.AnchorTransform.position);
        int radius = Mathf.CeilToInt(scope / (float)Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                              ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));

        return(RoundHelper.FillCircle(actorPosition.Column, actorPosition.Row, radius));
    }
    public override void Start()
    {
        base.Start();

        List <TilePosition> blindArray = RoundHelper.FillCircle(0, 0, Mathf.FloorToInt(this.m_BlindScope /
                                                                                       Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width,
                                                                                                 ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height)));

        foreach (TilePosition b in blindArray)
        {
            this.AttackScopeArray.Remove(b);
        }
    }
Exemple #9
0
    private void NotifyNearbyInvader()
    {
        Vector3      anchorPosition = this.m_BaseProperty.AnchorTransform.position;
        TilePosition center         = PositionConvertor.GetActorTileIndexFromWorldPosition(anchorPosition);
        int          tileRadius     = Mathf.CeilToInt(this.m_NotifyRadius /
                                                      Mathf.Min(ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.width, ClientSystemConstants.ACTOR_TILE_MAP_TILE_SIZE.height));
        List <TilePosition> points = RoundHelper.FillCircle(center.Column, center.Row, tileRadius);

        List <GameObject> actors = this.SceneHelper.GetActors(points, TargetType.Ground);

        foreach (GameObject actor in actors)
        {
            CharacterPropertyBehavior property = actor.GetComponent <CharacterPropertyBehavior>();
            if (property.CharacterType == CharacterType.Invader)
            {
                Vector2 dist = (Vector2)(anchorPosition - actor.transform.position);
                if (this.m_NotifyRadiusSqr >= Vector2.SqrMagnitude(dist))
                {
                    actor.GetComponent <CharacterAI>().SetIdle(false);
                }
            }
        }
    }