Exemplo n.º 1
0
 // Update is called once per frame
 void LoadDefaultArmor(BodyPartController myBody)
 {
     for (int i = 0; i < defaultArmor.Length; i++)
     {
         myBody.EquipArmor(defaultArmor[i]);
     }
 }
Exemplo n.º 2
0
 void LoadDefaultWeapon(BodyPartController myBody)
 {
     for (int i = 0; i < defaultWeapon.Length; i++)
     {
         myBody.EquipWeapon(defaultWeapon[i]);
     }
 }
Exemplo n.º 3
0
 protected override void GatherComponents()
 {
     base.GatherComponents();
     equipmentManager = GetComponent <EquipmentManager>();
     inventory        = InventoryManager.GetInstance().GetInventory();
     wallet           = ScriptToolbox.GetInstance().GetPlayerWallet();
     myBody           = GetComponent <BodyPartController>();
     combatSkills     = GetComponent <CombatSkills>();
 }
Exemplo n.º 4
0
    protected override void LoadComponents()
    {
        base.LoadComponents();
        unitTraits        = GetComponent <UnitTraits>();
        unitRelationships = GetComponent <UnitRelationships>();
        unitController    = GetComponent <UnitController>();
        unitAnim          = GetComponent <UnitAnimController>();
        attackTimer       = GetComponent <AttackTimer>();
        bodyController    = GetComponent <BodyPartController>();
        combatSkills      = GetComponent <CombatSkills>();

        attack1Parts = bodyController.attack1Parts; //main
        attack2Parts = bodyController.attack2Parts; //off
    }
Exemplo n.º 5
0
    private void OnTriggerEnter2D(Collider2D collision)
    {
        if (collision.CompareTag("Body Part"))
        {
            BodyPartController       thisBodyPart = collision.GetComponent <BodyPartController>();
            CenterBodypartController centerBody   = thisBodyPart.GetCenterBodyPart();
            centerBody.OnCharacterDie(centerBody.transform.parent);
            thisBodyPart.ApplyForceToThisBodyPart(_parentRigidbody2D.velocity, _forceApplyToBodyPart);
        }

        if (collision.CompareTag("Bomb"))
        {
            collision.GetComponent <TNTController>().TriggerBomb();
        }
    }
Exemplo n.º 6
0
    private void SendToBodyPart(Item item)
    {
        if (myBody == null)
        {
            myBody = GetComponent <BodyPartController>();
        }

        if (item.myEquipSlot == Item.EquipmentSlot.MainHand || item.myEquipSlot == Item.EquipmentSlot.OffHand)
        {
            myBody.EquipWeapon(item);
        }
        else
        {
            myBody.EquipArmor(item);
        }
    }
Exemplo n.º 7
0
    private void Attack()
    {
        AttackInfo         myAttack;
        AttackTimer        attackTimer = usm.attackTimer;
        BodyPartController myBody      = usm.bodyController;
        CombatSkills       mySkills    = usm.combatSkills;

        if (Random.Range(0, 100) <= 75)
        {
            if (!myBody.PartTooInjured(attack1Parts))
            {
                AttackAnimation();
                myAttack = mySkills.RequestAttackInfo(attack1Parts[0].MyWeapon());
            }
            else
            {
                string line = "<color=red>" + gameObject.name + " is too injured to attack with their " + attack1Parts[0].MyWeapon().name + "</color>";
                FloatingTextController.CreateFloatingText("Too injured!", transform, Color.red);
                BattleReport.AddToBattleReport(line);
                attackTimer.ResetAttackTimer(7f); //arbitrarily reset attack timer to prevent attack
                                                  //unit reactions -> run away if not player?
                return;
            }
        }
        else
        {
            if (!myBody.PartTooInjured(attack2Parts))
            {
                AttackAnimation();
                myAttack = mySkills.RequestAttackInfo(attack2Parts[0].MyWeapon());
            }
            else
            {
                string line = "<color=red>" + gameObject.name + " is too injured to attack with their " + attack2Parts[0].MyWeapon().name + "</color>";
                FloatingTextController.CreateFloatingText("Too injured!", transform, Color.red);
                BattleReport.AddToBattleReport(line);
                attackTimer.ResetAttackTimer(7f); //arbitrarily reset attack timer to prevent attack
                                                  //unit reactions -> run away if not player?
                return;
            }
        }
        Debug.Log(gameObject.name + " attacking with reset timer of " + myAttack.speed);
        targetBody.RecieveAttack(myAttack, transform); //should reset back to whatever weapon was used
        attackTimer.ResetAttackTimer(myAttack.speed);
    }
Exemplo n.º 8
0
        private void HandleRigidbodyCollision(CollisionData rigidbodyCollision)
        {
            AIActor component = rigidbodyCollision.OtherRigidbody.GetComponent <AIActor>();
            bool    flag      = false;

            if (component && component.IsNormalEnemy && component.healthHaver && component.healthHaver.IsVulnerable)
            {
                if (component.FlagToSetOnDeath == GungeonFlags.BOSSKILLED_DEMONWALL)
                {
                    flag = true;
                    component.healthHaver.ApplyDamage(35f, rigidbodyCollision.Normal * -1f, "nom nom", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                }
                else if (component.healthHaver.IsBoss)
                {
                    flag = true;
                    component.healthHaver.ApplyDamage(35f, rigidbodyCollision.Normal * -1f, "nom nom", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                }
                else
                {
                    flag = true;
                    component.healthHaver.ApplyDamage(20f, rigidbodyCollision.Normal * -1f, "nom nom", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                }
            }
            else
            {
                MajorBreakable     component3 = rigidbodyCollision.OtherRigidbody.GetComponent <MajorBreakable>();
                BodyPartController component4 = rigidbodyCollision.OtherRigidbody.GetComponent <BodyPartController>();
                if (component4 && component3)
                {
                    flag = true;
                    Vector2 normalized = (rigidbodyCollision.MyRigidbody.UnitCenter - rigidbodyCollision.OtherRigidbody.UnitCenter).normalized;
                    component3.ApplyDamage(20f, normalized * -1f, false, false, false);
                    if (component3.healthHaver)
                    {
                        component3.healthHaver.ApplyDamage(20f, normalized * -1f, "nom nom", CoreDamageTypes.None, DamageCategory.Normal, false, null, false);
                    }
                }
            }
            if (flag)
            {
                rigidbodyCollision.MyRigidbody.RegisterTemporaryCollisionException(rigidbodyCollision.OtherRigidbody, 0.5f, null);
            }
        }
Exemplo n.º 9
0
    public float bleedBonus     = 0f; //how rapidly we bleed from this part

    private void Start()
    {
        //might not want these in bodyparts because they're going to get called in every single body part in the game!
        myBrain        = GetComponent <Brain>();
        myBody         = GetComponent <BodyPartController>();
        myCombatSkills = GetComponent <CombatSkills>();
        anim           = GetComponent <UnitAnimController>();
        ai             = GetComponent <UnitReactions>();
        stateMachine   = GetComponent <UnitStateMachine>();

        if (dollPart != null)
        {
            dollPart.Initialize(PackagePartInfo());
        }

        MyWeapon(); //run this to make sure we hve unarmed weapon
        //Debug.Log("assigning parts for " + this);
        //Debug.Log("my armortype is " + armorType);
    }
Exemplo n.º 10
0
    // Use this for initialization
    void Start()
    {
        //don't grade us on this please.
        //get all rigidbodys in chillen
        Rigidbody[] rs = gameObject.GetComponentsInChildren <Rigidbody>();
        rbs = new List <Pair>();

        foreach (Rigidbody r in rs)
        {
            BodyPartController bpc = new BodyPartController();
            r.gameObject.AddComponent <BodyPartController> ();

            r.gameObject.tag = "model";
            Pair t = new Pair(r, r.rotation);
            //Debug.Log(t.rot);
            rbs.Add(t);
            r.maxDepenetrationVelocity = 1 / 111000;
            foreach (HingeJoint j in r.gameObject.GetComponents <HingeJoint> ())
            {
                allJoints.Add(j);
            }
        }
        gc = FindObjectOfType <GameController> ();
    }
Exemplo n.º 11
0
    private IEnumerator Engage(Transform _targetTransform)
    {
        //Debug.LogError(gameObject.name + " is engaging " + _targetTransform.name);
        bool inRange;

        targetTransform = _targetTransform;
        targetBody      = targetTransform.GetComponent <BodyPartController>();
        attack1Parts    = usm.attack1Parts;
        attack2Parts    = usm.attack2Parts;

        UnitController     uc       = usm.unitController;
        BodyPartController opponent = targetTransform.GetComponent <BodyPartController>();
        Collider2D         col      = GetComponent <Collider2D>();

        usm.unitAnim.FaceDirection(transform.position, targetTransform.position);

        while (!opponent.Incapacitated())
        {
            //eventually this will be a function that will check if ranged or melee, then decide if in range or not
            //for ranged we can use a raycast of some sort to check for obstabcles
            inRange = col.IsTouching(targetTransform.GetComponent <Collider2D>());

            if (!inRange)
            {
                PathfindingManager.RequestPath(new PathRequest(transform.position, targetTransform.position, uc.OnPathFound));
                yield return(new WaitForSeconds(.1f));
            }
            else if (!usm.attackTimer.coolingDown)
            {
                Attack();
            }
            yield return(null);
        }
        usm.RequestChangeState(StateMachine.States.Idle);
        yield break;
    }
Exemplo n.º 12
0
 //called in Start()
 protected override void GatherComponents()
 {
     base.GatherComponents();
     bodyParts = GetComponent <BodyPartController>();
     myBrain   = GetComponent <Brain>();
 }
Exemplo n.º 13
0
    //bools for toggling items on or off would make this script a little more flexable

    // Use this for initialization
    public void EquipLoadout(BodyPartController myBody)
    {
        InstantiateDefaultEquipment();
        LoadDefaultArmor(myBody);
        LoadDefaultWeapon(myBody);
    }
Exemplo n.º 14
0
 private void Start()
 {
     body          = GetComponent <BodyPartController>();
     blockingParts = body.attack2Parts; //possible script order issue if this is called before bodyparts are loaded
 }
Exemplo n.º 15
0
 private void Start()
 {
     inv    = InventoryManager.GetInstance().GetInventory();
     myBody = GetComponent <BodyPartController>();
     UI     = CanvasUI.instance.GetComponent <EquipUI>();
 }