// Use this for initialization
 void Start()
 {
     speed   = 100;
     rb      = GetComponent <Rigidbody>();
     sEffect = GetComponent <SpeedEffect>();
     sEffect.SetMinMaxSpeed(20, maxSpeed);
     returnOrigin  = false;
     pressedx      = false;
     pressedy      = false;
     recover       = false;
     takeDamage    = true;
     damageCounter = 30;
 }
Beispiel #2
0
 // Update is called once per frame
 void Update()
 {
     if (isActive && activeEffect == this)
     {
         if (effectTime != -1 && actTime + effectTime < Time.time)
         {
             actTime           = Time.time;
             isActive          = false;
             player.boostSpeed = 0;
             activeEffect      = null;
             if (oneActivation)
             {
                 GameObject.Destroy(gameObject);
             }
         }
         else if (fadeOverTime)
         {
             player.boostSpeed = boostSpeedValue * (1 - ((Time.time - startTime) / effectTime));
         }
     }
 }
Beispiel #3
0
 void OnTriggerEnter(Collider other)
 {
     if (other.tag == "Player")
     {
         if (dontPlaySound == false)
         {
             if (boostSpeedValue > 0)
             {
                 GetComponent <AudioSource> ().clip = speedSound;
                 GetComponent <AudioSource> ().Play();
             }
             else
             {
                 GetComponent <AudioSource> ().clip = slowSound;
                 GetComponent <AudioSource> ().Play();
             }
         }
         activeEffect      = this;
         player.boostSpeed = boostSpeedValue;
         isActive          = true;
         actTime           = Time.time;
         startTime         = Time.time;
     }
 }
Beispiel #4
0
    public static TimeEffect Creat(Unit targetUnit, EffectType EffectType,float power = 0)
    {
        Debug.Log("Effect setted " + EffectType);
        TimeEffect effect = null;
        switch (EffectType)
        {
            case EffectType.doubleDamage:
                effect = new DDEffect(targetUnit);
                break;
            case EffectType.slow:
//                targetUnit.Parameters.Parameters[ParamType.Speed] /= 3f;
                break;
            case EffectType.freez:

                break;
            case EffectType.speed:
                effect = new SpeedEffect(targetUnit);
                break;
            case EffectType.fire:
                effect = new FireEffect(targetUnit,power);
                break;
        }
        return effect;
    }
 private void PlayOpen(Hero hero)
 {
     isActive = false;
     ActivePart.gameObject.SetActive(isActive);
     switch (bonusElementMapType)
     {
         case BonusElementMapType.heal:
             hero.GetHeal((hero.Parameters.MaxHp - hero.CurHp)/2f);
             break;
         case BonusElementMapType.shield:
             hero.Shield = hero.Parameters.MaxHp/3f;
             break;
         case BonusElementMapType.speed:
             var speedEffect = new SpeedEffect(hero);
             break;
         case BonusElementMapType.killAll:
             var enemies = Map.Instance.GetEnimiesInRadius(30);
             foreach (var baseMonster in enemies)
             {
                 baseMonster.CurHp -= 90000;
             }
             break;
     }
 }
    void Start()
    {
        Application.targetFrameRate = 60;
        //S'il y a une erreur ici s'assurer que le prefab "Balancing" est bien dans la scène
        balanceData = GameObject.Find("Balancing").GetComponent <Balancing>();

        groundedControlForce = balanceData.groundedControlForce;
        hookMovementForce    = balanceData.hookMovementForce;
        airControlForce      = balanceData.airControlForce;
        dashTime             = balanceData.dashTime;
        dashForce            = balanceData.dashForce;
        dashCDTime           = balanceData.attackCDTime;
        dragEndOfDash        = balanceData.dragEndOfDash;
        inDashStatusTime     = balanceData.inDashStatusTime;

        rigid                   = this.GetComponent <Rigidbody2D>();
        speedEffectScript       = speedEffect.GetComponent <SpeedEffect>();
        dashReadyEffect         = transform.GetChild(2).gameObject;
        dashEffectColor         = dashReadyEffect.GetComponent <ParticleSystem>().main;
        dashEffectColorLifeTime = dashReadyEffect.GetComponent <ParticleSystem>().colorOverLifetime;
        lifeManager             = GetComponent <PlayerLifeManager>();

        dashRecovery = Resources.Load <GameObject>("Prefabs/Dash/DashRecovery");

        gravity = rigid.gravityScale;

        playerSprite = GetComponent <SpriteRenderer>().sprite;

        switch (playerNumber)
        {
        case "_P1":
            gameObject.layer = 8;
            break;

        case "_P2":
            gameObject.layer = 9;
            break;

        case "_P3":
            gameObject.layer = 10;
            break;

        case "_P4":
            gameObject.layer = 11;
            break;

        default:
            break;
        }

        lastFramePosition = transform.position;

        //Switch gérant la couleur du dash effect
        switch (playerSprite.name)
        {
        case "0":
            dashEffectColor.startColor = new Color(1, 1, 0);
            colorDashEffect[1].color   = new Color(.9215686f, 0.7294118f, 0.345098f);
            break;

        case "1":
            dashEffectColor.startColor = new Color(0.9960784f, 0.5686275f, 0.7568628f);
            colorDashEffect[1].color   = new Color(0.9960784f, 0.5686275f, 0.7568628f);
            break;

        case "2":
            dashEffectColor.startColor = new Color(0, 1, 1);
            colorDashEffect[1].color   = new Color(0.2313726f, 0.572549f, 0.9882353f);
            break;

        case "3":
            dashEffectColor.startColor = new Color(.3f, 1, 0);
            colorDashEffect[1].color   = new Color(0.4627451f, 0.7372549f, 0.2862745f);
            break;

        case "4":
            dashEffectColor.startColor = new Color(1, 0, 0);
            colorDashEffect[1].color   = new Color(0.9098039f, 0.1176471f, 0.3176471f);
            break;

        default:
            print("Default case switch start PlayerMovement.cs");
            break;
        }
        alphaDashEffect[0].alpha = 1;
        alphaDashEffect[0].time  = 0;
        alphaDashEffect[1].alpha = 1;
        alphaDashEffect[1].time  = 1;
        colorDashEffect[0].color = new Color(1, 1, 1);
        colorDashEffect[0].time  = 0;
        colorDashEffect[1].time  = 1;
        Gradient grad = new Gradient();

        grad.SetKeys(colorDashEffect, alphaDashEffect);
        dashEffectColorLifeTime.color = grad;
    }