예제 #1
0
 public static void StopAndClearAll()
 {
     if (loaded_sounds != null)
     {
         foreach (AudioSource source in loaded_sounds.Values)
         {
             if (source != null)
             {
                 source.Stop();
                 MonoBehaviour.DestroyImmediate(source);
             }
         }
         loaded_sounds.Clear();
     }
     if (loaded_musics != null)
     {
         foreach (AudioSource source in loaded_musics.Values)
         {
             if (source != null)
             {
                 source.Stop();
                 MonoBehaviour.DestroyImmediate(source);
             }
         }
         loaded_musics.Clear();
     }
     MonoBehaviour.DestroyObject(sound_obj);
     sound_obj       = null;
     camera_listener = null;
 }
예제 #2
0
    public void init(Transform masterTransform)
    {
        if (!masterTransform || !attachBone)
        {
            return;
        }
        if (effectPrefb == null)
        {
            Trace.Log("Sidekick effectPrefb is null!");
            return;
        }
        if (m_entityObject)
        {
            MonoBehaviour.DestroyObject(m_entityObject);
            m_entityObject = null;
        }
        m_entityObject = ResNode.InstantiateRes(effectPrefb) as GameObject;
        if (!m_entityObject)
        {
            return;
        }
        m_entityTransoform        = m_entityObject.transform;
        m_entityTransoform.parent = EntityFactory.Instance.transform;
        m_masterTransoform        = masterTransform;

        m_masterTransoform.SetPosition(attachBone.position + m_masterTransoform.rotation * bornOffset);
        m_entityTransoform.rotation = m_masterTransoform.rotation;

        m_Animator = m_entityObject.GetComponent <Animator>();
        playAnim(bornAnimation);
    }
예제 #3
0
 public void destroy()
 {
     MonoBehaviour.DestroyObject(m_entityObject);
     m_entityObject     = null;
     m_entityTransoform = null;
     m_Animator         = null;
     m_masterTransoform = null;
 }
예제 #4
0
 public static void exit()
 {
     if (WarpClient.GetInstance() != null)
     {
         Log("Multiplayer disconnect requested");
         WarpClient.GetInstance().Disconnect();
     }
     MonoBehaviour.DestroyObject(WarpClient.GetInstance());
 }
예제 #5
0
    public static void Read(FileStream file)
    {
        foreach (var nd in NoteData.Instances.ToArray())
        {
            MonoBehaviour.DestroyObject(nd.gameObject);
        }
        XmlDocument doc = new XmlDocument();

        doc.Load(file);
        XmlNode cmap = doc.SelectSingleNode("CMap");

        ChartInfoManager.Name = cmap.SelectSingleNode("m_path") == null?file.Name.Replace(".xml", "") : cmap.SelectSingleNode("m_path").InnerText;

        ChartInfoManager.BPM    = float.Parse(cmap.SelectSingleNode("m_barPerMin").InnerText) * 4;
        ChartInfoManager.Offset = (int)(-float.Parse(cmap.SelectSingleNode("m_timeOffset").InnerText) * 240000 / ChartInfoManager.BPM);

        XmlNode piano = cmap.SelectSingleNode("m_notes");

        piano = piano.SelectSingleNode("m_notes");
        int kind = 0;

        try {
            ReadNotes(0, piano.ChildNodes);
        }
        catch {
            kind++;
            piano = piano.ParentNode;
            ReadNotes(0, piano.ChildNodes);
        }

        XmlNode left = cmap.SelectSingleNode("m_notesLeft");

        if (kind == 0)
        {
            left = left.SelectSingleNode("m_notes");
        }
        ReadNotes(-1, left.ChildNodes);

        XmlNode right = cmap.SelectSingleNode("m_notesRight");

        if (kind == 0)
        {
            right = right.SelectSingleNode("m_notes");
        }
        ReadNotes(1, right.ChildNodes);
        try {
            ChartInfoManager.Difficulty = (ChartInfoManager.Difficulties)Enum.Parse(
                typeof(ChartInfoManager.Difficulties),
                cmap.SelectSingleNode("m_mapID").InnerText.Substring(cmap.SelectSingleNode("m_mapID").InnerText.Length - 1),
                true
                );
        }
        catch {
            Debug.LogWarning("Difficulty Unknown");
        }
    }
        private static void BuildToast(string toastText, Vector2 toastPosition, Vector2 toastDirection, float toastSpeed, GUIStyle toastStyle, float toastLifetime)
        {
            GameObject tempToastObject = new GameObject();

            tempToastObject.AddComponent <Toast>();

            SetToastProperties(tempToastObject, toastText, toastPosition, toastDirection, toastSpeed, toastStyle);

            tempToastObject.GetComponent <Toast>().BeginDisplayingToast();

            MonoBehaviour.DestroyObject(tempToastObject, toastLifetime);
        }
예제 #7
0
    public override void OnExit(GameObject affectedTarget)
    {
        affectedTargetCombatStats.MaxShield.Update();
        // Update current shield value. This will cause it to cap out at the maxShield value
        affectedTargetCombatStats.CurrentShield -= 0f;

        // Move to EntityParticlesManager
        foreach (ParticleSystem ps in energyShieldFXInstance.GetComponentsInChildren <ParticleSystem>())
        {
            ps.Stop(true, ParticleSystemStopBehavior.StopEmitting);
            MonoBehaviour.DestroyObject(energyShieldFXInstance, 3f);
        }
    }
예제 #8
0
        public static void DestroyChildren(this Transform parent)
        {
            if (parent.IsNull())
            {
                return;
            }                                // TODO: raise exception or log error
            int childCount = parent.childCount;

            for (int i = childCount - 1; i > -1; i--)
            {
                MonoBehaviour.DestroyObject(parent.GetChild(i).gameObject);
            }
        }
예제 #9
0
    public override void Cast(Transform casterTransform, Quaternion targetDir)
    {
        // Place a heal over time buff on caster. Place a 15% speed penalty and a 50% mana regen bonus. All buffs lasts 10 seconds.

        GameObject particleInstance = MonoBehaviour.Instantiate(rejuvParticles, casterTransform.position, targetDir);

        particleInstance.transform.parent = casterTransform;
        MonoBehaviour.DestroyObject(particleInstance.gameObject, 4f);

        casterTransform.gameObject.GetComponent <EffectManager>().ApplyEffect(new MoveModifier(10f, 0.85f));
        casterTransform.gameObject.GetComponent <EffectManager>().ApplyEffect(new ManaRegenModifier(10f, 1.5f));
        casterTransform.gameObject.GetComponent <EffectManager>().ApplyEffect(new Regenerate(10f, new Damage(new Damage.DamageInfo(casterTransform.gameObject, DamageType.Nature, null, false), null, 3f)));
    }
예제 #10
0
    public override void Cast(Transform casterTransform, Quaternion targetDir)
    {
        // Teleport caster a distance in targeted direction. Provide a 50% movement speed buff for 2 seconds.

        GameObject firstBlinkParticle = MonoBehaviour.Instantiate(blinkParticles, casterTransform.position, targetDir);

        MonoBehaviour.DestroyObject(firstBlinkParticle.gameObject, 1f);

        casterTransform.rotation = targetDir;
        casterTransform.Translate(Vector3.forward * distance);

        GameObject secondBlinkParticle = MonoBehaviour.Instantiate(blinkParticles, casterTransform.position, targetDir);

        MonoBehaviour.DestroyObject(secondBlinkParticle.gameObject, 1f);

        casterTransform.gameObject.GetComponent <EffectManager>().ApplyEffect(new MoveModifier(2f, 1.5f));
    }
예제 #11
0
    public override void Cast(Transform casterTransform, Quaternion targetDir)
    {
        Vector3    casterPosModified = casterTransform.position + Vector3.up * 1.5f;
        GameObject lunarBeam         = MonoBehaviour.Instantiate(beam, casterPosModified + casterTransform.forward * 1.5f, targetDir);
        Ray        ray = new Ray(casterPosModified, targetDir * Vector3.forward);

        RaycastHit[] hits = Physics.SphereCastAll(ray, 1f, distance, CombatStats.ATTACKABLE_LAYER);
        //Debug.DrawRay(casterPosModified, targetDir * Vector3.forward * distance, Color.blue, 10f);
        foreach (RaycastHit hit in hits)
        {
            if (hit.transform.gameObject != casterTransform.gameObject)
            {
                Damage  dmg          = new Damage(new Damage.DamageInfo(casterTransform.gameObject, DamageType.Arcane, null, true), null, damage);
                Vector3 hitPointYFix = hit.transform.position;
                hitPointYFix.y = lunarBeam.transform.position.y;
                Ray        terrainRay = new Ray(casterPosModified, hitPointYFix - casterPosModified);
                RaycastHit terrainHit;
                //Debug.DrawRay(casterPosModified, (hitPointYFix - casterPosModified) * distance, Color.green, 10f);
                if (Physics.Raycast(terrainRay, out terrainHit, distance, CombatStats.SCENE_OBJECTS_LAYER))
                {
                    float targetDistance  = Vector3.Distance(hit.point, casterPosModified);
                    float terrainDistance = Vector3.Distance(terrainHit.point, casterPosModified);

                    if (targetDistance < terrainDistance)
                    {
                        //Debug.Log("Target closer: TargetDistance: " + targetDistance + " vs TerrainDistance: " + terrainDistance);
                        hit.transform.gameObject.GetComponent <CombatStats>().ApplyDamage(dmg);
                    }
                    else
                    {
                        //Debug.Log("Terrain closer: TerrainDistance: " + terrainDistance + " vs TargetDistance: " + targetDistance);
                    }
                }
                else
                {
                    //Debug.Log("No Terrain");
                    hit.transform.gameObject.GetComponent <CombatStats>().ApplyDamage(dmg);
                }
            }
        }


        MonoBehaviour.DestroyObject(lunarBeam, 4f);
    }
예제 #12
0
    /// <summary>
    /// Method to destroy pool
    /// </summary>
    public void DestroyAll()
    {
        // Return stack
        prefab = null;

        // Clear stack
        inactive.Clear();

        // Destroy child
        for (int i = 0; i < prefabContrainer.transform.childCount; i++)
        {
            MonoBehaviour.DestroyObject(prefabContrainer.transform.GetChild(i).gameObject);
        }

        // Destroy parent
        Object.Destroy(prefabContrainer);

        Resources.UnloadUnusedAssets();
    }
예제 #13
0
 private void Update()
 {
     if (!isSetInfo)
     {
         return;
     }
     if (agent != null)
     {
         getPos(duration);
         duration += Time.deltaTime;
         if (duration > 1f)
         {
             getPos(duration);
             //PoolMgr.Instance.saveObj(this.CacheObj, this.info.config.tempId + this.info.config.path);
             MonoBehaviour.DestroyObject(this.gameObject);
             duration = 0;
         }
     }
 }
예제 #14
0
    public virtual void CreateHitParticle()
    {
        bool isCreate = false;

        // Create the hit particles
        foreach (SkillEffectData.SkillHitParticleData hitParticleData in _mSkillDataSlot._skillEffectData._skillHitParticleList)
        {
            // Play fire sound
            if (null != hitParticleData._skillSound)
            {
                Globals.Instance.MSoundManager.PlaySoundEffect(hitParticleData._skillSound._soundName);
            }

            // Calculate hit particle type according to DamageRange
            List <SkillDamageRange.Rect> rectList = null;

            // Check is need to inverse skill damage range
            bool isSingleSkill = _mSkillDataSlot._skillDamageRange._damageRectList.Count == 1;
            if (isSingleSkill || _mSkillUser.Property.WarshipIsAttacker)
            {
                rectList = _mSkillDataSlot._skillDamageRange._damageRectList;
            }
            else
            {
                // Inverse legend, x Axis
                rectList = new List <SkillDamageRange.Rect>();
                foreach (SkillDamageRange.Rect rect in _mSkillDataSlot._skillDamageRange._damageRectList)
                {
                    SkillDamageRange.Rect invRect = new SkillDamageRange.Rect();
                    invRect.left   = -rect.left;
                    invRect.right  = -rect.right;
                    invRect.bottom = rect.bottom;
                    invRect.top    = rect.top;

                    rectList.Add(invRect);
                }
            }

            // Calulate the Nivose damage range
            CalculateNivoseHitRange(rectList);

            // Optimize the warter effect count
            int waterBloomIndex = 0;
            int waterBloomLimit = 20;
            foreach (SkillDamageRange.Rect rect in rectList)
            {
                EHitParticleType hitType;
                Vector3          hitPos;

                CalculateHitParticleType(rect, out hitType, out hitPos);

                if (hitType == EHitParticleType.HIT_PARTICLE_WATER_SURFACE &&
                    waterBloomIndex >= waterBloomLimit)
                {
                    continue;
                }

                UnityEngine.Object obj = null;
                switch (hitType)
                {
                case EHitParticleType.HIT_PARTICLE_PRIMARY:
                {
                    obj = Resources.Load(hitParticleData._primaryParticleName);
                    break;
                }

                case EHitParticleType.HIT_PARTICLE_ASSISTANT:
                {
                    obj = Resources.Load(hitParticleData._assistantParticleName);
                    break;
                }

                case EHitParticleType.HIT_PARTICLE_WATER_SURFACE:
                {
                    waterBloomIndex++;
                    obj = Resources.Load(hitParticleData._waterSurfaceParticleName);
                    break;
                }
                }

                if (null == obj)
                {
                    isCreate = true;
                    Debug.Log("[Skill]: Cann't find the hit effect name " + hitParticleData._primaryParticleName);
                    break;
                }

                // Optimize the warter effect count
                if (hitType == EHitParticleType.HIT_PARTICLE_WATER_SURFACE)
                {
                    if (waterBloomIndex % 2 == 0)
                    {
                        GameObject go = GameObject.Instantiate(obj, hitPos, Quaternion.identity) as GameObject;
                        MonoBehaviour.DestroyObject(go, 3.0f);
                    }
                }
                else
                {
                    GameObject go = GameObject.Instantiate(obj, hitPos, Quaternion.identity) as GameObject;
                    MonoBehaviour.DestroyObject(go, 3.0f);
                }


                isCreate = true;
            }
        }

        _isHitParticleCreated = isCreate;
    }