/// <summary> /// Make single log message on the screen. /// </summary> /// <param name="message"></param> public void SendLogMessage(string message) { // get one log text from the pool JCS_LogText logText = mLogTextPool.ExecuteOneFromPool(); // all pool active? if (logText == null) { return; } UpdateSpace(); mRenderLogText.push(logText); Vector3 newPos = logText.SimpleTrackAction.TargetPosition; // set back to position. // NOTE(jenchieh): 不太懂這邊的原理... newPos.y = 0.0f; logText.SimpleTrackAction.TargetPosition = newPos; logText.SimpleTrackAction.LocalPosition = newPos; // this will set the log text active, // so it wont be reuse until is fade out. logText.Execute(message); }
/// <summary> /// Spawn all particle base on the count. /// </summary> public void SpawnParticles() { // check if particles already spawned? if (mParticleSpawned) { return; } if (mParticle == null) { JCS_Debug.Log( "No particle assign!"); return; } for (int index = 0; index < mNumOfParticle; ++index) { JCS_Particle trans = (JCS_Particle)JCS_Util.SpawnGameObject(mParticle); mParticles.push(trans); // disable the object trans.gameObject.SetActive(false); if (mSetChild) { // set parent trans.transform.SetParent(this.transform); } } mParticleSpawned = true; }
/// <summary> /// Shoot bullets in sequence queue. /// </summary> /// <param name="hit"></param> /// <param name="pos"></param> public void ShootsInSequence(int hit, Vector3 pos) { if (mShootAction.Bullet == null) { JCS_Debug.LogReminders( "There is no bullet assign to \"JCS_ShootAction\", so we cannot shoot a sequence..."); return; } if (hit <= 0) { JCS_Debug.LogReminders( "Cannot shoot sequence of bullet with lower than 0 hit..."); return; } // thread itself mThread.push(mThread.length); // needed data mTimers.push(0); // timer to calculate between each shoot. mShootCount.push(hit); // hit per sequence. mShootCounter.push(0); // counter to count how many shoot left? mShootPos.push(pos); // position to spawn the bullet implements the position stay effect! mShootAngles.push(mShootAction.SpawnPoint.eulerAngles); }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions /// <summary> /// If detect a target add it to list. /// </summary> /// <param name="jcsDo"></param> public void AddDetectedObject(JCS_DetectAreaObject jcsDo) { if (jcsDo == null) { return; } mDetectedObjects.push(jcsDo); }
/// <summary> /// Spawn a thread in order to get process. /// </summary> /// <param name="density"> density for the particle effect. </param> private void DoSequenceParticle(int density) { // thread itself mThread.push(mThread.length); // needed data mTimers.push(0); mParticleCount.push(density); mParticleCounter.push(0); }
/// <summary> /// Assgin the audio source to audio source list. /// </summary> /// <param name="list"> List of audio source. </param> /// <param name="sound"> audio source to add into list. </param> private void AssignSoundToList(JCS_Vector <AudioSource> list, AudioSource sound) { if (sound == null) { JCS_Debug.LogError("Assigning Source that is null..."); return; } list.push(sound); sound.volume = JCS_SoundSettings.instance.GetSFXSound_Volume(); }
//======================================== // Unity's function //------------------------------ private void Awake() { this.mAIActions = new JCS_Vector <JCS_AIAction>(); // add all the ai action into the array. JCS_AIAction[] actions = this.GetComponents <JCS_AIAction>(); for (int index = 0; index < actions.Length; ++index) { mAIActions.push(actions[index]); } }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions /// <summary> /// Switch AI move action state. /// </summary> /// <param name="type"> type of the ai move action. </param> public void SwitchAIMoveState(JCS_AIMoveActionType type) { switch (type) { case JCS_AIMoveActionType.NONE: { DisableActions(); } break; case JCS_AIMoveActionType.WALK: { // try to get the component on this transform. JCS_2DWalkAction wa = this.GetComponent <JCS_2DWalkAction>(); if (wa == null) // if nothing here. { // add it on to it wa = this.gameObject.AddComponent <JCS_2DWalkAction>(); // and push into array. mAIActions.push(wa); } // disable all the action DisableActions(); // enable this one. wa.enabled = true; } break; case JCS_AIMoveActionType.JUMP: { JCS_2DJumpAction ja = this.GetComponent <JCS_2DJumpAction>(); if (ja == null) { ja = this.gameObject.AddComponent <JCS_2DJumpAction>(); mAIActions.push(ja); } DisableActions(); ja.enabled = true; } break; case JCS_AIMoveActionType.FLY: { JCS_2DFlyAction fa = this.GetComponent <JCS_2DFlyAction>(); if (fa == null) { fa = this.gameObject.AddComponent <JCS_2DFlyAction>(); mAIActions.push(fa); } DisableActions(); fa.enabled = true; } break; case JCS_AIMoveActionType.SWIM: { JCS_2DSwimAction sa = this.GetComponent <JCS_2DSwimAction>(); if (sa == null) { sa = this.gameObject.AddComponent <JCS_2DSwimAction>(); mAIActions.push(sa); } DisableActions(); sa.enabled = true; } break; } this.mAIMoveActionType = type; }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions /// <summary> /// Shoot bullets multiple times in times. (not in per frame) /// </summary> public void Shoots(int hit, Vector3 pos) { if (mShootAction.Bullet == null) { JCS_Debug.LogReminders( "There is no bullet assign to \"JCS_ShootAction\", so we cannot shoot a sequence..."); return; } if (hit <= 0) { JCS_Debug.LogReminders( "Cannot shoot sequence of bullet with lower than 0 hit..."); return; } // after finding once is still null, // try it agian! if (mDetectedObject == null) { // find the target switch (mShootAction.GetTrackType()) { case JCS_ShootAction.TrackType.CLOSEST: mDetectedObject = mShootAction.GetDetectAreaAction().FindTheClosest(); break; case JCS_ShootAction.TrackType.FURTHEST: mDetectedObject = mShootAction.GetDetectAreaAction().FindTheFurthest(); break; } } // does not found the target to damage if (mDetectedObject == null) { mTargetsPerSequence.push(null); } else { // found target to damage, add in to data segment mTargetsPerSequence.push(mDetectedObject.transform); JCS_2DLiveObject liveObj = mDetectedObject.GetComponent <JCS_2DLiveObject>(); if (liveObj != null) { int defenseVal = 0; // get the targeting defense value if (liveObj.AbilityFormat != null) { defenseVal = liveObj.AbilityFormat.GetDefenseValue(); } // calculate the damage we are going to apply to // the target object. mDamageApplying = PreCalculateSequenceDamage( mAbilityFormat.GetMinDamage(), mAbilityFormat.GetMaxDamage(), hit, defenseVal); // pre calculate the damage before the // actual bullet hit the object, // so it could decide what object are dead already. // and other object or this object wont target the // object is going die. liveObj.ReceivePreCalDamage(mDamageApplying); // start targeting object to hit liveObj.BeenTarget = true; } } // thread itself mThread.push(mThread.length); // needed data mTimers.push(0); // timer to calculate between each shoot. mShootCount.push(hit); // hit per sequence. mShootCounter.push(0); // counter to count how many shoot left? mShootPos.push(pos); // position to spawn the bullet implements the position stay effect! bool isLeft = true; if (this.transform.localScale.x < 0) { isLeft = false; } // shoot direction mShootDirection.push(isLeft); // decide which direction should the bullet goes? (right/left) }
//======================================== // Self-Define //------------------------------ //---------------------- // Public Functions public void AddTargetToTrackList(JCS_Player p) { mTargetList.push(p); }