private void Update() { if (counter == 0) { // Instatiate gameObjects for (int i = 0; i < columns; i++) { for (int j = 0; j < rows; j++) { // Set current position currPos = new Vector3(initX + spacing * j, initY - spacing * i, 0.0f); // Instantiate, set parent and set attributes GameObject tileInstance = Instantiate(tile, currPos, Quaternion.identity); TileModifier tileModifier = tileInstance.GetComponent <TileModifier>(); tileModifier.x = initX + spacing * j; tileModifier.y = initY - spacing * i; tileMatrix[j, i] = tileInstance; tileInstance.transform.parent = transform; // Fill TileManager jagged array TileManager.instance.matrix[i, j] = 0; } } counter++; } }
//public bool HasTerrainProperty(TerrainDefinition.TerrainProperty property) //{ // return terrain.HasTerrainProperty(property); //} //public void SetRoadProperty(bool isRoad) //{ // if(HasTerrainProperty(TerrainDefinition.TerrainProperty.ROAD) != isRoad) // { // Debug.Log("[TileListener:SetRoadProperty] Setting ROAD to " + isRoad + "."); // terrain.properties ^= TerrainDefinition.TerrainProperty.ROAD; // if(isRoad) // { // var indicator = Instantiate(MapManager.singleton.roadIndicatorPrefab) as GameObject; // indicator.transform.SetParent(transform); // indicator.transform.localPosition = Vector3.zero; // streetSigns.Add(IntVector2.ZERO, indicator); // // add streetSigns for adjacent road tiles // foreach (GameObject tile in MapManager.singleton.AdjacentTiles(_gridPos,previewMap)) // { // var tL = tile.GetComponent<TileListener>(); // if (tL.HasTerrainProperty(TerrainDefinition.TerrainProperty.ROAD)) // { // var direction = tL.gridPos - gridPos; // AddRoadSegment(direction); // tL.AddRoadSegment(-direction); // } // } // } // else // { // foreach(var pair in streetSigns) // { // Destroy(pair.Value); // if(pair.Key != IntVector2.ZERO) // { // // remove matching streetSign from adjacent tile // var tL = MapManager.singleton.GetTileAt(gridPos + pair.Key, previewMap).GetComponent<TileListener>(); // tL.DeleteRoadSegment(-(pair.Key)); // } // } // streetSigns.Clear(); // } // } //} //public void AddRoadSegment(IntVector2 direction) //{ // if (streetSigns.ContainsKey(direction)) // { // Debug.LogError("[TileListener:AddRoadSegment] Already a RoadSegment in " + direction); // } // else // { // var segment = Instantiate(MapManager.singleton.roadSegmentPrefab) as GameObject; // segment.transform.SetParent(transform); // segment.transform.localPosition = Vector3.zero; // Quaternion angle = Quaternion.FromToRotation(Vector3.right, MapManager.singleton.GetTileAt(gridPos + direction, previewMap).transform.position - transform.position); // segment.transform.localRotation = angle; // streetSigns.Add(direction, segment); // } //} //public void DeleteRoadSegment(IntVector2 direction) //{ // if (streetSigns.ContainsKey(direction)) // { // Destroy(streetSigns[direction]); // streetSigns.Remove(direction); // } // else // { // Debug.LogError("[TileListener:AddRoadSegment] Already a RoadSegment in " + direction); // } //} public void AddModifier(TileModifier newMod) { if (modifiers != null) { if (!modifiers.Contains(newMod)) { modifiers.Add(newMod); } } }
protected override void Awake() { base.Awake(); rends = GetComponentsInChildren <Renderer>(true); mod = GetComponent <TileModifier>(); quest = GetComponent <TileQuestion>(); game = GetComponent <TileMinigame>(); move = GetComponent <TileMove>(); mod.score = quest.score = game.score = move.score = 15; mat = rends[0].material; }
public void GatherWeaponAttackStats(CharacterStats character, EnemyBaseClass enemy)//(CharacterCombat character, EnemyBaseClass enemy) { transform.LookAt(enemy.transform); Ray ray = new Ray(weaponFirePoint.transform.position, transform.forward * 100); //enemy.transform.position);//Input.mousePosition); Debug.DrawRay(weaponFirePoint.transform.position, transform.forward * 100, Color.red, 2); //enemy.transform.position, Color.red, 1);//Input.mousePosition, Color.red, 1); RaycastHit[] hits; hits = Physics.RaycastAll(ray, Vector3.Distance(this.transform.position, enemy.transform.position));//Mathf.Infinity);//enemy.transform.position.magnitude); ////Reset Odds //successShotProbability = 1; //damagePenalty = 1.0f; foreach (var hit in hits) { TileModifier cover = hit.collider.GetComponent <TileModifier>(); if (cover && cover.isCover) { if (cover.isHalfCover) { //Debug.Log("Hit HALF Cover"); successShotProbability -= cover.halfCoverPenalty; isHalfCover = true; } else if (cover.isFullCover) //&& !isCoverComputed) { //Debug.Log("Hit FULL Cover"); successShotProbability -= cover.fullCoverPenalty; isFullCover = true; } } EnemyBaseClass enemyclass = hit.collider.GetComponent <EnemyBaseClass>(); if (enemyclass) { //Debug.Log("Hit Enemy!!!"); distanceFromTarget = Vector3.Distance(character.transform.position, enemy.transform.position); //Debug.Log("Distance From The Target: " + distanceFromTarget); if (optimalRange + 1 >= distanceFromTarget && optimalRange - 1 <= distanceFromTarget)// { damagePenalty -= 0f; successShotProbability -= 0f; } else { damagePenalty -= 0.2f; successShotProbability -= .1f; } CalculateBaseDamage(); } } }
public void SetTileModifier(TileModifier modifier, int weight) { this.baseWeight = weight; if (modifier == TileModifier.Water) { graphics.GetComponent <MeshFilter>().mesh = JRPG.TerrainLibrary.instance.GetTerrain("hill").tileModel.GetComponent <MeshFilter>().sharedMesh; tileCenter.localPosition = new Vector3(tileCenter.localPosition.x, .23f, tileCenter.localPosition.z); text.transform.parent.localPosition = new Vector3(0f, 0.23f, 0f); } else { graphics.GetComponent <MeshFilter>().mesh = JRPG.TerrainLibrary.instance.GetTerrain("path").tileModel.GetComponent <MeshFilter>().sharedMesh; tileCenter.localPosition = new Vector3(tileCenter.localPosition.x, .02f, tileCenter.localPosition.z); text.transform.parent.localPosition = new Vector3(0f, 0.02f, 0f); } tileModifier = modifier; }
// Used to indirectly modify tile values through tile modifiers. 'name' parameter must be unique. public bool AddTileModifier(TileModifier newModifier, bool overwrite = false) { for (int index = 0; index < allModifiers.Count; index++) { if (allModifiers[index].name == newModifier.name) { if (overwrite == true) { allModifiers[index] = newModifier; return(true); } else { return(false); } } } allModifiers.Add(newModifier); return(true); }
public override IEnumerator DisplayAction(TileAction originTile) { inProgress = true; TileModifier tile = originTile as TileModifier; tile.IncrementScore(); if (tile.positive) { manager.DoublePlayer(); posContent.SetActive(true); } else { manager.BlockPlayer(); negContent.SetActive(true); } positive = tile.positive; while (inProgress) { yield return(null); } manager.EndTurn(); }
public TileModifier[] GetModifiers() { TileModifier[] output = new TileModifier[allModifiers.Count]; allModifiers.CopyTo(output); return(output); }
public void SetEmpty(int emptyWeight) { baseWeight = emptyWeight; tileModifier = TileModifier.None; entityPresent = EntityType.None; }
public void RemoveModifier(TileModifier modToRemove) { modifiers.Remove(modToRemove); }
private void Start() { IsBuildable = true; altitude = transform.position.y; tileModifier = GetComponent <TileModifier>(); }
public MapTile(Map map, int x, int y, TileModifier modifier) { _map = map; Location = new Point(x, y); Modifier = modifier; }