Exemple #1
0
	//setup
	void Awake()
	{
		gui = FindObjectOfType(typeof(GUIManager)) as GUIManager ;
		if(tag != "Coin")
		{
			tag = "Coin";
			Debug.LogWarning ("'Coin' script attached to object not tagged 'Coin', tag added automatically", transform);
		}
		GetComponent<Collider>().isTrigger = true;
		triggerParent = GetComponentInChildren<TriggerParent>();
		//if no trigger bounds are attached to coin, set them up
		if(!triggerParent)
		{
			GameObject bounds = new GameObject();
			bounds.name = "Bounds";
			bounds.AddComponent<SphereCollider>();
			bounds.GetComponent<SphereCollider>().radius = 7f;
			bounds.GetComponent<SphereCollider>().isTrigger = true;
			bounds.transform.parent = transform;
			bounds.transform.position = transform.position;
			bounds.AddComponent<TriggerParent>();
			triggerParent = GetComponentInChildren<TriggerParent>();
			triggerParent.tagsToCheck = new string[1];
			triggerParent.tagsToCheck[0] = "Player";
			Debug.LogWarning ("No pickup radius 'bounds' trigger attached to coin: " + transform.name + ", one has been added automatically", bounds);
		}
	}
Exemple #2
0
 //setup
 void Awake()
 {
     gui = FindObjectOfType(typeof(GUIManager)) as GUIManager;
     if (tag != "Coin")
     {
         tag = "Coin";
         Debug.LogWarning("'Coin' script attached to object not tagged 'Coin', tag added automatically", transform);
     }
     GetComponent <Collider>().isTrigger = true;
     triggerParent = GetComponentInChildren <TriggerParent>();
     //if no trigger bounds are attached to coin, set them up
     if (!triggerParent)
     {
         GameObject bounds = new GameObject();
         bounds.name = "Bounds";
         bounds.AddComponent <SphereCollider>();
         bounds.GetComponent <SphereCollider>().radius    = 7f;
         bounds.GetComponent <SphereCollider>().isTrigger = true;
         bounds.transform.parent   = transform;
         bounds.transform.position = transform.position;
         bounds.AddComponent <TriggerParent>();
         triggerParent                = GetComponentInChildren <TriggerParent>();
         triggerParent.tagsToCheck    = new string[1];
         triggerParent.tagsToCheck[0] = "Player";
         Debug.LogWarning("No pickup radius 'bounds' trigger attached to coin: " + transform.name + ", one has been added automatically", bounds);
     }
 }
    private TriggerParent triggerParent; //this is a utility class, that lets us check if the player is close to the coins "bounds sphere trigger"

    #endregion Fields

    #region Methods

    //private GUIManager gui;
    //setup
    void Awake()
    {
        //gui = FindObjectOfType(typeof(GUIManager)) as GUIManager ;
        if(tag != "Pickup")
        {
            tag = "Pickup";

        }
        bubbleBlowing = GameObject.FindGameObjectWithTag("Player").GetComponent<BubbleBlowing>();
        GetComponent<Collider>().isTrigger = true;
        triggerParent = GetComponentInChildren<TriggerParent>();
        //if no trigger bounds are attached to coin, set them up
        if(!triggerParent)
        {
            GameObject bounds = new GameObject();
            bounds.name = "Bounds";
            bounds.AddComponent<SphereCollider>();
            bounds.GetComponent<SphereCollider>().radius = 3f;
            bounds.GetComponent<SphereCollider>().isTrigger = true;
            bounds.transform.parent = transform;
            bounds.transform.position = transform.position;
            bounds.AddComponent<TriggerParent>();
            triggerParent = GetComponentInChildren<TriggerParent>();
            triggerParent.tagsToCheck = new string[1];
            triggerParent.tagsToCheck[0] = "Player";
        }
        for(int i = 0; i < transform.childCount; i++)
        {
            this.transform.GetChild(i).gameObject.layer = LayerMask.NameToLayer("Items");
        }
    }
Exemple #4
0
    public void MountPlayer(BasePlayer player)
    {
        if (this._mounted != null)
        {
            return;
        }
        if (Interface.CallHook("CanMountEntity", player, this) != null)
        {
            return;
        }
        player.EnsureDismounted();
        this._mounted = player;
        TriggerParent triggerParent = player.FindTrigger <TriggerParent>();

        if (triggerParent)
        {
            triggerParent.OnTriggerExit(player.GetComponent <Collider>());
        }
        player.MountObject(this, 0);
        player.MovePosition(this.mountAnchor.transform.position);
        player.transform.rotation = this.mountAnchor.transform.rotation;
        player.ServerRotation     = this.mountAnchor.transform.rotation;
        player.OverrideViewAngles(this.mountAnchor.transform.rotation.eulerAngles);
        this._mounted.eyes.NetworkUpdate(this.mountAnchor.transform.rotation);
        player.ClientRPCPlayer <Vector3>(null, player, "ForcePositionTo", player.transform.position);
        base.SetFlag(BaseEntity.Flags.Busy, true, false, true);
        Interface.CallHook("OnEntityMounted", this, player);
    }
Exemple #5
0
 public void Awake()
 {
     m_triggerParent = FindObjectOfType <TriggerParent>();
     myCol           = GetComponent <BoxCollider>();
     //moveCol = FindObjectOfType<MoveCollider>().movCol;
     //print(m_triggerParent.name);
 }
Exemple #6
0
    public override void PostContainerUpdate(FlexSolver solver, FlexContainer cntr, FlexParameters parameters)
    {
        //print("number of locked particles: " + m_lockedParticlesMasses.Count);
        m_cntr = cntr;  // cache local reference for Gizmo drawing
        if (m_triggerParent == null)
        {
            // have to potentially look for TriggerParent again, since it's added dynamically
            // TODO: rethink this logic, there are many TriggerParents, but this only looks for one!
            m_triggerParent = FindObjectOfType <TriggerParent>();
        }
        if (m_triggerParent.changeCollider || moveCol)
        {
            //print("change collider");
            // update the locked particles: first clear, then call FlexStart again
            //print("number of locked particles before clear: " + m_lockedParticlesMasses.Count);

            //this.m_lockedParticlesIds.Clear();
            /*this.*/
            this.m_lockedParticlesMasses.Clear();
            //Equate invMass to 0.0f in for loop below to accumulate locked particles
            for (int i = 0; i < m_lockedParticlesIds.Count; i++)
            {
                cntr.m_particles[m_lockedParticlesIds[i]].invMass = /*0.0f*/ m_Particles.m_mass /*1.0f*/;
            }
            this.m_lockedParticlesIds.Clear();
            base.FlexStart(solver, cntr, parameters);
            //for (int i = 0; i < m_lockedParticlesMasses.Count; i++)
            //{
            //    print("After clearing, locked particle index: " + m_lockedParticlesIds[i] + " and inv. mass of each locked particle: " + m_lockedParticlesMasses[i]);
            //}
            moveCol = false;
            m_triggerParent.changeCollider = false;
        }
        base.PostContainerUpdate(solver, cntr, parameters);
    }
        private void OnEntityEnter(TriggerParent triggerParent, BasePlayer player)
        {
            if (!_pluginConfig.DisarmOccupants ||
                player.IsNpc ||
                triggerParent.GetComponentInParent <SafeCart>() == null)
            {
                return;
            }

            var activeItem = player.GetActiveItem();

            if (activeItem == null || !player.IsHostileItem(activeItem))
            {
                return;
            }

            var position = activeItem.position;

            activeItem.RemoveFromContainer();
            player.inventory.SendUpdatedInventory(PlayerInventory.Type.Belt, player.inventory.containerBelt);

            // Note: It's possible to leak an item here if the player is killed during the delay,
            // but the number of items that would be leaked this way is insignificant.
            player.Invoke(() =>
            {
                if (!activeItem.MoveToContainer(player.inventory.containerBelt, position))
                {
                    player.inventory.GiveItem(activeItem);
                }
            }, 0.2f);
        }
Exemple #8
0
	//setup
	void Awake()
	{		
		characterMotor = GetComponent<CharacterMotor>();
		dealDamage = GetComponent<DealDamage>();
		//avoid setup errors
		if(tag != "Enemy")
		{
			tag = "Enemy";
			Debug.LogWarning("'EnemyAI' script attached to object without 'Enemy' tag, it has been assign automatically", transform);
		}
		
		if(sightBounds)
		{
			sightTrigger = sightBounds.GetComponent<TriggerParent>();
			if(!sightTrigger)
				Debug.LogError("'TriggerParent' script needs attaching to enemy 'SightBounds'", sightBounds);
		}
		if(!sightBounds)
			Debug.LogWarning("Assign a trigger with 'TriggerParent' script attached, to 'SightBounds' or enemy will not be able to see", transform);
		
		if(attackBounds)
		{
			attackTrigger = attackBounds.GetComponent<TriggerParent>();
			if(!attackTrigger)
				Debug.LogError("'TriggerParent' script needs attaching to enemy 'attackBounds'", attackBounds);
		}
		else
			Debug.LogWarning("Assign a trigger with 'TriggerParent' script attached, to 'AttackBounds' or enemy will not be able to attack", transform);
	}
Exemple #9
0
 public void MountPlayer(BasePlayer player)
 {
     if (_mounted != null || mountAnchor == null || Interface.CallHook("CanMountEntity", player, this) != null)
     {
         return;
     }
     player.EnsureDismounted();
     _mounted = player;
     if (unparentOnMount)
     {
         TriggerParent triggerParent = player.FindTrigger <TriggerParent>();
         if ((bool)triggerParent)
         {
             triggerParent.OnTriggerExit(player.GetComponent <Collider>());
         }
     }
     player.MountObject(this);
     player.MovePosition(mountAnchor.transform.position);
     player.transform.rotation = mountAnchor.transform.rotation;
     player.ServerRotation     = mountAnchor.transform.rotation;
     player.OverrideViewAngles(mountAnchor.transform.rotation.eulerAngles);
     _mounted.eyes.NetworkUpdate(mountAnchor.transform.rotation);
     player.ClientRPCPlayer(null, player, "ForcePositionTo", player.transform.position);
     SetFlag(Flags.Busy, true);
     OnPlayerMounted();
     Interface.CallHook("OnEntityMounted", this, player);
 }
Exemple #10
0
    public void MountPlayer(BasePlayer player)
    {
        if (Object.op_Inequality((Object)this._mounted, (Object)null) || Interface.CallHook("CanMountEntity", (object)player, (object)this) != null)
        {
            return;
        }
        player.EnsureDismounted();
        this._mounted = player;
        TriggerParent trigger = player.FindTrigger <TriggerParent>();

        if (Object.op_Implicit((Object)trigger))
        {
            trigger.OnTriggerExit((Collider)((Component)player).GetComponent <Collider>());
        }
        player.MountObject(this, 0);
        player.MovePosition(((Component)this.mountAnchor).get_transform().get_position());
        ((Component)player).get_transform().set_rotation(((Component)this.mountAnchor).get_transform().get_rotation());
        player.ServerRotation = ((Component)this.mountAnchor).get_transform().get_rotation();
        BasePlayer basePlayer  = player;
        Quaternion rotation    = ((Component)this.mountAnchor).get_transform().get_rotation();
        Vector3    eulerAngles = ((Quaternion) ref rotation).get_eulerAngles();

        basePlayer.OverrideViewAngles(eulerAngles);
        this._mounted.eyes.NetworkUpdate(((Component)this.mountAnchor).get_transform().get_rotation());
        player.ClientRPCPlayer <Vector3>((Connection)null, player, "ForcePositionTo", ((Component)player).get_transform().get_position());
        this.SetFlag(BaseEntity.Flags.Busy, true, false, true);
        Interface.CallHook("OnEntityMounted", (object)this, (object)player);
    }
    //private GUIManager gui;

    //setup
    void Awake()
    {
        //gui = FindObjectOfType(typeof(GUIManager)) as GUIManager ;
        if (tag != "Pickup")
        {
            tag = "Pickup";
        }
        bubbleBlowing = GameObject.FindGameObjectWithTag("Player").GetComponent <BubbleBlowing>();
        GetComponent <Collider>().isTrigger = true;
        triggerParent = GetComponentInChildren <TriggerParent>();
        //if no trigger bounds are attached to coin, set them up
        if (!triggerParent)
        {
            GameObject bounds = new GameObject();
            bounds.name = "Bounds";
            bounds.AddComponent <SphereCollider>();
            bounds.GetComponent <SphereCollider>().radius    = 3f;
            bounds.GetComponent <SphereCollider>().isTrigger = true;
            bounds.transform.parent   = transform;
            bounds.transform.position = transform.position;
            bounds.AddComponent <TriggerParent>();
            triggerParent                = GetComponentInChildren <TriggerParent>();
            triggerParent.tagsToCheck    = new string[1];
            triggerParent.tagsToCheck[0] = "Player";
        }
        for (int i = 0; i < transform.childCount; i++)
        {
            this.transform.GetChild(i).gameObject.layer = LayerMask.NameToLayer("Items");
        }
    }
Exemple #12
0
            void OnTriggerExit(Collider col)
            {
                TriggerParent triggerParent = col.GetComponentInParent <TriggerParent>();

                if (triggerParent == null)
                {
                    return;
                }
                triggerParent.OnEntityLeave(player);
            }
Exemple #13
0
    // Update is called once per frame
    void Update()
    {
        guiManager.UpdateGUIElementsSize(new Size(Screen.width, Screen.height));
        //guiHelper.UpdateGUIElementsSize();

        // Check if any player disconnected
        if (testMultiplayer)
        {
            if (MultiplayerManager.Instance.PlayersList.Count < 2 && gameEnd == 0)
            {
                gameEnd = 3;
                MultiplayerManager.Instance.LeaveRoom(2);
            }
        }

        //WINNING CONDITION CHECKING
        //Only server can check
        if (Network.isServer)
        {
            // Start moving platforms

            if (!isMovingPlatformStarted)
            {
                // Only start when all clients are ready
                if (numberOfReadyClients >= Network.connections.Length)
                {
                    StartMovingPlatform(Time.time);
                }
            }

            if (gameEnd == 0)
            {
                TriggerParent goalTrigger = goal.GetComponent <TriggerParent>();
                if (goalTrigger.collided)
                {
                    if (isStoneTaken && goalTrigger.hitObject.networkView.owner == stoneKeeper)
                    {
                        // Call RPC Display result only once
                        networkView.RPC("UpdateResult", RPCMode.AllBuffered);
                        MultiplayerManager.Instance.LeaveRoom(2); //Disconnect and unregister host for both server and client
                    }
                }
            }

            KeepStoneTimer(isStoneTaken.ToString(), startTimeKeepStone, elapsedTimeKeepStone);
        }

        if (guiManager.GetPauseButtonPress())
        {
            isPause = true;
        }

        guiManager.ChangeStoneStatusTexture(isStoneTaken, stoneKeeper);
    }
Exemple #14
0
    //setup
    void Awake()
    {
        characterMotor = GetComponent <CharacterMotor>();
        dealDamage     = GetComponent <DealDamage>();

        if (sightBounds)
        {
            sightTrigger = sightBounds.GetComponent <TriggerParent>();
        }
        if (attackBounds)
        {
            attackTrigger = attackBounds.GetComponent <TriggerParent>();
        }
        wanderBasePosition = transform.position;
        InvokeRepeating(nameof(Wander), 0, wanderTime);
    }
Exemple #15
0
    private void GrabReferences()
    {
        characterMotor = GetComponent <CharacterMotor>();
        dealDamage     = GetComponent <DealDamage>();
        m_player       = GameObject.FindGameObjectWithTag("Player").transform;
        pMelee         = m_player.GetComponentInParent <PlayerMelee>();

        //avoid setup errors
        if (tag != "Enemy")
        {
            tag = "Enemy";
            Debug.LogWarning("'EnemyAI' script attached to object without 'Enemy' tag, it has been assign automatically", transform);
        }

        // Grab sightbounds
        sightTrigger = transform.Find("Sight Bounds").GetComponent <TriggerParent> ();
        if (!sightTrigger)
        {
            Debug.LogError("'TriggerParent' script needs attaching to enemy 'SightBounds'");
        }

        // Grab attack bounds
        attackTrigger = transform.Find("Attack Bounds").GetComponent <TriggerParent> ();
        if (!attackTrigger)
        {
            Debug.LogError("'TriggerParent' script needs attaching to enemy 'attackBounds'");
        }

        health = GetComponent <Health> ();
        if (!health)
        {
            Debug.LogError("This gameoObject needs a 'Health' script");
        }

        // Grab animator controller
        animatorController = GetComponentInChildren <Animator> ();
        if (!animatorController)
        {
            Debug.LogError(gameObject.name + " needs an Animator controller. Attach one or enemy won't be able to animate!");
        }
    }
Exemple #16
0
    void Awake()
    {
        collider.isTrigger = true;
        triggerParent      = GetComponentInChildren <TriggerParent>();

        if (!triggerParent)
        {
            GameObject bounds = new GameObject();
            bounds.name = "Bounds";
            bounds.AddComponent("SphereCollider");
            bounds.GetComponent <SphereCollider>().radius    = 0.5f;
            bounds.GetComponent <SphereCollider>().isTrigger = true;
            bounds.transform.parent   = transform;
            bounds.transform.position = transform.position;
            bounds.AddComponent("TriggerParent");
            triggerParent                = GetComponentInChildren <TriggerParent>();
            triggerParent.tagsToCheck    = new string[1];
            triggerParent.tagsToCheck[0] = "Player";
            //Debug.LogWarning("No pickup radius 'bounds' trigger attached to coin: " + transform.name + ", one has been added automatically", bounds);
        }
    }
Exemple #17
0
    void Awake()
    {
        collider.isTrigger = true;
        triggerParent = GetComponentInChildren<TriggerParent>();

        if (!triggerParent)
        {
            GameObject bounds = new GameObject();
            bounds.name = "Bounds";
            bounds.AddComponent("SphereCollider");
            bounds.GetComponent<SphereCollider>().radius = 0.5f;
            bounds.GetComponent<SphereCollider>().isTrigger = true;
            bounds.transform.parent = transform;
            bounds.transform.position = transform.position;
            bounds.AddComponent("TriggerParent");
            triggerParent = GetComponentInChildren<TriggerParent>();
            triggerParent.tagsToCheck = new string[1];
            triggerParent.tagsToCheck[0] = "Player";
            //Debug.LogWarning("No pickup radius 'bounds' trigger attached to coin: " + transform.name + ", one has been added automatically", bounds);
        }
    }
Exemple #18
0
    //setup
    void Awake()
    {
        characterMotor = GetComponent <CharacterMotor>();
        dealDamage     = GetComponent <DealDamage>();
        //avoid setup errors
        if (tag != "Enemy")
        {
            tag = "Enemy";
            Debug.LogWarning("'EnemyAI' script attached to object without 'Enemy' tag, it has been assign automatically", transform);
        }

        if (sightBounds)
        {
            sightTrigger = sightBounds.GetComponent <TriggerParent>();
            if (!sightTrigger)
            {
                Debug.LogError("'TriggerParent' script needs attaching to enemy 'SightBounds'", sightBounds);
            }
        }
        if (!sightBounds)
        {
            Debug.LogWarning("Assign a trigger with 'TriggerParent' script attached, to 'SightBounds' or enemy will not be able to see", transform);
        }

        if (attackBounds)
        {
            attackTrigger = attackBounds.GetComponent <TriggerParent>();
            if (!attackTrigger)
            {
                Debug.LogError("'TriggerParent' script needs attaching to enemy 'attackBounds'", attackBounds);
            }
        }
        else
        {
            Debug.LogWarning("Assign a trigger with 'TriggerParent' script attached, to 'AttackBounds' or enemy will not be able to attack", transform);
        }
    }
Exemple #19
0
 void Start()
 {
     parent = GetComponentInParent <TriggerParent>();
 }