Day 101 — C# Fundamentals: Static Types

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Lives : MonoBehaviour
{
public int lives = 3;
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RemoveLives : MonoBehaviour
{
private Lives _lives;
private void Start()
{
_lives = GameObject.Find("Lives_Holder").GetComponent<Lives>();
}
private void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
_lives.lives -= 1;
Debug.Log("You have " + _lives.lives + " lives left");
}
}
}
public class Lives : MonoBehaviour
{
public static int lives = 3;
}
public class RemoveLives: MonoBehaviour
{
void Update()
{
if (Input.GetKeyDown(KeyCode.Space))
{
Lives.lives-= 1;
Debug.Log("You have " + Lives.lives + " lives left");
}
}
}
public class Weapon
{
public string name;
public float attackBonus;
public int id;
public static int weaponCount; public Weapon()
{
weaponCount++;
}
}
public class WeaponOverview : MonoBehaviour
{
private void Start()
{
Weapon spear = new Weapon();
Weapon sword = new Weapon();
Weapon club = new Weapon();
Debug.Log(Weapon.weaponCount);
}
}

--

--

--

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

How to use RxSwift with MVVM pattern — Part 2

How to Access Database with Kotlin using JDBC: The Fundamentals

OccamX Landing Page Goes Live — Meet Our Mascot and More!

Using Java Flight Recorder With OpenJDK 11 for WSO2 Products

StackBlitz SDK: Instantly Add Live Environments to Your Docs, Blogs, & more

building my first app

CrowSec EdTech Write-Up: Hijacking

CS 373 Fall 2021: Andrew Luo

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Connor Fullarton

Connor Fullarton

Hey and welcome! My name is Connor and my goal here is to put out a daily post for a full year about my game development journey.

More from Medium

Introduction to JSON

2D Mobile: Loot System

Creating the Main Menu

Basic concepts of Application Frameworks and JavaScript.