Coding

Class Dependency Diagram

Class Dependency Diagram

UML Diagram

reference: http://www.itsenka.com/contents/development/uml/class.html

  • Visibility
    • +…public
    • -…private
    • #…protected
  • Valuables
    • visibility name : type = default value {conditions}
  • Functions
    • visibility name (argument : type) : returned value’s type
  • Others
    • If underlined, static
  • Relationships
    • A——B…association: A and B have a relation
    • A◇—B…aggregation: B is a part of A
    • A◆—B…composition: B is a component of A
    • A< – -B…dependency: A depends on B
    • A◁—B…generalisaion: B is an A

Cord Generator

Class: Cord

Item Pick Up/Use

Input Setting: Input.GetButton (“Use”)

Class: Item (ver.01)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Item : MonoBehaviour {
	private ArrayList info;
	public enum ItemType{
		Vase,
		Hose
	}

	private string myName; //info[0]
	private ItemType itemType; //info[1]

	[SerializeField]
	private AudioClip soundEffect; //info[2]
	[SerializeField]
	private GameObject product; //info[3]
	[SerializeField]
	private GameObject myself; //info[4]

	void Awake () {
		myName = gameObject.name;
		info = new ArrayList (myName, itemType, soundEffect, product, myself);
	}

	public ArrayList PassInfo(){
		return info;
	}
}

Class: Item (ver.02)

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class Item : MonoBehaviour {
	public enum ItemType{
		SaltVase,
		MedVase,
		BeerVase,
		Hose
	}

	[SerializeField]
	private ItemType itemType; //info[0]
	[SerializeField]
	private AudioClip soundEffect; //info[1]
	[SerializeField]
	private GameObject product; //info[2]
	[SerializeField]
	private GameObject myself; //info[3]

	public Item PassInfo (){
		return new Item (){
			itemType = this.itemType,
			soundEffect = this.soundEffect,
			product = this.product,
			myself = this.myself
		};
	}
}

Improvements:

  • ArrayList does not keep type -> change to passing class info itself
Advertisements