public void Activate(PlaceableData pData) { timeToRemoval = pData.lifeTime; dieAudioClip = pData.dieClip; //TODO:添加更多的属性联系 StartCoroutine(Die()); }
public void Activate(Faction pFaction, PlaceableData pData) { pType = pData.pType; faction = pFaction; hitPoints = pData.hitPoints; targetType = pData.targetType; attackAudioClip = pData.attackClip; dieAudioClip = pData.dieClip; //TODO:添加更多的属性联系 constructionTimeline.Play(); }
private void SetupPlaceable(GameObject go, PlaceableData pDataRef, Placeable.Faction pFaction) { switch (pDataRef.pType) { case Placeable.PlaceableType.Unit: { Unit uScript = go.GetComponent <Unit>(); uScript.Activate(pFaction, pDataRef); uScript.OnDealDamage += OnPlaceableDealtDamage; uScript.OnProjectileFired += OnProjectileFired; AddPlaceableToList(uScript); uiManager.AddHealthUI(uScript); break; } case Placeable.PlaceableType.Building: case Placeable.PlaceableType.Castle: { Building bScript = go.GetComponent <Building>(); bScript.Activate(pFaction, pDataRef); bScript.OnDealDamage += OnPlaceableDealtDamage; bScript.OnProjectileFired += OnProjectileFired; AddPlaceableToList(bScript); uiManager.AddHealthUI(bScript); if (pDataRef.pType == Placeable.PlaceableType.Castle) { bScript.OnDie += OnCastleDead; } navMesh.BuildNavMesh(); //rebake the navmesh break; } case Placeable.PlaceableType.Obstacle: { Obstacle oScript = go.GetComponent <Obstacle>(); oScript.Activate(pDataRef); navMesh.BuildNavMesh(); //rebake the navmesh break; } case Placeable.PlaceableType.Spell: { //TODO:spell break; } } go.GetComponent <Placeable>().OnDie += OnPlaceableDead; }
//call by GameManager public void Activate(Faction pFaction, PlaceableData pData) { faction = pFaction; hitPoints = pData.hitPoints; targetType = pData.targetType; attackRange = pData.attackRange; attackRatio = pData.attackRatio; speed = pData.speed; damage = pData.damagePerAttack; attackAudioClip = pData.attackClip; dieAudioClip = pData.dieClip; //TODO:添加更多的属性关联 navMeshAgent.speed = speed; animator.SetFloat("MoveSpeed", speed); state = States.Idle; navMeshAgent.enabled = true; }
public void UseCard(CardData cardData, Vector3 position, Placeable.Faction pFaction) { for (int pNum = 0; pNum < cardData.placeablesData.Length; pNum++) { PlaceableData pDataRef = cardData.placeablesData[pNum]; Quaternion rot = (pFaction == Placeable.Faction.Player) ? Quaternion.identity : Quaternion.Euler(0f, 180f, 0f); GameObject prefabToSpawn = (pFaction == Placeable.Faction.Player) ? pDataRef.associatedPrefab : ((pDataRef.alternatePrefab == null) ? pDataRef.associatedPrefab : pDataRef.alternatePrefab); GameObject newPlaceableGO = GameObject.Instantiate <GameObject>(prefabToSpawn, position + cardData.relativeOffsets[pNum], rot); SetupPlaceable(newPlaceableGO, pDataRef, pFaction); appearEffectPool.UseParticles(position + cardData.relativeOffsets[pNum]); } updateAllPlaceables = true; //更新AI下次的update loop }