Example #1
0
    // Update is called once per frame
    void Update()
    {
        switch (state)
        {
        case TOWERSTATE.PLACING:
            Ray        ray = Camera.main.ScreenPointToRay(Input.mousePosition);
            RaycastHit hit;
            if (Physics.Raycast(ray, out hit, Mathf.Infinity, 1 << 10))
            {
                transform.position = hit.point;
                transform.position = new Vector3(transform.position.x, 0, transform.position.z);
            }
            if (_validLocation())
            {
                GetComponent <Renderer>().material.color = Color.green;
            }
            else
            {
                GetComponent <Renderer>().material.color = Color.red;
            }
            if (Input.GetMouseButtonUp(0))
            {
                state = TOWERSTATE.CONSTRUCTING;
                GetComponent <Renderer>().material.color = Color.white;
            }
            break;

        case TOWERSTATE.CONSTRUCTING:
            if (constructionTime > 0f)
            {
                constructionTime -= Time.deltaTime;
            }
            else
            {
                state = TOWERSTATE.READY;
            }
            break;

        case TOWERSTATE.READY:
            List <GameObject> enemies = new List <GameObject>(GameObject.FindGameObjectsWithTag("Enemy"));
            for (int i = 0; i < enemies.Count; ++i)
            {
                Debug.Log("Firing");
                GameObject enemy = enemies[i];
                Vector3    pos   = enemy.transform.position;
                if ((pos - transform.position).magnitude < range)
                {
                    Debug.Log("Firing");
                    GameObject.Destroy(enemy);
                    GameObject             shot = GameObject.Instantiate(shotPrefab);
                    VolumetricLineBehavior line = shot.GetComponent <VolumetricLineBehavior>();
                    line.StartPos = transform.position;
                    line.EndPos   = pos;
                    GameObject.Destroy(shot, 1f);
                }
            }

            break;
        }
    }
Example #2
0
 private void Awake()
 {
     Allomancer = null;
     highlightedTargetOutline = gameObject.AddComponent <Outline>();
     blueLine         = Instantiate(GameManager.MetalLineTemplate);
     Rb               = GetComponent <Rigidbody>();
     ColliderBody     = GetComponent <Collider>();
     lightSaberFactor = 1;
     lastWasPulled    = false;
     IsHighlighted    = false;
     IsStatic         = Rb == null;
     if (!IsStatic)
     {
         mass = Rb.mass;
         LocalCenterOfMass = Rb.centerOfMass;
     }
     else
     {
         LocalCenterOfMass = Vector3.zero;
     }
     Charge                   = Mathf.Pow(mass, AllomanticIronSteel.chargePower);
     LastPosition             = Vector3.zero;
     LastVelocity             = Vector3.zero;
     LastExpectedAcceleration = Vector3.zero;
     LastAllomanticForce      = Vector3.zero;
     LastAllomanticNormalForceFromAllomancer = Vector3.zero;
     LastAllomanticNormalForceFromTarget     = Vector3.zero;
     InRange = false;
 }
Example #3
0
 private void Awake()
 {
     //lr = GetComponent<LineRenderer>();
     vl = GetComponent <VolumetricLineBehavior>();
     ResetLineToInitState();
     fstate       = FingerState.Idle;
     segmentTrack = new List <Segment>();
 }
Example #4
0
    private void Awake()
    {
        vl = GetComponentInChildren <VolumetricLineBehavior>();

        endObject.transform.position = endPoint_1;
        currentPos = endPoint_1;
        rayendPos  = endPoint_1;
        UpdateLaser();
    }
 private void SetColor(UserObject uo, Color clrLine)
 {
     try
     {
         VolumetricLineBehavior volLine = uo.m_goVolumetricLine.GetComponent <VolumetricLineBehavior>();
         volLine.LineColor = clrLine;
     }
     catch (Exception ex)
     {
         System.Diagnostics.Trace.WriteLine(ex.Message);
         System.Diagnostics.Trace.WriteLine(ex.StackTrace);
     }
 }
    // Use this for initialization
    void Start()
    {
        VolumetricLineBehavior vline = GetComponent <VolumetricLineBehavior>();

        if (vline != null)
        {
            vline.StartPos = Camera.main.transform.position - Vector3.up * (0.12f);
            vline.EndPos   = GazeManager.Instance.HitInfo.point;
        }
        else
        {
            Debug.Log("LaserVline: VolumetricLineBehavior script object not found");
        }

        Destroy(gameObject, 0.8f);
    }
Example #7
0
        public void Shoot(GameObject entity)
        {
            if (!canShoot)
            {
                return;
            }
            canShoot = false;
            timer.Reset();
            IsLaserShooting = true;
            var laser = Object.Instantiate(Laser);

            line = laser.GetComponent <VolumetricLineBehavior>();
            var offset = Offset - Vector3.right * line.EndPos.z;

            laser.SetPosition(entity.GetPosition() + offset);
        }
Example #8
0
    void OnEnable()
    {
        bulletPool = BulletPool.GetInstance();
        BossEntrance();

        bossLaser = GameObject.Find("BossLaser").GetComponent <VolumetricLineBehavior>();

        if (GameObject.Find("[CameraRig]").transform.Find("Controller (right)").childCount > 1)
        {
            player = GameObject.Find("[CameraRig]").transform.Find("Controller (right)").transform.Find("Spaceship").transform;
        }
        else
        {
            player = GameObject.Find("[CameraRig]").transform.Find("Controller (left)").transform.Find("Spaceship").transform;
        }


        InvokeRepeating("Attack", 0, attackDuration);

        maxHealth = health;
    }
Example #9
0
    // Use this for initialization
    void Start()
    {
        shooting              = false;
        currentEnergy         = maxEnergy;
        overHeat              = false;
        initialEnergyBarWidth = energyBar.rectTransform.rect.width;
        if (!INSTANCE)
        {
            INSTANCE = this;
        }

        if (maxlifes == 0)
        {
            lifes = 3;
        }
        else
        {
            lifes = maxlifes;
        }
        left = (VolumetricLineBehavior)Instantiate(VolumetricLineBehavior, GlassesManager.transform, false);
        left.SetLinePropertiesAtStart = true;
        left.StartPos = 1.5f * Vector3.left;
        left.EndPos   = Vector3.forward * 150;
        right         = (VolumetricLineBehavior)Instantiate(VolumetricLineBehavior, GlassesManager.transform, false);
        right.SetLinePropertiesAtStart = true;
        right.StartPos = 1.5f * Vector3.right;
        right.EndPos   = Vector3.forward * 150;


        left.LineWidth  = 1;
        right.LineWidth = 1;
        left.LineColor  = Color.red;
        right.LineColor = Color.red;
        left.gameObject.SetActive(false);
        right.gameObject.SetActive(false);
    }
 private void Start()
 {
     line           = GetComponent <VolumetricLineBehavior>();
     hitbox         = GetComponent <Collider>();
     hitbox.enabled = false;
 }
Example #11
0
 void Start()
 {
     volumetricLineBehavior = GetComponent <VolumetricLineBehavior>();
     cameraPivot            = Camera.main.transform;
     StartCoroutine(BehaviorCoroutine());
 }
Example #12
0
 private void Awake()
 {
     vl = GetComponentInChildren <VolumetricLineBehavior>();
 }
 public void OnEnable()
 {
     m_Instance = target as VolumetricLineBehavior;
     m_fields   = ExposeProperties.GetProperties(m_Instance);
 }
Example #14
0
    protected void Awake()
    {
        if (childMagnetics == null || childMagnetics.Length == 0)
        {
            // If not assigned in the editor, assume that all children should glow
            childMagnetics = GetComponentsInChildren <Renderer>();
        }
        defaultEmissionColor = new Color[childMagnetics.Length];
        blueLine             = Instantiate(GameManager.MetalLineTemplate);
        colliders            = GetComponentsInChildren <Collider>();
        if (gameObject.layer != LayerMask.NameToLayer("Undetectable Magnetic"))
        {
            GameManager.AddMagnetic(this);
        }
        lightSaberFactor  = 1;
        lastWasPulled     = false;
        isBeingPushPulled = false;
        IsHighlighted     = false;
        if (!IsStatic)   // assigned by MagneticDense
        {
            Rb       = GetComponentInParent <Rigidbody>();
            IsStatic = (Rb == null);
        }
        HasColliders = colliders.Length > 0;

        if (IsStatic)   // No RigidBody attached
        {
            if (netMass == 0)
            {
                Debug.LogError("Magnetic's netMass is 0 on an object without a RigidBody " + name + " at " + transform.position);
            }
            if (magneticMass == 0)
            {
                magneticMass = netMass;
            }
            if (HasColliders)
            {
                //Vector3 centers = colliders[0].bounds.center;
                //int triggerCount = 0;
                //for (int i = 1; i < colliders.Length; i++) {
                //    if (!colliders[i].isTrigger)
                //        centers += colliders[i].bounds.center;
                //    else
                //        triggerCount++;
                //}
                //centerOfMass = transform.InverseTransformPoint(centers / (colliders.Length - triggerCount));
                //centerOfMass = transform.InverseTransformPoint(GetComponentInChildren<Renderer>().bounds.center);
                centerOfMass = Vector3.zero;
            }
        }
        else     // RigidBody attached, which has its own mass, which replaces netMass
        {
            netMass = Rb.mass;
            if (magneticMass == 0)
            {
                magneticMass = netMass;
            }
            if (colliders.Length == 1)
            {
                centerOfMass = Rb.centerOfMass;
            }
        }

        Charge                   = Mathf.Pow(magneticMass, AllomanticIronSteel.chargePower);
        LastPosition             = transform.position;
        LastVelocity             = Vector3.zero;
        LastExpectedAcceleration = Vector3.zero;
        //LastExpectedVelocityChange = Vector3.zero;
        //LastExpectedEnergyUsed = 0;
        LastAllomanticForce                 = Vector3.zero;
        LastMaxPossibleAllomanticForce      = Vector3.zero;
        LastAnchoredPushBoostFromAllomancer = Vector3.zero;
        LastAnchoredPushBoostFromTarget     = Vector3.zero;
    }
Example #15
0
    protected override void Start()
    {
        _device = GetCachedComponent <DeviceInteraction>();

        _volumetricLineBehavior = VolumetricLine.GetComponent <VolumetricLineBehavior>();
    }
Example #16
0
 private void Awake()
 {
     lineRenderComponent = GetComponent <VolumetricLineBehavior>();
 }
Example #17
0
 void Awake()
 {
     m_line = GetComponent <VolumetricLineBehavior>();
 }