diff --git a/Assets/Animation.meta b/Assets/Animation.meta new file mode 100644 index 000000000..350720dcf --- /dev/null +++ b/Assets/Animation.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 8e88556716dc51f45ab6e9303aa07c2d +folderAsset: yes +timeCreated: 1454603848 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/body.anim b/Assets/Animation/body.anim new file mode 100644 index 000000000..2e714765a --- /dev/null +++ b/Assets/Animation/body.anim @@ -0,0 +1,73 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: body + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: + - curve: + - time: 0 + value: {fileID: 21300000, guid: 7a657d060bb332a49ba8414af8c74414, type: 3} + - time: 0.083333336 + value: {fileID: 21300002, guid: 7a657d060bb332a49ba8414af8c74414, type: 3} + - time: 0.16666667 + value: {fileID: 21300004, guid: 7a657d060bb332a49ba8414af8c74414, type: 3} + attribute: m_Sprite + path: + classID: 212 + script: {fileID: 0} + m_SampleRate: 12 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - path: 0 + attribute: 0 + script: {fileID: 0} + classID: 212 + customType: 23 + isPPtrCurve: 1 + pptrCurveMapping: + - {fileID: 21300000, guid: 7a657d060bb332a49ba8414af8c74414, type: 3} + - {fileID: 21300002, guid: 7a657d060bb332a49ba8414af8c74414, type: 3} + - {fileID: 21300004, guid: 7a657d060bb332a49ba8414af8c74414, type: 3} + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 0.25 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 1 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_GenerateMotionCurves: 0 + m_Events: [] diff --git a/Assets/Animation/body.anim.meta b/Assets/Animation/body.anim.meta new file mode 100644 index 000000000..69815ddcb --- /dev/null +++ b/Assets/Animation/body.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: d4161c83e48d4fa47b7d304bd64125ba +timeCreated: 1454604215 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/head.anim b/Assets/Animation/head.anim new file mode 100644 index 000000000..ea7848ce1 --- /dev/null +++ b/Assets/Animation/head.anim @@ -0,0 +1,73 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: head + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: + - curve: + - time: 0 + value: {fileID: 21300000, guid: 459841720cf24d544b480412a96497c0, type: 3} + - time: 0.083333336 + value: {fileID: 21300002, guid: 459841720cf24d544b480412a96497c0, type: 3} + - time: 0.16666667 + value: {fileID: 21300004, guid: 459841720cf24d544b480412a96497c0, type: 3} + attribute: m_Sprite + path: + classID: 212 + script: {fileID: 0} + m_SampleRate: 12 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - path: 0 + attribute: 0 + script: {fileID: 0} + classID: 212 + customType: 23 + isPPtrCurve: 1 + pptrCurveMapping: + - {fileID: 21300000, guid: 459841720cf24d544b480412a96497c0, type: 3} + - {fileID: 21300002, guid: 459841720cf24d544b480412a96497c0, type: 3} + - {fileID: 21300004, guid: 459841720cf24d544b480412a96497c0, type: 3} + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 0.25 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 1 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_GenerateMotionCurves: 0 + m_Events: [] diff --git a/Assets/Animation/head.anim.meta b/Assets/Animation/head.anim.meta new file mode 100644 index 000000000..406f86679 --- /dev/null +++ b/Assets/Animation/head.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: a84d74996f8a7fd4983fc2c430970458 +timeCreated: 1454603866 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/inPortal.anim b/Assets/Animation/inPortal.anim new file mode 100644 index 000000000..0c34cb7bb --- /dev/null +++ b/Assets/Animation/inPortal.anim @@ -0,0 +1,76 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: inPortal + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: + - curve: + - time: 0 + value: {fileID: 21300000, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + - time: 0.083333336 + value: {fileID: 21300002, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + - time: 0.16666667 + value: {fileID: 21300004, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + - time: 0.25 + value: {fileID: 21300006, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + attribute: m_Sprite + path: + classID: 212 + script: {fileID: 0} + m_SampleRate: 12 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: + - path: 0 + attribute: 0 + script: {fileID: 0} + classID: 212 + customType: 23 + isPPtrCurve: 1 + pptrCurveMapping: + - {fileID: 21300000, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + - {fileID: 21300002, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + - {fileID: 21300004, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + - {fileID: 21300006, guid: 3cd4f75a0fe3e884683b2df3975933f6, type: 3} + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 0.33333334 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 1 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_GenerateMotionCurves: 0 + m_Events: [] diff --git a/Assets/Animation/inPortal.anim.meta b/Assets/Animation/inPortal.anim.meta new file mode 100644 index 000000000..ecaf2cf13 --- /dev/null +++ b/Assets/Animation/inPortal.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 8d7e37641ff58284c9a095c695ce36a9 +timeCreated: 1454705957 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/newhad-chvost_0 (1).controller b/Assets/Animation/newhad-chvost_0 (1).controller new file mode 100644 index 000000000..e42b5448a --- /dev/null +++ b/Assets/Animation/newhad-chvost_0 (1).controller @@ -0,0 +1,67 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: newhad-chvost_0 (1) + serializedVersion: 5 + m_AnimatorParameters: [] + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: New Layer + m_StateMachine: {fileID: 110775094} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1102 &110246442 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: tail + m_Speed: 0.4 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 32236c37f0276f34e8028e701cefc6b6, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: +--- !u!1107 &110775094 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: New Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 110246442} + m_Position: {x: 393, y: 15, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 264, y: 96, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 110246442} diff --git a/Assets/Animation/newhad-chvost_0 (1).controller.meta b/Assets/Animation/newhad-chvost_0 (1).controller.meta new file mode 100644 index 000000000..3f4872864 --- /dev/null +++ b/Assets/Animation/newhad-chvost_0 (1).controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0ef66ff41e6dfc54281b8fe147fbc46c +timeCreated: 1454664565 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/newhad-hlava_0 (1).controller b/Assets/Animation/newhad-hlava_0 (1).controller new file mode 100644 index 000000000..f6bb3a25b --- /dev/null +++ b/Assets/Animation/newhad-hlava_0 (1).controller @@ -0,0 +1,67 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: newhad-hlava_0 (1) + serializedVersion: 5 + m_AnimatorParameters: [] + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: Base Layer + m_StateMachine: {fileID: 110799810} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1102 &110208210 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: head + m_Speed: 0.4 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_Motion: {fileID: 7400000, guid: a84d74996f8a7fd4983fc2c430970458, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: +--- !u!1107 &110799810 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Base Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 110208210} + m_Position: {x: 200, y: 0, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 50, y: 120, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 110208210} diff --git a/Assets/Animation/newhad-hlava_0 (1).controller.meta b/Assets/Animation/newhad-hlava_0 (1).controller.meta new file mode 100644 index 000000000..890822665 --- /dev/null +++ b/Assets/Animation/newhad-hlava_0 (1).controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 0bd961b20c627b644836c67d34ce07d2 +timeCreated: 1454664274 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/newhad-telo_0 (1).controller b/Assets/Animation/newhad-telo_0 (1).controller new file mode 100644 index 000000000..30b903112 --- /dev/null +++ b/Assets/Animation/newhad-telo_0 (1).controller @@ -0,0 +1,67 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: newhad-telo_0 (1) + serializedVersion: 5 + m_AnimatorParameters: [] + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: Base Layer + m_StateMachine: {fileID: 110745792} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1102 &110222400 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: body + m_Speed: 0.4 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_Motion: {fileID: 7400000, guid: d4161c83e48d4fa47b7d304bd64125ba, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: +--- !u!1107 &110745792 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Base Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 110222400} + m_Position: {x: 312, y: 0, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 144, y: 120, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 110222400} diff --git a/Assets/Animation/newhad-telo_0 (1).controller.meta b/Assets/Animation/newhad-telo_0 (1).controller.meta new file mode 100644 index 000000000..e2caf3089 --- /dev/null +++ b/Assets/Animation/newhad-telo_0 (1).controller.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: bada347f1b611d5488f413a5bd028143 +timeCreated: 1454664441 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git "a/Assets/Animation/newport\303\241l-vstup_0.controller" "b/Assets/Animation/newport\303\241l-vstup_0.controller" new file mode 100644 index 000000000..be93d2484 --- /dev/null +++ "b/Assets/Animation/newport\303\241l-vstup_0.controller" @@ -0,0 +1,67 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!91 &9100000 +AnimatorController: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: "newport\xE1l-vstup_0" + serializedVersion: 5 + m_AnimatorParameters: [] + m_AnimatorLayers: + - serializedVersion: 5 + m_Name: Base Layer + m_StateMachine: {fileID: 110745320} + m_Mask: {fileID: 0} + m_Motions: [] + m_Behaviours: [] + m_BlendingMode: 0 + m_SyncedLayerIndex: -1 + m_DefaultWeight: 0 + m_IKPass: 0 + m_SyncedLayerAffectsTiming: 0 + m_Controller: {fileID: 9100000} +--- !u!1102 &110263268 +AnimatorState: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: inPortal + m_Speed: 1 + m_CycleOffset: 0 + m_Transitions: [] + m_StateMachineBehaviours: [] + m_Position: {x: 50, y: 50, z: 0} + m_IKOnFeet: 0 + m_WriteDefaultValues: 1 + m_Mirror: 0 + m_SpeedParameterActive: 0 + m_MirrorParameterActive: 0 + m_CycleOffsetParameterActive: 0 + m_Motion: {fileID: 7400000, guid: 8d7e37641ff58284c9a095c695ce36a9, type: 2} + m_Tag: + m_SpeedParameter: + m_MirrorParameter: + m_CycleOffsetParameter: +--- !u!1107 &110745320 +AnimatorStateMachine: + serializedVersion: 5 + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: Base Layer + m_ChildStates: + - serializedVersion: 1 + m_State: {fileID: 110263268} + m_Position: {x: 200, y: 0, z: 0} + m_ChildStateMachines: [] + m_AnyStateTransitions: [] + m_EntryTransitions: [] + m_StateMachineTransitions: {} + m_StateMachineBehaviours: [] + m_AnyStatePosition: {x: 50, y: 20, z: 0} + m_EntryPosition: {x: 50, y: 120, z: 0} + m_ExitPosition: {x: 800, y: 120, z: 0} + m_ParentStateMachinePosition: {x: 800, y: 20, z: 0} + m_DefaultState: {fileID: 110263268} diff --git "a/Assets/Animation/newport\303\241l-vstup_0.controller.meta" "b/Assets/Animation/newport\303\241l-vstup_0.controller.meta" new file mode 100644 index 000000000..4063d4ebc --- /dev/null +++ "b/Assets/Animation/newport\303\241l-vstup_0.controller.meta" @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f3d51a3fd7b1b994f94311b171053b23 +timeCreated: 1454705957 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Animation/tail.anim b/Assets/Animation/tail.anim new file mode 100644 index 000000000..7aa954092 --- /dev/null +++ b/Assets/Animation/tail.anim @@ -0,0 +1,53 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!74 &7400000 +AnimationClip: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: tail + serializedVersion: 6 + m_Legacy: 0 + m_Compressed: 0 + m_UseHighQualityCurve: 1 + m_RotationCurves: [] + m_CompressedRotationCurves: [] + m_EulerCurves: [] + m_PositionCurves: [] + m_ScaleCurves: [] + m_FloatCurves: [] + m_PPtrCurves: [] + m_SampleRate: 60 + m_WrapMode: 0 + m_Bounds: + m_Center: {x: 0, y: 0, z: 0} + m_Extent: {x: 0, y: 0, z: 0} + m_ClipBindingConstant: + genericBindings: [] + pptrCurveMapping: [] + m_AnimationClipSettings: + serializedVersion: 2 + m_AdditiveReferencePoseClip: {fileID: 0} + m_AdditiveReferencePoseTime: 0 + m_StartTime: 0 + m_StopTime: 1 + m_OrientationOffsetY: 0 + m_Level: 0 + m_CycleOffset: 0 + m_HasAdditiveReferencePose: 0 + m_LoopTime: 1 + m_LoopBlend: 0 + m_LoopBlendOrientation: 0 + m_LoopBlendPositionY: 0 + m_LoopBlendPositionXZ: 0 + m_KeepOriginalOrientation: 0 + m_KeepOriginalPositionY: 1 + m_KeepOriginalPositionXZ: 0 + m_HeightFromFeet: 0 + m_Mirror: 0 + m_EditorCurves: [] + m_EulerEditorCurves: [] + m_HasGenericRootTransform: 0 + m_HasMotionFloatCurves: 0 + m_GenerateMotionCurves: 0 + m_Events: [] diff --git a/Assets/Animation/tail.anim.meta b/Assets/Animation/tail.anim.meta new file mode 100644 index 000000000..92240d99c --- /dev/null +++ b/Assets/Animation/tail.anim.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 32236c37f0276f34e8028e701cefc6b6 +timeCreated: 1454604638 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fonts.meta b/Assets/Fonts.meta new file mode 100644 index 000000000..362668b8b --- /dev/null +++ b/Assets/Fonts.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 02e149247513d724bba26a67d2012c12 +folderAsset: yes +timeCreated: 1454440600 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fonts/GANG BANG CRIME.ttf b/Assets/Fonts/GANG BANG CRIME.ttf new file mode 100644 index 000000000..e556e0cc6 Binary files /dev/null and b/Assets/Fonts/GANG BANG CRIME.ttf differ diff --git a/Assets/Fonts/GANG BANG CRIME.ttf.meta b/Assets/Fonts/GANG BANG CRIME.ttf.meta new file mode 100644 index 000000000..b7df9fbec --- /dev/null +++ b/Assets/Fonts/GANG BANG CRIME.ttf.meta @@ -0,0 +1,19 @@ +fileFormatVersion: 2 +guid: 2c9eafd41cc2c6a47b75c3fce04199bf +timeCreated: 1454440566 +licenseType: Free +TrueTypeFontImporter: + serializedVersion: 2 + fontSize: 16 + forceTextureCase: -2 + characterSpacing: 1 + characterPadding: 0 + includeFontData: 1 + use2xBehaviour: 0 + fontNames: [] + fallbackFontReferences: [] + customCharacters: + fontRenderingMode: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Fonts/SNAKV___.TTF b/Assets/Fonts/SNAKV___.TTF new file mode 100644 index 000000000..089073d30 Binary files /dev/null and b/Assets/Fonts/SNAKV___.TTF differ diff --git a/Assets/Fonts/SNAKV___.TTF.meta b/Assets/Fonts/SNAKV___.TTF.meta new file mode 100644 index 000000000..985876ce6 --- /dev/null +++ b/Assets/Fonts/SNAKV___.TTF.meta @@ -0,0 +1,19 @@ +fileFormatVersion: 2 +guid: fe4de8c8f8accd842bf109d2885b91d8 +timeCreated: 1454500560 +licenseType: Free +TrueTypeFontImporter: + serializedVersion: 2 + fontSize: 16 + forceTextureCase: -2 + characterSpacing: 1 + characterPadding: 0 + includeFontData: 1 + use2xBehaviour: 0 + fontNames: [] + fallbackFontReferences: [] + customCharacters: + fontRenderingMode: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/background.png b/Assets/Materials/background.png new file mode 100644 index 000000000..21d3211f5 Binary files /dev/null and b/Assets/Materials/background.png differ diff --git a/Assets/Materials/background.png.meta b/Assets/Materials/background.png.meta new file mode 100644 index 000000000..287204d0c --- /dev/null +++ b/Assets/Materials/background.png.meta @@ -0,0 +1,57 @@ +fileFormatVersion: 2 +guid: e82e8117ee89e644580c544dde5ecf3c +timeCreated: 1454594378 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: 0.25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 7 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: 0.5, y: 0.5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 1 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + outline: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/backgroundMaterial.mat b/Assets/Materials/backgroundMaterial.mat new file mode 100644 index 000000000..a65e46529 --- /dev/null +++ b/Assets/Materials/backgroundMaterial.mat @@ -0,0 +1,142 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 0} + m_Name: backgroundMaterial + m_Shader: {fileID: 10800, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: PIXELSNAP_ON + m_LightmapFlags: 5 + m_CustomRenderQueue: 3000 + stringTagMap: {} + m_SavedProperties: + serializedVersion: 2 + m_TexEnvs: + data: + first: + name: _MainTex + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _BumpMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailNormalMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _ParallaxMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _OcclusionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _EmissionMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailMask + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _DetailAlbedoMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + data: + first: + name: _MetallicGlossMap + second: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + data: + first: + name: _SrcBlend + second: 1 + data: + first: + name: _DstBlend + second: 0 + data: + first: + name: _Cutoff + second: 0.5 + data: + first: + name: PixelSnap + second: 1 + data: + first: + name: _Parallax + second: 0.02 + data: + first: + name: _ZWrite + second: 1 + data: + first: + name: _Glossiness + second: 1 + data: + first: + name: _BumpScale + second: 1 + data: + first: + name: _OcclusionStrength + second: 1 + data: + first: + name: _DetailNormalMapScale + second: 1 + data: + first: + name: _UVSec + second: 0 + data: + first: + name: _Mode + second: 0 + data: + first: + name: _Metallic + second: 0 + m_Colors: + data: + first: + name: _EmissionColor + second: {r: 0, g: 0, b: 0, a: 1} + data: + first: + name: _Color + second: {r: 1, g: 1, b: 1, a: 1} diff --git a/Assets/Materials/backgroundMaterial.mat.meta b/Assets/Materials/backgroundMaterial.mat.meta new file mode 100644 index 000000000..718e6b2db --- /dev/null +++ b/Assets/Materials/backgroundMaterial.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: ef0a37ca83f8a944e9596c68176884c9 +timeCreated: 1454597442 +licenseType: Free +NativeFormatImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/border_horizontal.png b/Assets/Materials/border_horizontal.png new file mode 100644 index 000000000..48f3eea50 Binary files /dev/null and b/Assets/Materials/border_horizontal.png differ diff --git a/Assets/Materials/border_horizontal.png.meta b/Assets/Materials/border_horizontal.png.meta new file mode 100644 index 000000000..57544c86e --- /dev/null +++ b/Assets/Materials/border_horizontal.png.meta @@ -0,0 +1,56 @@ +fileFormatVersion: 2 +guid: 9e90dfcec8e38fa49a3ca5d50e481493 +timeCreated: 1444524214 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 1 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/border_vertical.png b/Assets/Materials/border_vertical.png new file mode 100644 index 000000000..208c37d0c Binary files /dev/null and b/Assets/Materials/border_vertical.png differ diff --git a/Assets/Materials/border_vertical.png.meta b/Assets/Materials/border_vertical.png.meta new file mode 100644 index 000000000..407b0d8e2 --- /dev/null +++ b/Assets/Materials/border_vertical.png.meta @@ -0,0 +1,56 @@ +fileFormatVersion: 2 +guid: 9c8481b34563c124f96d9e0ff4d907d8 +timeCreated: 1444524199 +licenseType: Free +TextureImporter: + fileIDToRecycleName: {} + serializedVersion: 2 + mipmaps: + mipMapMode: 0 + enableMipMap: 1 + linearTexture: 0 + correctGamma: 0 + fadeOut: 0 + borderMipMap: 0 + mipMapFadeDistanceStart: 1 + mipMapFadeDistanceEnd: 3 + bumpmap: + convertToNormalMap: 0 + externalNormalMap: 0 + heightScale: .25 + normalMapFilter: 0 + isReadable: 0 + grayScaleToAlpha: 0 + generateCubemap: 0 + cubemapConvolution: 0 + cubemapConvolutionSteps: 8 + cubemapConvolutionExponent: 1.5 + seamlessCubemap: 0 + textureFormat: -1 + maxTextureSize: 2048 + textureSettings: + filterMode: -1 + aniso: 16 + mipBias: -1 + wrapMode: 1 + nPOTScale: 0 + lightmap: 0 + rGBM: 0 + compressionQuality: 50 + allowsAlphaSplitting: 0 + spriteMode: 1 + spriteExtrude: 1 + spriteMeshType: 1 + alignment: 0 + spritePivot: {x: .5, y: .5} + spriteBorder: {x: 0, y: 0, z: 0, w: 0} + spritePixelsToUnits: 1 + alphaIsTransparency: 1 + textureType: 8 + buildTargetSettings: [] + spriteSheet: + sprites: [] + spritePackingTag: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Music.meta b/Assets/Music.meta new file mode 100644 index 000000000..d64fbd729 --- /dev/null +++ b/Assets/Music.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: eeb3c78c22ae9624394d404e15f12eb8 +folderAsset: yes +timeCreated: 1454628105 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Music/ham.mp3 b/Assets/Music/ham.mp3 new file mode 100644 index 000000000..f617010e8 Binary files /dev/null and b/Assets/Music/ham.mp3 differ diff --git a/Assets/Music/ham.mp3.meta b/Assets/Music/ham.mp3.meta new file mode 100644 index 000000000..1cbb0c057 --- /dev/null +++ b/Assets/Music/ham.mp3.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 2fa676a765e3aae4ebf3cc9849393231 +timeCreated: 1454705655 +licenseType: Free +AudioImporter: + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Music/snakeAudio2.mp3 b/Assets/Music/snakeAudio2.mp3 new file mode 100644 index 000000000..483072202 Binary files /dev/null and b/Assets/Music/snakeAudio2.mp3 differ diff --git a/Assets/Music/snakeAudio2.mp3.meta b/Assets/Music/snakeAudio2.mp3.meta new file mode 100644 index 000000000..b71945889 --- /dev/null +++ b/Assets/Music/snakeAudio2.mp3.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: f77dc9cf2edf1294b95fcfb1b8dace2d +timeCreated: 1454708216 +licenseType: Free +AudioImporter: + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Music/snakeMusic.mp3 b/Assets/Music/snakeMusic.mp3 new file mode 100644 index 000000000..e4f494dda Binary files /dev/null and b/Assets/Music/snakeMusic.mp3 differ diff --git a/Assets/Music/snakeMusic.mp3.meta b/Assets/Music/snakeMusic.mp3.meta new file mode 100644 index 000000000..6bc9f6cbd --- /dev/null +++ b/Assets/Music/snakeMusic.mp3.meta @@ -0,0 +1,22 @@ +fileFormatVersion: 2 +guid: 8c41c998f9735cd448d2713c0d979ffb +timeCreated: 1454683358 +licenseType: Free +AudioImporter: + serializedVersion: 6 + defaultSettings: + loadType: 0 + sampleRateSetting: 0 + sampleRateOverride: 44100 + compressionFormat: 1 + quality: 1 + conversionMode: 0 + platformSettingOverrides: {} + forceToMono: 0 + normalize: 1 + preloadAudioData: 1 + loadInBackground: 0 + 3D: 1 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources.meta b/Assets/Resources.meta new file mode 100644 index 000000000..b9f34c287 --- /dev/null +++ b/Assets/Resources.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 99cb72734b2f0b14a86b009618f98a9b +folderAsset: yes +timeCreated: 1454690018 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Resources/TextAsset.meta b/Assets/Resources/TextAsset.meta new file mode 100644 index 000000000..05c24efe5 --- /dev/null +++ b/Assets/Resources/TextAsset.meta @@ -0,0 +1,9 @@ +fileFormatVersion: 2 +guid: 7f40fa6a4f62cd94ca9431e1ab70fbda +folderAsset: yes +timeCreated: 1454624670 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: textasset + assetBundleVariant: diff --git a/Assets/Resources/TextAsset/test.txt b/Assets/Resources/TextAsset/test.txt new file mode 100644 index 000000000..7aef35e48 --- /dev/null +++ b/Assets/Resources/TextAsset/test.txt @@ -0,0 +1,71 @@ +{ + "levels": [ + {"name": "level_0", + "reqLength": 10, + + + "pictures": [ + { "x": 15, "y": 1 , "type": 0, "desc":"hrnek"} + ], + + "bariers": [ + { "x": 15, "y": 1 }, { "x": 16, "y": 1 }, { "x": 17, "y": 1 },{ "x": 18, "y": 1 },{ "x": 19, "y": 1 }, + { "x": 15, "y": 2 }, { "x": 16, "y": 2 }, { "x": 17, "y": 2 },{ "x": 18, "y": 2 },{ "x": 19, "y": 2 }, + { "x": 15, "y": 3 }, { "x": 16, "y": 3 }, { "x": 17, "y": 3 },{ "x": 18, "y": 3 },{ "x": 19, "y": 3 }, + { "x": 15, "y": 4 }, { "x": 16, "y": 4 }, { "x": 17, "y": 4 },{ "x": 18, "y": 4 },{ "x": 19, "y": 4 } + ] + }, + {"name": "level_1", + "reqLength": 10, + + "pictures": [ + { "x": 4, "y": 1 , "type": 1, "desc":"guma"},{ "x": 1, "y": 8 , "type": 2, "desc":"tuzka"} + ] + + "bariers": [ + { "x": 4, "y": 1 }, { "x": 5, "y": 1 }, { "x": 6, "y": 1 }, { "x": 7, "y": 1 }, { "x": 8, "y": 1 }, + { "x": 4, "y": 2 }, { "x": 5, "y": 2 }, { "x": 6, "y": 2 }, { "x": 7, "y": 2 }, { "x": 8, "y": 2 }, + { "x": 1, "y": 8 }, { "x": 2, "y": 8 }, { "x": 3, "y": 8 }, { "x": 4, "y": 8 }, { "x": 5, "y": 8 },{ "x": 9, "y": 8 }, { "x": 10, "y": 8 }, { "x": 11, "y": 8 }, { "x": 12, "y": 8 }, { "x": 13, "y": 8 }, { "x": 14, "y": 8 }, { "x": 15, "y": 8 }, { "x": 16, "y": 8 },{ "x": 17, "y": 8 }, { "x": 18, "y": 8 } + ] + }, + {"name": "level_3", + "reqLength": 10, + + "pictures": [ + { "x": 12, "y": 7 , "type": 1, "desc":"guma"},{ "x": 3, "y": 1 , "type": 3, "desc":"mobil"} + ] + + "bariers": [ + { "x": 12, "y": 7 }, { "x": 13, "y": 7 }, { "x": 14, "y": 7 }, { "x": 15, "y": 7 }, { "x": 16, "y": 7 }, + { "x": 12, "y": 8 }, { "x": 13, "y": 8 }, { "x": 14, "y": 8 }, { "x": 15, "y": 8 }, { "x": 16, "y": 8 }, + { "x": 3, "y": 1 }, { "x":4, "y": 1 }, { "x": 5, "y": 1 }, { "x": 6, "y": 1 }, { "x": 7, "y": 1 }, { "x": 8, "y": 1 }, + { "x": 3, "y": 2 }, { "x":4, "y": 2 }, { "x": 5, "y": 2 }, { "x": 6, "y": 2 }, { "x": 7, "y": 2 }, { "x": 8, "y": 2 }, + { "x": 3, "y": 3 }, { "x":4, "y": 3 }, { "x": 5, "y": 3 }, { "x": 6, "y": 3 }, { "x": 7, "y": 3 }, { "x": 8, "y": 3 }, + { "x": 3, "y": 4 }, { "x":4, "y": 4 }, { "x": 5, "y": 4 }, { "x": 6, "y": 4 }, { "x": 7, "y": 4 }, { "x": 8, "y": 4 }, + { "x": 3, "y": 5 }, { "x":4, "y": 5 }, { "x": 5, "y": 5 }, { "x": 6, "y": 5 }, { "x": 7, "y": 5 }, { "x": 8, "y": 5 }, + { "x": 3, "y": 6 }, { "x":4, "y": 6 }, { "x": 5, "y": 6 }, { "x": 6, "y": 6 }, { "x": 7, "y": 6 }, { "x": 8, "y": 6 }, + { "x": 3, "y": 7 }, { "x":4, "y": 7 }, { "x": 5, "y": 7 }, { "x": 6, "y": 7 }, { "x": 7, "y": 7 }, { "x": 8, "y": 7 }, + { "x": 3, "y": 8 }, { "x":4, "y": 8 }, { "x": 5, "y": 8 }, { "x": 6, "y": 8 }, { "x": 7, "y": 8 }, { "x": 8, "y": 8 }, + { "x": 3, "y": 9 }, { "x":4, "y": 9 }, { "x": 5, "y": 9 }, { "x": 6, "y": 9 }, { "x": 7, "y": 9 }, { "x": 8, "y": 9 }, + { "x": 3, "y": 10 }, { "x":4, "y": 10 }, { "x": 5, "y": 10 }, { "x": 6, "y": 10 }, { "x": 7, "y": 10 }, { "x": 8, "y": 10 }, + ] + }, + {"name": "level_4", + "reqLength": 10, + + "pictures": [ + { "x": 12, "y": 3 , "type": 1, "desc":"guma"},{ "x": 3, "y": 2, "type": 0, "desc":"hrnek"},{ "x": 1, "y": 8 , "type": 2, "desc":"tuzka"} + ] + + "bariers": [ + { "x": 1, "y": 8 }, { "x": 2, "y": 8 }, { "x": 3, "y": 8 }, { "x": 4, "y": 8 }, { "x": 5, "y": 8 },{ "x": 9, "y": 8 }, { "x": 10, "y": 8 }, { "x": 11, "y": 8 }, { "x": 12, "y": 8 }, { "x": 13, "y": 8 }, { "x": 14, "y": 8 }, { "x": 15, "y": 8 }, { "x": 16, "y": 8 },{ "x": 17, "y": 8 }, { "x": 18, "y": 8 } + { "x": 12, "y": 3 }, { "x": 13, "y": 3 }, { "x": 14, "y": 3 }, { "x": 15, "y": 3 },{ "x": 16, "y": 3 }, + { "x": 12, "y": 4 }, { "x": 13, "y": 4 }, { "x": 14, "y": 4 }, { "x": 15, "y": 4 },{ "x": 16, "y": 4 }, + { "x": 3, "y": 2 }, { "x": 4, "y": 2 }, { "x": 5, "y": 2 },{ "x": 6, "y": 2 },{ "x": 7, "y": 2 }, + { "x": 3, "y": 3 }, { "x": 4, "y": 3 }, { "x": 5, "y": 3 },{ "x": 6, "y": 3 },{ "x": 7, "y": 3 }, + { "x": 3, "y": 4 }, { "x": 4, "y": 4 }, { "x": 5, "y": 4 },{ "x": 6, "y": 4 },{ "x": 7, "y": 4 }, + { "x": 3, "y": 5 }, { "x": 4, "y": 5 }, { "x": 5, "y": 5 },{ "x": 6, "y": 5 },{ "x": 7, "y": 5 } + ] + } + ] +} \ No newline at end of file diff --git a/Assets/Resources/TextAsset/test.txt.meta b/Assets/Resources/TextAsset/test.txt.meta new file mode 100644 index 000000000..174a77b5a --- /dev/null +++ b/Assets/Resources/TextAsset/test.txt.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 72d98f3da95b9574a85c6711cc497e2a +timeCreated: 1454624615 +licenseType: Free +TextScriptImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/AddPortal.cs b/Assets/Scripts/AddPortal.cs new file mode 100644 index 000000000..ec8b223bb --- /dev/null +++ b/Assets/Scripts/AddPortal.cs @@ -0,0 +1,211 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; + +public class AddPortal : MonoBehaviour { + + // Use this for initialization + public float distance; + public GameObject backgroundIn; + public GameObject backgroundOut; + public Sprite inPortal; + public Sprite outPortalUp; + public Sprite outPortalDown; + public Sprite outPortalLeft; + public Sprite outPortalRight; + private bool input = true; + private bool outputPortal = false; + private InputPortal por; + private OutputPortal outPor; + private int id = 0; + private Vector3 pos; + private bool mouseDown = false; + public List portals = new List(); + private Color portalColor; + private GameObject currentOutputPortal; + private bool pause = true; + private bool inMenu = true; + + void Start () { + distance = 1.0f; + portalColor = new Color(Random.value, Random.value, Random.value, 1.0f); + } + + // Update is called once per frame + void Update () { + if (Input.GetKeyUp(KeyCode.P) && !inMenu) + { + pause = !pause; + } + } + + void OnMouseDown() + { + if (!pause) + { + + Debug.Log("pause" + pause); + var v3 = Input.mousePosition; + v3.z = distance; + pos = Camera.main.ScreenToWorldPoint(v3); + if (pos.x > 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 + 1; + if (pos.x <= 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 - 1; + if (pos.y < 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 - 1; + if (pos.y >= 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 + 1; + Debug.Log("OnMouseDown " + pos); + mouseDown = true; + if (input) + { + GameObject obj = (GameObject)Instantiate(backgroundIn, pos, Quaternion.identity); + obj.AddComponent(); + obj.AddComponent(); + obj.GetComponent().material.color = portalColor; + //obj.GetComponent().material.mainTexture = inPortal; + obj.GetComponent().sprite = inPortal; + + PortalId idOfNewPortal = obj.GetComponent(); + idOfNewPortal.setId(id); + por = new InputPortal(id); + por.InputPortalGO = obj; + input = false; + } + else + { + currentOutputPortal = (GameObject)Instantiate(backgroundOut, pos, Quaternion.identity); + currentOutputPortal.AddComponent(); + currentOutputPortal.AddComponent(); + currentOutputPortal.GetComponent().material.color = portalColor; + currentOutputPortal.GetComponent().sprite = inPortal; + PortalId idOfNewPortal = currentOutputPortal.GetComponent(); + idOfNewPortal.setId(id); + outputPortal = true; + input = true; + } + + } + } + + + void OnMouseUp() + { + if (outputPortal) + { + if (mouseDown) + { + outputPortal = false; + var v3 = Input.mousePosition; + v3.z = distance; + Vector3 posUp = Camera.main.ScreenToWorldPoint(v3); + //Debug.Log("OnMouseUp " + posUp); + float distX = Mathf.Abs(posUp.x - pos.x); + float distY = Mathf.Abs(posUp.y - pos.y); + //Debug.Log("distX: " + distX + ", distY: " + distY); + Vector2 vec; + if (distX > distY) + { + if (posUp.x > pos.x) + { + vec = Vector2.right; + currentOutputPortal.GetComponent().sprite = outPortalRight; + }else{ + vec = Vector2.left; + currentOutputPortal.GetComponent().sprite = outPortalLeft; + } + } + else + { + if (posUp.y > pos.y) + { + vec = Vector2.up; + currentOutputPortal.GetComponent().sprite = outPortalUp; + } + else { vec = Vector2.down; + currentOutputPortal.GetComponent().sprite = outPortalDown; + } + } + Debug.Log("Direction: " + vec); + mouseDown = false; + OutputPortal localOutputPortal = new OutputPortal(id, vec); + localOutputPortal.setOutputPortal(currentOutputPortal); + localOutputPortal.setPosition((int)pos.x, (int)pos.y); + + portals.Add(new Tuple(por, localOutputPortal)); + id++; + portalColor = new Color(Random.value, Random.value, Random.value, 1.0f); + } + } + } + + public void setPause(bool pause) + { + this.pause = pause; + } + + public void setInMenu(bool inMenu) + { + this.inMenu = inMenu; + } + + public class InputPortal + { + int id; + + public GameObject InputPortalGO; + + public InputPortal(int id) { + this.id = id; + } + public int getId() { + return this.id; + } + + } + + public class OutputPortal + { + int id; + Vector2 heading; + int x, y; + private GameObject outputPortlaGameObject; + + public void setOutputPortal(GameObject outport) { + outputPortlaGameObject = outport; + } + + public GameObject getOutputPortal() { + return outputPortlaGameObject; + } + + public Vector3 getPosition() { + return new Vector3(x,y,0) ; + } + + public void setPosition(int x, int y) { + this.x = x; + this.y = y; + } + + public OutputPortal(int id, Vector2 to) { + this.id = id; + heading = to; + } + + public Vector2 getHeading(){ + return heading; + } + public int getId() { + return id; + } + } + + public class Tuple + { + public InputPortal inputPortal; + public OutputPortal outputPortal; + + public Tuple(InputPortal inp, OutputPortal outp){ + inputPortal = inp; + outputPortal = outp; + } + } +} diff --git a/Assets/Scripts/AddPortal.cs.meta b/Assets/Scripts/AddPortal.cs.meta new file mode 100644 index 000000000..18227e227 --- /dev/null +++ b/Assets/Scripts/AddPortal.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d3f92de3fbc0c7f4f9a9beb7829abb12 +timeCreated: 1444774631 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ArrayList.cs b/Assets/Scripts/ArrayList.cs new file mode 100644 index 000000000..5f282702b --- /dev/null +++ b/Assets/Scripts/ArrayList.cs @@ -0,0 +1 @@ + \ No newline at end of file diff --git a/Assets/Scripts/ArrayList.cs.meta b/Assets/Scripts/ArrayList.cs.meta new file mode 100644 index 000000000..8fa2bed3f --- /dev/null +++ b/Assets/Scripts/ArrayList.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 2411d5edee4d3d34788d7aa113e587e4 +timeCreated: 1448228092 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/ClosePortal.cs b/Assets/Scripts/ClosePortal.cs new file mode 100644 index 000000000..56b060906 --- /dev/null +++ b/Assets/Scripts/ClosePortal.cs @@ -0,0 +1,36 @@ +using UnityEngine; +using System.Collections; +using System.Collections.Generic; +public class ClosePortal : MonoBehaviour { + public AddPortal AddPortalScript; + + void Start() { + + } + public GameObject inputPortal; + public GameObject outputPortal; + + void OnTriggerEnter2D(Collider2D coll) + { + List portals = AddPortalScript.portals; + Debug.Log("collision with: " + coll.name); + if ((coll.name.StartsWith(outputPortal.name))) { + + PortalId something = coll.gameObject.GetComponent(); + int id = something.id; + Debug.Log("Collision portal id: " + id); + AddPortal.Tuple onIndex = null; + foreach (AddPortal.Tuple tup in portals) + { + if (tup.outputPortal.getId() == id) + { + onIndex = tup; + break; + } + } + Destroy(coll.gameObject); + Destroy(onIndex.inputPortal.InputPortalGO); + } + + } +} diff --git a/Assets/Scripts/ClosePortal.cs.meta b/Assets/Scripts/ClosePortal.cs.meta new file mode 100644 index 000000000..34b807cbc --- /dev/null +++ b/Assets/Scripts/ClosePortal.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 31d135346f7ffd24d95aabb1b5175380 +timeCreated: 1454675776 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/PortalId.cs b/Assets/Scripts/PortalId.cs new file mode 100644 index 000000000..1a25aec11 --- /dev/null +++ b/Assets/Scripts/PortalId.cs @@ -0,0 +1,15 @@ +using UnityEngine; +using System.Collections; + +public class PortalId : MonoBehaviour { + public int id; + + public void setId(int id) { + this.id = id; + } + + int getId() { + return this.id; + } + +} diff --git a/Assets/Scripts/PortalId.cs.meta b/Assets/Scripts/PortalId.cs.meta new file mode 100644 index 000000000..bdb861aa2 --- /dev/null +++ b/Assets/Scripts/PortalId.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: c5163d83f4dd4ed4fa1560fea067cc19 +timeCreated: 1448294764 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/RemovePortal.cs b/Assets/Scripts/RemovePortal.cs new file mode 100644 index 000000000..84ed4f2c9 --- /dev/null +++ b/Assets/Scripts/RemovePortal.cs @@ -0,0 +1,10 @@ +using UnityEngine; +using System.Collections; + +public class RemovePortal : MonoBehaviour { + + void OnMouseDown() + { + Destroy(gameObject); + } +} diff --git a/Assets/Scripts/RemovePortal.cs.meta b/Assets/Scripts/RemovePortal.cs.meta new file mode 100644 index 000000000..34cbd35da --- /dev/null +++ b/Assets/Scripts/RemovePortal.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 673bc630822bdb543886c86cfd1d3d43 +timeCreated: 1444774633 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SaveLoad.cs b/Assets/Scripts/SaveLoad.cs new file mode 100644 index 000000000..75625ae03 --- /dev/null +++ b/Assets/Scripts/SaveLoad.cs @@ -0,0 +1,161 @@ +using UnityEngine; +using System.Collections; + +using SimpleJSON; +using System.IO; +using System.Text; + +using System.Runtime.Serialization.Formatters.Binary; + +namespace SaveLoad +{ + public static class Loading { + + private static JSONNode levels; + + + private static int lastLevelId = -1; + private static bool[] unlockLevels; + private static int[] highscoreLevels; + + public static JSONNode LoadLevels() + { + if (lastLevelId != -1) { + return levels; + } + + Debug.Log ("LoadLevels()"); + try + { + TextAsset data = Resources.Load("TextAsset/test") as TextAsset; + levels = JSON.Parse(data.text); + + lastLevelId = 0; + unlockLevels = new bool[levels["levels"].Count]; + unlockLevels[0] = true; + highscoreLevels = new int[levels["levels"].Count]; + highscoreLevels[0] = 0; + + for (int i=1; i levelId) + { + return levels ["levels"] [levelId] ["bariers"]; + } + + return null; + } + + public static JSONNode GetPictures(int levelId) + { + if(levels["levels"].Count > levelId) + { + return levels ["levels"] [levelId] ["pictures"]; + } + + return null; + } + + public static int getHighscore(int levelId) + { + Debug.Log ("get highscore" + highscoreLevels [levelId]); + return highscoreLevels[levelId]; + } + + public static bool setScore(int levelId, int score) + { + if (levelId >= highscoreLevels.Length) { + return false; + } + + if (score > highscoreLevels [levelId]) { + highscoreLevels [levelId] = score; + Debug.Log ("set highscore"+ highscoreLevels [levelId]); + return true; + } + + return false; + } + + public static bool isLock(int levelId) + { + if (levelId >= unlockLevels.Length) { + Debug.Log ("wrong id" + levelId); + return true; + } + + return !(unlockLevels [levelId]); + } + + public static void unlockLevel(int levelId) + { + unlockLevels [levelId] = true; + } + + public static int getLastLevelId() + { + return lastLevelId; + } + + public static void setLastLevelId(int id) + { + lastLevelId = id; + } + + public static void resetHighscore() + { + for (int i=0; i Childs { get { yield break;} } + public IEnumerable DeepChilds + { + get + { + foreach (var C in Childs) + foreach (var D in C.DeepChilds) + yield return D; + } + } + + public override string ToString() + { + return "JSONNode"; + } + public virtual string ToString(string aPrefix) + { + return "JSONNode"; + } + + #endregion common interface + + #region typecasting properties + public virtual int AsInt + { + get + { + int v = 0; + if (int.TryParse(Value,out v)) + return v; + return 0; + } + set + { + Value = value.ToString(); + } + } + public virtual float AsFloat + { + get + { + float v = 0.0f; + if (float.TryParse(Value,out v)) + return v; + return 0.0f; + } + set + { + Value = value.ToString(); + } + } + public virtual double AsDouble + { + get + { + double v = 0.0; + if (double.TryParse(Value,out v)) + return v; + return 0.0; + } + set + { + Value = value.ToString(); + } + } + public virtual bool AsBool + { + get + { + bool v = false; + if (bool.TryParse(Value,out v)) + return v; + return !string.IsNullOrEmpty(Value); + } + set + { + Value = (value)?"true":"false"; + } + } + public virtual JSONArray AsArray + { + get + { + return this as JSONArray; + } + } + public virtual JSONClass AsObject + { + get + { + return this as JSONClass; + } + } + + + #endregion typecasting properties + + #region operators + public static implicit operator JSONNode(string s) + { + return new JSONData(s); + } + public static implicit operator string(JSONNode d) + { + return (d == null)?null:d.Value; + } + public static bool operator ==(JSONNode a, object b) + { + if (b == null && a is JSONLazyCreator) + return true; + return System.Object.ReferenceEquals(a,b); + } + + public static bool operator !=(JSONNode a, object b) + { + return !(a == b); + } + public override bool Equals (object obj) + { + return System.Object.ReferenceEquals(this, obj); + } + public override int GetHashCode () + { + return base.GetHashCode(); + } + + + #endregion operators + + internal static string Escape(string aText) + { + string result = ""; + foreach(char c in aText) + { + switch(c) + { + case '\\' : result += "\\\\"; break; + case '\"' : result += "\\\""; break; + case '\n' : result += "\\n" ; break; + case '\r' : result += "\\r" ; break; + case '\t' : result += "\\t" ; break; + case '\b' : result += "\\b" ; break; + case '\f' : result += "\\f" ; break; + default : result += c ; break; + } + } + return result; + } + + public static JSONNode Parse(string aJSON) + { + Stack stack = new Stack(); + JSONNode ctx = null; + int i = 0; + string Token = ""; + string TokenName = ""; + bool QuoteMode = false; + while (i < aJSON.Length) + { + switch (aJSON[i]) + { + case '{': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + stack.Push(new JSONClass()); + if (ctx != null) + { + TokenName = TokenName.Trim(); + if (ctx is JSONArray) + ctx.Add(stack.Peek()); + else if (TokenName != "") + ctx.Add(TokenName,stack.Peek()); + } + TokenName = ""; + Token = ""; + ctx = stack.Peek(); + break; + + case '[': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + + stack.Push(new JSONArray()); + if (ctx != null) + { + TokenName = TokenName.Trim(); + if (ctx is JSONArray) + ctx.Add(stack.Peek()); + else if (TokenName != "") + ctx.Add(TokenName,stack.Peek()); + } + TokenName = ""; + Token = ""; + ctx = stack.Peek(); + break; + + case '}': + case ']': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + if (stack.Count == 0) + throw new Exception("JSON Parse: Too many closing brackets"); + + stack.Pop(); + if (Token != "") + { + TokenName = TokenName.Trim(); + if (ctx is JSONArray) + ctx.Add(Token); + else if (TokenName != "") + ctx.Add(TokenName,Token); + } + TokenName = ""; + Token = ""; + if (stack.Count>0) + ctx = stack.Peek(); + break; + + case ':': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + TokenName = Token; + Token = ""; + break; + + case '"': + QuoteMode ^= true; + break; + + case ',': + if (QuoteMode) + { + Token += aJSON[i]; + break; + } + if (Token != "") + { + if (ctx is JSONArray) + ctx.Add(Token); + else if (TokenName != "") + ctx.Add(TokenName, Token); + } + TokenName = ""; + Token = ""; + break; + + case '\r': + case '\n': + break; + + case ' ': + case '\t': + if (QuoteMode) + Token += aJSON[i]; + break; + + case '\\': + ++i; + if (QuoteMode) + { + char C = aJSON[i]; + switch (C) + { + case 't' : Token += '\t'; break; + case 'r' : Token += '\r'; break; + case 'n' : Token += '\n'; break; + case 'b' : Token += '\b'; break; + case 'f' : Token += '\f'; break; + case 'u': + { + string s = aJSON.Substring(i+1,4); + Token += (char)int.Parse(s, System.Globalization.NumberStyles.AllowHexSpecifier); + i += 4; + break; + } + default : Token += C; break; + } + } + break; + + default: + Token += aJSON[i]; + break; + } + ++i; + } + if (QuoteMode) + { + throw new Exception("JSON Parse: Quotation marks seems to be messed up."); + } + return ctx; + } + + public virtual void Serialize(System.IO.BinaryWriter aWriter) {} + + public void SaveToStream(System.IO.Stream aData) + { + var W = new System.IO.BinaryWriter(aData); + Serialize(W); + } + + #if USE_SharpZipLib + public void SaveToCompressedStream(System.IO.Stream aData) + { + using (var gzipOut = new ICSharpCode.SharpZipLib.BZip2.BZip2OutputStream(aData)) + { + gzipOut.IsStreamOwner = false; + SaveToStream(gzipOut); + gzipOut.Close(); + } + } + + public void SaveToCompressedFile(string aFileName) + { + #if USE_FileIO + System.IO.Directory.CreateDirectory((new System.IO.FileInfo(aFileName)).Directory.FullName); + using(var F = System.IO.File.OpenWrite(aFileName)) + { + SaveToCompressedStream(F); + } + #else + throw new Exception("Can't use File IO stuff in webplayer"); + #endif + } + public string SaveToCompressedBase64() + { + using (var stream = new System.IO.MemoryStream()) + { + SaveToCompressedStream(stream); + stream.Position = 0; + return System.Convert.ToBase64String(stream.ToArray()); + } + } + + #else + public void SaveToCompressedStream(System.IO.Stream aData) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public void SaveToCompressedFile(string aFileName) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public string SaveToCompressedBase64() + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + #endif + + public void SaveToFile(string aFileName) + { + #if USE_FileIO + System.IO.Directory.CreateDirectory((new System.IO.FileInfo(aFileName)).Directory.FullName); + using(var F = System.IO.File.OpenWrite(aFileName)) + { + SaveToStream(F); + } + #else + throw new Exception("Can't use File IO stuff in webplayer"); + #endif + } + public string SaveToBase64() + { + using (var stream = new System.IO.MemoryStream()) + { + SaveToStream(stream); + stream.Position = 0; + return System.Convert.ToBase64String(stream.ToArray()); + } + } + public static JSONNode Deserialize(System.IO.BinaryReader aReader) + { + JSONBinaryTag type = (JSONBinaryTag)aReader.ReadByte(); + switch(type) + { + case JSONBinaryTag.Array: + { + int count = aReader.ReadInt32(); + JSONArray tmp = new JSONArray(); + for(int i = 0; i < count; i++) + tmp.Add(Deserialize(aReader)); + return tmp; + } + case JSONBinaryTag.Class: + { + int count = aReader.ReadInt32(); + JSONClass tmp = new JSONClass(); + for(int i = 0; i < count; i++) + { + string key = aReader.ReadString(); + var val = Deserialize(aReader); + tmp.Add(key, val); + } + return tmp; + } + case JSONBinaryTag.Value: + { + return new JSONData(aReader.ReadString()); + } + case JSONBinaryTag.IntValue: + { + return new JSONData(aReader.ReadInt32()); + } + case JSONBinaryTag.DoubleValue: + { + return new JSONData(aReader.ReadDouble()); + } + case JSONBinaryTag.BoolValue: + { + return new JSONData(aReader.ReadBoolean()); + } + case JSONBinaryTag.FloatValue: + { + return new JSONData(aReader.ReadSingle()); + } + + default: + { + throw new Exception("Error deserializing JSON. Unknown tag: " + type); + } + } + } + + #if USE_SharpZipLib + public static JSONNode LoadFromCompressedStream(System.IO.Stream aData) + { + var zin = new ICSharpCode.SharpZipLib.BZip2.BZip2InputStream(aData); + return LoadFromStream(zin); + } + public static JSONNode LoadFromCompressedFile(string aFileName) + { + #if USE_FileIO + using(var F = System.IO.File.OpenRead(aFileName)) + { + return LoadFromCompressedStream(F); + } + #else + throw new Exception("Can't use File IO stuff in webplayer"); + #endif + } + public static JSONNode LoadFromCompressedBase64(string aBase64) + { + var tmp = System.Convert.FromBase64String(aBase64); + var stream = new System.IO.MemoryStream(tmp); + stream.Position = 0; + return LoadFromCompressedStream(stream); + } + #else + public static JSONNode LoadFromCompressedFile(string aFileName) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public static JSONNode LoadFromCompressedStream(System.IO.Stream aData) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + public static JSONNode LoadFromCompressedBase64(string aBase64) + { + throw new Exception("Can't use compressed functions. You need include the SharpZipLib and uncomment the define at the top of SimpleJSON"); + } + #endif + + public static JSONNode LoadFromStream(System.IO.Stream aData) + { + using(var R = new System.IO.BinaryReader(aData)) + { + return Deserialize(R); + } + } + public static JSONNode LoadFromFile(string aFileName) + { + #if USE_FileIO + using(var F = System.IO.File.OpenRead(aFileName)) + { + return LoadFromStream(F); + } + #else + throw new Exception("Can't use File IO stuff in webplayer"); + #endif + } + public static JSONNode LoadFromBase64(string aBase64) + { + var tmp = System.Convert.FromBase64String(aBase64); + var stream = new System.IO.MemoryStream(tmp); + stream.Position = 0; + return LoadFromStream(stream); + } + } // End of JSONNode + + public class JSONArray : JSONNode, IEnumerable + { + private List m_List = new List(); + public override JSONNode this[int aIndex] + { + get + { + if (aIndex<0 || aIndex >= m_List.Count) + return new JSONLazyCreator(this); + return m_List[aIndex]; + } + set + { + if (aIndex<0 || aIndex >= m_List.Count) + m_List.Add(value); + else + m_List[aIndex] = value; + } + } + public override JSONNode this[string aKey] + { + get{ return new JSONLazyCreator(this);} + set{ m_List.Add(value); } + } + public override int Count + { + get { return m_List.Count; } + } + public override void Add(string aKey, JSONNode aItem) + { + m_List.Add(aItem); + } + public override JSONNode Remove(int aIndex) + { + if (aIndex < 0 || aIndex >= m_List.Count) + return null; + JSONNode tmp = m_List[aIndex]; + m_List.RemoveAt(aIndex); + return tmp; + } + public override JSONNode Remove(JSONNode aNode) + { + m_List.Remove(aNode); + return aNode; + } + public override IEnumerable Childs + { + get + { + foreach(JSONNode N in m_List) + yield return N; + } + } + public IEnumerator GetEnumerator() + { + foreach(JSONNode N in m_List) + yield return N; + } + public override string ToString() + { + string result = "[ "; + foreach (JSONNode N in m_List) + { + if (result.Length > 2) + result += ", "; + result += N.ToString(); + } + result += " ]"; + return result; + } + public override string ToString(string aPrefix) + { + string result = "[ "; + foreach (JSONNode N in m_List) + { + if (result.Length > 3) + result += ", "; + result += "\n" + aPrefix + " "; + result += N.ToString(aPrefix+" "); + } + result += "\n" + aPrefix + "]"; + return result; + } + public override void Serialize (System.IO.BinaryWriter aWriter) + { + aWriter.Write((byte)JSONBinaryTag.Array); + aWriter.Write(m_List.Count); + for(int i = 0; i < m_List.Count; i++) + { + m_List[i].Serialize(aWriter); + } + } + } // End of JSONArray + + public class JSONClass : JSONNode, IEnumerable + { + private Dictionary m_Dict = new Dictionary(); + public override JSONNode this[string aKey] + { + get + { + if (m_Dict.ContainsKey(aKey)) + return m_Dict[aKey]; + else + return new JSONLazyCreator(this, aKey); + } + set + { + if (m_Dict.ContainsKey(aKey)) + m_Dict[aKey] = value; + else + m_Dict.Add(aKey,value); + } + } + public override JSONNode this[int aIndex] + { + get + { + if (aIndex < 0 || aIndex >= m_Dict.Count) + return null; + return m_Dict.ElementAt(aIndex).Value; + } + set + { + if (aIndex < 0 || aIndex >= m_Dict.Count) + return; + string key = m_Dict.ElementAt(aIndex).Key; + m_Dict[key] = value; + } + } + public override int Count + { + get { return m_Dict.Count; } + } + + + public override void Add(string aKey, JSONNode aItem) + { + if (!string.IsNullOrEmpty(aKey)) + { + if (m_Dict.ContainsKey(aKey)) + m_Dict[aKey] = aItem; + else + m_Dict.Add(aKey, aItem); + } + else + m_Dict.Add(Guid.NewGuid().ToString(), aItem); + } + + public override JSONNode Remove(string aKey) + { + if (!m_Dict.ContainsKey(aKey)) + return null; + JSONNode tmp = m_Dict[aKey]; + m_Dict.Remove(aKey); + return tmp; + } + public override JSONNode Remove(int aIndex) + { + if (aIndex < 0 || aIndex >= m_Dict.Count) + return null; + var item = m_Dict.ElementAt(aIndex); + m_Dict.Remove(item.Key); + return item.Value; + } + public override JSONNode Remove(JSONNode aNode) + { + try + { + var item = m_Dict.Where(k => k.Value == aNode).First(); + m_Dict.Remove(item.Key); + return aNode; + } + catch + { + return null; + } + } + + public override IEnumerable Childs + { + get + { + foreach(KeyValuePair N in m_Dict) + yield return N.Value; + } + } + + public IEnumerator GetEnumerator() + { + foreach(KeyValuePair N in m_Dict) + yield return N; + } + public override string ToString() + { + string result = "{"; + foreach (KeyValuePair N in m_Dict) + { + if (result.Length > 2) + result += ", "; + result += "\"" + Escape(N.Key) + "\":" + N.Value.ToString(); + } + result += "}"; + return result; + } + public override string ToString(string aPrefix) + { + string result = "{ "; + foreach (KeyValuePair N in m_Dict) + { + if (result.Length > 3) + result += ", "; + result += "\n" + aPrefix + " "; + result += "\"" + Escape(N.Key) + "\" : " + N.Value.ToString(aPrefix+" "); + } + result += "\n" + aPrefix + "}"; + return result; + } + public override void Serialize (System.IO.BinaryWriter aWriter) + { + aWriter.Write((byte)JSONBinaryTag.Class); + aWriter.Write(m_Dict.Count); + foreach(string K in m_Dict.Keys) + { + aWriter.Write(K); + m_Dict[K].Serialize(aWriter); + } + } + } // End of JSONClass + + public class JSONData : JSONNode + { + private string m_Data; + public override string Value + { + get { return m_Data; } + set { m_Data = value; } + } + public JSONData(string aData) + { + m_Data = aData; + } + public JSONData(float aData) + { + AsFloat = aData; + } + public JSONData(double aData) + { + AsDouble = aData; + } + public JSONData(bool aData) + { + AsBool = aData; + } + public JSONData(int aData) + { + AsInt = aData; + } + + public override string ToString() + { + return "\"" + Escape(m_Data) + "\""; + } + public override string ToString(string aPrefix) + { + return "\"" + Escape(m_Data) + "\""; + } + public override void Serialize (System.IO.BinaryWriter aWriter) + { + var tmp = new JSONData(""); + + tmp.AsInt = AsInt; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.IntValue); + aWriter.Write(AsInt); + return; + } + tmp.AsFloat = AsFloat; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.FloatValue); + aWriter.Write(AsFloat); + return; + } + tmp.AsDouble = AsDouble; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.DoubleValue); + aWriter.Write(AsDouble); + return; + } + + tmp.AsBool = AsBool; + if (tmp.m_Data == this.m_Data) + { + aWriter.Write((byte)JSONBinaryTag.BoolValue); + aWriter.Write(AsBool); + return; + } + aWriter.Write((byte)JSONBinaryTag.Value); + aWriter.Write(m_Data); + } + } // End of JSONData + + internal class JSONLazyCreator : JSONNode + { + private JSONNode m_Node = null; + private string m_Key = null; + + public JSONLazyCreator(JSONNode aNode) + { + m_Node = aNode; + m_Key = null; + } + public JSONLazyCreator(JSONNode aNode, string aKey) + { + m_Node = aNode; + m_Key = aKey; + } + + private void Set(JSONNode aVal) + { + if (m_Key == null) + { + m_Node.Add(aVal); + } + else + { + m_Node.Add(m_Key, aVal); + } + m_Node = null; // Be GC friendly. + } + + public override JSONNode this[int aIndex] + { + get + { + return new JSONLazyCreator(this); + } + set + { + var tmp = new JSONArray(); + tmp.Add(value); + Set(tmp); + } + } + + public override JSONNode this[string aKey] + { + get + { + return new JSONLazyCreator(this, aKey); + } + set + { + var tmp = new JSONClass(); + tmp.Add(aKey, value); + Set(tmp); + } + } + public override void Add (JSONNode aItem) + { + var tmp = new JSONArray(); + tmp.Add(aItem); + Set(tmp); + } + public override void Add (string aKey, JSONNode aItem) + { + var tmp = new JSONClass(); + tmp.Add(aKey, aItem); + Set(tmp); + } + public static bool operator ==(JSONLazyCreator a, object b) + { + if (b == null) + return true; + return System.Object.ReferenceEquals(a,b); + } + + public static bool operator !=(JSONLazyCreator a, object b) + { + return !(a == b); + } + public override bool Equals (object obj) + { + if (obj == null) + return true; + return System.Object.ReferenceEquals(this, obj); + } + public override int GetHashCode () + { + return base.GetHashCode(); + } + + public override string ToString() + { + return ""; + } + public override string ToString(string aPrefix) + { + return ""; + } + + public override int AsInt + { + get + { + JSONData tmp = new JSONData(0); + Set(tmp); + return 0; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override float AsFloat + { + get + { + JSONData tmp = new JSONData(0.0f); + Set(tmp); + return 0.0f; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override double AsDouble + { + get + { + JSONData tmp = new JSONData(0.0); + Set(tmp); + return 0.0; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override bool AsBool + { + get + { + JSONData tmp = new JSONData(false); + Set(tmp); + return false; + } + set + { + JSONData tmp = new JSONData(value); + Set(tmp); + } + } + public override JSONArray AsArray + { + get + { + JSONArray tmp = new JSONArray(); + Set(tmp); + return tmp; + } + } + public override JSONClass AsObject + { + get + { + JSONClass tmp = new JSONClass(); + Set(tmp); + return tmp; + } + } + } // End of JSONLazyCreator + + public static class JSON + { + public static JSONNode Parse(string aJSON) + { + return JSONNode.Parse(aJSON); + } + } +} \ No newline at end of file diff --git a/Assets/Scripts/SimpleJSON.cs.meta b/Assets/Scripts/SimpleJSON.cs.meta new file mode 100644 index 000000000..4af788696 --- /dev/null +++ b/Assets/Scripts/SimpleJSON.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 0c32bfb34beae4640a56a187062324a0 +timeCreated: 1454689047 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Snake.cs b/Assets/Scripts/Snake.cs new file mode 100644 index 000000000..d42017780 --- /dev/null +++ b/Assets/Scripts/Snake.cs @@ -0,0 +1,647 @@ +using UnityEngine; +using UnityEngine.UI; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine.SceneManagement; + +using SimpleJSON; +using SaveLoad; + +public class Snake : MonoBehaviour +{ + + public GameObject foodPrefab; + public GameObject decreaseSnakeLengthFoodPrefab; + public GameObject incraseSnakeSpeedFoodPrefab; + public GameObject decreaseSnakeSpeedPrefab; + public GameObject background; + public GameObject obstaclePrefab; + public GameObject eraserObstacleGo; + public GameObject pencilObstacleGO; + public GameObject phoneObstacleGo; + public Canvas gamePausedText; + public Canvas gameOverScreen; + public Text scoreText; + public Text gameOverScoreText; + public AddPortal AddPortalSript; + public GameObject finalPOrtalGameObject; + public AudioSource eatSound; + + public Transform borderTop; + public Transform borderBottom; + public Transform borderLeft; + public Transform borderRight; + + public float distance; + public float moveTime; + public float moveChangeRate; + public float moveDistance; + public GameObject tailPrefab; + public GameObject lastTailPrefab; + public GameObject initialBody; + public GameObject initialTail; + public int desiredLengthOfSnake; + Vector2 dir = Vector2.left; + private List tail = new List(); + bool ate = false; + bool shrink = false; + bool portal = false; + bool pause = true; + bool inMenu = true; + private int fixedUpdateCounter = 0; + private int specialFoodCount = 0; + private bool isSpecialOnTable = false; + private GameObject specialFoodObject; + private float specialTime; + private static int numOfRows = 12; + private static int numOfColls = 20; + + private int score = 0; + private static int foodScoreNormal = 10; + private static int foodScoreIncSpeed = 20; + private static int foodScoreDecrease = 5; //decrease speed or length + private bool finalPortalOpen = false; + private int nextLevel = 1; + private GameObject finalPortalGO; + private List obstaclesGO = new List(); + + + bool[][] obstacle = new bool[numOfRows][]; /*12*20*/ + // Use this for initialization + class PortalToDelete { + private static GameObject inputPortal; + private static GameObject outputPortal; + public int numberOfSteps; + + public void setInputPortal(GameObject input) { + inputPortal = input; + } + public GameObject getInputPortal() { + return inputPortal; + } + public void setOutPortal(GameObject output){ + outputPortal = output; + } + public GameObject getOutputPortal() { + return outputPortal; + } + + } + + void Start() + { + Loading.LoadLevels(); + background = GameObject.FindGameObjectWithTag("Background"); + gamePausedText = gamePausedText.GetComponent(); + gamePausedText.enabled = false; + scoreText = scoreText.GetComponent(); + gameOverScoreText = gameOverScoreText.GetComponent(); + gameOverScreen = gameOverScreen.GetComponent(); + AddPortalSript = background.GetComponent(); + eatSound = eatSound.GetComponent(); + eatSound.volume = 0; + fixedUpdateCounter = 0; + for (int i = 0; i < numOfRows; i++) + { + obstacle[i] = new bool[numOfColls]; + } + forgetObstacles(); + setObstacles(Loading.GetBariers(Loading.getLastLevelId())); + setPictures(Loading.GetPictures(Loading.getLastLevelId())); + tail.Add(initialBody.transform); + tail.Add(initialTail.transform); + SpawnFood(); + + } + + /*guarantees same time between each update*/ + void FixedUpdate() + { + if (!pause) + { + if (tail.Count == desiredLengthOfSnake) { + if (!finalPortalOpen) { + //otvorit vstupny portal jeden + finalPortalOpen = true; + OpenFinalPortal(); + } + } + fixedUpdateCounter++; + float time = (float)moveTime / 0.02f; + if ((int)time == fixedUpdateCounter) + { + fixedUpdateCounter = 0; + Move(); + } + if (isSpecialOnTable) + { + specialFoodCount++; + //Debug.Log("Actual time: " + specialFoodCount + " looking for: " + (int)specialTime); + if (specialFoodCount == (int)specialTime) + { + removeSpecialFood(); + } + } + } + } + + // Update is called once per frame + void Update() + { + + // Move in a new Direction? + if (Input.GetKeyUp(KeyCode.P) && !inMenu) + { + pause = !pause; + gamePausedText.enabled = !gamePausedText.enabled; + } + } + + void OnTriggerEnter2D(Collider2D coll) + { + if (portal) { return; } + if (coll.name.StartsWith(foodPrefab.name)) + { + // Get longer in next Move call + ate = true; + + // Remove the Food + Destroy(coll.gameObject); + score += foodScoreNormal; + Loading.setScore(Loading.getLastLevelId(), score); + scoreText.text = score.ToString(); + eatSound.Play(); + } + else if (coll.name.StartsWith(decreaseSnakeLengthFoodPrefab.name)) + { + // Get shorter in next Move call + shrink = true; + + // Remove the Food + Destroy(coll.gameObject); + score += foodScoreDecrease; + Loading.setScore(Loading.getLastLevelId(), score); + scoreText.text = score.ToString(); + eatSound.Play(); + } + else if (coll.name.StartsWith(incraseSnakeSpeedFoodPrefab.name)) + { + //increase speed of snake ??do we increase the lenght of snake as well?? + UpdateSpeed(true); + removeSpecialFood(); + //score updated in UpdateSpeed(); + } + else if (coll.name.StartsWith(decreaseSnakeSpeedPrefab.name)) + { + //decrease speed + UpdateSpeed(false); + + removeSpecialFood(); + + //score updated in UpdateSpeed(); + } + else if (coll.name.StartsWith(AddPortalSript.backgroundIn.name)) + { + portal = true; + //Debug.Log("hura portal!"); + List portals = AddPortalSript.portals; + PortalId something = coll.gameObject.GetComponent(); + int id = something.id; + Debug.Log("Collision portal id: " + id); + AddPortal.Tuple onIndex = null; + foreach (AddPortal.Tuple tup in portals) + { + if (tup.outputPortal.getId() == id) + { + onIndex = tup; + break; + } + } + if (onIndex != null) + { + + Vector3 head = new Vector3(dir.x, dir.y, 0); + Vector3 moveDirection = head; + if (moveDirection != Vector3.zero) + { + float angle = Mathf.Atan2(moveDirection.y, moveDirection.x) * Mathf.Rad2Deg; + if (angle < 0) + { + angle = -1 * Mathf.Abs(Mathf.RoundToInt(angle)) / 90 * 90; + } + else + { + angle = Mathf.RoundToInt(angle) / 90 * 90; + } + transform.rotation = Quaternion.AngleAxis(angle, Vector3.up); + } + dir = onIndex.outputPortal.getHeading(); + if (dir == Vector2.left) + { + transform.rotation = new Quaternion(0, 0, 0, 1); + } + if (dir == Vector2.right) + { + transform.rotation = new Quaternion(0, 1, 0, 0); + } + if (dir == Vector2.down) + { + transform.rotation = new Quaternion(1, 1, 0, 0); + } + if (dir == Vector2.up) + { + transform.rotation = new Quaternion(1, -1, 0, 0); + } + //Debug.Log(transform.rotation); + transform.position = onIndex.outputPortal.getPosition(); + + PortalToDelete local = new PortalToDelete(); + local.setInputPortal(coll.gameObject); + local.setOutPortal(onIndex.outputPortal.getOutputPortal()); + local.numberOfSteps = 0; + + } + + } + else if (coll.name.StartsWith(AddPortalSript.backgroundOut.name)) { + } else if (coll.name.StartsWith(finalPOrtalGameObject.name)) { + desiredLengthOfSnake *= 2; + SetLevel(nextLevel); + nextLevel = (nextLevel + 1) / 4; + + } + + + else + { + Loading.setScore(Loading.getLastLevelId(), score); + gameOver(); + score = 0; + scoreText.text = score.ToString(); + // ToDo 'You lose' screen + Debug.Log("collision with: " + coll.name); + Debug.Log("Score: " + tail.Count); + //initialize(); + } + } + + + + public void Move() + { + //Debug.Log("hybem sa!"); + GameObject lastPosition; + portal = false; + Vector2 currentPossition = transform.position; + Vector2 position; + Quaternion rotation; + transform.Translate(dir * moveDistance, Space.World); + + + if (ate) + { + SpawnFood(); + if (tail.Count == 0) { + tail.Add(((GameObject)Instantiate(lastTailPrefab, currentPossition, transform.rotation)).transform); + } + else + { + tail.Insert(0, ((GameObject)Instantiate(tailPrefab, currentPossition, transform.rotation)).transform); + } + ate = false; + + } + else if (shrink) + { + if (tail.Count >= 2) + { + isSpecialOnTable = false; + shrink = false; + //* tail.Insert(0, tail.Last()); + if (tail.Count >= 3) + { + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + position = tail.Last().position; + rotation = tail.Last().rotation; + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + tail.Insert(0, ((GameObject)Instantiate(tailPrefab, currentPossition, transform.rotation)).transform); + tail.Add(((GameObject)Instantiate(lastTailPrefab, position, rotation)).transform); + } + else { + //gameOver(); + tail.Last().position = currentPossition; + tail.Last().rotation = transform.rotation; + tail.Insert(0, tail.Last()); + tail.RemoveAt(tail.Count - 1); + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + + } + //tail.Insert(tail.Count - 1, (); + //tail.Last().GetComponent().sprite = lastTailPrefab.GetComponent().sprite; + SpawnFood(); + } + else { + /*GAME OVER dlzka hada je < 0*/ + gameOver(); + } + } + else if (tail.Count >=2 ) + { + + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + position = tail.Last().position; + rotation = tail.Last().rotation; + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + tail.Insert(0, ((GameObject)Instantiate(tailPrefab, currentPossition, transform.rotation)).transform); + tail.Add(((GameObject)Instantiate(lastTailPrefab, position, rotation)).transform); + + } + } + + bool inBounds(Vector3 bounds) + { + if ((bounds.x > borderLeft.position.x) && (bounds.x < borderRight.position.x) && (bounds.y > borderBottom.position.y) && (bounds.y < borderTop.position.y)) { return true; } + return false; + } + + void UpdateSpeed(bool increase) + { + if (increase) + { + moveTime -= moveChangeRate; + if (moveTime <= 0.1) { + moveTime = 0.1f; + score += foodScoreNormal; + } + else score += foodScoreIncSpeed; + } + else { + moveTime += moveChangeRate; + score += foodScoreDecrease; + } + scoreText.text = score.ToString(); + eatSound.Play(); + fixedUpdateCounter = 0; + } + + void SpawnFood() + { + Vector2 pos; + int foodX, foodY; + do + { + // x position between left & right border + int x = (int)Random.Range(borderLeft.position.x, + borderRight.position.x + 1); + + // y position between top & bottom border + int y = (int)Random.Range(borderBottom.position.y + 1, + borderTop.position.y); + + pos.x = x; + pos.y = y; + x = Mathf.Abs((int)(borderRight.position.x - borderLeft.position.x)); + y = Mathf.Abs((int)(borderBottom.position.y - borderTop.position.y)); + //Debug.Log("rozdiely na borderoch, x: " + x + " y: " + y); + if (pos.x > 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 - 1; + if (pos.x <= 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 + 1; + if (pos.y <= 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 + 1; + if (pos.y > 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 - 1; + //while popoziciach je na mieste x a y sa teraz nachadza rozpetie medzi hranicami + //foodX = (int)Mathf.Round(pos.x) / 2 + numOfRows / 2 ; + foodY = whichInRange((int)Mathf.Round(borderBottom.position.y), (int)Mathf.Round(pos.y), y / numOfRows); + foodX = whichInRange((int)Mathf.Round(borderLeft.position.x), (int)Mathf.Round(pos.x), x / numOfColls); + //Debug.Log("suradnice do pola prekazok x: " + foodX + " y: " + (numOfRows - foodY - 1)); + } while (!(isSafeFoodPlant(foodX, numOfRows - foodY - 1))); + // Debug.Log("Position food: " + pos); + // Instantiate the food at (x, y) + //need to shift the number + if ((int)Random.Range(0,20) > 16) + { + isSpecialOnTable = true; + specialFoodCount = 0; + /*0,1,2*/ + int ran = (int)Random.Range(0, 3); + Debug.Log("random: " + ran); + if (ran == 0) { + specialFoodObject = (GameObject)Instantiate(decreaseSnakeLengthFoodPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); + } + else if (ran == 2) { + specialFoodObject = (GameObject)Instantiate(decreaseSnakeSpeedPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); + } + else { + specialFoodObject = (GameObject)Instantiate(incraseSnakeSpeedFoodPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); + } + float rand = Random.Range(4, 7); + specialTime = rand / 0.02f; + } + else + { + Instantiate(foodPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); // default rotation + } + } + + int whichInRange(int start, int position, int step) + { + //Debug.Log("start: " + start + " position: " + position + " step: " + step); + int current = start + step; + int i = 0; + while (current <= position) + { + current += step; + i++; + } + return i; + } + + /*in case there are obstacles on board, we need to check whether the food is not going to be planted in some corner, since the snake can't rotate it's head*/ + bool isSafeFoodPlant(int x, int y) + { + if (((x == 0) && (y == 0)) || ((x == numOfRows) && (y == 0)) || + ((x == numOfRows) && (y == numOfColls)) || ((x == 0) && (y == numOfColls))) + { + return false; //corners of game plan + } + else if (obstacle[y][x] == true) + { + return false; //hit with the obstacle + } + else if ((y == 0) || (y == numOfColls)) + { + if ((obstacle[y][x - 1]) || obstacle[y][x + 1]) { return false; } // food by vertical border + } + else if ((x == 0) || (x == numOfRows)) + { + if ((obstacle[y - 1][x]) || (obstacle[y + 1][x])) { return false; } // food by horizontal border + } + else if ((obstacle[y - 1][x] && obstacle[y][x - 1]) || (obstacle[y - 1][x] && obstacle[y][x + 1]) || + (obstacle[y][x - 1] && obstacle[y + 1][x]) || (obstacle[y][x - 1] && obstacle[y + 1][x + 1])) + { + return false; + } + return true; + } + + void OpenFinalPortal() { + Vector2 position = new Vector2(1,1); + finalPortalGO = (GameObject) Instantiate(finalPOrtalGameObject, position, Quaternion.identity); + } + + void forgetObstacles() + { + for (int i = 0; i < numOfRows; i++) + { + for (int j = 0; j < numOfColls; j++) + { + obstacle[i][j] = false; + } + } + foreach (GameObject obj in obstaclesGO) { + Debug.Log("Destorying: " + obj); + Destroy(obj); + + } + obstaclesGO = new List(); + } + +void setObstacles(JSONNode bariers) + { + int x, y; + int xDist = Mathf.Abs((int)(borderRight.position.x - borderLeft.position.x)); + int yDist = Mathf.Abs((int)(borderBottom.position.y - borderTop.position.y)); + + Debug.Log ("setObstacles"); + for (int i = 0; i < bariers.Count; i++) + { + x = bariers[i]["x"].AsInt; + y = bariers[i]["y"].AsInt; + obstacle[y][x] = true; + Vector2 position = new Vector2(); + position.x =Mathf.Round( borderLeft.position.x + (x * xDist / numOfColls) +1); + position.y =Mathf.Round( borderTop.position.y - (y * yDist / numOfRows) -1 ); + //obstaclesGO.Add((GameObject)Instantiate(obstaclePrefab, position, Quaternion.identity)); + Debug.Log ("obstacle"+ obstacle[y][x] + "position: "+position); + } + } + + void setPictures(JSONNode pictures) + { + Debug.Log("setPictures"); + int xDist = Mathf.Abs((int)(borderRight.position.x - borderLeft.position.x)); + int yDist = Mathf.Abs((int)(borderBottom.position.y - borderTop.position.y)); + + for (int i = 0; i < pictures.Count; i++) + { + //todo add sprite + int type = pictures[i]["type"].AsInt; + int x = pictures[i]["x"].AsInt; + int y = pictures[i]["y"].AsInt; + Vector2 position = new Vector2(); + position.x = Mathf.Round(borderLeft.position.x + (x * xDist / numOfColls) + 1); + position.y = Mathf.Round(borderTop.position.y - (y * yDist / numOfRows) - 1); + + switch (type) + { + case 0: + //todo hrncek + for (int k = 0; k < 5; k++) { + for (int j = 0; j < 4; j++) { + position.x = Mathf.Round(borderLeft.position.x + (x * xDist / numOfColls) + 1 + j *2); + position.y = Mathf.Round(borderTop.position.y - (y * yDist / numOfRows) - 1 - k * 2); + obstaclesGO.Add((GameObject)Instantiate(obstaclePrefab, position, Quaternion.identity)); + + } + } + + break; + case 1: + //todo guma + position.y -= 1; + obstaclesGO.Add((GameObject)Instantiate(eraserObstacleGo, position, Quaternion.identity)); + break; + case 2: + //todo ceruzka + position.x -= 0.78f; + position.y -= 0.24f; + obstaclesGO.Add((GameObject)Instantiate(pencilObstacleGO, position, Quaternion.identity)); + break; + case 3: + //todo mobil + position.x -= 0.78f; + position.y -= 0.24f; + obstaclesGO.Add((GameObject)Instantiate(phoneObstacleGo, position, Quaternion.identity)); + break; + } + } + } + + void removeSpecialFood() { + Destroy(specialFoodObject); + isSpecialOnTable = false; + SpawnFood(); + } + + public void setPause(bool pause) + { + this.pause = pause; + } + + public void setInMenu(bool inMenu) + { + this.inMenu = inMenu; + } + + public bool isPaused() + { + return gamePausedText.enabled; + } + +public void SetLevel(int levelId) + { + Destroy(finalPortalGO); + forgetObstacles(); + Loading.setLastLevelId (levelId); + setObstacles(Loading.GetBariers(levelId)); + setPictures(Loading.GetPictures(Loading.getLastLevelId())); + } + /*TODO: implement game over screen here*/ + void gameOver() + { + forgetObstacles(); + + pause = true; + inMenu = true; + AddPortalSript.setPause(true); + AddPortalSript.setInMenu(true); + gameOverScoreText.text = score.ToString(); + gameOverScreen.enabled = true; + } + + public void loadSceneZero() + { + SceneManager.LoadScene(0); + } + +} diff --git a/Assets/Scripts/Snake.cs.bak b/Assets/Scripts/Snake.cs.bak new file mode 100644 index 000000000..11f92d616 --- /dev/null +++ b/Assets/Scripts/Snake.cs.bak @@ -0,0 +1,542 @@ +using UnityEngine; +using UnityEngine.UI; +using System.Collections; +using System.Collections.Generic; +using System.Linq; +using UnityEngine.SceneManagement; + +public class Snake : MonoBehaviour +{ + + public GameObject foodPrefab; + public GameObject decreaseSnakeLengthFoodPrefab; + public GameObject incraseSnakeSpeedFoodPrefab; + public GameObject decreaseSnakeSpeedPrefab; + public GameObject background; + public Canvas gamePausedText; + public Canvas gameOverScreen; + public Text scoreText; + public Text gameOverScoreText; + public AddPortal AddPortalSript; + + public Transform borderTop; + public Transform borderBottom; + public Transform borderLeft; + public Transform borderRight; + + public float distance; + public float moveTime; + public float moveChangeRate; + public float moveDistance; + public GameObject tailPrefab; + public GameObject lastTailPrefab; + public GameObject initialBody; + public GameObject initialTail; + + Vector2 dir = Vector2.left; + private List tail = new List(); + bool ate = false; + bool shrink = false; + bool portal = false; + bool pause = true; + bool inMenu = true; + private int fixedUpdateCounter = 0; + private int specialFoodCount = 0; + private bool isSpecialOnTable = false; + private GameObject specialFoodObject; + private float specialTime; + private static int numOfRows = 12; + private static int numOfColls = 20; + + private int score = 0; + private static int foodScoreNormal = 10; + private static int foodScoreIncSpeed = 20; + private static int foodScoreDecrease = 5; //decrease speed or length + + private List portalsToDelete = new List(); + + + bool[][] obstacle = new bool[numOfRows][]; /*12*20*/ + // Use this for initialization + class PortalToDelete { + private static GameObject inputPortal; + private static GameObject outputPortal; + public int numberOfSteps; + + public void setInputPortal(GameObject input) { + inputPortal = input; + } + public GameObject getInputPortal() { + return inputPortal; + } + public void setOutPortal(GameObject output){ + outputPortal = output; + } + public GameObject getOutputPortal() { + return outputPortal; + } + + } + + void Start() + { + background = GameObject.FindGameObjectWithTag("Background"); + gamePausedText = gamePausedText.GetComponent(); + gamePausedText.enabled = false; + scoreText = scoreText.GetComponent(); + gameOverScoreText = gameOverScoreText.GetComponent(); + gameOverScreen = gameOverScreen.GetComponent(); + AddPortalSript = background.GetComponent(); + fixedUpdateCounter = 0; + for (int i = 0; i < numOfRows; i++) + { + obstacle[i] = new bool[numOfColls]; + } + forgetObstacles(); + tail.Add(initialBody.transform); + tail.Add(initialTail.transform); + SpawnFood(); + + } + + /*guarantees same time between each update*/ + void FixedUpdate() + { + if (!pause) + { + + fixedUpdateCounter++; + float time = (float)moveTime / 0.02f; + if ((int)time == fixedUpdateCounter) + { + fixedUpdateCounter = 0; + Move(); + } + if (isSpecialOnTable) + { + specialFoodCount++; + //Debug.Log("Actual time: " + specialFoodCount + " looking for: " + (int)specialTime); + if (specialFoodCount == (int)specialTime) + { + removeSpecialFood(); + } + } + } + } + + // Update is called once per frame + void Update() + { + + // Move in a new Direction? + if (Input.GetKey(KeyCode.RightArrow)) + dir = Vector2.right; + else if (Input.GetKey(KeyCode.DownArrow)) + dir = Vector2.down; + else if (Input.GetKey(KeyCode.LeftArrow)) + dir = Vector2.left; + else if (Input.GetKey(KeyCode.UpArrow)) + dir = Vector2.up; + if (Input.GetKeyUp(KeyCode.P) && !inMenu) + { + pause = !pause; + gamePausedText.enabled = !gamePausedText.enabled; + } + } + + void OnTriggerEnter2D(Collider2D coll) + { + if (portal) { return; } + if (coll.name.StartsWith(foodPrefab.name)) + { + // Get longer in next Move call + ate = true; + + // Remove the Food + Destroy(coll.gameObject); + score += foodScoreNormal; + scoreText.text = score.ToString(); + } + else if (coll.name.StartsWith(decreaseSnakeLengthFoodPrefab.name)) + { + // Get shorter in next Move call + shrink = true; + + // Remove the Food + Destroy(coll.gameObject); + score += foodScoreDecrease; + scoreText.text = score.ToString(); + } + else if (coll.name.StartsWith(incraseSnakeSpeedFoodPrefab.name)) + { + //increase speed of snake ??do we increase the lenght of snake as well?? + UpdateSpeed(true); + removeSpecialFood(); + //score updated in UpdateSpeed(); + } + else if (coll.name.StartsWith(decreaseSnakeSpeedPrefab.name)) + { + //decrease speed + UpdateSpeed(false); + + removeSpecialFood(); + + //score updated in UpdateSpeed(); + } + else if (coll.name.StartsWith(AddPortalSript.backgroundIn.name)) + { + portal = true; + //Debug.Log("hura portal!"); + List portals = AddPortalSript.portals; + PortalId something = coll.gameObject.GetComponent(); + int id = something.id; + Debug.Log("Collision portal id: " + id); + AddPortal.Tuple onIndex = null; + foreach (AddPortal.Tuple tup in portals) + { + if (tup.outputPortal.getId() == id) + { + onIndex = tup; + break; + } + } + if (onIndex != null) + { + + Vector3 head = new Vector3(dir.x, dir.y, 0); + Vector3 moveDirection = head; + if (moveDirection != Vector3.zero) + { + float angle = Mathf.Atan2(moveDirection.y, moveDirection.x) * Mathf.Rad2Deg; + if (angle < 0) + { + angle = -1 * Mathf.Abs(Mathf.RoundToInt(angle)) / 90 * 90; + } + else + { + angle = Mathf.RoundToInt(angle) / 90 * 90; + } + transform.rotation = Quaternion.AngleAxis(angle, Vector3.up); + } + dir = onIndex.outputPortal.getHeading(); + if (dir == Vector2.left) + { + transform.rotation = new Quaternion(0, 0, 0, 1); + } + if (dir == Vector2.right) + { + transform.rotation = new Quaternion(0, 1, 0, 0); + } + if (dir == Vector2.down) + { + transform.rotation = new Quaternion(1, 1, 0, 0); + } + if (dir == Vector2.up) + { + transform.rotation = new Quaternion(1, -1, 0, 0); + } + //Debug.Log(transform.rotation); + transform.position = onIndex.outputPortal.getPosition(); + + PortalToDelete local = new PortalToDelete(); + local.setInputPortal(coll.gameObject); + local.setOutPortal(onIndex.outputPortal.getOutputPortal()); + local.numberOfSteps = 0; + portalsToDelete.Add(local); + } + + } + else if (coll.name.StartsWith(AddPortalSript.backgroundOut.name)) { + } + + + else + { + gameOver(); + score = 0; + scoreText.text = score.ToString(); + // ToDo 'You lose' screen + Debug.Log("collision with: " + coll.name); + Debug.Log("Score: " + tail.Count); + //initialize(); + } + } + + public void Move() + { + //Debug.Log("hybem sa!"); + GameObject lastPosition; + portal = false; + Vector2 currentPossition = transform.position; + Vector2 position; + Quaternion rotation; + transform.Translate(dir * moveDistance, Space.World); + + + if (ate) + { + SpawnFood(); + if (tail.Count == 0) { + tail.Add(((GameObject)Instantiate(lastTailPrefab, currentPossition, transform.rotation)).transform); + } + else + { + tail.Insert(0, ((GameObject)Instantiate(tailPrefab, currentPossition, transform.rotation)).transform); + } + ate = false; + + } + else if (shrink) + { + if (tail.Count >= 2) + { + isSpecialOnTable = false; + shrink = false; + //* tail.Insert(0, tail.Last()); + if (tail.Count >= 3) + { + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + position = tail.Last().position; + rotation = tail.Last().rotation; + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + tail.Insert(0, ((GameObject)Instantiate(tailPrefab, currentPossition, transform.rotation)).transform); + tail.Add(((GameObject)Instantiate(lastTailPrefab, position, rotation)).transform); + } + else { + //gameOver(); + tail.Last().position = currentPossition; + tail.Last().rotation = transform.rotation; + tail.Insert(0, tail.Last()); + tail.RemoveAt(tail.Count - 1); + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + + } + //tail.Insert(tail.Count - 1, (); + //tail.Last().GetComponent().sprite = lastTailPrefab.GetComponent().sprite; + SpawnFood(); + } + else { + /*GAME OVER dlzka hada je < 0*/ + gameOver(); + } + } + else if (tail.Count >=2 ) + { + + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + position = tail.Last().position; + rotation = tail.Last().rotation; + lastPosition = tail.Last().gameObject; + Destroy(lastPosition); + tail.RemoveAt(tail.Count - 1); + tail.Insert(0, ((GameObject)Instantiate(tailPrefab, currentPossition, transform.rotation)).transform); + tail.Add(((GameObject)Instantiate(lastTailPrefab, position, rotation)).transform); + + } + /*bool remove = false; + do + { + remove = false; + PortalToDelete port = new PortalToDelete(); + foreach (PortalToDelete localPortal in portalsToDelete) + { + localPortal.numberOfSteps++; + if (localPortal.numberOfSteps > tail.Count()) + { + remove = true; + Destroy(localPortal.getInputPortal()); + Destroy(localPortal.getOutputPortal()); + port = localPortal; + } + break; + } + if (remove) { portalsToDelete.Remove(port); } + + } while (remove);*/ + } + + bool inBounds(Vector3 bounds) + { + if ((bounds.x > borderLeft.position.x) && (bounds.x < borderRight.position.x) && (bounds.y > borderBottom.position.y) && (bounds.y < borderTop.position.y)) { return true; } + return false; + } + + void UpdateSpeed(bool increase) + { + if (increase) + { + moveTime -= moveChangeRate; + if (moveTime <= 0.1) { + moveTime = 0.1f; + score += foodScoreNormal; + } + else score += foodScoreIncSpeed; + } + else { + moveTime += moveChangeRate; + score += foodScoreDecrease; + } + scoreText.text = score.ToString(); + fixedUpdateCounter = 0; + } + + void SpawnFood() + { + Vector2 pos; + int foodX, foodY; + do + { + // x position between left & right border + int x = (int)Random.Range(borderLeft.position.x, + borderRight.position.x + 1); + + // y position between top & bottom border + int y = (int)Random.Range(borderBottom.position.y + 1, + borderTop.position.y); + + pos.x = x; + pos.y = y; + x = Mathf.Abs((int)(borderRight.position.x - borderLeft.position.x)); + y = Mathf.Abs((int)(borderBottom.position.y - borderTop.position.y)); + //Debug.Log("rozdiely na borderoch, x: " + x + " y: " + y); + if (pos.x > 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 - 1; + if (pos.x <= 0) pos.x = Mathf.Round((int)pos.x / 2) * 2 + 1; + if (pos.y <= 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 + 1; + if (pos.y > 0) pos.y = Mathf.Round((int)pos.y / 2) * 2 - 1; + //while popoziciach je na mieste x a y sa teraz nachadza rozpetie medzi hranicami + //foodX = (int)Mathf.Round(pos.x) / 2 + numOfRows / 2 ; + foodY = whichInRange((int)Mathf.Round(borderBottom.position.y), (int)Mathf.Round(pos.y), y / numOfRows); + foodX = whichInRange((int)Mathf.Round(borderLeft.position.x), (int)Mathf.Round(pos.x), x / numOfColls); + //Debug.Log("suradnice do pola prekazok x: " + foodX + " y: " + (numOfRows - foodY - 1)); + } while (!(isSafeFoodPlant(foodX, numOfRows - foodY - 1))); + // Debug.Log("Position food: " + pos); + // Instantiate the food at (x, y) + //need to shift the number + if ((int)Random.Range(0,20) > 16) + { + isSpecialOnTable = true; + specialFoodCount = 0; + /*0,1,2*/ + int ran = (int)Random.Range(0, 3); + Debug.Log("random: " + ran); + if (ran == 0) { + specialFoodObject = (GameObject)Instantiate(decreaseSnakeLengthFoodPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); + } + else if (ran == 2) { + specialFoodObject = (GameObject)Instantiate(decreaseSnakeSpeedPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); + } + else { + specialFoodObject = (GameObject)Instantiate(incraseSnakeSpeedFoodPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); + } + float rand = Random.Range(4, 7); + specialTime = rand / 0.02f; + } + else + { + Instantiate(foodPrefab, + new Vector2(pos.x, pos.y), + Quaternion.identity); // default rotation + } + } + + int whichInRange(int start, int position, int step) + { + //Debug.Log("start: " + start + " position: " + position + " step: " + step); + int current = start + step; + int i = 0; + while (current <= position) + { + current += step; + i++; + } + return i; + } + + /*in case there are obstacles on board, we need to check whether the food is not going to be planted in some corner, since the snake can't rotate it's head*/ + bool isSafeFoodPlant(int x, int y) + { + if (((x == 0) && (y == 0)) || ((x == numOfRows) && (y == 0)) || + ((x == numOfRows) && (y == numOfColls)) || ((x == 0) && (y == numOfColls))) + { + return false; //corners of game plan + } + else if (obstacle[y][x] == true) + { + return false; //hit with the obstacle + } + else if ((y == 0) || (y == numOfColls)) + { + if ((obstacle[y][x - 1]) || obstacle[y][x + 1]) { return false; } // food by vertical border + } + else if ((x == 0) || (x == numOfRows)) + { + if ((obstacle[y - 1][x]) || (obstacle[y + 1][x])) { return false; } // food by horizontal border + } + else if ((obstacle[y - 1][x] && obstacle[y][x - 1]) || (obstacle[y - 1][x] && obstacle[y][x + 1]) || + (obstacle[y][x - 1] && obstacle[y + 1][x]) || (obstacle[y][x - 1] && obstacle[y + 1][x + 1])) + { + return false; + } + return true; + } + + void forgetObstacles() + { + for (int i = 0; i < numOfRows; i++) + { + for (int j = 0; j < numOfColls; j++) + { + obstacle[i][j] = false; + } + } + } + + void removeSpecialFood() { + Destroy(specialFoodObject); + isSpecialOnTable = false; + SpawnFood(); + } + + public void setPause(bool pause) + { + this.pause = pause; + } + + public void setInMenu(bool inMenu) + { + this.inMenu = inMenu; + } + + public bool isPaused() + { + return gamePausedText.enabled; + } + + /*TODO: implement game over screen here*/ + void gameOver() + { + pause = true; + inMenu = true; + AddPortalSript.setPause(true); + AddPortalSript.setInMenu(true); + gameOverScoreText.text = score.ToString(); + gameOverScreen.enabled = true; + } +} diff --git a/Assets/Scripts/Snake.cs.bak.meta b/Assets/Scripts/Snake.cs.bak.meta new file mode 100644 index 000000000..7d2de6359 --- /dev/null +++ b/Assets/Scripts/Snake.cs.bak.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: f86f41abc9d30d04e8e61ca8f81eff66 +timeCreated: 1454689243 +licenseType: Free +DefaultImporter: + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Snake.cs.meta b/Assets/Scripts/Snake.cs.meta new file mode 100644 index 000000000..14bd848c0 --- /dev/null +++ b/Assets/Scripts/Snake.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: d94cf41d5b697814cb80a689290fa04c +timeCreated: 1444580642 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/SpawnFood.cs b/Assets/Scripts/SpawnFood.cs new file mode 100644 index 000000000..14bf59498 --- /dev/null +++ b/Assets/Scripts/SpawnFood.cs @@ -0,0 +1,35 @@ +using UnityEngine; +using System.Collections; + +public class SpawnFood : MonoBehaviour { + + public GameObject foodPrefab; + + public Transform borderTop; + public Transform borderBottom; + public Transform borderLeft; + public Transform borderRight; + + // Use this for initialization + void Start () { + InvokeRepeating("Spawn", 3, 4); + } + + // Spawn one piece of food + void Spawn() + { + // x position between left & right border + int x = (int)Random.Range(borderLeft.position.x, + borderRight.position.x); + + // y position between top & bottom border + int y = (int)Random.Range(borderBottom.position.y, + borderTop.position.y); + + // Instantiate the food at (x, y) + Instantiate(foodPrefab, + new Vector2(x, y), + Quaternion.identity); // default rotation + } + +} diff --git a/Assets/Scripts/SpawnFood.cs.meta b/Assets/Scripts/SpawnFood.cs.meta new file mode 100644 index 000000000..e9005df2d --- /dev/null +++ b/Assets/Scripts/SpawnFood.cs.meta @@ -0,0 +1,12 @@ +fileFormatVersion: 2 +guid: 3e0be03fa03377f4ea15976d7f3454c1 +timeCreated: 1444524772 +licenseType: Free +MonoImporter: + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/StartMenu.cs b/Assets/Scripts/StartMenu.cs new file mode 100644 index 000000000..e2b5ecde1 --- /dev/null +++ b/Assets/Scripts/StartMenu.cs @@ -0,0 +1,248 @@ +using UnityEngine; +using UnityEngine.UI; +using System.Collections; +using UnityEngine.SceneManagement; + +using SaveLoad; +public class StartMenu : MonoBehaviour { + + public Canvas quitDialog; + public Canvas aboutCanvas; +public Canvas levelsCanvas; + public Canvas controlsCanvas; + public Canvas controls1Canvas; + public Canvas optionsCanvas; + public Canvas menuCanvas; + public Canvas uiCanvas; + public Canvas gameOver; + public Button playButton; + public Button exitButton; + public Button controlsButton; + public Button optionsButton; + public Button aboutButton; + public Button levelsButton; + public AudioSource[] audio; + public Slider musicSlider; + public Slider soundSlider; + + public GameObject snakeObject; + public Snake snakeScript; + public GameObject backgroundObject; + public AddPortal addPortalScript; + + public Text lock1; + public Text lock2; + public Text lock3; + public Text lock4; + + public Button level1; + public Button level2; + public Button level3; + public Button level4; + + // Use this for initialization + void Start () { + + quitDialog = quitDialog.GetComponent(); //assigned actual game object to variable + aboutCanvas = aboutCanvas.GetComponent(); +levelsCanvas = levelsCanvas.GetComponent(); + controlsCanvas = controlsCanvas.GetComponent(); + controls1Canvas = controls1Canvas.GetComponent(); + optionsCanvas = optionsCanvas.GetComponent(); + menuCanvas = menuCanvas.GetComponent(); + uiCanvas = uiCanvas.GetComponent(); + gameOver = gameOver.GetComponent(); + playButton = playButton.GetComponent