Exemple #1
0
    private void Start()
    {
        if (!photonView.IsMine)
        {
            return;
        }
        canvas             = GameObject.FindGameObjectWithTag("UI").gameObject;
        animatorController = GetComponent <AnimatorController>();
        movementClass      = GetComponent <MovementAbstract>();
        iplayer            = GetComponent <IPlayer>();
        ability            = GetComponent <AbilityAbstract>();
        trapClass          = GetComponent <TrapAbstract>();
        weaponManager      = GetComponent <WeaponManager>();

        shopCanvas = GameObject.Find("Shop Canvas");
        shopCanvas = shopCanvas.transform.GetChild(0).gameObject;

        saberPrefab = Resources.Load <GameObject>("Melee Weapon Saber");
        //saberPrefab = Resources.Load<GameObject>("Objective");
        macePrefab   = Resources.Load <GameObject>("Melee Weapon Mace");
        knifePrefab  = Resources.Load <GameObject>("Melee Weapon Knife");
        clubPrefab   = Resources.Load <GameObject>("Melee Weapon Club");
        pistolPrefab = Resources.Load <GameObject>("Gun Vintage Pistol");

        //Set the action button listener
        uiBtns = GameObject.FindGameObjectWithTag("UI").GetComponent <UIBtns>();
        AddDelegates();
    }
Exemple #2
0
 /// <summary> Call this when you drop this weapon </summary>
 public void OnDrop(CharacterMasterAbstract newHolder)
 {
     OnUnequip();
     holder = null;
     ctrl   = null;
     anim   = null;
     mvmt   = null;
 }
Exemple #3
0
    /// <summary> Call this when you pickup or switch to this weapon </summary>
    /// <param name="newHolder"> The CharacterMasterAbstract of the character that just picked up this weapon </param>
    public void OnEquip(CharacterMasterAbstract newHolder)
    {
        holder = newHolder;

        // All hittable things minus this layer
        whatIsHittable = CommonObjectsSingleton.Instance.whatIsHittableMaster & ~(1 << holder.gameObject.layer);

        ctrl          = holder.control;
        holder.weapon = this;
        anim          = holder.anim;
        mvmt          = holder.gameObject.GetComponent <MovementAbstract>();
    }
    private void Awake()
    {
        _movement = GetComponent <MovementAbstract>();
        _parts    = GetComponent <PartsAbstract>();
        _rb       = GetComponent <Rigidbody2D>();

        _nonLegBendParts   = (GameObject[])nonLegBendParts.Clone();
        _nonLegBendAmounts = (float[])nonLegBendAmounts.Clone();

        foreach (var part in bodyParts)
        {
            part.Initialize(this);
        }
    }
    protected virtual void Awake()
    {
        //References
        rb = GetComponent <Rigidbody2D>();
        characterPhysics = GetComponent <CharacterPhysics>();
        control          = GetComponent <CharacterControlAbstract>();
        movement         = GetComponent <MovementAbstract>();
        anim             = GetComponent <Animator>();
        characterStats   = Instantiate(characterStats); //create local instance that can be modified

        statusIndicator?.SubscribeToChangeEvents(characterStats);
        characterStats.Initialize();

        faction = characterFaction.GetHashCode();

        if (weapon != null)
        {
            weapon.OnEquip(this);
        }
    }
    public IEnumerator _Explode(int damage, float knockback, CharacterControlAbstract ctrl, MovementAbstract mvmt)
    {
        void AirControl() => _rb.AddForce(10 * _rb.mass * new Vector2(ctrl.moveHorizontal, ctrl.moveVertical));

        _hitOther.DamageMe(_hitOtherPoint, knockback * _rb.mass * _hitOtherDir, damage, _hitOtherCollider);
        exploded = true;
        float initGrav = _rb.gravityScale;

        _rb.gravityScale = 0;
        float initDrag = _rb.drag;

        _rb.drag             = 1;
        mvmt.disableMovement = true;
        float startTime   = Time.time;
        Color spriteColor = sprite.color;

        spriteColor.a = 0;
        sprite.color  = spriteColor;
        if (_repelTriggerExists)
        {
            repelTrigger.transform.localScale = Vector3.zero;
        }
        if (particleBurst != null)
        {
            particleBurst.Play();
            float particleLife = particleBurst.main.startLifetimeMultiplier;
            while (Time.time < startTime + particleLife / 2)
            {
                AirControl();
                yield return(null);
            }
            _recovering          = true;
            mvmt.disableMovement = false;
            var   velMod        = particleBurst.velocityOverLifetime;
            float initialRadial = velMod.radialMultiplier;
            var   limitVelMod   = particleBurst.limitVelocityOverLifetime;
            float initialDrag   = limitVelMod.dragMultiplier;
            limitVelMod.dragMultiplier = 0;
            while (Time.time < startTime + particleLife + .4f)
            {
                velMod.radialMultiplier = velMod.radialMultiplier.SharpInDamp(-10, 0.1f);
                float howCloseToEnd = Mathf.Min((Time.time - (startTime + particleLife / 2)) / (particleLife / 2), 1);
                energy           = howCloseToEnd;
                _rb.gravityScale = howCloseToEnd;

                _rb.AddForce(new Vector2(ctrl.moveHorizontal, ctrl.moveVertical));
                yield return(null);
            }
            velMod.radialMultiplier    = initialRadial;
            limitVelMod.dragMultiplier = initialDrag;
        }
        exploded         = false;
        _recovering      = false;
        _rb.gravityScale = initGrav;
        _rb.drag         = initDrag;
    }