本次将要加入黑夜场景和阳光菇
导入黑夜背景和阳光菇
设置卡片和遮罩的名称和图片为阳光菇
在PlantManager加入代码
public enum PlantType
{
SunFlower,
Peashooter,
SunShroom
}
public GameObject GetPlantByType(PlantType type)
{
switch (type)
{
case PlantType.SunFlower:
return GameManager.Instance.GameConf.SunFlower;
case PlantType.Peashooter:
return GameManager.Instance.GameConf.Peashooter;
case PlantType.SunShroom:
return GameManager.Instance.GameConf.SunShroom;
}
return null;
}
设置unity 中UIPlantCard的Planttype为SunShroom
更改GameConf的脚本,加入以下代码
[Tooltip("阳光菇")]
public GameObject SunShroom;
创建预制体和动画
加入animator 导入动画
编写阳光菇脚本
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SunShroom : PlantBase
{
private float createSunTime = 24;
private float goldWantTime = 1;
public override float MaxHp
{
get
{
return 300;
}
}
protected override void OnInitForPlace()
{
InvokeRepeating("CreateSun", createSunTime, createSunTime);
}
private void CreateSun()
{
StartCoroutine(ColorEF(goldWantTime, new Color(1, 0.6f, 0), 0.05F, InstantiateSun));
}
private void InstantiateSun()
{
Sun sun = PoolManager.Instance.GetObj(GameManager.Instance.GameConf.Sun).GetComponent<Sun>();
sun.transform.SetParent(transform);
sun.InitForSunFlower(transform.position);
}
}
设置关卡管理器中阳光的创建
if(SceneManager.GetActiveScene().name!="Black") SkySunManager.Instance.StartCreatSun(6);
|