コード例 #1
0
ファイル: IfNearExplode.cs プロジェクト: Thirrash/LudumDare40
    void Explode()
    {
        Collider[] floaters = Physics.OverlapSphere(transform.position, explosionRange, 1 << 9, QueryTriggerInteraction.Collide);
        foreach (Collider c in floaters)
        {
            float dist = (c.transform.position - transform.position).magnitude;
            float dmg  = Mathf.Clamp(dist / explosionRange, 0.0f, 1.0f);

            Ballast bal = c.GetComponent <Ballast>();
            if (bal != null)
            {
                bal.CurrentHp -= damage * dmg;
                Debug.Log("Ballast: " + (damage * dmg));
            }

            ShipBallaster shipBal = c.GetComponent <ShipBallaster>();
            if (shipBal != null)
            {
                shipBal.CurrentHp -= damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp);
                Debug.Log("ShipBal damage: " + (damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp)));
            }
        }


        Explosives.SetActive(true);
        StartCoroutine(Destruction());
    }
コード例 #2
0
ファイル: Rocket.cs プロジェクト: Thirrash/LudumDare40
    private void Blow()
    {
        if (typ)
        {
            model.SetActive(false);
        }
        Destroy(rigid);
        bHasCollided = true;
        Destroy(GetComponent <FollowShip>());
        explosion.SetActive(true);

        Collider[] floaters = Physics.OverlapSphere(transform.position, explosionRange, 1 << 9, QueryTriggerInteraction.Collide);
        foreach (Collider c in floaters)
        {
            dg = true;
            float dist = (c.transform.position - transform.position).magnitude;
            float dmg  = Mathf.Clamp(dist / explosionRange, 0.0f, 1.0f);

            Ballast bal = c.GetComponent <Ballast>();
            if (bal != null)
            {
                bal.CurrentHp -= damage * dmg * dmg;
                Debug.Log("Ballast: " + (damage * dmg * dmg));
            }

            ShipBallaster shipBal = c.GetComponent <ShipBallaster>();
            if (shipBal != null)
            {
                shipBal.CurrentHp -= damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp);
                Debug.Log("ShipBal damage: " + (damage * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp) * (1.0f - shipBal.sumCurrHp / shipBal.sumMaxHp)));
            }
        }

        StartCoroutine(Destruction());
    }
コード例 #3
0
    public void OnTrigger(Swimming Swi, ShipBallaster Bal)
    {
        foreach (ChainShoot c in HookManager.Instance.chains)
        {
            if (c.bPicked)
            {
                Points   += PointsPerTreasure;
                c.bPicked = false;
                c.DestroyChain();
                HookManager.Instance.readiness[HookManager.Instance.chains.IndexOf(c)] = false;
            }
        }

        Points = Bal.Repair(Points / PointsPerHp) * PointsPerHp;
        if (Points < (Swi.maxPetrol - Swi.CurrentPetrol) * PointsPerFuel)
        {
            Swi.CurrentPetrol += Points / PointsPerFuel;
            Points             = 0.0f;
        }
        else
        {
            Points           -= (Swi.maxPetrol - Swi.CurrentPetrol) * PointsPerFuel;
            Swi.CurrentPetrol = Swi.maxPetrol;
        }
    }
コード例 #4
0
    // Use this for initialization
    void Start()
    {
        GameObject ship = GameObject.FindGameObjectWithTag("Ship");

        playerCollider = ship.GetComponent <BoxCollider>();
        ballaster      = ship.GetComponent <ShipBallaster>();
    }
コード例 #5
0
 void Awake()
 {
     rigid         = GetComponent <Rigidbody>();
     bal           = GetComponent <ShipBallaster>();
     currentPetrol = maxPetrol;
 }