Hey guys, to be honest, this is my first real attempt at coding and Game Development and I just wanted some feedback on my coding practices and if you guys think there is a more human readable or efficient way to do this script
On a side note this is literally my first week of coding so I won’t be hurt if it’s absolutely horrific
#pragma strict
// Other Scripts
var Inventory : Inventory;
// Soil State
var IsTilled : boolean = false;
var IsHarvested : boolean = false;
var IsWatered : boolean = false;
var IsPlanted : boolean = false;
// Interaction
var HasCollided : boolean = false;
// Stats
var WaterLevel : int = 0;
var WaterCapacity : int = 100;
// Plants And Seeds
// Objects
//Wheat
var RealWheat : GameObject;
var FakeWheat : GameObject;
// Pumpkin
var RealPumpkin : GameObject;
var FakePumpkin : GameObject;
// Flower
var RealFlower : GameObject;
var FakeFlower : GameObject;
// Cucumber
var RealCucumber : GameObject;
var FakeCucumber : GameObject;
// Seeds
// Wheat
var WheatIsPlanted : boolean = false;
// Pumpkin
var PumpkinIsPlanted : boolean = false;
// Flower
var FlowerIsPlanted : boolean = false;
// Cucumber
var CucumberIsPlanted : boolean = false;
function Start () {
}
function Update () {
}
function OnCollisionEnter ( col : Collision ) {
if ( col.gameObject.name == “Player” ) {
HasCollided = true;
Debug.Log(“Entering Soil”);
}
}
function OnTriggerExit ( col : Collider ) {
if (col.gameObject.name == “Player” ) {
HasCollided = false;
Debug.Log(“Leaving Soil”);
}
}
function CreateCrop() {
if (IsPlanted == false && IsTilled == true && IsWatered == true) {
if ( WheatIsPlanted == true ) {
Instantiate(RealWheat,transform.position, Quaternion.identity);
Inventory.Seed[2].Amount -= 1;
IsPlanted = true;
WheatIsPlanted = false;
} else if ( PumpkinIsPlanted == true) {
Instantiate(RealPumpkin, transform.position, Quaternion.identity);
Inventory.Seed[1].Amount -= 1;
IsPlanted = true;
WheatIsPlanted = false;
} else if ( FlowerIsPlanted == true ) {
Inventory.Seed[0].Amount -= 1;
Instantiate(RealFlower, transform.position, Quaternion.identity);
IsPlanted = true;
FlowerIsPlanted = false;
} else if ( CucumberIsPlanted == true ) {
Inventory.Seed[3].Amount =- 1;
Instantiate(RealCucumber, transform.position, Quaternion.identity);
IsPlanted = true;
FlowerIsPlanted = false;
}
} else if (IsPlanted == true) {
PlayerInfo.HelpInfo = “Something Is already Planted here, let it grow.”;
} else if (IsTilled == false && IsWatered == false) {
PlayerInfo.HelpInfo = “You need to till and water this tile first”;
} else if (IsTilled == true && IsWatered == false) {
PlayerInfo.HelpInfo = “You need to water whis tile first.”;
} else if (IsTilled == false && IsWatered == true) {
PlayerInfo.HelpInfo = “You need to till the land first.”;
}
}