// Use this only for ennemies or obstacles
    //this kind of kill check akuaku
    public void KillPlayer(DeadType deadType)
    {
        if (dead)
        {
            return;
        }
        if (akuAku.RemoveFeather())
        {
            return;
        }
        audioManager.Play("woah");
        if (deadType == DeadType.HEAVEN)
        {
            audioManager.Play("angel");
        }
        else if (deadType == DeadType.BURN)
        {
            audioManager.Play("burn");
        }

        //freeze player
        GetComponent <Rigidbody2D>().constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezePositionX;
        animator.Rebind();

        //first check if aku aku is enabled ?
        StartCoroutine(PlayDieAnimation(deadType));
        StartCoroutine(Respawn());
        GetComponent <CharacterController2D>().enabled = false;
        GetComponent <PlayerMovement>().enabled        = false;
        dead = true;
    }
        /// <summary>
        /// 检测死亡的类型
        /// </summary>
        /// <param name="dead"></param>
        /// <returns></returns>
        private bool CheckDeadIsAsignedType(DeadType deadType) {

            if (killTask.DeadType == deadType)
            {
                    return true;
            }
            return false;
        }
Example #3
0
    public override void DoBeforeLeaving()
    {
        StopCoroutine("ReloadLevel");
        anim.SetBool("isDead", false);
        rigidBody2D.velocity = Vector2.zero;
        typeOfDead           = DeadType.Normal;
        anim.SetBool("DeadAcid", false);
        anim.SetBool("DeadRay", false);
        SFX = null;

        rigidBody2D.gravityScale = store_gravity;
        inputController.SetNoInput();
    }
Example #4
0
        public void LoadFromDef(string id)
        {
            this.id = id;

            Hashtable def = Defs.GetBuff(this.id);

            this.name = def.GetString("name");

            this.campType        = ( CampType )def.GetInt("camp_type");
            this.targetFlag      = ( EntityFlag )def.GetInt("target_flag");
            this.rangeType       = ( RangeType )def.GetInt("range_type");
            this.spawnPoint      = ( SpawnPoint )def.GetInt("spawn_point");
            this.deadType        = ( DeadType )def.GetInt("dead_type");
            this.orbit           = ( Orbit )def.GetInt("orbit");
            this.autoScaleAreaFx = def.GetBoolean("auto_scale_area_fx");
            this.canInterrupt    = def.GetBoolean("can_interrupt");
            this.enterStates     = def.GetStringArray("enter_states");
            this.triggerStates   = def.GetStringArray("trigger_states");

            ArrayList lvls = def.GetList("level");

            if (lvls != null)
            {
                int count = lvls.Count;
                this.levels = new Level[count];
                for (int i = 0; i < count; i++)
                {
                    Level     lvl  = this.levels[i] = new Level();
                    Hashtable ldef = ( Hashtable )lvls[i];
                    lvl.radius   = ldef.GetFloat("radius");
                    lvl.areaFx   = ldef.GetString("area_fx");
                    lvl.extra    = ldef.GetFloatArray("extra");
                    lvl.extra_s  = ldef.GetStringArray("extra_s");
                    lvl.duration = ldef.GetFloat("duration");
                    lvl.speed    = ldef.GetFloat("speed");
                    int n = ldef.GetInt("max_trigger_targets");
                    lvl.maxTriggerTargets = n == 0 ? int.MaxValue : n;
                    n = ldef.GetInt("per_target_trigger_count");
                    lvl.perTargetTriggerCount = n == 0 ? int.MaxValue : n;
                    lvl.maxTriggerCount       = ldef.GetInt("max_trigger_count");
                    if (ldef.ContainsKey("trigger"))
                    {
                        lvl.trigger = new Trigger(ldef.GetMap("trigger"));
                    }
                    else if (this.triggerStates != null)
                    {
                        lvl.trigger = new Trigger();
                    }
                }
            }
        }
    public IEnumerator PlayDieAnimation(DeadType deadType)
    {
        yield return(new WaitForSeconds(0.5F));

        GetComponent <Animator>().enabled       = false;
        GetComponent <SpriteRenderer>().enabled = false;
        deadGameObject = Instantiate(deadPlayer,
                                     new Vector3(transform.position.x, transform.position.y, transform.position.z), Quaternion.identity);
        deadGameObject.GetComponent <Animator>().Play("crash_" + deadType.ToString().ToLower());
        if (deadType == DeadType.BURN)
        {
            //TODO play burn sound
            Rigidbody2D rigidbody2D = deadGameObject.AddComponent <Rigidbody2D>();
            rigidbody2D.constraints = RigidbodyConstraints2D.FreezeRotation | RigidbodyConstraints2D.FreezePositionX;
        }
        else if (deadType == DeadType.HEAVEN)
        {
            audioManager.Play("angel");
            deadGameObject.AddComponent <DeadPlayerHeaven>();
        }
    }