Items #3
@ -1,9 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 7e1a318c8d9fd41a1928e605163c3994
|
|
||||||
folderAsset: yes
|
|
||||||
timeCreated: 1454018238
|
|
||||||
licenseType: Pro
|
|
||||||
DefaultImporter:
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,74 +0,0 @@
|
|||||||
%YAML 1.1
|
|
||||||
%TAG !u! tag:unity3d.com,2011:
|
|
||||||
--- !u!21 &2100000
|
|
||||||
Material:
|
|
||||||
serializedVersion: 6
|
|
||||||
m_ObjectHideFlags: 0
|
|
||||||
m_CorrespondingSourceObject: {fileID: 0}
|
|
||||||
m_PrefabInstance: {fileID: 0}
|
|
||||||
m_PrefabAsset: {fileID: 0}
|
|
||||||
m_Name: Vertex Colors
|
|
||||||
m_Shader: {fileID: 4800000, guid: 933d1387820694f55b3255b64eb5afcc, type: 3}
|
|
||||||
m_ShaderKeywords:
|
|
||||||
m_LightmapFlags: 5
|
|
||||||
m_EnableInstancingVariants: 0
|
|
||||||
m_DoubleSidedGI: 0
|
|
||||||
m_CustomRenderQueue: 2000
|
|
||||||
stringTagMap: {}
|
|
||||||
disabledShaderPasses: []
|
|
||||||
m_SavedProperties:
|
|
||||||
serializedVersion: 3
|
|
||||||
m_TexEnvs:
|
|
||||||
- _BumpMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _DetailAlbedoMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _DetailMask:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _DetailNormalMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _EmissionMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _MainTex:
|
|
||||||
m_Texture: {fileID: 2800000, guid: 983242f4b4db7a841af48234cf0021b8, type: 3}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _MetallicGlossMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _OcclusionMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
- _ParallaxMap:
|
|
||||||
m_Texture: {fileID: 0}
|
|
||||||
m_Scale: {x: 1, y: 1}
|
|
||||||
m_Offset: {x: 0, y: 0}
|
|
||||||
m_Floats:
|
|
||||||
- _BumpScale: 1
|
|
||||||
- _Cutoff: 0.5
|
|
||||||
- _DetailNormalMapScale: 1
|
|
||||||
- _DstBlend: 0
|
|
||||||
- _Glossiness: 0.5
|
|
||||||
- _Metallic: 0
|
|
||||||
- _Mode: 0
|
|
||||||
- _OcclusionStrength: 1
|
|
||||||
- _Parallax: 0.02
|
|
||||||
- _SrcBlend: 1
|
|
||||||
- _UVSec: 0
|
|
||||||
- _ZWrite: 1
|
|
||||||
m_Colors:
|
|
||||||
- _Color: {r: 1, g: 1, b: 1, a: 1}
|
|
||||||
- _EmissionColor: {r: 0, g: 0, b: 0, a: 1}
|
|
||||||
m_BuildTextureStacks: []
|
|
@ -1,8 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 6a3f5c7892e4b478e9e745026e6fe9f7
|
|
||||||
timeCreated: 1454018353
|
|
||||||
licenseType: Pro
|
|
||||||
NativeFormatImporter:
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -1,37 +0,0 @@
|
|||||||
Shader "Custom/VertexColors" {
|
|
||||||
Properties {
|
|
||||||
_Color ("Color", Color) = (1,1,1,1)
|
|
||||||
_MainTex ("Albedo (RGB)", 2D) = "white" {}
|
|
||||||
_Glossiness ("Smoothness", Range(0,1)) = 0.5
|
|
||||||
_Metallic ("Metallic", Range(0,1)) = 0.0
|
|
||||||
}
|
|
||||||
SubShader {
|
|
||||||
Tags { "RenderType"="Opaque" }
|
|
||||||
LOD 200
|
|
||||||
|
|
||||||
CGPROGRAM
|
|
||||||
#pragma surface surf Standard fullforwardshadows
|
|
||||||
#pragma target 3.0
|
|
||||||
|
|
||||||
sampler2D _MainTex;
|
|
||||||
|
|
||||||
struct Input {
|
|
||||||
float2 uv_MainTex;
|
|
||||||
float4 color : COLOR;
|
|
||||||
};
|
|
||||||
|
|
||||||
half _Glossiness;
|
|
||||||
half _Metallic;
|
|
||||||
fixed4 _Color;
|
|
||||||
|
|
||||||
void surf (Input IN, inout SurfaceOutputStandard o) {
|
|
||||||
fixed4 c = tex2D(_MainTex, IN.uv_MainTex) * _Color;
|
|
||||||
o.Albedo = c.rgb * IN.color;
|
|
||||||
o.Metallic = _Metallic;
|
|
||||||
o.Smoothness = _Glossiness;
|
|
||||||
o.Alpha = c.a;
|
|
||||||
}
|
|
||||||
ENDCG
|
|
||||||
}
|
|
||||||
FallBack "Diffuse"
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
fileFormatVersion: 2
|
|
||||||
guid: 933d1387820694f55b3255b64eb5afcc
|
|
||||||
timeCreated: 1454018276
|
|
||||||
licenseType: Pro
|
|
||||||
ShaderImporter:
|
|
||||||
defaultTextures: []
|
|
||||||
userData:
|
|
||||||
assetBundleName:
|
|
||||||
assetBundleVariant:
|
|
@ -80,4 +80,4 @@ MonoBehaviour:
|
|||||||
m_FallbackScreenDPI: 96
|
m_FallbackScreenDPI: 96
|
||||||
m_DefaultSpriteDPI: 96
|
m_DefaultSpriteDPI: 96
|
||||||
m_DynamicPixelsPerUnit: 10
|
m_DynamicPixelsPerUnit: 10
|
||||||
m_PresetInfoIsWorld: 0
|
m_PresetInfoIsWorld: 1
|
||||||
|
@ -29,7 +29,7 @@ Transform:
|
|||||||
m_GameObject: {fileID: 1661242500252451528}
|
m_GameObject: {fileID: 1661242500252451528}
|
||||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||||
m_LocalScale: {x: 5, y: 1, z: 5}
|
m_LocalScale: {x: 0.95, y: 1, z: 0.95}
|
||||||
m_Children: []
|
m_Children: []
|
||||||
m_Father: {fileID: 0}
|
m_Father: {fileID: 0}
|
||||||
m_RootOrder: 0
|
m_RootOrder: 0
|
||||||
@ -84,7 +84,7 @@ MeshRenderer:
|
|||||||
m_RenderingLayerMask: 1
|
m_RenderingLayerMask: 1
|
||||||
m_RendererPriority: 0
|
m_RendererPriority: 0
|
||||||
m_Materials:
|
m_Materials:
|
||||||
- {fileID: 2100000, guid: 6a3f5c7892e4b478e9e745026e6fe9f7, type: 2}
|
- {fileID: 2100000, guid: c02e8d529be43e94ab7b3ebd42206ef3, type: 2}
|
||||||
m_StaticBatchInfo:
|
m_StaticBatchInfo:
|
||||||
firstSubMesh: 0
|
firstSubMesh: 0
|
||||||
subMeshCount: 0
|
subMeshCount: 0
|
||||||
|
@ -489,6 +489,28 @@ AnimatorStateTransition:
|
|||||||
m_InterruptionSource: 0
|
m_InterruptionSource: 0
|
||||||
m_OrderedInterruption: 1
|
m_OrderedInterruption: 1
|
||||||
m_CanTransitionToSelf: 1
|
m_CanTransitionToSelf: 1
|
||||||
|
--- !u!1101 &4538047501552815396
|
||||||
|
AnimatorStateTransition:
|
||||||
|
m_ObjectHideFlags: 1
|
||||||
|
m_CorrespondingSourceObject: {fileID: 0}
|
||||||
|
m_PrefabInstance: {fileID: 0}
|
||||||
|
m_PrefabAsset: {fileID: 0}
|
||||||
|
m_Name:
|
||||||
|
m_Conditions: []
|
||||||
|
m_DstStateMachine: {fileID: 0}
|
||||||
|
m_DstState: {fileID: 9131620394910522952}
|
||||||
|
m_Solo: 0
|
||||||
|
m_Mute: 0
|
||||||
|
m_IsExit: 0
|
||||||
|
serializedVersion: 3
|
||||||
|
m_TransitionDuration: 0.25
|
||||||
|
m_TransitionOffset: 0
|
||||||
|
m_ExitTime: 0.53125
|
||||||
|
m_HasExitTime: 1
|
||||||
|
m_HasFixedDuration: 1
|
||||||
|
m_InterruptionSource: 0
|
||||||
|
m_OrderedInterruption: 1
|
||||||
|
m_CanTransitionToSelf: 1
|
||||||
--- !u!1101 &4600196034638274153
|
--- !u!1101 &4600196034638274153
|
||||||
AnimatorStateTransition:
|
AnimatorStateTransition:
|
||||||
m_ObjectHideFlags: 1
|
m_ObjectHideFlags: 1
|
||||||
@ -548,6 +570,7 @@ AnimatorState:
|
|||||||
- {fileID: -6460354900618266653}
|
- {fileID: -6460354900618266653}
|
||||||
- {fileID: -9165632119200558840}
|
- {fileID: -9165632119200558840}
|
||||||
- {fileID: -528955148574366107}
|
- {fileID: -528955148574366107}
|
||||||
|
- {fileID: 4538047501552815396}
|
||||||
m_StateMachineBehaviours: []
|
m_StateMachineBehaviours: []
|
||||||
m_Position: {x: 50, y: 50, z: 0}
|
m_Position: {x: 50, y: 50, z: 0}
|
||||||
m_IKOnFeet: 0
|
m_IKOnFeet: 0
|
||||||
|
@ -400,49 +400,49 @@ AnimatorController:
|
|||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: BackToIdle
|
- m_Name: BackToIdle
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: Build
|
- m_Name: Build
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: TreeAttack
|
- m_Name: TreeAttack
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: Move
|
- m_Name: Move
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: SuperJump
|
- m_Name: SuperJump
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: Frozen
|
- m_Name: Frozen
|
||||||
m_Type: 9
|
m_Type: 9
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
- m_Name: isMoving
|
- m_Name: isMoving
|
||||||
m_Type: 4
|
m_Type: 4
|
||||||
m_DefaultFloat: 0
|
m_DefaultFloat: 0
|
||||||
m_DefaultInt: 0
|
m_DefaultInt: 0
|
||||||
m_DefaultBool: 0
|
m_DefaultBool: 0
|
||||||
m_Controller: {fileID: 9100000}
|
m_Controller: {fileID: 0}
|
||||||
m_AnimatorLayers:
|
m_AnimatorLayers:
|
||||||
- serializedVersion: 5
|
- serializedVersion: 5
|
||||||
m_Name: Base Layer
|
m_Name: Base Layer
|
||||||
|
@ -2984,7 +2984,7 @@ Animator:
|
|||||||
m_GameObject: {fileID: 7527582019267571087}
|
m_GameObject: {fileID: 7527582019267571087}
|
||||||
m_Enabled: 1
|
m_Enabled: 1
|
||||||
m_Avatar: {fileID: 0}
|
m_Avatar: {fileID: 0}
|
||||||
m_Controller: {fileID: 9100000, guid: 6c6726efa8f26a44c89dbcc255bf46f9, type: 2}
|
m_Controller: {fileID: 9100000, guid: 9e1a6090cd4d65d4599676c24fcb5cff, type: 2}
|
||||||
m_CullingMode: 0
|
m_CullingMode: 0
|
||||||
m_UpdateMode: 0
|
m_UpdateMode: 0
|
||||||
m_ApplyRootMotion: 0
|
m_ApplyRootMotion: 0
|
||||||
|
@ -12,5 +12,5 @@ MonoBehaviour:
|
|||||||
m_Script: {fileID: 11500000, guid: 83b1020f31bf45569f5af6c77fc77d4e, type: 3}
|
m_Script: {fileID: 11500000, guid: 83b1020f31bf45569f5af6c77fc77d4e, type: 3}
|
||||||
m_Name: CameraData
|
m_Name: CameraData
|
||||||
m_EditorClassIdentifier:
|
m_EditorClassIdentifier:
|
||||||
offset: {x: -10, y: 15, z: -15}
|
offset: {x: 0, y: 15, z: -5}
|
||||||
smoothSpeed: 0.001
|
smoothSpeed: 2
|
||||||
|
@ -20,3 +20,4 @@ MonoBehaviour:
|
|||||||
joystickView: {fileID: 4385872142190176059, guid: 4df6913b39f4979429158c344680d83f,
|
joystickView: {fileID: 4385872142190176059, guid: 4df6913b39f4979429158c344680d83f,
|
||||||
type: 3}
|
type: 3}
|
||||||
Tick: 0.8
|
Tick: 0.8
|
||||||
|
hexTexture: {fileID: 2800000, guid: 0298dfcb0756f534a9a125d510461c7a, type: 3}
|
||||||
|
@ -31,7 +31,7 @@ namespace CamControl
|
|||||||
Vector3 desiredPosition = _target.position + _offset;
|
Vector3 desiredPosition = _target.position + _offset;
|
||||||
Vector3 smothedPosition =
|
Vector3 smothedPosition =
|
||||||
Vector3.Lerp(_camera.transform.position, desiredPosition, _smoothSpeed * Time.deltaTime);
|
Vector3.Lerp(_camera.transform.position, desiredPosition, _smoothSpeed * Time.deltaTime);
|
||||||
_camera.transform.position = desiredPosition;
|
_camera.transform.position = smothedPosition;
|
||||||
_camera.transform.LookAt(_target);
|
_camera.transform.LookAt(_target);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using Data;
|
using Data;
|
||||||
using HexFiled;
|
using HexFiled;
|
||||||
|
using TMPro;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
using Object = UnityEngine.Object;
|
using Object = UnityEngine.Object;
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ namespace Chars
|
|||||||
private GameObject prefab;
|
private GameObject prefab;
|
||||||
private HexCell _cell;
|
private HexCell _cell;
|
||||||
private HexGrid _hexGrid;
|
private HexGrid _hexGrid;
|
||||||
|
private Texture _texture;
|
||||||
public Action<GameObject> OnPlayerSpawned;
|
public Action<GameObject> OnPlayerSpawned;
|
||||||
|
|
||||||
public GameObject Playerinstance => _instance;
|
public GameObject Playerinstance => _instance;
|
||||||
@ -24,6 +26,7 @@ namespace Chars
|
|||||||
prefab = playerData.playerPrefab;
|
prefab = playerData.playerPrefab;
|
||||||
_isAlive = false;
|
_isAlive = false;
|
||||||
_hexGrid = hexGrid;
|
_hexGrid = hexGrid;
|
||||||
|
_texture = playerData.hexTexture;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -33,7 +36,7 @@ namespace Chars
|
|||||||
{
|
{
|
||||||
_cell = _cell.GetNeighbor(direction);
|
_cell = _cell.GetNeighbor(direction);
|
||||||
_curentPosition = _cell.coordinates;
|
_curentPosition = _cell.coordinates;
|
||||||
|
_cell.PaintHex(_texture);
|
||||||
_instance.transform.localPosition = _cell.transform.localPosition;
|
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -43,9 +46,15 @@ namespace Chars
|
|||||||
if (!_isAlive)
|
if (!_isAlive)
|
||||||
{
|
{
|
||||||
_cell = _hexGrid.GetCellFromCoord(_curentPosition);
|
_cell = _hexGrid.GetCellFromCoord(_curentPosition);
|
||||||
|
_cell.PaintHex(_texture);
|
||||||
|
for (int i = 0; i < 6; i++)
|
||||||
|
{
|
||||||
|
_cell.GetNeighbor((HexDirection)i).PaintHex(_texture);
|
||||||
|
}
|
||||||
_instance = Object.Instantiate(prefab, _cell.transform.parent);
|
_instance = Object.Instantiate(prefab, _cell.transform.parent);
|
||||||
_instance.transform.localPosition = _cell.transform.localPosition;
|
_instance.transform.localPosition = _cell.transform.localPosition;
|
||||||
OnPlayerSpawned?.Invoke(_instance);
|
OnPlayerSpawned?.Invoke(_instance);
|
||||||
|
_isAlive = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,5 +16,6 @@ namespace Runtime.Data
|
|||||||
public GameObject cellPrefab;
|
public GameObject cellPrefab;
|
||||||
public TMP_Text cellLabelPrefab;
|
public TMP_Text cellLabelPrefab;
|
||||||
public GameObject CoordinatesCanvas;
|
public GameObject CoordinatesCanvas;
|
||||||
|
public Texture DefaultTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -11,5 +11,6 @@ namespace Data
|
|||||||
public GameObject playerPrefab;
|
public GameObject playerPrefab;
|
||||||
public PlayerControlView joystickView;
|
public PlayerControlView joystickView;
|
||||||
public float Tick;
|
public float Tick;
|
||||||
|
public Texture hexTexture;
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,4 +1,5 @@
|
|||||||
using UnityEngine;
|
using System;
|
||||||
|
using UnityEngine;
|
||||||
|
|
||||||
namespace HexFiled
|
namespace HexFiled
|
||||||
{
|
{
|
||||||
@ -7,8 +8,10 @@ namespace HexFiled
|
|||||||
|
|
||||||
public HexCoordinates coordinates;
|
public HexCoordinates coordinates;
|
||||||
public Color color;
|
public Color color;
|
||||||
|
public Action<HexCell> OnHexPainted;
|
||||||
|
|
||||||
[SerializeField] private HexCell[] neighbors;
|
[SerializeField] private HexCell[] neighbors;
|
||||||
|
private static readonly int Player = Shader.PropertyToID("player");
|
||||||
|
|
||||||
public HexCell GetNeighbor(HexDirection direction)
|
public HexCell GetNeighbor(HexDirection direction)
|
||||||
{
|
{
|
||||||
@ -20,5 +23,11 @@ namespace HexFiled
|
|||||||
neighbors[(int)direction] = cell;
|
neighbors[(int)direction] = cell;
|
||||||
cell.neighbors[(int)direction.Opposite()] = this;
|
cell.neighbors[(int)direction.Opposite()] = this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void PaintHex(Texture texture)
|
||||||
|
{
|
||||||
|
gameObject.GetComponent<MeshRenderer>().material.mainTexture = texture;
|
||||||
|
OnHexPainted?.Invoke(this);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,7 @@ using Object = UnityEngine.Object;
|
|||||||
|
|
||||||
namespace HexFiled
|
namespace HexFiled
|
||||||
{
|
{
|
||||||
public class HexGrid : IInitialization, IExecute
|
public class HexGrid : IInitialization
|
||||||
{
|
{
|
||||||
private int _width;
|
private int _width;
|
||||||
private int _height;
|
private int _height;
|
||||||
@ -48,24 +48,6 @@ namespace HexFiled
|
|||||||
return _cells[i - 1];
|
return _cells[i - 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
void HandleInput()
|
|
||||||
{
|
|
||||||
Ray inputRay = _camera.ScreenPointToRay(Input.mousePosition);
|
|
||||||
RaycastHit hit;
|
|
||||||
if (Physics.Raycast(inputRay, out hit))
|
|
||||||
{
|
|
||||||
TouchCell(hit.point);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
void TouchCell(Vector3 position)
|
|
||||||
{
|
|
||||||
position = _baseGameObject.transform.InverseTransformPoint(position);
|
|
||||||
HexCoordinates coordinates = HexCoordinates.FromPosition(position);
|
|
||||||
PaintHex(_touchedColor, coordinates);
|
|
||||||
}
|
|
||||||
|
|
||||||
private void PaintHex(Color color, HexCoordinates coordinates)
|
private void PaintHex(Color color, HexCoordinates coordinates)
|
||||||
{
|
{
|
||||||
int index = coordinates.X + coordinates.Z * _width + coordinates.Z / 2;
|
int index = coordinates.X + coordinates.Z * _width + coordinates.Z / 2;
|
||||||
@ -88,6 +70,7 @@ namespace HexFiled
|
|||||||
cell.transform.localPosition = position;
|
cell.transform.localPosition = position;
|
||||||
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);
|
cell.coordinates = HexCoordinates.FromOffsetCoordinates(x, z);
|
||||||
cell.color = _defaultColor;
|
cell.color = _defaultColor;
|
||||||
|
cell.OnHexPainted += OnHexPainted;
|
||||||
|
|
||||||
if (x > 0) {
|
if (x > 0) {
|
||||||
cell.SetNeighbor(HexDirection.W, _cells[i - 1]);
|
cell.SetNeighbor(HexDirection.W, _cells[i - 1]);
|
||||||
@ -130,12 +113,5 @@ namespace HexFiled
|
|||||||
OnGridLoaded.Invoke();
|
OnGridLoaded.Invoke();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Execute()
|
|
||||||
{
|
|
||||||
if (Input.GetMouseButton(0))
|
|
||||||
{
|
|
||||||
HandleInput();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -4,18 +4,10 @@ namespace HexFiled
|
|||||||
{
|
{
|
||||||
public static class HexMetrics {
|
public static class HexMetrics {
|
||||||
|
|
||||||
public const float outerRadius = 5f;
|
public const float outerRadius = 1f;
|
||||||
|
|
||||||
public const float innerRadius = outerRadius * 0.866025404f;
|
public const float innerRadius = outerRadius * 0.866025404f;
|
||||||
|
|
||||||
public static Vector3[] corners = {
|
|
||||||
new Vector3(0f, 0f, outerRadius),
|
|
||||||
new Vector3(innerRadius, 0f, 0.5f * outerRadius),
|
|
||||||
new Vector3(innerRadius, 0f, -0.5f * outerRadius),
|
|
||||||
new Vector3(0f, 0f, -outerRadius),
|
|
||||||
new Vector3(-innerRadius, 0f, -0.5f * outerRadius),
|
|
||||||
new Vector3(-innerRadius, 0f, 0.5f * outerRadius),
|
|
||||||
new Vector3(0f, 0f, outerRadius)
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user