コード例 #1
0
ファイル: TaserGun.cs プロジェクト: ZiDiZhu/jerome
    public override void use()
    {
        stimulus zap = stimulus.spawn(stimulusType.electric, myPlayer.transform.position, myPlayer.lookDirection, 0);

        zap.speed    = zapSpeed;
        zap.lifeTime = zapTime;
    }
コード例 #2
0
ファイル: stimulus.cs プロジェクト: ZiDiZhu/jerome
    private void OnCollisionEnter(Collision col)
    {
        GameObject obj = col.gameObject;

        switch (obj.tag)
        {
        case "stimulus":
            stimulus cStim = col.gameObject.GetComponent <stimulus>();

            if (myType == stimulusType.water)
            {
                if (cStim.myType == stimulusType.electric)
                {
                    electrified = true;
                }
            }
            if (myType == stimulusType.fire)
            {
                if (cStim.myType == stimulusType.water)
                {
                    Destroy(gameObject);
                }
            }
            break;

        case "environmentalObject":
        case "environmentSwitch":
            speed = 0f;
            break;
        }
    }
コード例 #3
0
    public void environmentCollisions()
    {
        Bounds b = GetComponent <Collider>().bounds;
        float  r = boundsRadius(b);

        Collider[] col = Physics.OverlapSphere(b.center, r);
        foreach (Collider c in col)
        {
            GameObject obj = c.gameObject;
            if (obj == gameObject)
            {
                continue;
            }
            switch (obj.tag)
            {
            case "stimulus":
                stimulus cStim = obj.GetComponent <stimulus>();
                if (conductive && cStim.electrified)
                {
                    electrified = true;
                }
                if (cStim.myType == stimulusType.water)
                {
                    if (waterDestructible)
                    {
                        Destroy(gameObject);
                    }
                    onFire = false;
                    wet    = true;
                }
                else
                {
                    wet = false;
                }
                if (burnable && cStim.hot && !wet)
                {
                    onFire = true;
                }
                break;

            case "environmentalObject":
                environmentalObject cE = obj.GetComponent <environmentalObject>();
                if (cE.electrified && conductive)
                {
                    electrified = true;
                }
                break;
            }
        }
    }
コード例 #4
0
ファイル: stimulus.cs プロジェクト: ZiDiZhu/jerome
    public static stimulus spawn(stimulusType t, Vector3 pos, Vector3 dir, float randomRange)
    {
        float dx = Random.Range(dir.x - randomRange, dir.x + randomRange);
        float dy = Random.Range(dir.y - randomRange, dir.y + randomRange);
        float dz = Random.Range(dir.z - randomRange, dir.z + randomRange);

        GameObject newStimObj = (GameObject)Instantiate(Resources.Load("stimulus"));

        newStimObj.transform.position = pos;
        stimulus newStim = newStimObj.GetComponent <stimulus>();

        newStim.myType        = t;
        newStim.moveDirection = new Vector3(dx, dy, dz).normalized;
        return(newStim);
    }