コード例 #1
0
    void OnMouseEnter()
    {
        if (map != null)
        {
            canAttack = true;
//		Material[] mat = this.GetComponent<Renderer>().materials;
//		mat[1] = hoverMaterialMouse;
//		GameObject ButtonScripts = GameObject.Find ("ButtonsCanvas");
//		ButtonScripts buttonScripts = ButtonScripts.GetComponent<ButtonScripts> ();
            GameObject        Player         = GameObject.Find(map.selecterPlayer);
            PlayableCharacter player         = Player.GetComponent <PlayableCharacter> ();
            GameObject        HighlightTiles = GameObject.Find("_Scripts");
            HighlightTiles    highlightTiles = HighlightTiles.GetComponent <HighlightTiles> ();
//		highlightTiles.HighlightTilesInRange();

            if (buttonScripts.moveSelected)
            {
                highlightTiles.tileX = tileX;
                highlightTiles.tileY = tileY;
                highlightTiles.ShowHoveringTileMovement();
            }

            if (buttonScripts.changeAreaTiles && hexVisible)
            {
                highlightTiles.ColorTargettedTiles();
                if (EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }
                GameObject      ChangeTilesArea = GameObject.Find("_Scripts");
                ChangeTilesArea changeTilesArea = ChangeTilesArea.GetComponent <ChangeTilesArea> ();
                changeTilesArea.tileX = tileX;
                changeTilesArea.tileY = tileY;
                changeTilesArea.CalculateArea(tileX, tileY);
            }


            if (buttonScripts.changeAreaTilesNoMid && map.UnitCanEnterTile(tileX, tileY) == true && hexVisible)
            {
                highlightTiles.ColorTargettedTiles();

                GameObject[] Enemies = GameObject.FindGameObjectsWithTag("Enemy");
                foreach (GameObject enemyAi in Enemies)
                {
                    BaseEnemy enemy = enemyAi.GetComponent <BaseEnemy> ();
                    if (enemy.TileX == tileX && enemy.TileY == tileY)
                    {
                        canAttack = false;
                        return;
                    }
                }

                if (EventSystem.current.IsPointerOverGameObject())
                {
                    return;
                }
                GameObject      ChangeTilesArea = GameObject.Find("_Scripts");
                ChangeTilesArea changeTilesArea = ChangeTilesArea.GetComponent <ChangeTilesArea> ();
                changeTilesArea.tileX = tileX;
                changeTilesArea.tileY = tileY;
                changeTilesArea.CalculateAreaNoMid(tileX, tileY);
            }


            if (buttonScripts.drawSelected && hexVisible)
            {
                highlightTiles.ColorTargettedTiles();
                GameObject   DrawLine = GameObject.Find("LineRenderer");
                DrawLine     drawLine = DrawLine.GetComponent <DrawLine> ();
                GameObject[] Tiles    = GameObject.FindGameObjectsWithTag("Hex");
                foreach (GameObject tile in Tiles)
                {
                    ClickableTile clickableTile = tile.GetComponent <ClickableTile> ();
                    clickableTile.lineTargetted = false;
                }
                drawLine.CheckLineTiles(player.PlayerClass.TileX, player.PlayerClass.TileY, tileX, tileY);

                drawLine.CheckEnemiesInLine();
            }

            if (buttonScripts.coneSelected)
            {
//			Debug.Log("tile " + tileX + " " + tileY);
                GameObject Cone = GameObject.Find("_Scripts");
                Cone       cone = Cone.GetComponent <Cone> ();
//			GameObject Unit = GameObject.Find (map.selecterPlayer);
//			Unit unit = Unit.GetComponent<Unit> ();
//			Debug.Log("tile " + unit.tileX + " " + unit.tileY);
                cone.CalculateCone(player.PlayerClass.TileX, player.PlayerClass.TileY, tileX, tileY);
                if (!willTakeHit)
                {
                    cone.CalculateConeEquals(player.PlayerClass.TileX, player.PlayerClass.TileY, tileX, tileY);
                }
            }
            if (buttonScripts.allySelected)
            {
                canAttack   = false;
                enemyTarget = false;
                // Makes basic coloring for all tiles in range
                highlightTiles.ShowTilesThatInRangeGeneral(player.PlayerClass.TileX, player.PlayerClass.TileY);
                highlightTiles.tileX = tileX;
                highlightTiles.tileY = tileY;
                if (canAttack)
                {
                    highlightTiles.ShowTilesThatWillBeHitSkill();
                }
                else if (!canAttack)
                {
                    highlightTiles.ShowTilesThatWillNotBeHitSkill();
                }
            }
            if (buttonScripts.trapSelected)
            {
                canAttack = false;
//			enemyTarget = true;
                // Makes basic coloring for all tiles in range
                highlightTiles.ShowTilesThatInTrapRange(player.PlayerClass.TileX, player.PlayerClass.TileY);
                highlightTiles.tileX = tileX;
                highlightTiles.tileY = tileY;
                if (canAttack)
                {
                    highlightTiles.ShowTilesThatWillBeHitSkill();
                }
                else if (!canAttack)
                {
                    highlightTiles.ShowTilesThatWillNotBeHitSkill();
                }
            }

            if (buttonScripts.attackSelected)
            {
                canAttack   = false;
                enemyTarget = true;
                // Makes basic coloring for all tiles in range
                highlightTiles.ShowTilesThatInRangeGeneral(player.PlayerClass.TileX, player.PlayerClass.TileY);
                highlightTiles.tileX = tileX;
                highlightTiles.tileY = tileY;
                if (canAttack)
                {
                    highlightTiles.ShowTilesThatWillBeHitSkill();
                }
                else if (!canAttack)
                {
                    highlightTiles.ShowTilesThatWillNotBeHitSkill();
                }
            }
        }
    }