| 1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495 |
- using System;
- using System.Collections.Generic;
- using UnityEngine;
- namespace BuffaloSiege
- {
- public sealed class TowerDef
- {
- public string Id, Name, Description; public int Cost; public int[] Up; public float[] Damage, Interval, Range, Splash;
- public bool Air, Pierce; public float ProjectileSpeed;
- public TowerDef(string id,string name,int cost,int[] up,float[] damage,float[] interval,float[] range,string description,float speed=520,bool air=false,bool pierce=false,float[] splash=null)
- { Id=id;Name=name;Cost=cost;Up=up;Damage=damage;Interval=interval;Range=range;Description=description;ProjectileSpeed=speed;Air=air;Pierce=pierce;Splash=splash??new float[3]; }
- }
- public sealed class EnemyDef
- {
- public string Id,Name; public float Hp,Speed,Armor,Radius; public int Gold,Leak; public bool Air,Boss;
- public EnemyDef(string id,string name,float hp,float speed,float armor,int gold,int leak,float radius,bool air=false,bool boss=false)
- {Id=id;Name=name;Hp=hp;Speed=speed;Armor=armor;Gold=gold;Leak=leak;Radius=radius;Air=air;Boss=boss;}
- }
- public sealed class ItemDef
- {
- public string Id,Name,Description;public int Price;
- public ItemDef(string id,string name,int price,string desc){Id=id;Name=name;Price=price;Description=desc;}
- }
- public sealed class MapDef
- {
- public string Id,Name; public Vector2[] Path; public Vector2 Base; public List<Vector2> Slots=new List<Vector2>(); public float Length;
- public MapDef(string id,string name,float[] points,Vector2 basePosition,int[] rows,int[] cols)
- {
- Id=id;Name=name;Base=basePosition;Path=new Vector2[points.Length/2];
- for(int i=0;i<Path.Length;i++){Path[i]=new Vector2(points[i*2],points[i*2+1]);if(i>0)Length+=Vector2.Distance(Path[i-1],Path[i]);}
- foreach(int y in rows) foreach(int x in cols)
- {var p=new Vector2(x,y);if(x>=24&&x<=406&&y>=18&&y<=580&&DistanceToPath(p)>=53&&Vector2.Distance(p,Base)>=80)Slots.Add(p);}
- }
- // Painted-road centerlines and hand-placed clearings, authored in the 430 x 600 field.
- // Sample round bends so units follow the dirt trail instead of cutting across its banks.
- public MapDef(string id,string name,float[] points,Vector2 basePosition,float[] clearings)
- {
- Id=id;Name=name;Base=basePosition;var corners=new List<Vector2>();
- for(int i=0;i<points.Length;i+=2)corners.Add(new Vector2(points[i],points[i+1]));
- var route=new List<Vector2>{corners[0]};
- for(int i=1;i<corners.Count-1;i++)
- {
- var p=corners[i];float radius=Mathf.Min(22,Vector2.Distance(p,corners[i-1])*.4f,Vector2.Distance(p,corners[i+1])*.4f);
- var a=p+(corners[i-1]-p).normalized*radius;var b=p+(corners[i+1]-p).normalized*radius;
- route.Add(a);for(int j=1;j<=8;j++){float t=j/8f;route.Add((1-t)*(1-t)*a+2*(1-t)*t*p+t*t*b);}
- }
- route.Add(corners[corners.Count-1]);Path=route.ToArray();
- for(int i=1;i<Path.Length;i++)Length+=Vector2.Distance(Path[i-1],Path[i]);
- for(int i=0;i<clearings.Length;i+=2)Slots.Add(new Vector2(clearings[i],clearings[i+1]));
- }
- public float DistanceToPath(Vector2 p)
- {
- float best=float.MaxValue;for(int i=1;i<Path.Length;i++){var a=Path[i-1];var d=Path[i]-a;var q=a+d*Mathf.Clamp01(Vector2.Dot(p-a,d)/d.sqrMagnitude);best=Mathf.Min(best,Vector2.Distance(p,q));}return best;
- }
- public Vector2 Position(float distance)
- {
- if(distance>=Length)return Path[Path.Length-1];
- distance=Mathf.Clamp(distance,0,Length);for(int i=1;i<Path.Length;i++){float len=Vector2.Distance(Path[i-1],Path[i]);if(distance<=len)return Vector2.Lerp(Path[i-1],Path[i],distance/len);distance-=len;}return Path[Path.Length-1];
- }
- }
- public static class GameData
- {
- public static readonly TowerDef[] Towers={
- new TowerDef("archer","Archer",100,new[]{90,150},new[]{11f,18,29},new[]{.75f,.68f,.60f},new[]{108f,116,124},"Rapid single target"),
- new TowerDef("pistol","Pistol",130,new[]{110,180},new[]{7f,11,17},new[]{.38f,.33f,.29f},new[]{92f,98,105},"Fast, affordable fire",760),
- new TowerDef("crossbow","Crossbow",170,new[]{150,240},new[]{46f,74,118},new[]{2f,1.85f,1.70f},new[]{150f,160,172},"Ignores enemy armor",620,false,true),
- new TowerDef("rifle","Rifle",250,new[]{220,340},new[]{38f,62,98},new[]{1.3f,1.2f,1.1f},new[]{180f,192,205},"Long range; hits flying enemies",0,true),
- new TowerDef("mortar","Mortar",320,new[]{280,430},new[]{58f,95,150},new[]{2.5f,2.35f,2.2f},new[]{165f,175,188},"Ground splash damage",300,false,false,new[]{48f,54,62})};
- public static readonly EnemyDef[] Enemies={
- new EnemyDef("rabbit","Jackrabbit",30,118,0,10,1,12),new EnemyDef("bison","Bison",84,70,0,14,1,16),
- new EnemyDef("wolf","Wolf",104,92,2,16,1,14),new EnemyDef("vulture","Vulture",68,104,0,18,1,13,true),
- new EnemyDef("scorpion","Scorpion",176,58,9,26,2,16),new EnemyDef("king","Buffalo King",1200,50,6,150,5,27,false,true)};
- public static readonly ItemDef[] Items={new ItemDef("airstrike","Airstrike",800,"Tap the field: 400 damage in a wide blast."),new ItemDef("frost","Frost Nova",600,"Freeze every enemy for 4 seconds."),new ItemDef("repair","Repair Kit",1200,"Restore 3 base HP, up to 20."),new ItemDef("gold","Gold Rush",500,"Instantly gain 300 battle gold.")};
- public static readonly string[] Avatars={"bison","wolf","eagle","scorpion","rabbit","bear","horse","snake"};
- public static readonly string[] ComboNames={"Volley","Suppression","Siege Line","Pierce Shell"};
- public static readonly string[] ComboDescriptions={"Archer + Crossbow: +15% range, +10% fire rate.","Pistol + Rifle: +25% fire rate.","Rifle + Mortar: mortar +25% blast radius, +10% damage.","Crossbow + Mortar: crossbow +20% damage; mortar ignores armor."};
- public static readonly int[,] ComboPairs={{0,2},{1,3},{3,4},{2,4}};
- public static readonly MapDef[] Maps={
- new MapDef("serpentine","Serpentine Canyon",new float[]{-30,77,304,77,304,204,108,204,108,312,304,312,304,425,108,425,108,505,345,505},new Vector2(379,505),new float[]{143,143,219,146,262,142,174,259,244,259,64,362,160,368,242,366,172,465,242,465,177,554,274,554}),
- new MapDef("longhorn","Longhorn Basin",new float[]{-30,71,327,71,327,203,59,203,59,335,327,335,327,490,365,490},new Vector2(380,490),new float[]{115,137,183,137,261,137,143,269,217,269,293,269,128,400,202,400,277,400,176,459,265,459,202,533,278,551,123,536}),
- new MapDef("switchback","Redrock Switchback",new float[]{-30,58,352,58,352,182,152,182,152,293,352,293,352,405,152,405,152,524,366,524},new Vector2(386,524),new float[]{164,120,228,120,300,120,211,238,285,238,207,350,285,350,100,350,210,465,289,465,225,566,302,568}),
- new MapDef("chokepoint","Chokepoint Gorge",new float[]{-30,81,334,81,334,207,49,207,49,338,334,338,334,463,368,463},new Vector2(382,463),new float[]{115,143,185,143,263,143,122,270,194,270,276,270,121,401,195,401,271,401,169,466,255,466,173,525,276,535,105,526})};
- public static int WaveCount(int level)=>4+level/2;
- public static int Reward(int level)=>250+level*135;
- public static int Round(float n)=>Mathf.FloorToInt(n+.5f);
- // The prototype's quadratic late-game curve could overwhelm a full arsenal in wave one.
- // Keep the onboarding stages; later stages grow gradually alongside larger starting defenses.
- public static float HpMultiplier(int level){float n=level-1;if(level<=6)return (1+.2f*n+.0125f*n*n)*(level<=4?.66f:.72f);return Mathf.Max(1.75f,1+.1f*n+.001f*n*n);}
- public static int StartingGold(int level)=>760+(level-1)*160+(level%5==0?level*40:0);
- public static int ArmoryCost(int type,int level)=>level>=5?0:Round(Towers[type].Cost*new[]{2f,3.5f,5.5f,8f}[level-1]/10)*10;
- public static readonly LeaderEntry[] Bots={new LeaderEntry("DustDevil",48200,34),new LeaderEntry("PrairieKing",41500,31),new LeaderEntry("MesaRanger",36900,28),new LeaderEntry("VultureEye",31400,26),new LeaderEntry("BisonBane",27800,24),new LeaderEntry("CactusJack",23100,21),new LeaderEntry("RedDune",18700,19),new LeaderEntry("SilverSpur",14200,16),new LeaderEntry("Tumbleweed",9800,13),new LeaderEntry("RookieRanger",5600,10)};
- }
- [Serializable] public class LeaderEntry {public string name;public int score,wave;public bool player;public LeaderEntry(string n,int s,int w,bool p=false){name=n;score=s;wave=w;player=p;}}
- }
|