public void SetShip( GameObject go, Ship ship, int index, Vector3 position ) { ResetShip( index ); EditorShip ec = new EditorShip(); ec.Go = go; ec.ship = ship; ec.OrginPosition = position; ec.Index = index; ec.Group = this; Ships_[index] = ec; }
private void ShowShip( EditorShip ship, Vector3 position ) { GameObject go = ship.Go; go.transform.position = position; position.x = 0; go.transform.LookAt( position ); PreviewManager.ReplaceShader( go ); }
private IEnumerator OnCastLaser( string resPath, EditorShip target, Transform[] castPoints, Transform[] hitPoints ) { if( castPoints.Length != hitPoints.Length ) { Debugger.LogWarning( "attack point count not equal hit point count!" ); } GameObject prefab = Effects_[resPath] as GameObject; if( prefab == null ) { Debugger.LogError( "OnBulletMove(), prefab is null!" ); yield break; } float duration = 1f; for( int i = 0; i < castPoints.Length; i++ ) { GameObject bullet = ESUtility.AddChild( castPoints[i], prefab ); PreviewManager.ReplaceShader( bullet );//if not, shader would be lost in editor! //LeanTween.move( bullet, hitPoints[i].position, duration ).setOnComplete( ( obj ) => { Destroy( obj as GameObject ); } ).setOnCompleteParam( bullet ); } yield return new WaitForSeconds( duration ); }
private IEnumerator OnCast( EditorShip caster, EditorShip[] targets, Skill skill ) { Debugger.Log( "DoSpellSequences()..." ); Transform[] castPoints = FindOutAllAttackPoint( caster.Go.transform, skill.attackPoint ).ToArray(); Transform[] hitPoints = new Transform[castPoints.Length]; for( int i = 0; i < hitPoints.Length; i++ ) { hitPoints[i] = GetHitPointTrans( targets[0] );//random } //1.on sing stage yield return StartCoroutine( PlayEffect( skill.singEffect.effectPath, skill.singEffect.audioPath, skill.singEffect.duration, castPoints ) ); //2.on attack stage yield return StartCoroutine( PlayEffect( skill.attackEffect.effectPath, skill.attackEffect.audioPath, skill.attackEffect.duration, castPoints ) ); //3.on bullet move stage yield return StartCoroutine( OnCastLaser( skill.bulletPath, targets[0], castPoints, hitPoints ) ); //4.on hit stage yield return StartCoroutine( PlayEffect( skill.hitEffect.effectPath, skill.hitEffect.audioPath, skill.hitEffect.duration, hitPoints ) ); }
private Transform GetHitPointTrans( EditorShip hitShipInfo ) { //编辑器逻辑从简,随机取正前方的一个点 int index = Random.Range( 0, hitShipInfo.ship.hitPointFront.Length - 1 ); string pointName = hitShipInfo.ship.hitPointFront[index]; Debugger.Log( string.Format( "GetHitPointName(), random index is {0}, point name is {1}.", index, pointName ) ); Transform hitPointTrans = hitShipInfo.Go.transform.FindChild( pointName ); return hitPointTrans; }
private IEnumerator CastSpell( EditorShip caster, Part part, CharactersGroup group, int targetIndex ) { Debugger.Log( "CastSpell()..." ); yield return StartCoroutine( PreloadAllResources( part ) ); //just test the first ship of the other side EditorShip[] targetShips = new EditorShip[] { group.GetShip( targetIndex ) }; yield return StartCoroutine( OnCast( caster, targetShips, part ) ); }