Advertisement
Guest User

Untitled

a guest
May 25th, 2019
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.06 KB | None | 0 0
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4.  
  5. public class Player : MonoBehaviour
  6. {
  7.  
  8.     CardCollection myColection;
  9.     // Start is called before the first frame update
  10.  
  11.     public GameObject axe;
  12.     void Start()
  13.     {
  14.         myColection = ScriptableObject.CreateInstance<CardCollection>();
  15.         myColection.Start();
  16.     }
  17.  
  18.     // Update is called once per frame
  19.     void Update()
  20.     {
  21.         bool isAnimationPlaying = axe.gameObject.GetComponent<Axe>();
  22.  
  23.         if (isAnimationPlaying == false)
  24.         {
  25.  
  26.             if (Input.GetKeyDown(KeyCode.LeftArrow))
  27.             {
  28.                 Vector3 position = this.transform.position;
  29.                 position.x--;
  30.                 this.transform.position = position;
  31.  
  32.             }
  33.             if (Input.GetKeyDown(KeyCode.RightArrow))
  34.             {
  35.                 Vector3 position = this.transform.position;
  36.                 position.x++;
  37.                 this.transform.position = position;
  38.  
  39.             }
  40.             if (Input.GetKeyDown(KeyCode.UpArrow))
  41.             {
  42.                 Vector3 position = this.transform.position;
  43.                 position.y++;
  44.                 this.transform.position = position;
  45.  
  46.             }
  47.             if (Input.GetKeyDown(KeyCode.DownArrow))
  48.             {
  49.                 Vector3 position = this.transform.position;
  50.                 position.y--;
  51.                 this.transform.position = position;
  52.  
  53.             }
  54.             if (Input.GetKeyDown(KeyCode.Space))
  55.             {
  56.                 var shooter = GetComponent<Shooter>();
  57.                 shooter.Fire();
  58.  
  59.             }
  60.             if (Input.GetKeyDown(KeyCode.C))
  61.             {
  62.                 var melee = GetComponent<Melee>();
  63.                 melee.Swing();
  64.                 //Debug.Log("hello");
  65.  
  66.             }
  67.             if (Input.GetKeyDown(KeyCode.V))
  68.             {
  69.                 var placeWall = GetComponent<WallPlacer>();
  70.                 placeWall.PlaceWall();
  71.                 //Debug.Log("hello");
  72.  
  73.             }
  74.         }
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement