Inheritance: MapAdjuster
Beispiel #1
0
    // fonction qui permet de sélectionner une tour
    public void Select(Weapon.WeaponType type)
    {
        // déselection de la tour présentement sélectionnée
        if(tower != null)
            tower.weapon.Unselect();

        // sélectionner la nouvelle tour
        switch(type)
        {
            case Weapon.WeaponType.WEAPON_GUN:
                tower = gun;
                break;

            case Weapon.WeaponType.WEAPON_CANNON:
                tower = cannon;
                break;

            case Weapon.WeaponType.WEAPON_LASER:
                tower = laser;
                break;

            case Weapon.WeaponType.WEAPON_FLAME:
                tower = flame;
                break;

            default:
                Debug.Log("<unknow weapon type>");
                break;
        }

        // configuration de la tour sélectionnée
        if(tower != null)
            tower.weapon.Select();
    }
 private GUIStyle GetInspectorStyle(Tower t, int i, bool nada)
 {
     Section s = t.GetSection(i);
     GUIStyle gStyle;
     GUIStyle yStyle;
     GUIStyle rStyle;
     if(nada) {
         gStyle = nadagStyle;
         yStyle = nadayStyle;
         rStyle = nadarStyle;
     } else {
         bool hasWeapon = s.attributes.weapon.GetWeaponType() != "Nothing";
         gStyle = hasWeapon ? wgStyle : ngStyle;
         yStyle = hasWeapon ? wyStyle : nyStyle;
         rStyle = hasWeapon ? wrStyle : nrStyle;
     }
     int stress = t.GetWeightAboveSection(i);
     int maxSP = s.attributes.sp;
     double ratio = (double)stress / (double)maxSP;
     if(ratio < 0.33) {
         return gStyle;
     } else if(ratio >= 0.33 && ratio < 0.66) {
         return yStyle;
     } else {
         return rStyle;
     }
 }
    //Mehtod Checking if current tower have correct TotalPoints. If not tower is removed from List
    private static void CheckingCurrentPoints()
    {
        int currentPoints = towerArray[towerToPlay.Row, towerToPlay.Col];

        if (towerToPlay.LeftNeighbour == true)
        {
            currentPoints += towerArray[towerToPlay.Row, towerToPlay.Col - 1];
        }
        if (towerToPlay.TopNeighbour == true)
        {
            currentPoints += towerArray[towerToPlay.Row - 1, towerToPlay.Col];
        }
        if (towerToPlay.RigthNeigbour == true)
        {
            currentPoints += towerArray[towerToPlay.Row, towerToPlay.Col + 1];
        }
        if (towerToPlay.BottomNeighbour == true)
        {
            currentPoints += towerArray[towerToPlay.Row + 1, towerToPlay.Col];
        }
        if (towerToPlay.TotalPoints == currentPoints)
        {
            return;
        }
        else
        {
            towers.Remove(towerToPlay);
            if (towers.Count == 0)
            {
                return;
            }
            towerToPlay = towers[0];
            CheckingCurrentPoints();
        }
    }
    /// <summary>
    /// Metoda odpowiedzialna za dodawanie odpowiedniego obiektu wieży, definiowanego przez argument type, w miejscu i jako dziecko obiektu parent. Zwraca koszt wieży.
    /// </summary>
    /// <param name="type">Argument typu TowerType określająca typ wieży, jak ma zostać utworzona.</param>
    /// <param name="parent">Argument typu GameObject, którego dzieckiem stanie się nowa wieża.</param>
    /// <returns>Wzraca koszt wybudowania wieży.</returns>
    public int SpawnTower(TowerType type, GameObject parent)
    {
        Tower tempTower = new Tower();
        GameObject tempGameObject = null;
        switch (type)
        {
                case TowerType.Wall:
                    tempTower = WallTower;
                    tempGameObject = Resources.Load("Prefabs/Towers/Wall") as GameObject;
                    break;
                case TowerType.Shooting:
                    tempTower = ShootingTower;
                    tempGameObject = Resources.Load("Prefabs/Towers/Shooting") as GameObject;
                    break;
                case TowerType.Aoe:
                    tempTower = AoeTower;
                    tempGameObject = Resources.Load("Prefabs/Towers/Aoe") as GameObject;
                    break;
        }
        GameObject tower = Instantiate(tempGameObject, parent.transform.position, Quaternion.identity) as GameObject;
        tower.transform.parent = parent.transform;
        tower.transform.localPosition = new Vector3(tower.transform.localPosition.x, -(2.0f/parent.transform.localScale.y), tower.transform.localPosition.z);

        return tempTower.Cost;
    }
 public void Deselect()
 {
     selectedTower = null;
     CurrentlySelectedTower = null;
     RangeCircle.transform.localScale = new Vector3(0, 0, 0);
     infoManager.DisplayInfo(null, true);
 }
Beispiel #6
0
            public void MoveDisks(int n, Tower destination, Tower buffer){
		        if (n > 0) {
                    ////////////String tag = "move_" + n + "_disks_from_" + Index + "_to_" + destination.Index + "_with_buffer_" + buffer.Index; 
                    ////////////Console.WriteLine("<" + tag + ">");
			        MoveDisks(n - 1, buffer, destination);
                    ////////////Console.WriteLine("<move_top_from_" + Index + "_to_" + destination.Index + ">");
                    ////////////Console.WriteLine("<before>");
                    ////////////Console.WriteLine("<source_print>");
                    ////////////Print();
                    ////////////Console.WriteLine("</source_print>");
                    ////////////Console.WriteLine("<destination_print>");
                    ////////////destination.Print();
                    ////////////Console.WriteLine("</destination_print>");
                    ////////////Console.WriteLine("</before>");
			        MoveTopTo(destination);
                    ////////////Console.WriteLine("<after>");
                    ////////////Console.WriteLine("<source_print>");
                    ////////////Print();
                    ////////////Console.WriteLine("</source_print>");
                    ////////////Console.WriteLine("<destination_print>");
                    ////////////destination.Print();
                    ////////////Console.WriteLine("</destination_print>");
                    ////////////Console.WriteLine("</after>");
                    ////////////Console.WriteLine("</move_top_from_" + Index + "_to_" + destination.Index + ">");
			        buffer.MoveDisks(n - 1, destination, this);
                    ////////////Console.WriteLine("</" + tag + ">");
		        }
	        }
 public AbstractBuilding Build(string type, Game.Point coords)
 {
     AbstractBuilding building = null;
     switch (type)
     {
         case ("Farm"):
             {
                 building = new Farm(coords);
                 break;
             }
         case ("Barrack"):
             {
                 building = new Barrack(coords);
                 break;
             }
         case ("BowWorkshop"):
             {
                 building = new BowWorkshop(coords);
                 break;
             }
         case ("Tower"):
             {
                 building = new Tower(coords);
                 break;
             }
         default:
             break;
     }
     return building;
 }
Beispiel #8
0
    public bool Build(Tower prefab)
    {
        bool result = false;

        if (this.Tower == null && prefab == null)
        {
            GameObject.Destroy(this.gameObject);
            result = true;
        }
        else
        {
            if (this.Tower != null)
            {
                GameObject.Destroy(this.Tower.gameObject);
                result = true;
            }

            if (prefab != null)
            {
                var tower = GameObject.Instantiate<Tower>(prefab);
                tower.transform.parent = this.transform;
                tower.transform.localPosition = Vector3.zero;
                tower.transform.localRotation = Quaternion.identity;
                this.Tower = tower;

                result = true;
            }
        }
        return result;
    }
Beispiel #9
0
        public void Run()
        {
            // Set up code.
            int n = 5;
            Tower[] towers = new Tower[3];
            for (int i = 0; i < 3; i++)
            {
                towers[i] = new Tower(i);
                towers[i].Label = string.Format("{0}", i); ;
            }
            for (int i = n - 1; i >= 0; i--)
            {
                towers[0].Add(i);
            }

            // Copy and paste output into a .XML file and open it with internet explorer.
            towers[0].Print();
            towers[1].Print();
            towers[2].Print();

            towers[0].MoveDisks(n, towers[2], towers[1]);

            towers[0].Print();
            towers[1].Print();
            towers[2].Print();
        }
 public void Add_FirstDisk_AddsOneDiskToTower()
 {
     var tower = new Tower();
     tower.AddDisk("A");
     tower.Count.ShouldEqual(1);
     tower.TopDisk().ShouldEqual("A");
 }
    public void DisplayInfo(Tower t, bool preview)
    {
        if (t == null)
        {
            NameText.text = "";
            CostText.text = "";
            DamageText.text = "";
            FireRateText.text = "";
            DPSText.text = "";
            RangeText.text = "";
            ProjectileFollowsText.text = "";
            SellText.text = "";
            SellButton.gameObject.SetActive(false);
            return;
        }
        NameText.text = t.TowerName;
        CostText.text = "Cost: $" + t.Cost.ToString();
        DamageText.text = "Damage: " + t.ProjectileDamage.ToString();
        FireRateText.text = "Fire Rate: " + t.FireRate.ToString();
        DPSText.text = "Optimal DPS: " + (t.ProjectileDamage * t.FireRate).ToString();
        RangeText.text = "Range: " + t.Range.ToString();

        if (t.ProjectileFollows)
            ProjectileFollowsText.text = "Projectile follows";
        else
            ProjectileFollowsText.text = "Projectile doesn't follow";

        if (!preview)
        {
            SellButton.gameObject.SetActive(true);
            SellText.text = "Sell For: $" + (t.Cost / 2).ToString();
        }
    }
Beispiel #12
0
    public override List<Section> GetDamagedSections(Tower t, int center)
    {
        int ranNum1 = Random.Range(1, Mathf.RoundToInt(100/missPercentage) + 1);
        List<Section> list = new List<Section>();

        if (ranNum1 == 1)//If missed, miss
        {
            int ranNum2 = Random.Range(1, 3);
            CombatLog.addLine ("ran1 = " + ranNum1 + ". ran2 = " + ranNum2);
            if (ranNum2 == 1)//miss high
            {
                CombatLog.addLine("Miss Higher (blind)");
                if (center + 1 < t.GetHeight())//Missed above tower
                {
                    list.Add(t.GetSection(center+1));
                }
            }
            else//miss low
            {
                CombatLog.addLine("Miss Lower (blind)");
                if (center - 1 >= 0) //Missed below tower
                {
                    list.Add (t.GetSection(center - 1));
                }
            }
        }
        else{
                list.Add(t.GetSection(center));
            }
        return list;
    }
Beispiel #13
0
 public virtual void SetTurret(Tower turret)
 {
     Velocity = turret.ProjectileSpeed;
     Damage = turret.Damage;
     currentTarget = turret.CurrentEnemy;
     range = Vector3.Distance(transform.position, currentTarget.transform.position);
 }
	protected void buttonAction(int i){
		if(tower == null){
			tower = GameObject.FindObjectOfType<Tower>();
		}
		switch (i){
		case 0: //Golem 1
			if(InventroyManager.instance.getCount(Element.DIRT) >= DIRT_GOLEM_COST){
				InventroyManager.instance.removeFromInventory(Element.DIRT, DIRT_GOLEM_COST);
				// make a CUTIE
				unitSpawner.spawnObject();
			}
			break;
		case 1: //Golem 2
			
			break;
		case 2: //Golem 3
			//return ;
			break;
		case 3: //Tower 1
			if(tower != null && InventroyManager.instance.getCount(Element.DIRT) >= DIRT_TOWER_COST){
				InventroyManager.instance.removeFromInventory(Element.DIRT, DIRT_TOWER_COST);			
				tower.increaseHeight();
			}
			break;
		case 4: //Tower 2
			//
			break;
		case 5: //Tower 3
			//
			break;
		}
	}
	// Update is called once per frame
	void OnMouseUp()
	{

		if (!hasTower) {

			if (GameManager.argent >= turret.Valeur()) {
				//Vector3 vect = new Vector3 (transform.position.x, transform.position.y + 0.5f, transform.position.z);

				CurrentTurret = (Tower)Instantiate (turret, transform.position, Quaternion.identity);
				CurrentTurret.name = "Turret";
				CurrentTurret.transform.parent = gameObject.transform;
				GameManager.argent -= turret.Valeur();
				hasTower = true;

			}
			else{
				this.GetComponent<Renderer>().material.mainTexture = textureError;
			}

		}
		else {
			Destroy(transform.FindChild("Turret").gameObject);
			GameManager.argent+= CurrentTurret.Valeur()/2;
			hasTower = false;
		}

	}
Beispiel #16
0
    public override void DoDamage(Tower t, int center, int damage, Tower self, int firingSection)
    {
        if(t.GetSections().Count >= 1) {
            //t.DamageSection(center, damage);
            Section s = t.GetSection (center);
            if (!modifiedSecs.ContainsKey(s)) //if not modified before...
            {
                ModifyWeight(s, t, damage, self);
                modifiedSecs.Add(s, 1);

            }
            else if (modifiedSecs[s] >= numTimesModifiable)
            {
                ModifyWeight(s, t, damage, self);
                modifiedSecs[s]++;
            }
            else
            {
                //TODO: Make this a warning and let them go back to their turn
                CombatLog.addLine("This section has already altered the weight " + modifiedSecs[s] + "times.");
            }
        }
        else if(center < 0) {
            CombatLog.addLine("Attack was too low");
            CombatLog.addLine("Fill the aim bar more.");
        } else if(center >= t.GetSections().Count) {
            CombatLog.addLine("Attack was too high");
            CombatLog.addLine("Lower the aim bar.");
        }
    }
Beispiel #17
0
	// Use this for initialization
	void Start ()
	{
		if (tower == null) {
			tower = GameObject.FindGameObjectWithTag ("Tower").GetComponent<Tower> ();

		}
	}
Beispiel #18
0
 private static void Print(Tower[] t)
 {
     for (int i = 0; i < 3; ++i) {
         Console.WriteLine (t[i]);
     }
     Console.WriteLine ();
 }
        public Tower PreviousTower(Game game, Tower tower)
        {
            if (game.Towers.Tower2 == tower) return game.Towers.Tower1;

            return game.Towers.Tower3 == tower
                ? game.Towers.Tower2
                : game.Towers.Tower3;
        }
Beispiel #20
0
 public FreezeShot(Game game, Tower parent, Creep target, List<Creep> creeps, Vector2 position,
                   string shotTextName, float speed, float damage, float percentage, float time)
     : base(game, parent, target, creeps, position, shotTextName, speed, damage)
 {
     FreezePercentage = percentage;
     FreezeTime = time;
     Parent = (FreezeTower) parent;
 }
 public void Add_SmallerSecondDisk_AddsOneMoreDiskToTower()
 {
     var tower = new Tower();
     tower.AddDisk("B");
     tower.AddDisk("A");
     tower.Count.ShouldEqual(2);
     tower.TopDisk().ShouldEqual("A");
 }
        public Tower NextTower(Game game, Tower tower)
        {
            if (game.Towers.Tower1 == tower) return game.Towers.Tower2;

            return game.Towers.Tower2 == tower
                ? game.Towers.Tower3
                : game.Towers.Tower1;
        }
Beispiel #23
0
 public void MoveDisks(int n, Tower destination, Tower buffer)
 {
     if (n > 0) {
         MoveDisks (n - 1, buffer, destination);
         MoveToTop (destination);
         buffer.MoveDisks (n - 1, destination, this);
     }
 }
 public override List<Section> GetDamagedSections(Tower t, int center)
 {
     List<Section> list = new List<Section>();
     if(center >= 0 && center < t.GetSections().Count) {
         list.Add(t.GetSections()[center]);
     }
     return list;
 }
 // Use this for initialization
 void Start()
 {
     myButton = GetComponent<Button>();
     Graphic = toRepresent.StoreIcon;
     myButton.gameObject.GetComponent<Image>().sprite = Graphic;
     toRepresent = MasterValues.TowerTypes[TowerToRepresent].GetComponent<Tower>();
     towerGameObject = MasterValues.TowerTypes[TowerToRepresent];
 }
Beispiel #26
0
 public static double GetAngle(Tower t, Enemy e)
 {
     float Xdist = t.CenterPos.X - e.CenterPos.X;
     float Ydist = t.CenterPos.Y - e.CenterPos.Y;
     if (t.CenterPos.X > e.CenterPos.X) {
         return Math.Atan(Ydist / Xdist) + 180;
     }
     return Math.Atan(Ydist / Xdist);
 }
Beispiel #27
0
 //returns true if the tower could be build and false if not
 public void createTower(int typ)
 {
     int xCoord = height - 1 - (int)(((nextPos.x * -1)) / 5d);
     int zCoord = (int)(nextPos.z) / 5;
     Tower instance = new Tower (typ, nextPos, this);
     towerList.AddLast (instance);
     towerPlaced [xCoord, zCoord] = instance;
     money -= instance.getCost();
 }
Beispiel #28
0
 public bool CanBuildFloor(Tower.Tower tower, string floorDescName)
 {
     var prefab = RegisteredPrefabs.FirstOrDefault(x => x.FloorName == floorDescName);
     if (prefab != null)
     {
         return prefab.Builder.CanCreateInTower(tower);
     }
     return true;
 }
Beispiel #29
0
    public static void FindEmpTower(int direction, FieldIndex ind, Field<bool> taken, ref List<Tower> buildList)
    {
        //Debug.Log("Finding 2nd piece forward on "+tmp.ToString());
        Tower newTower = new Tower();
        FieldIndex tmp = ind.Up(direction);
        newTower.Add(ind);
        newTower.Add(tmp);
        newTower.type = TowerType.silence;
        ind = tmp;
        FieldIndex right = ind.Right(direction);
        FieldIndex left = ind.Left(direction);
        bool left_tower = left.index != -1 && taken[left] == true;
        bool right_tower = right.index != -1 && taken[right] == true;
        if(left_tower && right_tower){
        //			Debug.Log("Finding 3rd piece forward on "+tmp.ToString());
            Tower rightTower = newTower.Copy();

            newTower.Add(left);
            //Debug.Log(newTower.ToString());
            rightTower.Add(right);
            //Debug.Log(rightTower.ToString());

            tmp = left.Up(direction);
            FieldIndex tmpRight = right.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
            if(tmpRight.index != -1 && taken[tmpRight]==true){
                rightTower.Add(tmpRight);
        //				Debug.Log(newTower.ToString());
                buildList.Add(rightTower);
            }
        }
        else if(left_tower){
            newTower.Add(left);
            tmp = left.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
        else if(right_tower){
            newTower.Add(right);
            tmp = right.Up(direction);

            if(tmp.index != -1 && taken[tmp]==true){
                newTower.Add(tmp);
        //				Debug.Log(newTower.ToString());
                buildList.Add(newTower);
            }
        }
    }
Beispiel #30
0
 public void moveDisks(int n, Tower destination, Tower buffer)
 {
     if (n > 0)
     {
         moveDisks(n - 1, buffer, destination);
         moveTopTo(destination);
         buffer.moveDisks(n - 1, destination, this);
     }
 }
Beispiel #31
0
 internal static void Postfix(Tower __instance, Entity target, Model modelToUse)
 {
     __instance.display = __instance.entity.displayBehaviorCache;
     MelonMain.DoPatchMethods(mod => mod.OnTowerCreated(__instance, target, modelToUse));
 }
Beispiel #32
0
 public void SetTower(Tower tw)
 {
     this.HasTower = true;
     this.tower    = tw;
 }
Beispiel #33
0
 // Use this for initialization
 void Start()
 {
     s_towerPrefab = towerPrefab;
     towers        = new Tower[9, 9];
     addTower(3, 5);
 }
Beispiel #34
0
    public void UnregisterTower(Tower tower)
    {
        _registeredTowers.Remove(tower);

        Destroy(tower.gameObject);
    }
Beispiel #35
0
 /// <summary>
 /// Allows you to dynamically allow an upgrade to not be purchasable based on the InGame values of a Tower
 /// </summary>
 /// <param name="tower"></param>
 /// <returns>If </returns>
 public virtual bool RestrictUpgrading(Tower tower)
 {
     return(false);
 }
Beispiel #36
0
 public void setClosestTower(Tower t)
 {
     closestTower = t;
     canCharge    = true;
 }
Beispiel #37
0
 public void RegisterTower(Tower tower)
 {
     TowerList.Add(tower);
 }
Beispiel #38
0
 public Contagious_effectiveMissile(int instanceId, Tower ownerTower, Minion targetMinion) : base(instanceId, ownerTower, targetMinion)
 {
 }
Beispiel #39
0
    private Tower GetRandomTower(Tower[] List)
    {
        Tower randomTower = List[Random.Range(0, List.Length)];

        return(randomTower);
    }
Beispiel #40
0
 public abstract void Modify(Tower tower);
 public void Initialize(Tower parent)
 {
     this.target = parent.Target;
     this.parent = parent;
 }
Beispiel #42
0
 public bool InstantiateTower(Tower tower, Vector3 position, Transform parentTransform)
 {
     Instantiate(tower, position, Quaternion.identity, parentTransform);
     return(true);
 }
Beispiel #43
0
 internal static void Postfix(Tower __instance, Model modelToUse)
 {
     MelonMain.DoPatchMethods(mod => mod.OnTowerModelChanged(__instance, modelToUse));
 }
Beispiel #44
0
 public void OnSellTower()
 {
     _gameController.MoneyCounter.OnChangeMoney(_currentSellPrice);
     _currentTower = null;
 }
Beispiel #45
0
 public TowerBuilderCannon()
 {
     _tower = new Tower();
 }
Beispiel #46
0
 public void AddTower(Tower t)
 {
     _towers.Add(t);
 }
 // Start is called before the first frame update
 void Start()
 {
     parent_tower = transform.parent.gameObject.GetComponent <Tower>();
     target       = parent_tower.targetList[0];
 }
Beispiel #48
0
 private void Awake()
 {
     tower     = GetComponent <Tower>();
     gunGO     = transform.FindChild("Gun").gameObject;
     gunFireGO = gunGO.gameObject.transform.FindChild("GunFire").gameObject;
 }
Beispiel #49
0
 public void setBuildTowers(Tower towerToAdd, int index)
 {
     TowersOnButtons[index] = towerToAdd;
 }
Beispiel #50
0
        /// <summary>
        /// The MultiResidence function.
        /// </summary>
        /// <param name="model">The model.
        /// Add elements to the model to have them persisted.</param>
        /// <param name="input">The arguments to the execution.</param>
        /// <returns>A MultiResidenceOutputs instance containing computed results.</returns>
        public static MultiResidenceOutputs Execute(Model model, MultiResidenceInputs input)
        {
            var boundary = new Elements.Geometry.Polygon(ParseCoords(model, input));
            var centroid = boundary.Centroid();
            var site     = new Mass(new Profile(boundary),
                                    0.2,
                                    new Material("site", new Color(1.0f, 1.0f, 1.0f, 0.0f), 0.0f, 0.0f),
                                    new Transform(0.0, 0.0, 0.2));

            model.AddElement(site);
            var tower = new Tower
            {
                Color       = Palette.White,
                StoryHeight = 4.0,
                TargetArea  = 0.0
            };

            if (input.Units < 8)
            {
                var polygon = Elements.Geometry.Polygon.Rectangle(23.0, 16.0);
                //if (boundary.Covers(polygon.MoveFromTo(Vector3.Origin, centroid)))
                //{
                //    model.AddElement(site);
                //    return new MultiResidenceOutputs(0.0, 0.0, 0.0, 0.0);
                //}
                tower.Floors    = (int)Math.Ceiling(input.Units / 2);
                tower.Perimeter = polygon;
                tower.Stack();
                foreach (var story in tower.Stories)
                {
                    story.RoomsByDivision(2, 1, 3.5, 0.1, color: Palette.Aqua);
                    Room corridor = null;
                    if (story.Elevation <= 0.0)
                    {
                        corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(0.0, -8.0), new Vector3(0.0, 8.0)).Thicken(3.0),
                                            height: 3.5);
                    }
                    else
                    {
                        corridor = new Room(perimeter: new Elements.Geometry.Line(Vector3.Origin, new Vector3(0.0, 8.0)).Thicken(3.0),
                                            height: 3.5);
                    }
                    story.AddCorridor(corridor);
                    if (tower.Floors > 1)
                    {
                        var core = Elements.Geometry.Polygon.Rectangle(3.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(0.0, 8.0));
                        tower.AddCore(core, 0, 3.0, Palette.Gray);
                    }
                }
            }
            else if (input.Units < 30)
            {
                var polygon = Elements.Geometry.Polygon.Rectangle(23.0, 32.0);
                //if (boundary.Covers(polygon.MoveFromTo(Vector3.Origin, centroid)))
                //{
                //    model.AddElement(site);
                //    return new MultiResidenceOutputs(0.0, 0.0, 0.0, 0.0);
                //}
                tower.Floors    = (int)input.Units / 4;
                tower.Perimeter = polygon;
                tower.Stack();
                foreach (var story in tower.Stories)
                {
                    story.RoomsByDivision(2, 1, 3.5, 0.1, color: Palette.Aqua);
                    Room corridor = null;
                    if (story.Elevation <= 0.0)
                    {
                        corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(0.0, -16.0), new Vector3(0.0, 16.0)).Thicken(3.0),
                                            height: 3.5);
                    }
                    else
                    {
                        corridor = new Room(perimeter: new Elements.Geometry.Line(Vector3.Origin, new Vector3(0.0, 8.0)).Thicken(3.0),
                                            height: 3.5);
                    }
                    story.AddCorridor(corridor);
                    if (tower.Floors > 1)
                    {
                        var core = Elements.Geometry.Polygon.Rectangle(3.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(0.0, 8.0));
                        tower.AddCore(core, 0, 3.0, Palette.Gray);
                    }
                }
            }
            else
            {
                var polygon = Elements.Geometry.Polygon.Rectangle(36.0, 32.0);
                //if (!boundary.Covers(polygon.MoveFromTo(Vector3.Origin, centroid)))
                //{
                //    model.AddElement(site);
                //    return new MultiResidenceOutputs(0.0, 0.0, 0.0, 0.0);
                //}
                tower.Floors    = (int)input.Units / 6;
                tower.Perimeter = Elements.Geometry.Polygon.Rectangle(36.0, 32.0);
                tower.Stack();
                foreach (var story in tower.Stories)
                {
                    story.RoomsByDivision(3, 2, 3.5, 0.1, color: Palette.Aqua);
                    Room corridor = null;
                    if (story.Elevation <= 0.0)
                    {
                        corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(-6.5, -16.0), new Vector3(-6.5, 16.0)).Thicken(3.0),
                                            height: 3.5);
                        story.AddCorridor(corridor);
                        corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(6.5, -16.0), new Vector3(6.5, 16.0)).Thicken(3.0),
                                            height: 3.5);
                        story.AddCorridor(corridor);
                    }
                    else
                    {
                        corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(-6.5, 0.0), new Vector3(-6.5, 16.0)).Thicken(3.0),
                                            height: 3.5);
                        story.AddCorridor(corridor);
                        corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(6.5, 0.0), new Vector3(6.5, 16.0)).Thicken(3.0),
                                            height: 3.5);
                        story.AddCorridor(corridor);
                    }
                    corridor = new Room(perimeter: new Elements.Geometry.Line(new Vector3(-10.0, 0.0), new Vector3(10, 0.0)).Thicken(3.0),
                                        height: 3.5);
                    story.AddCorridor(corridor);
                    if (tower.Floors > 1)
                    {
                        var core = Elements.Geometry.Polygon.Rectangle(6.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(-8.0, 16.0));
                        tower.AddCore(core, 0, 3.0, Palette.Gray);
                        core = Elements.Geometry.Polygon.Rectangle(6.0, 6.0).MoveFromTo(Vector3.Origin, new Vector3(8.0, 16.0));
                        tower.AddCore(core, 0, 3.0, Palette.Gray);
                    }
                }
            }
            tower.MoveFromTo(Vector3.Origin, centroid);
            foreach (var core in tower.Cores)
            {
                model.AddElement(core.AsMass);
            }
            var unitQty   = 0;
            var totalArea = 0.0;

            foreach (var story in tower.Stories)
            {
                unitQty   += story.Rooms.Count;
                totalArea += story.Area;
                foreach (var mass in story.InteriorsAsMasses)
                {
                    model.AddElement(mass);
                }
                model.AddElement(story.Slab);
            }

            var output = new MultiResidenceOutputs(unitQty, totalArea, Math.Abs(tower.Area / boundary.Area()), tower.Height);

            return(output);
        }
Beispiel #51
0
 private void Start()
 {
     tower = transform.GetComponentInParent <Tower>();
 }
Beispiel #52
0
    void BuildControls()
    {
        Ray   raycast;
        float enter;

        if (tower == null)
        {
            if (deviceR.GetPressDown(Touchpad))
            {
                raycast = new Ray(controllerR.transform.position, controllerR.transform.forward);
                enter   = 0.0F;

                if (ground.Raycast(raycast, out enter))
                {
                    scaleOrigin.transform.position = raycast.GetPoint(enter);

                    tower = new Tower(block, scaleOrigin, length, width, height, nsides, nfloors, offset);
                }
            }
        }

        else if (!tower.placed)
        {
            raycast = new Ray(controllerR.transform.position, controllerR.transform.forward);
            enter   = 0.0F;

            if (ground.Raycast(raycast, out enter))
            {
                if (!tower.Active)
                {
                    tower.Active = true;
                }

                tower.origin.transform.position = raycast.GetPoint(enter);

                if (deviceR.GetPressDown(Trigger))
                {
                    tower.SetMaterial(solid);
                    tower.EnablePhysics(true);

                    BuildMode = false;
                }

                if (deviceR.GetTouchDown(Touchpad))
                {
                    init_touchX = deviceR.GetAxis(TouchpadID).x;
                    init_touchY = deviceR.GetAxis(TouchpadID).y;
                }

                else if (deviceR.GetTouch(Touchpad))
                {
                    final_touchX = deviceR.GetAxis(TouchpadID).x;
                    final_touchY = deviceR.GetAxis(TouchpadID).y;

                    double dispX = final_touchX - init_touchX;
                    double dispY = final_touchY - init_touchY;
                    double absX  = Math.Abs(dispX);
                    double absY  = Math.Abs(dispY);

                    if (absX >= 0.34F && absY < 0.34F)
                    {
                        if ((tmp_sides = nsides + (int)(3 * dispX)) >= 3)
                        {
                            tower.Despawn();
                            tower = new Tower(block, scaleOrigin, length, width, height, tmp_sides, nfloors, offset);
                        }
                    }

                    else if (absY >= 0.34F && absX < 0.34F)
                    {
                        if ((tmp_floors = nfloors + (int)(3 * dispY)) >= 1)
                        {
                            tower.Despawn();
                            tower = new Tower(block, scaleOrigin, length, width, height, nsides, tmp_floors, offset);
                        }
                    }
                }

                else if (deviceR.GetTouchUp(Touchpad))
                {
                    if (tmp_sides >= 3)
                    {
                        nsides = tmp_sides;
                    }
                    if (tmp_floors >= 1)
                    {
                        nfloors = tmp_floors;
                    }
                }
            }
            else
            {
                tower.Active = false;
            }
        }
    }
Beispiel #53
0
    void CheckPlayer()
    {
        GameObject[] Towers = GameObject.FindGameObjectsWithTag("TOWER");

        int iRedTeamCnt = 0;

        foreach (GameObject Tower in Towers)
        {
            if (Tower.GetComponent <TowerCtrl>().m_eTeam == TowerCtrl.ePLAYER_TEAM.PLAYER_RED)
            {
                ++iRedTeamCnt;
            }
        }

        if (iRedTeamCnt == 4)
        {
            //레드팀의 4개탑 점거 성공..

            PhotonPlayer[] Players = PhotonNetwork.playerList;

            foreach (PhotonPlayer Player in Players)
            {
                if (Player.GetTeam() == PunTeams.Team.red)
                {
                    Player.SetScore(1);
                }
                else if (Player.GetTeam() == PunTeams.Team.blue)
                {
                    Player.SetScore(0);
                }
            }

            m_bCheck = true;

            Application.LoadLevelAdditive("scMessage");
        }
        else if (m_fTime >= 2.0f)
        {
            if (m_fTime >= 600.0f)
            {
                //제한시간 초과 블루 팀 승리
                PhotonPlayer[] PHPlayers = PhotonNetwork.playerList;

                foreach (PhotonPlayer Player in PHPlayers)
                {
                    if (Player.GetTeam() == PunTeams.Team.red)
                    {
                        Player.SetScore(0);
                    }
                    else if (Player.GetTeam() == PunTeams.Team.blue)
                    {
                        Player.SetScore(1);
                    }
                }

                m_bCheck = true;

                Application.LoadLevelAdditive("scMessage");
            }
            else
            {
                GameObject[] Players = GameObject.FindGameObjectsWithTag("Player");

                int iRedCnt     = 0;
                int iDieCnt     = 0;
                int iBlueCnt    = 0;
                int iBlueDieCnt = 0;

                foreach (GameObject Player in Players)
                {
                    PlayerCtrl _PlayerCtrl = Player.GetComponent <PlayerCtrl>();

                    if (_PlayerCtrl.m_PlayerTeam == PlayerCtrl.PLAYER_TEAM.PLAYER_TEAM_RED)
                    {
                        ++iRedCnt;

                        if (_PlayerCtrl.m_PlayerState == PlayerCtrl.PLAYER_STATE.PLAYER_DIE)
                        {
                            ++iDieCnt;
                        }
                    }
                    else if (_PlayerCtrl.m_PlayerTeam == PlayerCtrl.PLAYER_TEAM.PLAYER_TEAM_BLUE)
                    {
                        ++iBlueCnt;

                        if (_PlayerCtrl.m_PlayerState == PlayerCtrl.PLAYER_STATE.PLAYER_DIE)
                        {
                            ++iBlueDieCnt;
                        }
                    }
                }

                //여기서 살아있는 숫자를 표시해주자.

                if (m_BlueScore != null && m_RedScore != null)
                {
                    m_BlueScore.text = "Blue Die : " + iBlueDieCnt.ToString();
                    m_RedScore.text  = "Red Die : " + iDieCnt.ToString();
                }

                if (iRedCnt == iDieCnt)
                {
                    //레드 팀 전원 사망 블루 팀 승리!

                    PhotonPlayer[] PHPlayers = PhotonNetwork.playerList;

                    foreach (PhotonPlayer Player in PHPlayers)
                    {
                        if (Player.GetTeam() == PunTeams.Team.red)
                        {
                            Player.SetScore(0);
                        }
                        else if (Player.GetTeam() == PunTeams.Team.blue)
                        {
                            Player.SetScore(1);
                        }
                    }

                    m_bCheck = true;

                    Application.LoadLevelAdditive("scMessage");
                }
                else if (iBlueCnt == iBlueDieCnt)
                {
                    PhotonPlayer[] PHPlayers = PhotonNetwork.playerList;

                    foreach (PhotonPlayer Player in PHPlayers)
                    {
                        if (Player.GetTeam() == PunTeams.Team.red)
                        {
                            Player.SetScore(1);
                        }
                        else if (Player.GetTeam() == PunTeams.Team.blue)
                        {
                            Player.SetScore(0);
                        }
                    }

                    m_bCheck = true;

                    Application.LoadLevelAdditive("scMessage");
                }
            }
        }
    }
Beispiel #54
0
 private void Awake()
 {
     tower = gameObject.GetComponent <Tower>();
 }
Beispiel #55
0
 void Start()
 {
     tower        = GameObject.Find("Tower").GetComponent <Tower>();
     meshRenderer = GetComponent <MeshRenderer>();
 }
Beispiel #56
0
 public void Load(Tower tower)
 {
     tow = tower;
 }
Beispiel #57
0
    protected virtual void TowerInvadeAI()
    {
        if (type == NPCType.Neutral)
        {
            invadeCommand = InvadeCmd.DoNothing;
            return;
        }
        Tower nearestCompanionTower         = GetNearestTower(true, false);
        Tower nearestEnemyTower             = GetNearestTower(false, false);
        Tower nearestCompanionTowerInCombat = GetNearestTower(true, true);
        Tower nearestEnemyTowerInCombat     = GetNearestTower(false, false);

        if (IsCombat())
        {
            List <NPCController> npcInRange = new List <NPCController>();
            for (int i = 0; i < characterInBuffRange.Count; i++)
            {
                if (characterInBuffRange[i] is NPCController && Tags.IsCompanion(this, characterInBuffRange[i]))
                {
                    //只針對範圍內的下命令
                    npcInRange.Add(characterInBuffRange[i] as NPCController);
                }
            }
            //是塔的排前面
            npcInRange.Sort((a, b) =>
            {
                if (TowerFollowers.Contains(a) && !TowerFollowers.Contains(b))
                {
                    return(-1);
                }
                if (TowerFollowers.Contains(b) && !TowerFollowers.Contains(a))
                {
                    return(1);
                }
                return(0);
            });
            switch (invadeCommand)
            {
            case InvadeCmd.DoNothing:
                //戰鬥中將npc駐防
                for (int i = 0; i < stationNPC.Length; i++)
                {
                    if (npcInRange.Count > i && stationNPC[i] == null && TowerFollowers.Contains(npcInRange[i]))
                    {
                        stationNPC[i] = npcInRange[i];
                        npcInRange[i].Garrison(stationPosition[i]);
                    }
                }
                return;

            case InvadeCmd.OccupyNearestTower:
                invadeCommand = InvadeCmd.DoNothing;
                break;

            case InvadeCmd.DestroyNearestTower:
                invadeCommand = InvadeCmd.DoNothing;
                break;

            case InvadeCmd.SupportNearestTower:
                //外調的時候被打,開始防守
                invadeCommand = InvadeCmd.DoNothing;
                break;
            }
            for (int i = 0; i < npcInRange.Count; i++)
            {
                //只針對範圍內的下命令
                CommandFollowerInvade(npcInRange[i]);
            }
        }
        else
        {
            switch (invadeCommand)
            {
            case InvadeCmd.DoNothing:

                if (TowerFollowers.Count >= 5)
                {
                    ////滿了就解除駐守全送出去打
                    //for (int i = 0; i < stationNPC.Length; i++)
                    //{
                    //    if (stationNPC[i] != null)
                    //    {
                    //        stationNPC[i].Garrison(null);
                    //        stationNPC[i] = null;
                    //    }
                    //}
                    //鄰塔有戰事,支援林塔
                    if (nearestCompanionTowerInCombat != null)
                    {
                        invadeCommand = InvadeCmd.SupportNearestTower;
                    }
                    //或者衝最進敵塔
                    else if (nearestEnemyTower != null)
                    {
                        invadeCommand = InvadeCmd.DestroyNearestTower;
                    }
                }
                else
                {
                    //平時敵塔有戰事 增援
                    if (nearestCompanionTowerInCombat != null)
                    {
                        invadeCommand = InvadeCmd.DestroyNearestTower;
                    }
                }

                break;

            case InvadeCmd.OccupyNearestTower:
                if (nearestEnemyTower == null)
                {
                    invadeCommand = InvadeCmd.DoNothing;
                }
                break;

            case InvadeCmd.DestroyNearestTower:
                if (nearestEnemyTower == null)
                {
                    invadeCommand = InvadeCmd.DoNothing;
                }
                break;

            case InvadeCmd.SupportNearestTower:
                if (nearestCompanionTowerInCombat == null)
                {
                    invadeCommand = InvadeCmd.DoNothing;
                }
                break;
            }
            CommandFollowersInvade();
        }
    }
Beispiel #58
0
        private void CheckSpecialTriggers()
        {
            if (this.parent.player.mind.MindNow == MindWindow.MIND.smile)
            {
                this.parent.player.mind.MindNow = MindWindow.MIND.normal;
            }
            if (this.stageInitialized && this.parent.player.Hp > 5 && this.stage != Stage.Enraged)
            {
                this.enrageStage = this.stage;
                this.stage       = Stage.Enraged;
                this.EndStage(null);
            }

            var panels = Enumerable.Range(0, this.parent.panel.GetLength(0))
                         .SelectMany(px => Enumerable.Range(0, this.parent.panel.GetLength(1)).Select(py => new Point(px, py)));

            foreach (var panelPos in panels)
            {
                var panel        = this.parent.panel[panelPos.X, panelPos.Y];
                var delay        = 60;
                var reverseColor = panel.color == Panel.COLOR.blue ? Panel.COLOR.red : Panel.COLOR.blue;
                switch (panel.State)
                {
                case Panel.PANEL._grass:
                    if (!this.delayedPanelActions.ContainsKey(panelPos))
                    {
                        this.parent.attacks.Add(new Dummy(this.sound, this.parent, panelPos.X, panelPos.Y, reverseColor, Point.Empty, delay, true));
                        this.delayedPanelActions[panelPos] = new DelayedAction(delay, () =>
                        {
                            var burnTower = new Tower(this.sound, this.parent, panelPos.X, panelPos.Y, reverseColor, 50, -1, ChipBase.ELEMENT.heat);
                            this.parent.attacks.Add(burnTower);
                            panel.state = Panel.PANEL._nomal;
                        });
                    }
                    break;

                case Panel.PANEL._poison:
                    if (!this.delayedPanelActions.ContainsKey(panelPos))
                    {
                        this.parent.attacks.Add(new Dummy(this.sound, this.parent, panelPos.X, panelPos.Y, reverseColor, Point.Empty, delay, true));
                        this.delayedPanelActions[panelPos] = new DelayedAction(delay, () =>
                        {
                            var poisTower = new Tower(this.sound, this.parent, panelPos.X, panelPos.Y, reverseColor, 50, -1, ChipBase.ELEMENT.poison);
                            this.parent.attacks.Add(poisTower);
                            panel.state = Panel.PANEL._nomal;
                        });
                    }
                    break;
                }
            }

            foreach (var kvp in this.delayedPanelActions.ToList())
            {
                if (kvp.Value.RemainingLife != 0)
                {
                    kvp.Value.RemainingLife--;
                }
                else
                {
                    kvp.Value.Action.Invoke();
                    this.delayedPanelActions.Remove(kvp.Key);
                }
            }
        }
Beispiel #59
0
    public override void _Ready()
    {
        level = levels.GetLevel(0);

        path2d            = (Path2D)GetNode("Path2D");
        creditsLabel      = (Label)GetNode("Credits");
        healthLabel       = (Label)GetNode("Health");
        waveLabel         = (Label)GetNode("Wave");
        timer             = (Timer)GetNode("Timer");
        animationNextWave = (AnimationPlayer)GetNode("AnimationPlayer");

        deleteButton  = (Button)GetNode("DeleteButton");
        upgradeButton = (Button)GetNode("UpgradeButton");
        tower1Button  = (Button)GetNode("Tower1Button");
        tower2Button  = (Button)GetNode("Tower2Button");

        deleteButton.Disabled  = true;
        upgradeButton.Disabled = true;
        tower1Button.Disabled  = true;
        tower2Button.Disabled  = true;

        ground      = (PackedScene)ResourceLoader.Load("res://scenes/ground.tscn");
        wall        = (PackedScene)ResourceLoader.Load("res://scenes/wall.tscn");
        home        = (PackedScene)ResourceLoader.Load("res://scenes/home.tscn");
        enemy       = (PackedScene)ResourceLoader.Load("res://scenes/enemy.tscn");
        cursorScene = (PackedScene)ResourceLoader.Load("res://scenes/Cursor.tscn");
        alien1      = (PackedScene)ResourceLoader.Load("res://scenes/Alien1.tscn");
        alien2      = (PackedScene)ResourceLoader.Load("res://scenes/Alien2.tscn");
        alien3      = (PackedScene)ResourceLoader.Load("res://scenes/Alien3.tscn");
        tower1      = (PackedScene)ResourceLoader.Load("res://scenes/Tower1.tscn");
        tower2      = (PackedScene)ResourceLoader.Load("res://scenes/Tower2.tscn");

        cursor          = (Sprite)cursorScene.Instance();
        cursor.Position = GetPosition(0, 0);
        AddChild(cursor);

        cursorGrid = new Vector2(0, 0);

        rows    = level.Count;
        columns = level[0].Count;

        Position enemyPos = new Position(0, 0);
        Position homePos  = new Position(0, 0);

        var grid = new Grid(columns, rows, 1.0f);

        for (int y = 0; y < rows; y++)
        {
            for (int x = 0; x < columns; x++)
            {
                var index = level[y][x];
                var pos   = GetPosition(x, y);

                Node2D instance = null;
                Tower  tower    = null;

                switch (index)
                {
                case 0:
                    instance = (Sprite)ground.Instance();
                    break;

                case 1:
                    instance = (Sprite)wall.Instance();
                    grid.BlockCell(new Position(x, y));
                    break;

                case 2:
                    instance = (Sprite)enemy.Instance();
                    enemyPos = new Position(x, y);
                    break;

                case 3:
                    instance = (Home)home.Instance();
                    homePos  = new Position(x, y);
                    break;

                case 4:
                    instance = (Sprite)ground.Instance();
                    grid.BlockCell(new Position(x, y));

                    tower   = (Tower)tower1.Instance();
                    tower.X = x;
                    tower.Y = y;
                    break;
                }

                instance.Position = pos;
                AddChild(instance);
                if (tower != null)
                {
                    tower.Position = pos;
                    AddChild(tower);
                }
            }

            SetCredits();
            SetHealth();
        }

        var movement = new[]
        {
            new Offset(-1, 0),
            new Offset(0, -1),
            new Offset(1, 0),
            new Offset(0, 1)
        };
        var path = grid.GetPath(enemyPos, homePos, movement);

        foreach (var point in path)
        {
            var pos = GetPosition(point.X, point.Y);
            path2d.Curve.AddPoint(pos);
        }

        pathFollowers = new PathFollow2D[NUM_FOLLOWERS];

        GenerateAliens();
    }
Beispiel #60
0
 public void main()
 {
     Tower tower = new Tower();
 }