Exemplo n.º 1
0
    protected override void OnConstruct()
    {
        waypoint       = new Vector2(-1, -1);
        queuedWaypoint = new Vector2(-1, -1);
        stateMachine   = new EntityStateMachine <HeroState, Hero>(this);
        stateMachine.RegisterInitialState(HeroState.Standing, new StandingState());
        stateMachine.RegisterState(HeroState.Running, new RunningState());

        boxCollider = this.GetComponentStrict <BoxCollider2D>();
        OrbBehavior = this.GetComponentStrict <OrbBehavior>();
        buffs       = new Buffable <HeroBuffs, Hero, IHero>(this);

        collisionFilter = new ContactFilter2D();
        var layerMask = new LayerMask();

        layerMask.value |= 1 << 8;
        collisionFilter.SetLayerMask(layerMask);

        this.stats.Initialize();

        regenTimer        = new Timer(1);
        isSpellOnCooldown = true;

        this.paddle = AddChild(Game.Resources.LoadPrefab <Paddle>("Heroes/Paddle"), resetPosition: true);
        audioSource = this.GetComponentStrict <AudioSource>();

        this.spell         = AddChild(Game.Objects.CreatePrefab(this.spell));
        spellCooldownTimer = new Timer(this.spell.cooldown);
    }
Exemplo n.º 2
0
    void Awake()
    {
        collider    = this.GetComponentStrict <BoxCollider2D>();
        buffs       = new Buffable <MinionBuffs, Minion, IMinion>(this);
        this.sprite = this.GetComponentStrict <SpriteWrapper>();

        collisionFilter = new ContactFilter2D();
        var layerMask = new LayerMask();

        layerMask.value |= 1 << 8;
        collisionFilter.SetLayerMask(layerMask);
        collisionFilter.useTriggers = true;

        attackChargeTimer   = new Timer(stats.attackChargeTimeBase);
        attackCooldownTimer = new Timer(stats.AttackCooldown);
        deathTimer          = new Timer(1);

        this.healthBar = Game.Resources.LoadPrefab <MinionHealthBar>("MinionHealthBar");
        this.healthBar.gameObject.name = "MinionHealthBar";
        this.healthBar.gameObject.transform.SetParent(gameObject.transform);

        this.waypoint = Game.Resources.LoadPrefab <MinionWaypoint>("Minions/Waypoint");
        this.waypoint.Initialize(this);

        AddChild(Game.Resources.LoadPrefab <SpriteWrapper>("Sprites/ShadowSmall"));
    }
Exemplo n.º 3
0
    // Use this for initialization
    void Start()
    {
        buffList = new List<Component>(GetComponents(typeof(Buff)));
        buffable = (Buffable)GetComponent(typeof(Buffable));
        originalSpeed = buffable.Speed;
        originalSize = 1;

        spriteRenderer = (SpriteRenderer)GetComponent(typeof(SpriteRenderer));
        originalSprite = spriteRenderer.sprite;
    }
Exemplo n.º 4
0
    public void buff(Buffable e, float factor, float time) {
        float end = time + Time.time;
        buffable(e, (float baseVal, ref float cacheVal, ref List<Buff> buffs) => {
            if(buffs == null) buffs = new List<Buff>();

            Buff b = new Buff();
            b.Factor = factor;
            b.TimeEnd = end;
            buffs.Add(b);
            BuffsDirty = true;
        });

    }
Exemplo n.º 5
0
        public override int GetHashCode()
        {
            var hashCode = -2145328967;

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(PowerFullName);

            hashCode = hashCode * -1521134295 + UniqueId.GetHashCode();
            hashCode = hashCode * -1521134295 + EffectClass.GetHashCode();
            hashCode = hashCode * -1521134295 + EffectType.GetHashCode();
            hashCode = hashCode * -1521134295 + DamageType.GetHashCode();
            hashCode = hashCode * -1521134295 + MezmorizeType.GetHashCode();
            hashCode = hashCode * -1521134295 + EffectModifiers.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Summon);

            hashCode = hashCode * -1521134295 + DelayedTime.GetHashCode();
            hashCode = hashCode * -1521134295 + Ticks.GetHashCode();
            hashCode = hashCode * -1521134295 + Stacking.GetHashCode();
            hashCode = hashCode * -1521134295 + BaseProbability.GetHashCode();
            hashCode = hashCode * -1521134295 + Suppression.GetHashCode();
            hashCode = hashCode * -1521134295 + Buffable.GetHashCode();
            hashCode = hashCode * -1521134295 + Resistible.GetHashCode();
            hashCode = hashCode * -1521134295 + SpecialCase.GetHashCode();
            hashCode = hashCode * -1521134295 + VariableModifiedOverride.GetHashCode();
            hashCode = hashCode * -1521134295 + PlayerVersusMode.GetHashCode();
            hashCode = hashCode * -1521134295 + ToWho.GetHashCode();
            hashCode = hashCode * -1521134295 + DisplayPercentageOverride.GetHashCode();
            hashCode = hashCode * -1521134295 + Scale.GetHashCode();
            hashCode = hashCode * -1521134295 + Magnitude.GetHashCode();
            hashCode = hashCode * -1521134295 + Duration.GetHashCode();
            hashCode = hashCode * -1521134295 + AttribType.GetHashCode();
            hashCode = hashCode * -1521134295 + Aspect.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(ModifierTable);

            hashCode = hashCode * -1521134295 + NearGround.GetHashCode();
            hashCode = hashCode * -1521134295 + CancelOnMiss.GetHashCode();
            hashCode = hashCode * -1521134295 + RequiresToHitCheck.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(UidClassName);

            hashCode = hashCode * -1521134295 + IdClassName.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(MagnitudeExpression);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Reward);

            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(EffectId);

            hashCode = hashCode * -1521134295 + IgnoreEnhancementDiversification.GetHashCode();
            hashCode = hashCode * -1521134295 + EqualityComparer <string> .Default.GetHashCode(Override);

            hashCode = hashCode * -1521134295 + ProcsPerMinute.GetHashCode();
            return(hashCode);
        }
Exemplo n.º 6
0
 void OnTriggerEnter2D(Collider2D other)
 {
     if (other.tag == "Player")
     {
         try {
             Buffable zadel = PlayerMain.playerOne;
             applyBuff(zadel);
         }
         catch (NullReferenceException kaj)
         {
             throw new NullReferenceException(kaj + " ,verjetno ni skripta na objektu");
         }
         Destroy(gameObject);
     }
 }
Exemplo n.º 7
0
    public override bool applyEffect(Buffable target)
    {
        //Attempt to get a reference to the ProjectileHandler of the object we're giving the energy to
        ProjectileHandler handler = target.GetComponent <ProjectileHandler>();

        //If handler exists, add energyBonus to its energy pool
        if (handler)
        {
            handler.energy += energyBonus;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 8
0
    public override bool applyEffect(Buffable target)
    {
        //The target of this effect is a BombController
        buffTarget = target.GetComponent <BombController>();

        //Set the BombController's (not RigidBody2D) gravity to 0
        //Return false if the given object doesn't have a BombController
        if (buffTarget)
        {
            storedGravity      = buffTarget.gravity;
            buffTarget.gravity = 0;
            applied            = true;
            return(true);
        }
        else
        {
            return(false);
        }
    }
Exemplo n.º 9
0
    // Use this for initialization
    void Start()
    {
        target = transform.position;
        start = transform.position;

        GameObject background = GameObject.Find("Background");
        if (!background)
            Debug.LogError("Background could not be found.");

        upperBounds = background.renderer.bounds.max;
        lowerBounds = background.renderer.bounds.min;

        originalSpeed = MoveSpeed;
        originalSize = transform.localScale.x;
        spriteRenderer = this.GetComponent<SpriteRenderer>();
        originalSprite = spriteRenderer.sprite;

        soundEffect = soundManager.GetComponent<Sounds> ();

        buffable = (Buffable)GetComponent(typeof(Buffable));
        doubleSpeedBuff = this.gameObject.GetComponent<DoubleSpeedBuff>();
        halfSpeedBuff = this.gameObject.GetComponent<HalfSpeedBuff>();
    }
Exemplo n.º 10
0
    public void explode()
    {
        //When exploding, check for colliders within the blast radius
        Collider2D[] results = Physics2D.OverlapCircleAll(circle.transform.position, explosionRadius);

        if (results.Length > 0)
        {
            //Declare a bunch of things to hold references to things to be affected by the explosion
            Rigidbody2D hitRb;
            HealthBar   hitHb;
            Buffable    hitBuff = null;

            float pushForce;
            float damage;

            foreach (Collider2D hitCol in results)
            {
                //set hitRb to the rigidbody of the current collider, if it exists
                hitRb = hitCol.GetComponent <Rigidbody2D>();

                //set hitHB to the HealthBar of the current collider, if it exists
                hitHb = hitCol.GetComponent <HealthBar>();

                //set hitBuff to the Buffable object of the current collider, if there are any to apply
                ///TODO: This will likely need to be reworked later on, as many GameObjects will likely have more than one Buffable component
                if (explosionEffects.Count > 0)
                {
                    hitBuff = hitCol.GetComponent <Buffable>();
                }

                //The ranges of force/damage that can be applied to explosion targets, max at the edge of the collider, min at the edge of the explosion
                float forceRange = maxPushForce - minPushForce;
                float dmgRange   = maxExplosionDMG - minExplosionDMG;

                if (hitCol != circle.col)
                {
                    ColliderDistance2D cd = circle.col.Distance(hitCol);

                    //Clamp the collider distance to positive numbers to avoid issues related to negative collider distance
                    float dst = Mathf.Clamp(cd.distance, 0, Mathf.Infinity);

                    //Tbh, don't remember what exact purpose this had for explosion force/damage calculations
                    float adjustedRadius = explosionRadius - circle.adjustedRadius();

                    //Add forces to colliders with rigidbodies
                    if (hitRb)
                    {
                        pushForce = (adjustedRadius - dst) / adjustedRadius * (forceRange) + minPushForce;
                        hitRb.AddForce(cd.normal * pushForce * (cd.distance < 0 ? 1 : -1), ForceMode2D.Impulse);
                    }

                    //deal damage to colliders attached to HealthBars
                    if (hitHb)
                    {
                        damage = (adjustedRadius - dst) / adjustedRadius * (dmgRange) + minExplosionDMG;
                        hitHb.takeDamage(damage);
                    }

                    //Add status effects (if any) to retrieved Buffables
                    if (hitBuff)
                    {
                        foreach (StatusEffect effect in explosionEffects)
                        {
                            hitBuff.addStatusEffect(effect);
                        }
                    }
                }
            }
        }
        Debug.Log("Message sent");
        SendMessage("OnExplosion");
    }
Exemplo n.º 11
0
 // Use this for initialization
 void Start()
 {
     obj = (Buffable)gameObject.GetComponent(typeof(Buffable));
     spriteRenderer = (SpriteRenderer)gameObject.GetComponent(typeof(SpriteRenderer));
 }
Exemplo n.º 12
0
 //Should return true if the buff could be applied to the recieving object
 public abstract bool applyEffect(Buffable target);
Exemplo n.º 13
0
 public abstract void applyBuff(Buffable zadel);
Exemplo n.º 14
0
 public override void applyBuff(Buffable zadel)
 {
     zadel.applyFireRateBuff(duration);
 }
 public void AddBuffable(Buffable buff)
 {
     buffables.Add(buff);
 }
Exemplo n.º 16
0
 public abstract void removeEffect(Buffable target);
Exemplo n.º 17
0
 public virtual void tick(Buffable target)
 {
     duration -= Time.deltaTime;
     //Debug.Log(this.GetType());
 }
Exemplo n.º 18
0
 public override void applyBuff(Buffable zadel)
 {
     zadel.applyMovementSpeedBuff(duration);
 }
Exemplo n.º 19
0
    //Revert the gravity to what it was
    public override void removeEffect(Buffable target)
    {
        BombController controller = (BombController)target;

        controller.gravity = storedGravity;
    }
 public void RemoveBuffable(Buffable buff)
 {
     buffables.Remove(buff);
 }
Exemplo n.º 21
0
 void buffable(Buffable e, Buff_Dlg act) {
     switch(e) {
         case Buffable.MaxSpeed: act(_MaxSpeed, ref MaxSpeed_Cached, ref MaxSpeed_Buffs); break;
         case Buffable.Acceleration: act(_Acceleration, ref Acceleration_Cached, ref Acceleration_Buffs); break;
     }
 }