Exemplo n.º 1
0
    private void tryChangeTarget()
    {
        if (rootFlow.isHostInstance)
        {
            changeCycleCounter -= Time.deltaTime;
            if (changeCycleCounter < 0)
            {
                changeCycleCounter = changeCycleCounterMax;

                CombatFlow targetFlow = findNearestTarget();
                if (targetFlow != null && targetFlow.GetComponent <Rigidbody>() != targetRb)
                {
                    //Debug.LogWarning
                    //Debug.LogWarning("new target name: " + targetFlow.name);
                    if (targetRb != null && targetFlow != null)
                    {
                        Debug.LogWarning("AAA found new target. Old: " + targetRb.gameObject.name + ", new: " + targetFlow.gameObject.name);
                    }

                    turretNet.setTarget(targetFlow);

                    // only target's instance will deal damage. Rest will be cosmetic-only
                    rootFlow.giveOwnership(targetFlow.photonView.ViewID);
                }
            }
        }
    }
Exemplo n.º 2
0
    private void FixedUpdate()
    {
        if (launched)
        {
            if (myCombatFlow.localOwned)
            {
                if (myTarget != null && !hasPassed && myTarget.GetComponent <CreepControl>() == null &&
                    Vector3.Distance(myTarget.transform.position,
                                     transform.position) < PASS_OWNERSHIP_DISTANCE)
                {
                    // target's instance will own this missile and show accurate position
                    myCombatFlow.giveOwnership(targetID);
                    Debug.LogWarning("Giving missile ownership");
                }


                if (armed && rbRef.velocity.magnitude < selfDestructSpeed)
                {
                    myCombatFlow.dealLocalDamage(myCombatFlow.getHP());
                }

                if (myTarget != null)
                {
                    updateTargetPosition();
                }

                if (checkProximityFuse())
                {
                    // make this rpc
                    if (effectsObj != null)
                    {
                        //effectsObj.GetComponent<Light>().enabled = false;
                        photonView.RPC("rpcDisableLight", RpcTarget.All);
                    }
                    if (myCombatFlow != null && myCombatFlow.localOwned)
                    {
                        // blow up local instance. Death itself should be networked fine
                        myCombatFlow.dealLocalDamage(myCombatFlow.getHP());
                    }
                }
            }
        }
    }