Exemplo n.º 1
0
        float StraightDistance(Tile a, Tile b)
        {
            Vector2 A      = HexMap.ToScreenLocation(a.MapCoord);
            Vector2 B      = HexMap.ToScreenLocation(b.MapCoord);
            float   dist   = Vector2.Distance(A, B);
            float   result = dist / HexMap.TileHeight;

            result = (float)Math.Round(result, 1);
            //float result = Vector2.Distance(A, B) / HexMap.TileHeight;
            return(result);
        }
Exemplo n.º 2
0
        //--------------------------Constructors------------------------------------ //---------------------------------------------------muista että tuki useammalle maalille on!
        public Creature(HexMap map, string creatureType, int spawnPointIndex, int goalPointIndex, Texture2D texture)
        {
            ParentGame      = map.ParentGame;
            ParentMap       = map;
            OrigPath        = new List <Vector2>();
            Type            = creatureType;
            SpawnPointIndex = spawnPointIndex;
            GoalPointIndex  = goalPointIndex;
            Location        = map.SpawnPoints.Length > 0 ? map.ToScreenLocation(map.SpawnPoints[spawnPointIndex]) : Vector2.Zero;
            nextWaypoint    = 1;

            Spritesheet     = texture;
            SpriteScale     = 1f;
            SpritesheetRows = 1;
            if (texture != null)
            {
                SpritesheetColumns = texture.Width / texture.Height <= 1 ? 1 : texture.Width / texture.Height;
            }
            totalFrames     = SpritesheetRows * SpritesheetColumns;
            animationCycles = 30;
            //Angle = (float)Math.Atan2(PosY - Path[nextWaypoint].Y, PosX - Path[nextWaypoint].X);
            //Angle = AnglesBetweenWaypoints[0]; //------------------------------------------------------fix
            //AngleOffset = (float)Math.PI;
            Origin     = texture != null ? new Vector2(Width / 2, Height / 2) : Vector2.Zero;
            Alive      = false;
            LifeDmg    = 1;
            hpBarWidth = 25;
            spin       = (float)(ParentMap.rnd.NextDouble() - 0.5f) * 0.08f;

            TowersTargetingThis = new List <Tower>();
            CurrentSlowEffect   = new float[2];
            DmgHeadedThisWay    = new List <KeyValuePair <uint, int> >();

            ElemArmors = new GeneSpecs();

            HpBarColor = new Color(0, 255, 0);
        }