Search Unity

help with my project 'Shadowlight: the power of the dark'

Discussion in 'Editor & General Support' started by coen22, Aug 27, 2013.

  1. coen22

    coen22

    Joined:
    Aug 27, 2013
    Posts:
    31
    $banner_1080.png

    Hi, my name is Coen Hacking, I'm 17 and live in the Netherlands.
    I want to make a game to make some money (for university :))
    It's a game planned for OUYA,, Windows, Mac and Linux (and later Android and IOS)

    I need a few people to help me finish this project:
    • A co-programmer
    • A level-designer
    • A modeller

    If possible I'd like to sell it for €10,- ($13,-) and maybe start a kickstarter campaign
    It will include the story I wrote and 12 levels
    this is my website: http://csoftrepair.comze.com/dev/ (Dutch) (but you'll be able to find the download button :D )

    Tell me what you think! :D

    Specular + Rim + Normal shader
    Code (csharp):
    1. Shader "Rim/Rim Specular" {
    2.     Properties {
    3.         _Color ("Main Color", Color) = (1,1,1,1)
    4.         _MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
    5.         _BumpMap ("Normalmap", 2D) = "bump" {}
    6.        
    7.         _SpecTex ("Spec (RGB)", 2D) = "white" {}
    8.         _SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
    9.         _Shininess ("Shininess", Range (0, 1)) = 0.078125
    10.        
    11.         _RimColor ("Rim Color", Color) = (0.26,0.19,0.16,0.0)
    12.         _RimPower ("Rim Power", Range(0.5,8.0)) = 3.0
    13.         _RimRange ("Rim Strengh", Range(1.0,2.0)) = 1.0
    14.     }
    15.    
    16.     SubShader {
    17.         Tags { "RenderType"="Opaque" }
    18.         LOD 400
    19.  
    20.         CGPROGRAM
    21.         #pragma surface surf BlinnPhong
    22.        
    23.         sampler2D _MainTex;
    24.         sampler2D _BumpMap;
    25.         sampler2D _SpecTex;
    26.         float4 _Color;
    27.         float _Shininess;
    28.                
    29.         float4 _RimColor;
    30.         float _RimPower;
    31.         float _RimRange;
    32.        
    33.         struct Input {
    34.             float2 uv_MainTex;
    35.             float2 uv_BumpMap;
    36.             float3 viewDir;
    37.         };
    38.        
    39.         void surf (Input IN, inout SurfaceOutput o) {
    40.             half4 tex = tex2D(_MainTex, IN.uv_MainTex);
    41.             half4 spectex = tex2D(_SpecTex, IN.uv_MainTex);
    42.             _SpecColor = _SpecColor * spectex;
    43.        
    44.             o.Albedo = tex.rgb * _Color.rgb;
    45.             o.Gloss = tex.a;
    46.             o.Alpha = tex.a * _Color.a;
    47.             o.Specular = _Shininess;
    48.             o.Normal = UnpackNormal(tex2D(_BumpMap, IN.uv_BumpMap));
    49.            
    50.             half rim = _RimRange - saturate(dot (normalize(IN.viewDir), o.Normal));
    51.             o.Emission = _RimColor.rgb * pow (rim, _RimPower);
    52.         }
    53.         ENDCG
    54.     }
    55.     FallBack "Rim/Rim Diffuse"
    56. }
    PlayerControl.cs
    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class PlayerControl : MonoBehaviour {
    5.    
    6.     private float xVel;
    7.     private float yVel;
    8.     public float yGravity = 5F;
    9.        
    10.     private float lastPlatformY;
    11.     private float lastPlatformX;
    12.     private float platformMovementX;
    13.     private float lastCollider = 0;
    14.     private bool jumpPressed = false;
    15.     private bool move = true;
    16.    
    17.     public float walkSpeed = 10;
    18.     public float runSpeed = 15;
    19.     private float speed;
    20.    
    21.     public float halfPlayerHeight = 1.0f;
    22.     private float rotation;
    23.     public float rotationSpeed = 0.1f;
    24.    
    25.     // Use this for initialization
    26.     void Start () {
    27.         xVel = 0;
    28.         yVel = 0;
    29.     }
    30.    
    31.     // Its a percentage
    32.     public float buttonSize = 0.2f;
    33.    
    34.     public float GetUniversalAxis() {
    35.        
    36.         if(Input.touches.Length > 0) { 
    37.             Vector2 touchPosition = Input.GetTouch(0).position;
    38.             // pressed = touchPosition.x.ToString();
    39.             int i = 0;
    40.             while(i <= Input.touchCount)
    41.             {
    42.                 touchPosition = Input.GetTouch(i).position;
    43.                 if (touchPosition.x < Screen.width*buttonSize)
    44.                 {
    45.                     return -1;
    46.                 }
    47.                 else if (touchPosition.x > Screen.width*buttonSize  touchPosition.x < Screen.width*buttonSize*2)
    48.                 {
    49.                     return 1;
    50.                 }
    51.                 ++i;
    52.             }
    53.         }
    54.        
    55.         return Input.GetAxis("Horizontal");
    56.     }
    57.    
    58.     public bool GetUniversalJump() {
    59.        
    60.         if(Input.touches.Length > 0) { 
    61.             Vector2 touchPosition = Input.GetTouch(0).position;
    62.  
    63.             int i = 0;
    64.             while(i <= Input.touchCount)
    65.             {
    66.                 if (touchPosition.x > Screen.width*(1 - buttonSize))
    67.                 {
    68.                     return true;
    69.                 }
    70.                 ++i;
    71.             }
    72.         }
    73.        
    74.         if(Input.GetButton("Jump")){
    75.             return true;   
    76.         }
    77.        
    78.         return false;
    79.     }
    80.    
    81.     public bool GetUniversalFire() {
    82.        
    83.         if(Input.touches.Length > 0) { 
    84.             Vector2 touchPosition = Input.GetTouch(0).position;
    85.  
    86.             int i = 0;
    87.             while(i < Input.touchCount)
    88.             {
    89.                 if (touchPosition.x < Screen.width*(1 - buttonSize)  touchPosition.x > Screen.width*(1 - buttonSize*2))
    90.                 {
    91.                     return true;
    92.                 }
    93.                 ++i;
    94.             }
    95.         }
    96.        
    97.         if(Input.GetButton("Fire1")){
    98.             return true;   
    99.         }
    100.        
    101.         return false;
    102.     }
    103.    
    104.     void OnDie() {
    105.         Application.LoadLevel(Application.loadedLevel);
    106.         animation.Play("deathFall");
    107.     }
    108.    
    109.     void OnThrow(Vector3 target) {
    110.         move = false;
    111.         parabolTarget = target;
    112.         yVel = -0.1f;
    113.         animation.Play("jump");
    114.     }
    115.    
    116.     void OnThrowStop() {
    117.         move = true;
    118.     }
    119.    
    120.     Vector3 parabolTarget;
    121.     float nextN;
    122.    
    123.     // Update is called once per frame
    124.     void Update() {
    125.         if (move)
    126.             Move();
    127.         if (!move)
    128.         {
    129.             // float finalN = Mathf.Sqrt(Mathf.Pow(parabolTarget.x, 2) + Mathf.Pow(parabolTarget.z, 2));
    130.             // float startN = Mathf.Sqrt(Mathf.Pow(parabolStart.x, 2) + Mathf.Pow(parabolStart.z, 2));
    131.            
    132.             Vector3 nextPosition;
    133.            
    134.             // nextPosition.y = transform.position.y -nextN + 1f;
    135.             // nextN += Time.smoothDeltaTime;
    136.             // if (nextN >= 1f) move = true;
    137.            
    138.             nextPosition.x = 0.95f * transform.position.x + 0.05f * parabolTarget.x;
    139.             nextPosition.y = 0.95f * transform.position.y + 0.05f * parabolTarget.y;
    140.             nextPosition.z = 0.95f * transform.position.z + 0.05f * parabolTarget.z;
    141.            
    142.             this.transform.position = new Vector3(nextPosition.x, nextPosition.y, nextPosition.z);
    143.         }
    144.     }
    145.    
    146.     void Move() {
    147.         transform.position = new Vector3(transform.position.x,transform.position.y,Mathf.Round(transform.position.z/10)*10);
    148.        
    149.         RaycastHit hitDown;
    150.            
    151.         if (Physics.SphereCast(transform.position + Vector3.up,0.1f, Vector3.down, out hitDown, halfPlayerHeight - 0.1f)) {
    152.             if (!hitDown.collider.isTrigger)
    153.             {
    154.                 yVel = 0;
    155.                
    156.                 float newX = hitDown.transform.position.x;
    157.                 if (lastPlatformX == 0)
    158.                     lastPlatformX = newX;
    159.                    
    160.                 // Debug.Log(0.5f/Time.smoothDeltaTime);
    161.                
    162.                 platformMovementX = newX - lastPlatformX;
    163.                
    164.                 if (platformMovementX < -0.5f || platformMovementX > 0.5f || lastCollider != hitDown.collider.GetInstanceID())
    165.                 {
    166.                     platformMovementX = 0;
    167.                 }
    168.                
    169.                 lastCollider = hitDown.collider.GetInstanceID();
    170.                
    171.                 this.transform.position = new Vector3(transform.position.x + platformMovementX,
    172.                         hitDown.point.y,
    173.                         Mathf.Round(transform.position.z));
    174.                
    175.                 lastPlatformX = newX;
    176.                
    177.                 animation.Play(GetUniversalAxis() == 0 ? "idle" : "run");
    178.                
    179.                 if (hitDown.collider.gameObject.name.ToLower().Equals("grasshopper"))
    180.                 {
    181.                     hitDown.collider.BroadcastMessage("Die");
    182.                     yVel = 20;
    183.                     animation.Play("jump");
    184.                 }
    185.                
    186.                 if (hitDown.collider.gameObject.name.ToLower().Equals("springbook"))
    187.                 {
    188.                     yVel = 20;
    189.                     animation.Play("jump");
    190.                 }
    191.                
    192.                 if (GetUniversalFire())
    193.                     speed = runSpeed;
    194.                 else
    195.                     speed = walkSpeed;
    196.                
    197.                 if (GetUniversalJump()) {
    198.                     if (!jumpPressed)
    199.                     {
    200.                         jumpPressed = true;
    201.                         yVel = 20F;
    202.                         animation.Play("jump");
    203.                     }
    204.                 }else{
    205.                     jumpPressed = false;
    206.                 }
    207.             }
    208.         } else {   
    209.             yVel -= yGravity * Time.smoothDeltaTime;
    210.             if (yVel < -1) animation.Blend("jumpFall",0.9f,1);
    211.         }
    212.        
    213.         if (GetUniversalAxis() != 0)
    214.             rotation = GetUniversalAxis();
    215.        
    216.         if (rotation < 0)
    217.         {
    218.             this.transform.eulerAngles = new Vector3(0,(1 - rotationSpeed) * this.transform.eulerAngles.y + rotationSpeed * 270,0);
    219.         }
    220.         if (rotation > 0)
    221.         {
    222.             this.transform.eulerAngles = new Vector3(0,(1 - rotationSpeed) * this.transform.eulerAngles.y + rotationSpeed * 90,0);
    223.         }
    224.        
    225.         bool cast = Physics.SphereCast(transform.position + Vector3.up,0.5f, new Vector3(GetUniversalAxis(), 0, 0), out hitDown, 0.25f);
    226.        
    227.         if (!cast || hitDown.collider.isTrigger)
    228.             this.transform.Translate(new Vector3(0, 0, Mathf.Abs(GetUniversalAxis()*speed*Time.smoothDeltaTime)));
    229.  
    230.         cast = Physics.SphereCast(transform.position + Vector3.up,0.1f, Vector3.up, out hitDown, halfPlayerHeight - 0.1f);
    231.        
    232.         if (cast  !hitDown.collider.gameObject.tag.ToLower().Equals("hollow"))
    233.         {
    234.             this.transform.position = new Vector3(transform.position.x, hitDown.point.y - 2, transform.position.z);
    235.             yVel = -2 * yGravity * Time.smoothDeltaTime;
    236.         }
    237.        
    238.         // Update the y
    239.         float yUpdate = yVel * Time.smoothDeltaTime;
    240.        
    241.         if (yUpdate > -0.9f)
    242.             this.transform.Translate(new Vector3(0,yUpdate , 0));
    243.         else
    244.             this.transform.Translate(new Vector3(0,-0.9f , 0));
    245.     }
    246. }