個人ゲームアプリ制作 -
unityによるゲーム制作

リリースアプリ一覧

unity2D


[Unity2D]キャラクターの継承

ベーススクリプトを作成

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

public class CharacterStatus : MonoBehaviour{

	public string name;
	public int baseHP;
	public int maxHP;
	public int hp;
	public int baseST;
	public int maxST;
	public int st;
	public int gold;
	public Lis<int> deck;
	public string condition;

	public Sprite sprite;
	public float spriteSizeX;
	public float spriteSizeY;

	public GameObject attackEffect;
	public GameObject missEffect;

	private CardsStatus action;
	private GameObject effect;

	protected virtual void Start(){

	}
}

継承するスクリプトを作成

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;

public class PlayerScript : CharacterStatus {

	public List<int> inventory = new List<int>();
	public int bp;
	public int maxBP;
	public int BPCount;
	public int equipHP;
	public int equipST;
	public int df;
	public int baseDF;
	public int equipDF;
	public int baseHand;
	public int hand;
	public int equipHand;

	protected override void Start () {

		equipHP = SaveData.GetInt("equipHP", equipHP);
		equipST = SaveData.GetInt("equipST", equipST);
		equipDF = SaveData.GetInt("equipDF", equipDF);
		equipHand = SaveData.GetInt("equipHand", equipHand);

		maxBP = SaveData.GetInt("maxBP", maxBP);
		BPCount = SaveData.GetInt("BPCount", BPCount);
		bp = SaveData.GetInt("bp", bp);
		gold = SaveData.GetInt("gold", gold);

		deck = SaveData.GetList("deck", deck);
		inventory = SaveData.GetList("inventory", inventory);

		hand = baseHand + equipHand;	
	}
}

2017 / 08 / 27
unity2D
C#

スポンサーリンク

© 2018 Takahiro Ueda